@deslop/workbench 0.0.327 → 0.0.332

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 (43) hide show
  1. package/dist/client/assets/agent-ksblBy0b.js +2 -0
  2. package/dist/client/assets/agent-qBUgLqez.js +1 -0
  3. package/dist/client/assets/button-Cl3QGxsE.js +16 -0
  4. package/dist/client/assets/{diff-C_X2wnRm.js → diff-DRdkZUfM.js} +2 -2
  5. package/dist/client/assets/{diff-hUFci-J4.js → diff-V_u66cov.js} +43 -43
  6. package/dist/client/assets/{external-link-CTjuCORn.js → external-link-CHsqlplI.js} +1 -1
  7. package/dist/client/assets/{fallbacks-DZ7ciusO.js → fallbacks-DRWx0EQv.js} +1 -1
  8. package/dist/client/assets/{index-DpbZkluz.js → index-COqgQoHe.js} +3 -3
  9. package/dist/client/assets/{input-group-CAejCCyD.js → input-group-DfylGHnW.js} +2 -2
  10. package/dist/client/assets/loader-circle-G9WKrfSd.js +1 -0
  11. package/dist/client/assets/portless-CIQUkBPx.js +1 -0
  12. package/dist/client/assets/portless-M280rnul.js +2 -0
  13. package/dist/client/assets/{resizable-B1fIW9sm.js → resizable-bJdqT1JF.js} +1 -1
  14. package/dist/client/assets/route-CzD0EIT6.js +2 -0
  15. package/dist/client/assets/route-JiIT6ta2.js +45 -0
  16. package/dist/client/assets/{run-BzrHh2aK.js → run-JZrpFZA0.js} +1 -1
  17. package/dist/client/assets/run-nZsFjagi.js +2 -0
  18. package/dist/client/assets/state-DG0Oc1Jw.js +2 -0
  19. package/dist/client/assets/{terminal-DgodR87i.js → terminal-BehqmxVT.js} +2 -2
  20. package/dist/client/assets/terminal-CRGNH_jn.js +1 -0
  21. package/dist/client/assets/terminal-DtCniSNL.js +2 -0
  22. package/dist/client/assets/{triangle-alert-CGj-8H_a.js → triangle-alert-D2wmXkyn.js} +1 -1
  23. package/dist/client/index.html +11 -11
  24. package/dist/{execAsync-Gqapz_ET.mjs → execAsync-CgtnVVso.mjs} +1 -1
  25. package/dist/{getMachineId-bsd-D2D8E0zh.mjs → getMachineId-bsd-DYUtJhPR.mjs} +2 -2
  26. package/dist/{getMachineId-darwin-DD7WkQgq.mjs → getMachineId-darwin-BYjMzwa2.mjs} +2 -2
  27. package/dist/{getMachineId-linux-NsJbNTda.mjs → getMachineId-linux-7FQ_TPIw.mjs} +1 -1
  28. package/dist/{getMachineId-unsupported-BdKw63O1.mjs → getMachineId-unsupported-CqYci84U.mjs} +1 -1
  29. package/dist/{getMachineId-win-CpX0o49t.mjs → getMachineId-win-BxTTz_Ds.mjs} +2 -2
  30. package/dist/server.js +401 -346
  31. package/package.json +3 -3
  32. package/dist/client/assets/agent-CRsoHYEG.js +0 -1
  33. package/dist/client/assets/agent-DYjX-Pzl.js +0 -2
  34. package/dist/client/assets/button-fe_R2wzr.js +0 -16
  35. package/dist/client/assets/loader-circle-B1mHTP2Y.js +0 -1
  36. package/dist/client/assets/portless-D4NDzBYJ.js +0 -1
  37. package/dist/client/assets/portless-D73tczCx.js +0 -2
  38. package/dist/client/assets/route-0gFXuUyt.js +0 -2
  39. package/dist/client/assets/route-BcNQ-aN-.js +0 -45
  40. package/dist/client/assets/run-B5fcXFyP.js +0 -2
  41. package/dist/client/assets/state-C-LyNCwu.js +0 -2
  42. package/dist/client/assets/terminal-B3oT0xJm.js +0 -2
  43. package/dist/client/assets/terminal-EfiQ0Ote.js +0 -1
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S node --max-old-space-size=8192
2
2
  import { createRequire } from "node:module";
3
3
  import * as Http from "node:http";
4
4
  import { createServer } from "node:http";
@@ -5442,7 +5442,7 @@ const flatMap$6 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(s
5442
5442
  * @category filtering
5443
5443
  * @since 2.0.0
5444
5444
  */
5445
- const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some$1(self.value) : none());
5445
+ const filter$2 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some$1(self.value) : none());
5446
5446
  //#endregion
5447
5447
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/Result.js
5448
5448
  /**
@@ -6034,6 +6034,61 @@ const Array$1 = globalThis.Array;
6034
6034
  */
6035
6035
  const allocate = (n) => new Array$1(n);
6036
6036
  /**
6037
+ * Creates a `NonEmptyArray` of length `n` where element `i` is computed by `f(i)`.
6038
+ *
6039
+ * **When to use**
6040
+ *
6041
+ * Use when you need an array whose values depend on the index.
6042
+ * - `n` is normalized to an integer >= 1 — always returns at least one element.
6043
+ * - Dual: `Array.makeBy(5, f)` or `pipe(5, Array.makeBy(f))`.
6044
+ *
6045
+ * **Example** (Generating values from indices)
6046
+ *
6047
+ * ```ts
6048
+ * import { Array } from "effect"
6049
+ *
6050
+ * const result = Array.makeBy(5, (n) => n * 2)
6051
+ * console.log(result) // [0, 2, 4, 6, 8]
6052
+ * ```
6053
+ *
6054
+ * @see {@link range} — create a range of integers
6055
+ * @see {@link replicate} — repeat a single value
6056
+ *
6057
+ * @category constructors
6058
+ * @since 2.0.0
6059
+ */
6060
+ const makeBy = /*#__PURE__*/ dual(2, (n, f) => {
6061
+ const max = Math.max(1, Math.floor(n));
6062
+ const out = new Array$1(max);
6063
+ for (let i = 0; i < max; i++) out[i] = f(i);
6064
+ return out;
6065
+ });
6066
+ /**
6067
+ * Creates a `NonEmptyArray` containing a range of integers, inclusive on both
6068
+ * ends.
6069
+ *
6070
+ * **When to use**
6071
+ *
6072
+ * Use when you need a sequence of consecutive integers.
6073
+ * - If `start > end`, returns `[start]`.
6074
+ * - Always returns a `NonEmptyArray`.
6075
+ *
6076
+ * **Example** (Creating a range)
6077
+ *
6078
+ * ```ts
6079
+ * import { Array } from "effect"
6080
+ *
6081
+ * const result = Array.range(1, 3)
6082
+ * console.log(result) // [1, 2, 3]
6083
+ * ```
6084
+ *
6085
+ * @see {@link makeBy} — generate values from a function
6086
+ *
6087
+ * @category constructors
6088
+ * @since 2.0.0
6089
+ */
6090
+ const range = (start, end) => start <= end ? makeBy(end - start + 1, (i) => start + i) : [start];
6091
+ /**
6037
6092
  * Converts an `Iterable` to an `Array`.
6038
6093
  *
6039
6094
  * **When to use**
@@ -6535,6 +6590,35 @@ const drop$1 = /*#__PURE__*/ dual(2, (self, n) => {
6535
6590
  return input.slice(clamp(n, input), input.length);
6536
6591
  });
6537
6592
  /**
6593
+ * Removes the last `n` elements, creating a new array.
6594
+ *
6595
+ * **When to use**
6596
+ *
6597
+ * Use to remove the last `n` elements from an iterable.
6598
+ *
6599
+ * **Details**
6600
+ *
6601
+ * `n` is clamped to `[0, length]`.
6602
+ *
6603
+ * **Example** (Dropping from the end)
6604
+ *
6605
+ * ```ts
6606
+ * import { Array } from "effect"
6607
+ *
6608
+ * console.log(Array.dropRight([1, 2, 3, 4, 5], 2)) // [1, 2, 3]
6609
+ * ```
6610
+ *
6611
+ * @see {@link drop} — remove from the start
6612
+ * @see {@link takeRight} — keep from the end
6613
+ *
6614
+ * @category getters
6615
+ * @since 2.0.0
6616
+ */
6617
+ const dropRight = /*#__PURE__*/ dual(2, (self, n) => {
6618
+ const input = fromIterable$2(self);
6619
+ return input.slice(0, input.length - clamp(n, input));
6620
+ });
6621
+ /**
6538
6622
  * Reverses an iterable into a new array.
6539
6623
  *
6540
6624
  * **When to use**
@@ -6895,7 +6979,7 @@ const getSuccesses = (self) => {
6895
6979
  * @category filtering
6896
6980
  * @since 2.0.0
6897
6981
  */
6898
- const filter$2 = /*#__PURE__*/ dual(2, (self, predicate) => {
6982
+ const filter$1 = /*#__PURE__*/ dual(2, (self, predicate) => {
6899
6983
  const as = fromIterable$2(self);
6900
6984
  const out = [];
6901
6985
  for (let i = 0; i < as.length; i++) if (predicate(as[i], i)) out.push(as[i]);
@@ -19599,7 +19683,7 @@ function transformOptional(f) {
19599
19683
  */
19600
19684
  function withDefault$1(defaultValue) {
19601
19685
  return new Getter((o) => {
19602
- const filtered = filter$3(o, isNotUndefined);
19686
+ const filtered = filter$2(o, isNotUndefined);
19603
19687
  return isSome(filtered) ? succeed$3(filtered) : mapEager(defaultValue, some$1);
19604
19688
  });
19605
19689
  }
@@ -20748,7 +20832,7 @@ var Declaration = class Declaration extends Base {
20748
20832
  * @category models
20749
20833
  * @since 4.0.0
20750
20834
  */
20751
- var Null = class extends Base {
20835
+ var Null$1 = class extends Base {
20752
20836
  _tag = "Null";
20753
20837
  /** @internal */
20754
20838
  getParser() {
@@ -20759,7 +20843,7 @@ var Null = class extends Base {
20759
20843
  return "null";
20760
20844
  }
20761
20845
  };
20762
- const null_ = /*#__PURE__*/ new Null();
20846
+ const null_ = /*#__PURE__*/ new Null$1();
20763
20847
  /**
20764
20848
  * AST node matching the `undefined` value.
20765
20849
  *
@@ -23209,7 +23293,7 @@ const takeAll$2 = (self) => takeN(self, self.length);
23209
23293
  * @category elements
23210
23294
  * @since 4.0.0
23211
23295
  */
23212
- const take$4 = (self) => {
23296
+ const take$3 = (self) => {
23213
23297
  if (!self.head) return Empty$2;
23214
23298
  const message = self.head.array[self.head.offset];
23215
23299
  if (self.head.mutable) self.head.array[self.head.offset] = void 0;
@@ -23263,7 +23347,7 @@ const take$4 = (self) => {
23263
23347
  * @category mutations
23264
23348
  * @since 4.0.0
23265
23349
  */
23266
- const filter$1 = (self, f) => {
23350
+ const filter = (self, f) => {
23267
23351
  const array = [];
23268
23352
  let chunk = self.head;
23269
23353
  while (chunk) {
@@ -23329,7 +23413,7 @@ const filter$1 = (self, f) => {
23329
23413
  * @category mutations
23330
23414
  * @since 4.0.0
23331
23415
  */
23332
- const remove$5 = (self, value) => filter$1(self, (v) => v !== value);
23416
+ const remove$5 = (self, value) => filter(self, (v) => v !== value);
23333
23417
  //#endregion
23334
23418
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/MutableRef.js
23335
23419
  const TypeId$38 = "~effect/MutableRef";
@@ -23911,7 +23995,7 @@ const unsubscribe = (self) => uninterruptible(withFiber((state) => {
23911
23995
  * @category subscriptions
23912
23996
  * @since 4.0.0
23913
23997
  */
23914
- const take$3 = (self) => suspend$2(() => {
23998
+ const take$2 = (self) => suspend$2(() => {
23915
23999
  if (self.shutdownFlag.current) return interrupt$1;
23916
24000
  if (self.replayWindow.remaining > 0) return succeed$3(self.replayWindow.take());
23917
24001
  const message = self.pollers.length === 0 ? self.subscription.poll() : Empty$2;
@@ -24657,7 +24741,7 @@ var BackPressureStrategy = class {
24657
24741
  onPubSubEmptySpaceUnsafe(pubsub, subscribers) {
24658
24742
  let keepPolling = true;
24659
24743
  while (keepPolling && !pubsub.isFull()) {
24660
- const publisher = take$4(this.publishers);
24744
+ const publisher = take$3(this.publishers);
24661
24745
  if (publisher === Empty$2) keepPolling = false;
24662
24746
  else {
24663
24747
  const [value, deferred] = publisher;
@@ -24696,7 +24780,7 @@ var BackPressureStrategy = class {
24696
24780
  }
24697
24781
  }
24698
24782
  removeUnsafe(deferred) {
24699
- filter$1(this.publishers, ([_, d]) => d !== deferred);
24783
+ filter(this.publishers, ([_, d]) => d !== deferred);
24700
24784
  }
24701
24785
  };
24702
24786
  /**
@@ -24769,7 +24853,7 @@ var DroppingStrategy = class {
24769
24853
  const strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscription, pollers) => {
24770
24854
  let keepPolling = true;
24771
24855
  while (keepPolling && !subscription.isEmpty()) {
24772
- const poller = take$4(pollers);
24856
+ const poller = take$3(pollers);
24773
24857
  if (poller === Empty$2) {
24774
24858
  removeSubscribers(subscribers, subscription, pollers);
24775
24859
  if (pollers.length === 0) keepPolling = false;
@@ -25155,7 +25239,7 @@ const offer = (self, message) => suspend$3(() => {
25155
25239
  }
25156
25240
  return offerRemainingSingle(self, message);
25157
25241
  case "sliding":
25158
- take$4(self.messages);
25242
+ take$3(self.messages);
25159
25243
  append(self.messages, message);
25160
25244
  return exitTrue;
25161
25245
  }
@@ -25198,7 +25282,7 @@ const offerUnsafe = (self, message) => {
25198
25282
  if (self.state._tag !== "Open") return false;
25199
25283
  else if (self.messages.length >= self.capacity) {
25200
25284
  if (self.strategy === "sliding") {
25201
- take$4(self.messages);
25285
+ take$3(self.messages);
25202
25286
  append(self.messages, message);
25203
25287
  return true;
25204
25288
  } else if (self.capacity <= 0 && self.state.takers.size > 0) {
@@ -25561,7 +25645,7 @@ const takeBetween = (self, min, max) => suspend$3(() => takeBetweenUnsafe(self,
25561
25645
  * @category taking
25562
25646
  * @since 2.0.0
25563
25647
  */
25564
- const take$2 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake(self), take$2(self)));
25648
+ const take$1 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake(self), take$1(self)));
25565
25649
  /**
25566
25650
  * Attempts to take one message from the queue synchronously.
25567
25651
  *
@@ -25603,14 +25687,14 @@ const take$2 = (self) => suspend$3(() => takeUnsafe(self) ?? andThen$1(awaitTake
25603
25687
  const takeUnsafe = (self) => {
25604
25688
  if (self.state._tag === "Done") return self.state.exit;
25605
25689
  if (self.messages.length > 0) {
25606
- const message = take$4(self.messages);
25690
+ const message = take$3(self.messages);
25607
25691
  releaseCapacity(self);
25608
25692
  return exitSucceed(message);
25609
25693
  } else if (self.capacity <= 0 && self.state.offers.size > 0) {
25610
25694
  self.capacity = 1;
25611
25695
  releaseCapacity(self);
25612
25696
  self.capacity = 0;
25613
- const message = take$4(self.messages);
25697
+ const message = take$3(self.messages);
25614
25698
  releaseCapacity(self);
25615
25699
  return exitSucceed(message);
25616
25700
  }
@@ -25682,7 +25766,7 @@ const takeBetweenUnsafe = (self, min, max) => {
25682
25766
  self.capacity = 1;
25683
25767
  releaseCapacity(self);
25684
25768
  self.capacity = 0;
25685
- const messages = [take$4(self.messages)];
25769
+ const messages = [take$3(self.messages)];
25686
25770
  releaseCapacity(self);
25687
25771
  return exitSucceed(messages);
25688
25772
  }
@@ -26841,7 +26925,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
26841
26925
  } else {
26842
26926
  const effects = yield* bounded(concurrencyN - 2);
26843
26927
  yield* addFinalizer$1(forkedScope, shutdown(queue));
26844
- yield* take$2(effects).pipe(flatten$1, flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), catchCause$1((cause) => failCause$1(queue, cause)), forkIn(forkedScope));
26928
+ yield* take$1(effects).pipe(flatten$1, flatMap$2((value) => offer(queue, value)), forever({ disableYield: true }), catchCause$1((cause) => failCause$1(queue, cause)), forkIn(forkedScope));
26845
26929
  let errorCause;
26846
26930
  const onExit = (exit) => {
26847
26931
  if (exit._tag === "Success") return;
@@ -26856,7 +26940,7 @@ const mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntrace
26856
26940
  return offer(effects, join$1(fiber));
26857
26941
  }), forever({ disableYield: true }), catchCause$1((cause) => offer(effects, failCause$3(cause)).pipe(andThen(failCause$1(effects, cause)))), forkIn(forkedScope));
26858
26942
  }
26859
- return take$2(queue);
26943
+ return take$1(queue);
26860
26944
  }));
26861
26945
  /**
26862
26946
  * Maps each output element to a channel and flattens the child channel
@@ -26966,47 +27050,6 @@ const flattenArray = (self) => transformPull$1(self, (pull) => {
26966
27050
  }));
26967
27051
  });
26968
27052
  /**
26969
- * Filters arrays of elements emitted by a channel, applying the filter
26970
- * to each element within the arrays and only emitting non-empty filtered arrays.
26971
- *
26972
- * **Example** (Filtering array output)
26973
- *
26974
- * ```ts
26975
- * import { Array, Channel } from "effect"
26976
- *
26977
- * const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty
26978
- *
26979
- * // Create a channel that outputs arrays of mixed data
26980
- * const arrayChannel = Channel.fromIterable([
26981
- * Array.make(1, 2, 3, 4, 5),
26982
- * Array.make(6, 7, 8, 9, 10),
26983
- * Array.make(11, 12, 13, 14, 15)
26984
- * ]).pipe(Channel.filter(nonEmptyArrayPredicate))
26985
- *
26986
- * // Filter arrays to keep only even numbers
26987
- * const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0)
26988
- * // Outputs: [2, 4], [6, 8, 10], [12, 14]
26989
- * // Note: Only non-empty filtered arrays are emitted
26990
- *
26991
- * // Arrays that would become empty after filtering are discarded entirely
26992
- * const oddChannel = Channel.fromIterable([
26993
- * Array.make(1, 3, 5),
26994
- * Array.make(2, 4),
26995
- * Array.make(7, 9)
26996
- * ]).pipe(Channel.filter(nonEmptyArrayPredicate))
26997
- * const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0)
26998
- * // Outputs: [2, 4] (the arrays [1,3,5] and [7,9] are discarded)
26999
- * ```
27000
- *
27001
- * @category filtering
27002
- * @since 4.0.0
27003
- */
27004
- const filterArray = /*#__PURE__*/ dual(2, (self, predicate) => transformPull$1(self, (pull) => succeed$3(flatMap$2(pull, function loop(arr) {
27005
- const passes = [];
27006
- for (let i = 0; i < arr.length; i++) if (predicate(arr[i])) passes.push(arr[i]);
27007
- return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$2(pull, loop);
27008
- }))));
27009
- /**
27010
27053
  * Catches any cause of failure from the channel and allows recovery by
27011
27054
  * creating a new channel based on the caught cause.
27012
27055
  *
@@ -27175,7 +27218,7 @@ const mergeAll = /*#__PURE__*/ dual(2, (channels, { bufferSize = 16, concurrency
27175
27218
  fibers.add(fiber);
27176
27219
  }
27177
27220
  }).pipe(catchCause$1((cause) => doneLatch.whenOpen(failCause$1(queue, cause))), forkIn(forkedScope));
27178
- return take$2(queue);
27221
+ return take$1(queue);
27179
27222
  })));
27180
27223
  /**
27181
27224
  * Returns a new channel, which is the merge of this channel and the specified
@@ -27224,7 +27267,7 @@ const merge$2 = /*#__PURE__*/ dual((args) => isChannel(args[0]) && isChannel(arg
27224
27267
  const runSide = (side, channel, scope) => toTransform(channel)(upstream, scope).pipe(flatMap$2((pull) => pull.pipe(flatMap$2((value) => offer(queue, value)), forever)), onError((cause) => andThen(close(scope, doneExitFromCause(cause)), onExit(side, cause))), forkIn(forkedScope));
27225
27268
  yield* runSide("left", left, forkUnsafe(forkedScope));
27226
27269
  yield* runSide("right", right, forkUnsafe(forkedScope));
27227
- return take$2(queue);
27270
+ return take$1(queue);
27228
27271
  })));
27229
27272
  /**
27230
27273
  * Splits upstream string chunks into lines, recognizing `\n`, `\r\n`, and
@@ -27464,35 +27507,6 @@ const runWith = (self, f, onHalt) => suspend$2(() => {
27464
27507
  */
27465
27508
  const provideContext$1 = /*#__PURE__*/ dual(2, (self, context) => fromTransform$1((upstream, scope) => map$4(provideContext$2(toTransform(self)(upstream, scope), context), provideContext$2(context))));
27466
27509
  /**
27467
- * Runs a channel and discards all output elements, returning only the final result.
27468
- *
27469
- * **Example** (Draining channel output at runtime)
27470
- *
27471
- * ```ts
27472
- * import { Channel, Data } from "effect"
27473
- *
27474
- * class DrainError extends Data.TaggedError("DrainError")<{
27475
- * readonly stage: string
27476
- * }> {}
27477
- *
27478
- * // Create a channel that outputs elements and completes with a result
27479
- * const resultChannel = Channel.fromIterable([1, 2, 3])
27480
- * const completedChannel = Channel.concatWith(
27481
- * resultChannel,
27482
- * () => Channel.succeed("completed")
27483
- * )
27484
- *
27485
- * // Drain all elements and get only the final result
27486
- * const drainEffect = Channel.runDrain(completedChannel)
27487
- *
27488
- * // Effect.runSync(drainEffect) // Returns: "completed"
27489
- * ```
27490
- *
27491
- * @category execution
27492
- * @since 2.0.0
27493
- */
27494
- const runDrain$1 = (self) => runWith(self, (pull) => forever(pull, { disableYield: true }));
27495
- /**
27496
27510
  * Runs a channel and applies an effect to each output element.
27497
27511
  *
27498
27512
  * **Example** (Running effects for each output)
@@ -27711,7 +27725,7 @@ const drain = /*#__PURE__*/ fromTransform((upstream) => catchDone(forever(upstre
27711
27725
  * @category collecting
27712
27726
  * @since 2.0.0
27713
27727
  */
27714
- const take$1 = (n) => fromTransform((upstream) => {
27728
+ const take = (n) => fromTransform((upstream) => {
27715
27729
  const taken = [];
27716
27730
  if (n <= 0) return succeed$3([taken]);
27717
27731
  let leftover = void 0;
@@ -28364,6 +28378,56 @@ const release = (self, key, entry) => withFiber((fiber) => {
28364
28378
  })), runForkWith(fiber.context), runIn(self.scope));
28365
28379
  return void_$1;
28366
28380
  });
28381
+ /**
28382
+ * Invalidates and removes a specific key from the RcMap. If the resource is not
28383
+ * currently in use (reference count is 0), it will be immediately released.
28384
+ *
28385
+ * **When to use**
28386
+ *
28387
+ * Use to remove a resource by key so the next access performs a fresh lookup.
28388
+ *
28389
+ * **Example** (Invalidating a resource)
28390
+ *
28391
+ * ```ts
28392
+ * import { Effect, RcMap } from "effect"
28393
+ *
28394
+ * Effect.gen(function*() {
28395
+ * const map = yield* RcMap.make({
28396
+ * lookup: (key: string) =>
28397
+ * Effect.acquireRelease(
28398
+ * Effect.succeed(`Resource: ${key}`),
28399
+ * () => Effect.log(`Released ${key}`)
28400
+ * )
28401
+ * })
28402
+ *
28403
+ * // Get a resource
28404
+ * yield* RcMap.get(map, "cache")
28405
+ *
28406
+ * // Invalidate the resource - it will be removed from the map
28407
+ * // and released if no longer in use
28408
+ * yield* RcMap.invalidate(map, "cache")
28409
+ *
28410
+ * // Next access will create a new resource
28411
+ * yield* RcMap.get(map, "cache")
28412
+ * }).pipe(Effect.scoped)
28413
+ * ```
28414
+ *
28415
+ * @see {@link get} for acquiring or retaining the resource for a key
28416
+ * @see {@link touch} for extending the idle lifetime without removing the entry
28417
+ *
28418
+ * @category combinators
28419
+ * @since 3.13.0
28420
+ */
28421
+ const invalidate = /*#__PURE__*/ dual(2, /*#__PURE__*/ fnUntraced(function* (self, key) {
28422
+ if (self.state._tag === "Closed") return;
28423
+ const o = get$7(self.state.map, key);
28424
+ if (o._tag === "None") return;
28425
+ const entry = o.value;
28426
+ remove$4(self.state.map, key);
28427
+ if (entry.refCount > 0) return;
28428
+ if (entry.fiber) yield* interrupt(entry.fiber);
28429
+ yield* close(entry.scope, void_$2);
28430
+ }, uninterruptible));
28367
28431
  //#endregion
28368
28432
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.74/node_modules/effect/dist/internal/rcRef.js
28369
28433
  const TypeId$30 = "~effect/RcRef";
@@ -29313,30 +29377,6 @@ const concat = /*#__PURE__*/ dual(2, (self, that) => flatten(fromArray([self, th
29313
29377
  * @since 2.0.0
29314
29378
  */
29315
29379
  const merge$1 = /*#__PURE__*/ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel(merge$2(toChannel(self), toChannel(that), options)));
29316
- /**
29317
- * Filters a stream to the elements that satisfy a predicate.
29318
- *
29319
- * **Example** (Filtering stream values)
29320
- *
29321
- * ```ts
29322
- * import { Console, Effect, Stream } from "effect"
29323
- *
29324
- * const program = Effect.gen(function*() {
29325
- * const stream = Stream.make(1, 2, 3, 4).pipe(
29326
- * Stream.filter((n) => n % 2 === 0)
29327
- * )
29328
- * const values = yield* Stream.runCollect(stream)
29329
- * yield* Console.log(values)
29330
- * })
29331
- *
29332
- * Effect.runPromise(program)
29333
- * // Output: [ 2, 4 ]
29334
- * ```
29335
- *
29336
- * @category filtering
29337
- * @since 2.0.0
29338
- */
29339
- const filter = /*#__PURE__*/ dual(2, (self, predicate) => fromChannel(filterArray(toChannel(self), predicate)));
29340
29380
  const catch_ = /*#__PURE__*/ dual(2, (self, f) => fromChannel(catch_$1(self.channel, (error) => f(error).channel)));
29341
29381
  /**
29342
29382
  * Turns typed failures into defects, making the stream infallible.
@@ -29364,30 +29404,6 @@ const catch_ = /*#__PURE__*/ dual(2, (self, f) => fromChannel(catch_$1(self.chan
29364
29404
  */
29365
29405
  const orDie = (self) => fromChannel(orDie$1(self.channel));
29366
29406
  /**
29367
- * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`.
29368
- *
29369
- * **Example** (Taking values from the left)
29370
- *
29371
- * ```ts
29372
- * import { Console, Effect, Stream } from "effect"
29373
- *
29374
- * const program = Effect.gen(function*() {
29375
- * const values = yield* Stream.make(1, 2, 3, 4, 5).pipe(
29376
- * Stream.take(3),
29377
- * Stream.runCollect
29378
- * )
29379
- * yield* Console.log(values)
29380
- * })
29381
- *
29382
- * Effect.runPromise(program)
29383
- * // Output: [ 1, 2, 3 ]
29384
- * ```
29385
- *
29386
- * @category filtering
29387
- * @since 2.0.0
29388
- */
29389
- const take = /*#__PURE__*/ dual(2, (self, n) => n < 1 ? empty$8 : takeUntil(self, (_, i) => i === n - 1));
29390
- /**
29391
29407
  * Takes elements until the predicate matches.
29392
29408
  *
29393
29409
  * **Details**
@@ -29563,7 +29579,7 @@ const debounce = /*#__PURE__*/ dual(2, (self, duration) => transformPull(self, f
29563
29579
  * @category grouping
29564
29580
  * @since 2.0.0
29565
29581
  */
29566
- const groupedWithin = /*#__PURE__*/ dual(3, (self, chunkSize, duration) => aggregateWithin(self, take$1(chunkSize), spaced(duration)));
29582
+ const groupedWithin = /*#__PURE__*/ dual(3, (self, chunkSize, duration) => aggregateWithin(self, take(chunkSize), spaced(duration)));
29567
29583
  /**
29568
29584
  * Applies a sink transducer to the stream and emits each sink result.
29569
29585
  *
@@ -29651,7 +29667,7 @@ const aggregateWithin = /*#__PURE__*/ dual(3, (self, sink, schedule) => fromChan
29651
29667
  const stepToBuffer = suspend$2(function loop() {
29652
29668
  return step(lastOutput).pipe(flatMap$2(() => !sinkHasInput ? loop() : offer(buffer, scheduleStep)), flatMap$2(() => never$1), catchDone(() => done()));
29653
29669
  });
29654
- const pullFromBuffer = take$2(buffer).pipe(flatMap$2((arr) => {
29670
+ const pullFromBuffer = take$1(buffer).pipe(flatMap$2((arr) => {
29655
29671
  if (arr === scheduleStep) return done();
29656
29672
  sinkHasInput = true;
29657
29673
  return succeed$3(arr);
@@ -29939,32 +29955,6 @@ const runForEach = /*#__PURE__*/ dual(2, (self, f) => runForEach$1(self.channel,
29939
29955
  */
29940
29956
  const runForEachArray = /*#__PURE__*/ dual(2, (self, f) => runForEach$1(self.channel, f));
29941
29957
  /**
29942
- * Runs the stream for its effects, discarding emitted elements.
29943
- *
29944
- * **Example** (Draining a stream run)
29945
- *
29946
- * ```ts
29947
- * import { Console, Effect, Stream } from "effect"
29948
- *
29949
- * const program = Effect.gen(function*() {
29950
- * const stream = Stream.make(1, 2, 3).pipe(
29951
- * Stream.mapEffect((n) => Console.log(`Processing: ${n}`))
29952
- * )
29953
- *
29954
- * yield* Stream.runDrain(stream)
29955
- * })
29956
- *
29957
- * Effect.runPromise(program)
29958
- * // Processing: 1
29959
- * // Processing: 2
29960
- * // Processing: 3
29961
- * ```
29962
- *
29963
- * @category destructors
29964
- * @since 2.0.0
29965
- */
29966
- const runDrain = (self) => runDrain$1(self.channel);
29967
- /**
29968
29958
  * Concatenates all emitted strings into a single string.
29969
29959
  *
29970
29960
  * **Example** (Joining strings from a stream)
@@ -33331,6 +33321,14 @@ const Any = /*#__PURE__*/ make$35(any);
33331
33321
  */
33332
33322
  const Unknown = /*#__PURE__*/ make$35(unknown);
33333
33323
  /**
33324
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
33325
+ *
33326
+ * @see {@link NullOr} for a union with another schema.
33327
+ * @category schemas
33328
+ * @since 3.10.0
33329
+ */
33330
+ const Null = /*#__PURE__*/ make$35(null_);
33331
+ /**
33334
33332
  * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
33335
33333
  *
33336
33334
  * @see {@link UndefinedOr} for a union with another schema.
@@ -33536,6 +33534,13 @@ function Literals(literals) {
33536
33534
  });
33537
33535
  }
33538
33536
  /**
33537
+ * Creates a union schema of `S | null`.
33538
+ *
33539
+ * @category constructors
33540
+ * @since 3.10.0
33541
+ */
33542
+ const NullOr = /*#__PURE__*/ lambda((self) => Union([self, Null]));
33543
+ /**
33539
33544
  * Creates a union schema of `S | undefined`.
33540
33545
  *
33541
33546
  * @category constructors
@@ -43775,7 +43780,7 @@ const make$16 = /*#__PURE__*/ fnUntraced(function* (group, options) {
43775
43780
  }).pipe(provide$3(scope));
43776
43781
  yield* forkChild(whileLoop({
43777
43782
  while: constTrue,
43778
- body: constant(flatMap$2(take$2(disconnects), (clientId) => {
43783
+ body: constant(flatMap$2(take$1(disconnects), (clientId) => {
43779
43784
  clients.delete(clientId);
43780
43785
  return server.disconnect(clientId);
43781
43786
  })),
@@ -52257,6 +52262,22 @@ var GitHubReviewThread = class extends Class("GitHubReviewThread")({
52257
52262
  side: optional(Literals(["additions", "deletions"])),
52258
52263
  url: optional(String$1)
52259
52264
  }) {};
52265
+ const GitHubRepositoryResponse = Struct({
52266
+ name: String$1,
52267
+ owner: Struct({ login: String$1 })
52268
+ });
52269
+ const GitHubReviewThreadsResponse = Struct({ data: optional(Struct({ repository: optional(Struct({ pullRequest: optional(Struct({ reviewThreads: optional(Struct({ nodes: ArraySchema(Struct({
52270
+ comments: Struct({ nodes: ArraySchema(Struct({
52271
+ body: String$1,
52272
+ line: optional(NullOr(Number$1)),
52273
+ originalLine: optional(NullOr(Number$1)),
52274
+ path: String$1,
52275
+ url: optional(String$1)
52276
+ })) }),
52277
+ diffSide: optional(String$1),
52278
+ id: String$1,
52279
+ isResolved: Boolean$1
52280
+ })) })) })) })) })) });
52260
52281
  var GitRepository = class extends Class("GitRepository")({
52261
52282
  gitDirectory: String$1,
52262
52283
  root: String$1
@@ -52349,6 +52370,7 @@ const AgentSession = Struct({
52349
52370
  "pi"
52350
52371
  ]),
52351
52372
  label: String$1,
52373
+ state: TerminalState,
52352
52374
  uuid: String$1
52353
52375
  });
52354
52376
  var ReviewMark = class extends Class("ReviewMark")({
@@ -52570,6 +52592,26 @@ const makeGitExecutor = gen(function* () {
52570
52592
  })
52571
52593
  };
52572
52594
  });
52595
+ function toArgs(to) {
52596
+ return to.type === "ref" ? [to.ref] : empty$13();
52597
+ }
52598
+ function segmentsByFile(segments) {
52599
+ return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some$1(append$1(getOrElse$1(current, () => empty$13()), segment))));
52600
+ }
52601
+ function diffFromPatchChunk(chunk, segments) {
52602
+ const deleted = /^deleted file mode /mu.test(chunk);
52603
+ const filePath = (deleted ? chunk.match(/^--- a\/(.+)$/mu)?.[1] : void 0) ?? chunk.match(/^\+\+\+ b\/(.+)$/mu)?.[1] ?? chunk.match(/^--- a\/(.+)$/mu)?.[1] ?? chunk.match(/^diff --git a\/.+ b\/(.+)$/mu)?.[1] ?? "";
52604
+ const status = value(chunk).pipe(when((value) => /^new file mode /mu.test(value), () => "added"), when(() => deleted, () => "deleted"), when((value) => /^rename (from|to) /mu.test(value), () => "renamed"), orElse(() => "modified"));
52605
+ return new GitDiff({
52606
+ filePath,
52607
+ patch: chunk,
52608
+ segments: getOrElse$1(get$1(segments, filePath), () => empty$13()),
52609
+ status
52610
+ });
52611
+ }
52612
+ function isWipSubject(subject) {
52613
+ return subject === "wip" || startsWith("wip: ")(subject);
52614
+ }
52573
52615
  var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", { make: gen(function* () {
52574
52616
  const execString = yield* ChildProcessSpawner.useSync((spawner) => spawner.string);
52575
52617
  const git = yield* makeGitExecutor;
@@ -52615,25 +52657,28 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52615
52657
  const collectRepositoriesFromRoots = fnUntraced(function* (roots, repositories) {
52616
52658
  return yield* match$3(roots, {
52617
52659
  onEmpty: () => succeed$3(repositories),
52618
- onNonEmpty: (roots) => pipe(fs.readDirectory(roots[0]), orElseSucceed(() => empty$13()), flatMap$2((entries) => {
52619
- if (contains(entries, ".git")) return pipe(git.string(roots[0], [
52620
- "rev-parse",
52621
- "--path-format=absolute",
52622
- "--git-common-dir"
52623
- ]), map$4(trim), map$4((gitDirectory) => succeed$7(new GitRepository({
52624
- gitDirectory,
52625
- root: roots[0]
52626
- }))), orElseSucceed(() => failVoid), flatMap$2((repository) => collectRepositoriesFromRoots(drop$1(roots, 1), append$1(repositories, repository))));
52627
- return pipe(entries, filter$2((entry) => !(new Set([
52628
- ".git",
52629
- ".next",
52630
- ".turbo",
52631
- "build",
52632
- "coverage",
52633
- "dist",
52634
- "node_modules"
52635
- ]).has(entry) || startsWith(".")(entry) && entry !== ".git")), forEach$1((entry) => pipe(fs.stat(path.join(roots[0], entry)), map$4((info) => info.type === "Directory" ? path.join(roots[0], entry) : ""), orElseSucceed(() => ""))), flatMap$2((nextRoots) => collectRepositoriesFromRoots(pipe(nextRoots, filter$2(isNonEmpty$1), appendAll(drop$1(roots, 1))), repositories)));
52636
- }))
52660
+ onNonEmpty: (remainingRoots) => {
52661
+ const root = remainingRoots[0];
52662
+ return pipe(fs.readDirectory(root), orElseSucceed(() => empty$13()), flatMap$2((entries) => {
52663
+ if (contains(entries, ".git")) return pipe(git.string(root, [
52664
+ "rev-parse",
52665
+ "--path-format=absolute",
52666
+ "--git-common-dir"
52667
+ ]), map$4(trim), map$4((gitDirectory) => succeed$7(new GitRepository({
52668
+ gitDirectory,
52669
+ root
52670
+ }))), orElseSucceed(() => failVoid), flatMap$2((repository) => collectRepositoriesFromRoots(drop$1(remainingRoots, 1), append$1(repositories, repository))));
52671
+ return pipe(entries, filter$1((entry) => !(new Set([
52672
+ ".git",
52673
+ ".next",
52674
+ ".turbo",
52675
+ "build",
52676
+ "coverage",
52677
+ "dist",
52678
+ "node_modules"
52679
+ ]).has(entry) || startsWith(".")(entry) && entry !== ".git")), forEach$1((entry) => pipe(fs.stat(path.join(root, entry)), map$4((info) => info.type === "Directory" ? path.join(root, entry) : ""), orElseSucceed(() => ""))), flatMap$2((nextRoots) => collectRepositoriesFromRoots(pipe(nextRoots, filter$1(isNonEmpty$1), appendAll(drop$1(roots, 1))), repositories)));
52680
+ }));
52681
+ }
52637
52682
  });
52638
52683
  });
52639
52684
  const listWorktrees = fnUntraced(function* (cwd) {
@@ -52694,7 +52739,11 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52694
52739
  yield* set(projects, yield* listProjectsFrom(home));
52695
52740
  });
52696
52741
  yield* refreshProjects();
52697
- yield* acquireRelease(sync(() => NFS.watch(home, () => run(refreshProjects()))), (watcher) => sync(() => watcher.close()));
52742
+ yield* acquireRelease(sync(() => NFS.watch(home, () => {
52743
+ run(refreshProjects());
52744
+ })), (watcher) => sync(() => {
52745
+ watcher.close();
52746
+ }));
52698
52747
  return {
52699
52748
  branches: fnUntraced(function* (cwd) {
52700
52749
  return new GitBranchesSnapshot({
@@ -52709,11 +52758,11 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52709
52758
  "for-each-ref",
52710
52759
  "--format=%(refname:short)",
52711
52760
  "refs/remotes"
52712
- ]), map$4((lines) => pipe(lines, filter$2((name) => !endsWith("/HEAD")(name)), map$7((name) => new GitBranch({
52761
+ ]), map$4((lines) => pipe(lines, filter$1((name) => !endsWith("/HEAD")(name)), map$7((name) => new GitBranch({
52713
52762
  name: pipe(split$1("/")(name), drop$1(1), join$2("/")),
52714
52763
  remote: split$1("/")(name)[0],
52715
52764
  type: "remote"
52716
- })), filter$2((branch) => isNonEmpty$1(branch.name)), appendAll(localBranches)))))),
52765
+ })), filter$1((branch) => isNonEmpty$1(branch.name)), appendAll(localBranches)))))),
52717
52766
  defaultBranch: yield* getDefaultBranch(cwd)
52718
52767
  });
52719
52768
  }),
@@ -52816,7 +52865,7 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52816
52865
  ...input.force ? ["--force"] : [],
52817
52866
  input.cwd
52818
52867
  ]), asVoid);
52819
- if (worktree.branch !== void 0) yield* pipe(git.string(worktree.mainRoot, [
52868
+ if (isNotUndefined(worktree.branch)) yield* pipe(git.string(worktree.mainRoot, [
52820
52869
  "branch",
52821
52870
  "-D",
52822
52871
  worktree.branch
@@ -52845,26 +52894,9 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52845
52894
  "HEAD"
52846
52895
  ]), map$4(trim));
52847
52896
  });
52848
- function toArgs(to) {
52849
- return to.type === "ref" ? [to.ref] : empty$13();
52850
- }
52851
- function segmentsByFile(segments) {
52852
- return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some$1(append$1(getOrElse$1(current, () => empty$13()), segment))));
52853
- }
52854
- function diffFromPatchChunk(chunk, segments) {
52855
- const deleted = /^deleted file mode /mu.test(chunk);
52856
- const filePath = (deleted ? chunk.match(/^--- a\/(.+)$/mu)?.[1] : void 0) ?? chunk.match(/^\+\+\+ b\/(.+)$/mu)?.[1] ?? chunk.match(/^--- a\/(.+)$/mu)?.[1] ?? chunk.match(/^diff --git a\/.+ b\/(.+)$/mu)?.[1] ?? "";
52857
- const status = /^new file mode /mu.test(chunk) ? "added" : deleted ? "deleted" : /^rename (from|to) /mu.test(chunk) ? "renamed" : "modified";
52858
- return new GitDiff({
52859
- filePath,
52860
- patch: chunk,
52861
- segments: getOrElse$1(get$1(segments, filePath), () => empty$13()),
52862
- status
52863
- });
52864
- }
52865
52897
  function diffsFromPatch(patch, segments) {
52866
52898
  const groupedSegments = segmentsByFile(segments);
52867
- return pipe(patch.split(/(?=^diff --git )/mu), filter$2(isNonEmpty$1), map$7((chunk) => diffFromPatchChunk(chunk, groupedSegments)));
52899
+ return pipe(patch.split(/(?=^diff --git )/mu), filter$1(isNonEmpty$1), map$7((chunk) => diffFromPatchChunk(chunk, groupedSegments)));
52868
52900
  }
52869
52901
  function attachSegments(diffs, segments) {
52870
52902
  const groupedSegments = segmentsByFile(segments);
@@ -52911,13 +52943,13 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52911
52943
  "--find-renames",
52912
52944
  "--name-only",
52913
52945
  `${input.from}..${input.to}`
52914
- ])).split("\0DESLOP-COMMIT\0"), filter$2(isNonEmpty$1), flatMap$5((entry) => {
52946
+ ])).split("\0DESLOP-COMMIT\0"), filter$1(isNonEmpty$1), flatMap$5((entry) => {
52915
52947
  const lines = split$1("\n")(entry);
52916
- const header = lines[0] ?? "";
52948
+ const header = lines[0];
52917
52949
  const parts = split$1("\0")(header);
52918
- const commit = parts[0] ?? "";
52919
- const id = `${pipe(parts[1] ?? "", split$1(" "), filter$2(isNonEmpty$1))[0] ?? `${commit}^`}->${commit}`;
52920
- return pipe(drop$1(lines, 1), filter$2(isNonEmpty$1), map$7((filePath) => new GitDiffSegment({
52950
+ const commit = parts[0];
52951
+ const id = `${pipe(parts[1] ?? "", split$1(" "), filter$1(isNonEmpty$1))[0] ?? `${commit}^`}->${commit}`;
52952
+ return pipe(drop$1(lines, 1), filter$1(isNonEmpty$1), map$7((filePath) => new GitDiffSegment({
52921
52953
  filePath,
52922
52954
  fingerprint: `${id}:${filePath}`,
52923
52955
  id,
@@ -52993,15 +53025,12 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52993
53025
  "--jq",
52994
53026
  ".url"
52995
53027
  ]), map$4(trim), map$4((url) => isNonEmpty$1(url) ? some$1(url) : none()), catchTag("GitError", () => succeed$3(none())));
52996
- function isWipSubject(subject) {
52997
- return subject === "wip" || startsWith("wip: ")(subject);
52998
- }
52999
53028
  function commitFromLogLine(line) {
53000
53029
  const parts = split$1("\0")(line);
53001
53030
  const subject = parts[2] ?? "";
53002
53031
  return new GitCommit({
53003
- hash: parts[0] ?? "",
53004
- parents: pipe(parts[3] ?? "", split$1(" "), filter$2(isNonEmpty$1)),
53032
+ hash: parts[0],
53033
+ parents: pipe(parts[3] ?? "", split$1(" "), filter$1(isNonEmpty$1)),
53005
53034
  shortHash: parts[1] ?? "",
53006
53035
  subject,
53007
53036
  wip: isWipSubject(subject)
@@ -53085,7 +53114,10 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53085
53114
  "view",
53086
53115
  "--json",
53087
53116
  "owner,name"
53088
- ]), map$4((output) => JSON.parse(output)));
53117
+ ]), flatMap$2(decodeUnknownEffect(fromJsonString(GitHubRepositoryResponse))), mapError$2((cause) => new GitError({
53118
+ cause,
53119
+ message: "Failed to parse GitHub repository."
53120
+ })));
53089
53121
  const response = yield* ghString([
53090
53122
  "api",
53091
53123
  "graphql",
@@ -53120,12 +53152,15 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53120
53152
  "-F",
53121
53153
  `number=${pr}`
53122
53154
  ]);
53123
- return pipe(JSON.parse(response).data?.repository?.pullRequest?.reviewThreads?.nodes ?? [], filter$2((thread) => thread.id !== void 0), flatMap$5((thread) => pipe(thread.comments?.nodes ?? [], filter$2((comment) => comment.body !== void 0 && comment.path !== void 0), map$7((comment) => new GitHubReviewThread({
53124
- body: comment.body ?? "",
53125
- filePath: comment.path ?? "",
53126
- id: thread.id ?? "",
53155
+ return pipe((yield* pipe(decodeUnknownEffect(fromJsonString(GitHubReviewThreadsResponse))(response), mapError$2((cause) => new GitError({
53156
+ cause,
53157
+ message: "Failed to parse GitHub review threads."
53158
+ })))).data?.repository?.pullRequest?.reviewThreads?.nodes ?? [], flatMap$5((thread) => pipe(thread.comments.nodes, map$7((comment) => new GitHubReviewThread({
53159
+ body: comment.body,
53160
+ filePath: comment.path,
53161
+ id: thread.id,
53127
53162
  lineNumber: comment.line ?? comment.originalLine ?? 1,
53128
- resolved: thread.isResolved === true,
53163
+ resolved: thread.isResolved,
53129
53164
  side: thread.diffSide === "LEFT" ? "deletions" : "additions",
53130
53165
  url: comment.url
53131
53166
  })))));
@@ -53155,7 +53190,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53155
53190
  createWipCommit: fnUntraced(function* (message) {
53156
53191
  if (!(yield* hasWorktreeChanges)) return yield* new GitError({ message: "No changes to commit." });
53157
53192
  yield* pipe(git.string(config.cwd, ["add", "-A"]), asVoid);
53158
- const subject = pipe(message, trim, (message) => isEmpty$1(message) ? "wip" : `wip: ${message}`);
53193
+ const subject = pipe(message, trim, (value) => isEmpty$1(value) ? "wip" : `wip: ${value}`);
53159
53194
  yield* pipe(git.string(config.cwd, [
53160
53195
  "commit",
53161
53196
  "-m",
@@ -53231,7 +53266,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53231
53266
  filePath
53232
53267
  ]), asVoid);
53233
53268
  }),
53234
- watchReviewRangeDiffs: (input) => pipe(worktreeChanges, mapEffect(() => pipe(reviewRangeDiffs(input), catchTag("GitError", () => succeed$3(empty$13())))), changesWith((left, right) => length(left) === length(right) && every(left, (leftDiff, index) => right[index] !== void 0 && leftDiff.filePath === right[index].filePath && leftDiff.status === right[index].status && leftDiff.patch === right[index].patch)))
53269
+ watchReviewRangeDiffs: (input) => pipe(worktreeChanges, mapEffect(() => pipe(reviewRangeDiffs(input), catchTag("GitError", () => succeed$3(empty$13())))), changesWith((left, right) => length(left) === length(right) && every(left, (leftDiff, index) => isNotUndefined(right[index]) && leftDiff.filePath === right[index].filePath && leftDiff.status === right[index].status && leftDiff.patch === right[index].patch)))
53235
53270
  };
53236
53271
  }) }) {
53237
53272
  static layer = flow(this.make, effect(this));
@@ -53264,14 +53299,14 @@ const discover = fnUntraced(function* (cwd, input) {
53264
53299
  "package.json",
53265
53300
  "**/package.json"
53266
53301
  ], { cwd }));
53267
- return yield* pipe(pipe(split$1("\n")(output), filter$2((path) => path === "package.json" || endsWith("/package.json")(path))), map$7((packagePath) => pipe(fs.readFileString(path.join(cwd, packagePath)), flatMap$2((source) => try_({
53302
+ return yield* pipe(pipe(split$1("\n")(output), filter$1((packagePath) => packagePath === "package.json" || endsWith("/package.json")(packagePath))), map$7((packagePath) => pipe(fs.readFileString(path.join(cwd, packagePath)), flatMap$2((source) => try_({
53268
53303
  catch: (error) => error,
53269
53304
  try: () => pipe(JSON.parse(source), decodeUnknownOption(PackageJson))
53270
53305
  })), catch_$2(() => succeed$3(none())), flatMap$2((packageJson) => {
53271
53306
  if (isNone(packageJson)) return succeed$3([]);
53272
53307
  const packageDirectory = packagePath === "package.json" ? cwd : path.join(cwd, path.dirname(packagePath));
53273
53308
  const folder = path.basename(packageDirectory);
53274
- const scriptEntries = pipe(Object.entries(packageJson.value.scripts ?? {}), filter$2((entry) => entry[0] === "dev" || startsWith("dev:")(entry[0])));
53309
+ const scriptEntries = pipe(Object.entries(packageJson.value.scripts ?? {}), filter$1((entry) => entry[0] === "dev" || startsWith("dev:")(entry[0])));
53275
53310
  const packageOrigin = input.origin([
53276
53311
  folder,
53277
53312
  path.basename(cwd),
@@ -53327,10 +53362,10 @@ const INJECTED_HEAD = `<script>
53327
53362
  if (typeof value === 'string') return value
53328
53363
  try { return JSON.stringify(value) } catch { return String(value) }
53329
53364
  }
53330
- const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
53365
+ const send = (level, message) => window.parent?.postMessage({deslopBrowserLog: true, level, message}, '*')
53331
53366
  const sendFavicon = () => {
53332
53367
  const icon = Array.from(document.head.querySelectorAll('link')).find(link => link.rel === 'shortcut icon' || link.rel.split(/\\s+/).includes('icon'))
53333
- window.parent?.postMessage({__deslopBrowserFavicon: true, href: icon?.href}, '*')
53368
+ window.parent?.postMessage({deslopBrowserFavicon: true, href: icon?.href}, '*')
53334
53369
  }
53335
53370
 
53336
53371
  for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
@@ -53344,7 +53379,7 @@ const INJECTED_HEAD = `<script>
53344
53379
  window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
53345
53380
  window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
53346
53381
  window.addEventListener('message', event => {
53347
- if (event.data?.__deslopBrowserClear !== true) return
53382
+ if (event.data?.deslopBrowserClear !== true) return
53348
53383
  localStorage.clear()
53349
53384
  sessionStorage.clear()
53350
53385
  document.cookie.split(';').forEach(cookie => {
@@ -53355,7 +53390,7 @@ const INJECTED_HEAD = `<script>
53355
53390
  location.reload()
53356
53391
  })
53357
53392
 
53358
- const sendLocation = () => window.parent?.postMessage({__deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
53393
+ const sendLocation = () => window.parent?.postMessage({deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
53359
53394
  const wrapHistory = name => {
53360
53395
  const original = history[name]
53361
53396
  history[name] = function(...args) {
@@ -53411,7 +53446,7 @@ const proxy = fnUntraced(function* (request, origin) {
53411
53446
  });
53412
53447
  const proxyWebSocket = fnUntraced(function* (request, origin) {
53413
53448
  const [pathname = "/", search = ""] = request.url.split("?");
53414
- const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((protocols) => pipe(protocols, split$1(","), map$7(trim), filter$2(isNonEmpty$1))));
53449
+ const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((header) => pipe(header, split$1(","), map$7(trim), filter$1(isNonEmpty$1))));
53415
53450
  const inbound = yield* request.upgrade;
53416
53451
  const upstreamUrl = new URL(origin);
53417
53452
  upstreamUrl.protocol = upstreamUrl.protocol === "https:" ? "wss:" : "ws:";
@@ -53425,7 +53460,7 @@ const proxyWebSocket = fnUntraced(function* (request, origin) {
53425
53460
  return empty();
53426
53461
  });
53427
53462
  function requestHostname(host) {
53428
- return pipe(fromUndefinedOr(host), flatMap$6((host) => pipe(host, split$1(":"), head)));
53463
+ return pipe(fromUndefinedOr(host), flatMap$6((value) => pipe(value, split$1(":"), head)));
53429
53464
  }
53430
53465
  function isLocalHostname(hostname) {
53431
53466
  return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
@@ -53455,11 +53490,11 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
53455
53490
  const existing = ports.get(key);
53456
53491
  if (existing !== void 0) return existing;
53457
53492
  const reserved = new Set(ports.values());
53458
- for (let port = 4e3; port <= 4999; port += 1) {
53459
- const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${port}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
53460
- if (!reserved.has(port) && !occupied) {
53461
- ports.set(key, port);
53462
- return port;
53493
+ for (let candidatePort = 4e3; candidatePort <= 4999; candidatePort += 1) {
53494
+ const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${candidatePort}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
53495
+ if (!reserved.has(candidatePort) && !occupied) {
53496
+ ports.set(key, candidatePort);
53497
+ return candidatePort;
53463
53498
  }
53464
53499
  }
53465
53500
  throw new Error("no portless app ports available");
@@ -53472,7 +53507,7 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
53472
53507
  port: (sessionId) => port(`${cwd}:${sessionId}`)
53473
53508
  }), tap((discovered) => sync(() => {
53474
53509
  for (const route of discovered) routes.set(route.host, `http://127.0.0.1:${route.port}`);
53475
- })), map$4((routes) => routes.map((route) => ({
53510
+ })), map$4((discovered) => discovered.map((route) => ({
53476
53511
  host: route.host,
53477
53512
  port: route.port,
53478
53513
  script: {
@@ -53567,7 +53602,6 @@ var import_addon_progress = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSM
53567
53602
  })(), e;
53568
53603
  })()));
53569
53604
  })))(), 1);
53570
- const eventBacklogCapacity = 512;
53571
53605
  const terminalReset = "\x1Bc";
53572
53606
  function parseTitleSignal(title) {
53573
53607
  const trimmed = title.trim();
@@ -53605,24 +53639,17 @@ function parseTitleSignal(title) {
53605
53639
  }
53606
53640
  function snapshotEvents(data, sequence) {
53607
53641
  if (data === "") return empty$13();
53608
- const events = [];
53609
- for (let index = 0; index < data.length; index += 256 * 1024) events.push({
53610
- data: data.slice(index, index + 256 * 1024),
53642
+ return pipe(range(0, Math.floor((data.length - 1) / (256 * 1024))), map$7((index) => ({
53643
+ data: data.slice(index * 256 * 1024, (index + 1) * 256 * 1024),
53611
53644
  sequence,
53612
53645
  type: "data"
53613
- });
53614
- return events;
53646
+ })));
53615
53647
  }
53616
53648
  function adjacentGroups(items, sameGroup, merge) {
53617
53649
  return pipe(items, reduce(empty$13(), (groups, item) => {
53618
- const next = groups;
53619
53650
  const previous = groups.at(-1);
53620
- if (!(previous && sameGroup(previous, item))) {
53621
- next.push(item);
53622
- return next;
53623
- }
53624
- next[next.length - 1] = merge(previous, item);
53625
- return next;
53651
+ if (previous === void 0 || !sameGroup(previous, item)) return append$1(groups, item);
53652
+ return append$1(dropRight(groups, 1), merge(previous, item));
53626
53653
  }));
53627
53654
  }
53628
53655
  function queuedDataGroups(items, merge) {
@@ -53642,13 +53669,9 @@ function queuedWriteGroups(items) {
53642
53669
  }
53643
53670
  var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { make: fnUntraced(function* (config) {
53644
53671
  const dataQueue = yield* unbounded();
53645
- const screenQueue = yield* unbounded();
53646
53672
  const writeQueue = yield* unbounded();
53647
53673
  const resizeQueue = yield* sliding(1);
53648
- const events = yield* bounded$1({
53649
- capacity: 1024,
53650
- replay: eventBacklogCapacity
53651
- });
53674
+ const events = yield* bounded$1(1024);
53652
53675
  const lifecycleLock = yield* make$47(1);
53653
53676
  const screenLock = yield* make$47(1);
53654
53677
  const eventSequenceRef = yield* make$38(0);
@@ -53676,11 +53699,11 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53676
53699
  scrollback: 1e4
53677
53700
  });
53678
53701
  const serialize = new SerializeModule.SerializeAddon();
53679
- const progress = new import_addon_progress.ProgressAddon();
53702
+ const progressAddon = new import_addon_progress.ProgressAddon();
53680
53703
  screen.loadAddon(serialize);
53681
- screen.loadAddon(progress);
53704
+ screen.loadAddon(progressAddon);
53682
53705
  const publish$1 = fnUntraced(function* (data) {
53683
- const sequence = yield* updateAndGet(eventSequenceRef, (sequence) => sequence + 1);
53706
+ const sequence = yield* updateAndGet(eventSequenceRef, (current) => current + 1);
53684
53707
  yield* publish(events, {
53685
53708
  data,
53686
53709
  sequence,
@@ -53695,15 +53718,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53695
53718
  };
53696
53719
  }));
53697
53720
  function setState(state) {
53698
- return update(stateRef, (current) => ({
53721
+ return update(stateRef, (current) => current.state === state ? current : {
53699
53722
  ...current,
53700
53723
  state
53701
- }));
53724
+ });
53702
53725
  }
53703
- function setProgressState(progress) {
53726
+ function setProgressState(progressState) {
53704
53727
  return update(stateRef, (current) => {
53705
53728
  if (current.state === "stopped" || current.state === "exited" || current.state === "failed") return current;
53706
- const state = pipe(progress.state, value, when(0, () => "idle"), when(2, () => "failed"), when(4, () => "waiting"), orElse(() => "running"));
53729
+ const state = pipe(progressState.state, value, when(0, () => "idle"), when(2, () => "failed"), when(4, () => "waiting"), orElse(() => "running"));
53730
+ if (current.state === state) return current;
53707
53731
  return {
53708
53732
  ...current,
53709
53733
  state
@@ -53713,9 +53737,11 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53713
53737
  function setTitle(title) {
53714
53738
  return update(stateRef, (current) => {
53715
53739
  if (!terminalStateActive(current.state)) return current;
53740
+ const next = parseTitleSignal(title);
53741
+ if (current.state === next.state && current.title === next.title) return current;
53716
53742
  return {
53717
53743
  ...current,
53718
- ...parseTitleSignal(title)
53744
+ ...next
53719
53745
  };
53720
53746
  });
53721
53747
  }
@@ -53733,7 +53759,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53733
53759
  runFork(setTitle(title));
53734
53760
  return false;
53735
53761
  });
53736
- progress.onChange((nextProgress) => {
53762
+ progressAddon.onChange((nextProgress) => {
53737
53763
  runFork(setProgressState(nextProgress));
53738
53764
  });
53739
53765
  const interruptProcess = fnUntraced(function* (subprocess, signal) {
@@ -53752,7 +53778,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53752
53778
  if ((yield* get$3(screenGenerationRef)) !== input.generation) return;
53753
53779
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
53754
53780
  screen.write(input.data, () => {
53755
- resume(void_$1);
53781
+ resume(succeed$3(void 0));
53756
53782
  });
53757
53783
  }), andThen(gen(function* () {
53758
53784
  if ((yield* get$3(screenGenerationRef)) === input.generation) yield* set$4(parsedSequenceRef, yield* publish$1(input.data));
@@ -53776,7 +53802,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53776
53802
  if (state) yield* setState(state);
53777
53803
  });
53778
53804
  const spawnProcess = fnUntraced(function* () {
53779
- const generation = yield* updateAndGet(screenGenerationRef, (generation) => generation + 1);
53805
+ const generation = yield* updateAndGet(screenGenerationRef, (current) => current + 1);
53780
53806
  yield* withPermit(screenLock, pipe(sync(() => {
53781
53807
  screen.reset();
53782
53808
  }), andThen(publish$1(terminalReset)), tap((sequence) => set$4(parsedSequenceRef, sequence))));
@@ -53800,9 +53826,9 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53800
53826
  })
53801
53827
  });
53802
53828
  const handle = {
53803
- data: subprocess.onData((data) => {
53829
+ data: subprocess.onData((chunk) => {
53804
53830
  offerUnsafe(dataQueue, {
53805
- data,
53831
+ data: chunk,
53806
53832
  generation
53807
53833
  });
53808
53834
  }),
@@ -53827,19 +53853,16 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53827
53853
  yield* stopProcess();
53828
53854
  return yield* spawnProcess();
53829
53855
  });
53830
- yield* pipe(fromQueue(dataQueue), groupedWithin(256, millis(8)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), (item) => gen(function* () {
53831
- if ((yield* get$3(screenGenerationRef)) !== item.generation) return;
53832
- yield* offer(screenQueue, item);
53833
- }), { discard: true })), forkScoped);
53834
- yield* pipe(fromQueue(screenQueue), groupedWithin(256, millis(16)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), writeScreen, { discard: true })), forkScoped);
53856
+ yield* pipe(fromQueue(dataQueue), groupedWithin(256, millis(16)), runForEach((items) => forEach$1(queuedDataGroups(fromIterable$2(items), mergeQueuedData), writeScreen, { discard: true })), forkScoped);
53835
53857
  yield* addFinalizer(() => all([
53836
53858
  stopProcess(),
53837
53859
  shutdown$1(events),
53838
53860
  shutdown(dataQueue),
53839
- shutdown(screenQueue),
53840
53861
  shutdown(writeQueue),
53841
53862
  shutdown(resizeQueue),
53842
- sync(() => screen.dispose())
53863
+ sync(() => {
53864
+ screen.dispose();
53865
+ })
53843
53866
  ], {
53844
53867
  concurrency: "unbounded",
53845
53868
  discard: true
@@ -53885,7 +53908,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53885
53908
  const subscription = yield* subscribe(events);
53886
53909
  const snapshot = yield* requestSnapshot;
53887
53910
  const pending = yield* takeUpTo(subscription, Number.POSITIVE_INFINITY);
53888
- const replay = filter$2(pending, (event) => event.sequence > snapshot.sequence);
53911
+ const replay = filter$1(pending, (event) => event.sequence > snapshot.sequence);
53889
53912
  const replaySequence = replay.at(-1)?.sequence ?? snapshot.sequence;
53890
53913
  return pipe(fromIterable$1([
53891
53914
  {
@@ -53895,8 +53918,8 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53895
53918
  },
53896
53919
  ...snapshotEvents(snapshot.data, snapshot.sequence),
53897
53920
  ...replay,
53898
- ...filter$2(pending, (event) => event.sequence > replaySequence)
53899
- ]), concat(fromEffectRepeat(take$3(subscription))));
53921
+ ...filter$1(pending, (event) => event.sequence > replaySequence)
53922
+ ]), concat(fromEffectRepeat(take$2(subscription))));
53900
53923
  })));
53901
53924
  const stateUpdates = unwrap$1(pipe(get(stateRef), map$4((state) => concat(drop(1)(changes(stateRef)))(make$43(state)))));
53902
53925
  const updates = merge$1(stateUpdates.pipe(map$2((state) => ({
@@ -53945,6 +53968,29 @@ const AgentSessionKey = Struct({
53945
53968
  cwd: String$1,
53946
53969
  uuid: String$1
53947
53970
  });
53971
+ function terminalSessionInput(session) {
53972
+ if ("args" in session || "env" in session) return {
53973
+ command: session.command === void 0 ? void 0 : make$40(session.command, session.args ?? [], { env: session.env }),
53974
+ cwd: session.cwd,
53975
+ sessionId: session.sessionId
53976
+ };
53977
+ if (typeof session.command === "string") return {
53978
+ command: make$40(session.command),
53979
+ cwd: session.cwd,
53980
+ sessionId: session.sessionId
53981
+ };
53982
+ return {
53983
+ command: session.command,
53984
+ cwd: session.cwd,
53985
+ sessionId: session.sessionId
53986
+ };
53987
+ }
53988
+ function commentKey(input) {
53989
+ return `${input.filePath}:${input.side ?? "additions"}:${input.lineNumber}`;
53990
+ }
53991
+ function markKey(input) {
53992
+ return `${input.filePath}:${input.segmentId}:${input.fingerprint}`;
53993
+ }
53948
53994
  const TerminalSessions = make$46({
53949
53995
  idleTimeToLive: infinity,
53950
53996
  lookup: fnUntraced(function* (config) {
@@ -54000,24 +54046,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54000
54046
  sessionId: script.sessionId
54001
54047
  };
54002
54048
  });
54003
- function terminalSessionInput(session) {
54004
- if ("args" in session || "env" in session) return {
54005
- command: session.command === void 0 ? void 0 : make$40(session.command, session.args ?? [], { env: session.env }),
54006
- cwd: session.cwd,
54007
- sessionId: session.sessionId
54008
- };
54009
- if (typeof session.command === "string") return {
54010
- command: make$40(session.command),
54011
- cwd: session.cwd,
54012
- sessionId: session.sessionId
54013
- };
54014
- return {
54015
- command: session.command,
54016
- cwd: session.cwd,
54017
- sessionId: session.sessionId
54018
- };
54019
- }
54020
- const terminal = fnUntraced(function* (input) {
54049
+ const getTerminal = fnUntraced(function* (input) {
54021
54050
  return yield* pipe(terminalSession(input), map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
54022
54051
  });
54023
54052
  const reviewStateKey = fnUntraced(function* (input) {
@@ -54043,46 +54072,72 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54043
54072
  yield* reviewStore.set(`review-state/${key}`, state);
54044
54073
  })), mapError$2((cause) => new GitError({ cause })));
54045
54074
  });
54046
- function commentKey(input) {
54047
- return `${input.filePath}:${input.side ?? "additions"}:${input.lineNumber}`;
54048
- }
54049
- function markKey(input) {
54050
- return `${input.filePath}:${input.segmentId}:${input.fingerprint}`;
54051
- }
54052
54075
  const agents = yield* make$3(empty$6());
54076
+ const removeAgent = fnUntraced(function* (payload) {
54077
+ const session = pipe(yield* get(agents), get$1(payload), getOrUndefined$1);
54078
+ yield* update(agents, (current) => remove$2(current, payload));
54079
+ if (session === void 0) return;
54080
+ const input = terminalSessionInput({
54081
+ args: session.args,
54082
+ command: session.command,
54083
+ cwd: session.cwd,
54084
+ sessionId: session.uuid
54085
+ });
54086
+ yield* pipe(get$6(terminals, input), flatMap$2((terminal) => terminal.stop()), ignore$1);
54087
+ yield* pipe(invalidate(terminals, input), ignore$1);
54088
+ });
54053
54089
  return RpcContracts.of({
54054
54090
  "agents.create": (payload) => gen(function* () {
54055
- const labelCount = pipe(fromIterable$2(values(yield* get(agents))), filter$2((session) => session.cwd === payload.cwd && session.command === payload.command), length);
54056
- const session = {
54091
+ const labelCount = pipe(fromIterable$2(values(yield* get(agents))), filter$1((agentSession) => agentSession.cwd === payload.cwd && agentSession.command === payload.command), length);
54092
+ const agentSession = {
54057
54093
  args: [...payload.args],
54058
54094
  command: payload.command,
54059
54095
  cwd: payload.cwd,
54060
54096
  icon: payload.icon,
54061
54097
  label: `${payload.label} ${labelCount + 1}`,
54098
+ state: {
54099
+ runId: 0,
54100
+ state: "starting",
54101
+ title: ""
54102
+ },
54062
54103
  uuid: randomUUID()
54063
54104
  };
54064
54105
  yield* update(agents, (sessions) => set$2(sessions, AgentSessionKey.make({
54065
- cwd: session.cwd,
54066
- uuid: session.uuid
54067
- }), session));
54068
- const terminal = yield* terminalSession(TerminalSessionKey.make({
54069
- args: session.args,
54070
- command: session.command,
54071
- cwd: session.cwd,
54072
- sessionId: session.uuid
54073
- })).pipe(map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
54074
- yield* terminal.restart();
54075
- yield* pipe(terminal.stateUpdates, map$2((state) => state.state), filter((state) => state === "exited" || state === "failed" || state === "stopped"), take(1), runDrain, andThen(update(agents, (current) => remove$2(current, AgentSessionKey.make({
54076
- cwd: session.cwd,
54077
- uuid: session.uuid
54078
- })))), forkDetach);
54079
- return session;
54106
+ cwd: agentSession.cwd,
54107
+ uuid: agentSession.uuid
54108
+ }), agentSession));
54109
+ const sessionTerminal = yield* terminalSession(TerminalSessionKey.make({
54110
+ args: agentSession.args,
54111
+ command: agentSession.command,
54112
+ cwd: agentSession.cwd,
54113
+ sessionId: agentSession.uuid
54114
+ })).pipe(map$4(terminalSessionInput), flatMap$2((input) => get$6(terminals, input)));
54115
+ yield* sessionTerminal.restart();
54116
+ yield* pipe(sessionTerminal.stateUpdates, takeUntil((state) => state.state === "exited" || state.state === "failed" || state.state === "stopped"), runForEach((state) => gen(function* () {
54117
+ const key = AgentSessionKey.make({
54118
+ cwd: agentSession.cwd,
54119
+ uuid: agentSession.uuid
54120
+ });
54121
+ yield* update(agents, (sessions) => modifyAt(sessions, key, match$5({
54122
+ onNone: () => none(),
54123
+ onSome: (session) => some$1({
54124
+ ...session,
54125
+ state
54126
+ })
54127
+ })));
54128
+ if (state.state !== "exited" && state.state !== "failed" && state.state !== "stopped") return;
54129
+ yield* update(agents, (sessions) => remove$2(sessions, key));
54130
+ yield* pipe(invalidate(terminals, terminalSessionInput({
54131
+ args: agentSession.args,
54132
+ command: agentSession.command,
54133
+ cwd: agentSession.cwd,
54134
+ sessionId: agentSession.uuid
54135
+ })), ignore$1);
54136
+ })), forkDetach);
54137
+ return agentSession;
54080
54138
  }),
54081
- "agents.remove": (payload) => update(agents, (current) => remove$2(current, AgentSessionKey.make({
54082
- cwd: payload.cwd,
54083
- uuid: payload.uuid
54084
- }))),
54085
- "agents.watch": (payload) => unwrap$1(pipe(get(agents), map$4((current) => pipe(make$43(current), concat(drop(1)(changes(agents))), map$2((sessions) => pipe(fromIterable$2(values(sessions)), filter$2((session) => session.cwd === payload.cwd))))))),
54139
+ "agents.remove": (payload) => removeAgent(AgentSessionKey.make(payload)),
54140
+ "agents.watch": (payload) => unwrap$1(pipe(get(agents), map$4((current) => pipe(make$43(current), concat(drop(1)(changes(agents))), map$2((sessions) => pipe(fromIterable$2(values(sessions)), filter$1((session) => session.cwd === payload.cwd))))))),
54086
54141
  "projects.branches": (payload) => git.branches(payload.cwd),
54087
54142
  "projects.createWorktree": (payload) => git.createWorktree(payload),
54088
54143
  "projects.deleteWorktree": (payload) => git.deleteWorktree(payload),
@@ -54090,14 +54145,14 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54090
54145
  "review.comments.resolve": (payload) => updateReviewState(payload, (state) => {
54091
54146
  const key = commentKey(payload);
54092
54147
  return new ReviewState({
54093
- comments: filter$2(state.comments, (comment) => commentKey(comment) !== key),
54148
+ comments: filter$1(state.comments, (comment) => commentKey(comment) !== key),
54094
54149
  marks: state.marks
54095
54150
  });
54096
54151
  }),
54097
54152
  "review.comments.save": (payload) => updateReviewState(payload, (state) => {
54098
54153
  const key = commentKey(payload.comment);
54099
54154
  return new ReviewState({
54100
- comments: append$1(filter$2(state.comments, (comment) => commentKey(comment) !== key), new ReviewComment({
54155
+ comments: append$1(filter$1(state.comments, (comment) => commentKey(comment) !== key), new ReviewComment({
54101
54156
  ...payload.comment,
54102
54157
  resolved: false
54103
54158
  })),
@@ -54118,14 +54173,14 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54118
54173
  const keys = new Set(map$7(payload.marks, markKey));
54119
54174
  return new ReviewState({
54120
54175
  comments: state.comments,
54121
- marks: appendAll(filter$2(state.marks, (mark) => !keys.has(markKey(mark))), payload.marks)
54176
+ marks: appendAll(filter$1(state.marks, (mark) => !keys.has(markKey(mark))), payload.marks)
54122
54177
  });
54123
54178
  }),
54124
54179
  "review.state.unmark": (payload) => updateReviewState(payload, (state) => {
54125
54180
  const keys = new Set(map$7(payload.marks, markKey));
54126
54181
  return new ReviewState({
54127
54182
  comments: state.comments,
54128
- marks: filter$2(state.marks, (mark) => !keys.has(markKey(mark)))
54183
+ marks: filter$1(state.marks, (mark) => !keys.has(markKey(mark)))
54129
54184
  });
54130
54185
  }),
54131
54186
  "review.state.watch": (payload) => unwrap$1(pipe(reviewStateKey(payload), flatMap$2((key) => get$6(reviewStates, key)), flatMap$2((ref) => pipe(get(ref), map$4((state) => concat(drop(1)(changes(ref)))(make$43(state))))))),
@@ -54135,15 +54190,15 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54135
54190
  to: payload.to
54136
54191
  })))),
54137
54192
  "runs.portless": (payload) => get$6(portlessWorktrees, payload.cwd),
54138
- "terminal.resize": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
54193
+ "terminal.resize": (payload) => pipe(getTerminal(TerminalSessionKey.make(payload)), flatMap$2((sessionTerminal) => sessionTerminal.resize({
54139
54194
  cols: payload.cols,
54140
54195
  rows: payload.rows
54141
54196
  }))),
54142
- "terminal.restart": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.restart()),
54143
- "terminal.state.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stateUpdates)),
54144
- "terminal.stop": (payload) => flatMap$2(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.stop()),
54145
- "terminal.watch": (payload) => unwrap$1(map$4(terminal(TerminalSessionKey.make(payload)), (terminal) => terminal.updates)),
54146
- "terminal.write": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.write(payload.data)))
54197
+ "terminal.restart": (payload) => flatMap$2(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.restart()),
54198
+ "terminal.state.watch": (payload) => unwrap$1(map$4(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.stateUpdates)),
54199
+ "terminal.stop": (payload) => flatMap$2(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.stop()),
54200
+ "terminal.watch": (payload) => unwrap$1(map$4(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.updates)),
54201
+ "terminal.write": (payload) => pipe(getTerminal(TerminalSessionKey.make(payload)), flatMap$2((sessionTerminal) => sessionTerminal.write(payload.data)))
54147
54202
  });
54148
54203
  }));
54149
54204
  //#endregion
@@ -60241,19 +60296,19 @@ var require_getMachineId = /* @__PURE__ */ __commonJSMin(((exports) => {
60241
60296
  async function getMachineId() {
60242
60297
  if (!getMachineIdImpl) switch (process$1.platform) {
60243
60298
  case "darwin":
60244
- getMachineIdImpl = (await import("./getMachineId-darwin-DD7WkQgq.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60299
+ getMachineIdImpl = (await import("./getMachineId-darwin-BYjMzwa2.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60245
60300
  break;
60246
60301
  case "linux":
60247
- getMachineIdImpl = (await import("./getMachineId-linux-NsJbNTda.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60302
+ getMachineIdImpl = (await import("./getMachineId-linux-7FQ_TPIw.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60248
60303
  break;
60249
60304
  case "freebsd":
60250
- getMachineIdImpl = (await import("./getMachineId-bsd-D2D8E0zh.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60305
+ getMachineIdImpl = (await import("./getMachineId-bsd-DYUtJhPR.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60251
60306
  break;
60252
60307
  case "win32":
60253
- getMachineIdImpl = (await import("./getMachineId-win-CpX0o49t.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60308
+ getMachineIdImpl = (await import("./getMachineId-win-BxTTz_Ds.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60254
60309
  break;
60255
60310
  default:
60256
- getMachineIdImpl = (await import("./getMachineId-unsupported-BdKw63O1.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60311
+ getMachineIdImpl = (await import("./getMachineId-unsupported-CqYci84U.mjs").then((m) => /* @__PURE__ */ __toESM(m.default))).getMachineId;
60257
60312
  break;
60258
60313
  }
60259
60314
  return getMachineIdImpl();