@deslop/workbench 0.0.327 → 0.0.330

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 (37) hide show
  1. package/dist/client/assets/agent-BAplunWJ.js +1 -0
  2. package/dist/client/assets/agent-DORiXY9q.js +2 -0
  3. package/dist/client/assets/button-DJfQFnBl.js +16 -0
  4. package/dist/client/assets/{diff-C_X2wnRm.js → diff-5y5Ly0fZ.js} +2 -2
  5. package/dist/client/assets/{diff-hUFci-J4.js → diff-Cu8yhVQs.js} +45 -45
  6. package/dist/client/assets/{external-link-CTjuCORn.js → external-link-DSkEzLiB.js} +1 -1
  7. package/dist/client/assets/{fallbacks-DZ7ciusO.js → fallbacks-2XEEl4BI.js} +1 -1
  8. package/dist/client/assets/{index-DpbZkluz.js → index-CU4FmmbE.js} +3 -3
  9. package/dist/client/assets/{input-group-CAejCCyD.js → input-group-tkTwlIFp.js} +2 -2
  10. package/dist/client/assets/loader-circle-vwjgn9E1.js +1 -0
  11. package/dist/client/assets/portless-Cn_0jtX4.js +2 -0
  12. package/dist/client/assets/portless-DRWo8KFX.js +1 -0
  13. package/dist/client/assets/{resizable-B1fIW9sm.js → resizable-BICft2JP.js} +1 -1
  14. package/dist/client/assets/route-D-VRm0UM.js +2 -0
  15. package/dist/client/assets/route-DAzFV54O.js +45 -0
  16. package/dist/client/assets/{run-BzrHh2aK.js → run-C08WVAIM.js} +1 -1
  17. package/dist/client/assets/run-Dx2tn3Qe.js +2 -0
  18. package/dist/client/assets/state-DrPxOHMO.js +2 -0
  19. package/dist/client/assets/terminal-BGn5gevX.js +2 -0
  20. package/dist/client/assets/terminal-BTXMxFEq.js +1 -0
  21. package/dist/client/assets/{terminal-DgodR87i.js → terminal-CPpKsotd.js} +2 -2
  22. package/dist/client/assets/{triangle-alert-CGj-8H_a.js → triangle-alert-DrGIVhEI.js} +1 -1
  23. package/dist/client/index.html +11 -11
  24. package/dist/server.js +171 -125
  25. package/package.json +1 -1
  26. package/dist/client/assets/agent-CRsoHYEG.js +0 -1
  27. package/dist/client/assets/agent-DYjX-Pzl.js +0 -2
  28. package/dist/client/assets/button-fe_R2wzr.js +0 -16
  29. package/dist/client/assets/loader-circle-B1mHTP2Y.js +0 -1
  30. package/dist/client/assets/portless-D4NDzBYJ.js +0 -1
  31. package/dist/client/assets/portless-D73tczCx.js +0 -2
  32. package/dist/client/assets/route-0gFXuUyt.js +0 -2
  33. package/dist/client/assets/route-BcNQ-aN-.js +0 -45
  34. package/dist/client/assets/run-B5fcXFyP.js +0 -2
  35. package/dist/client/assets/state-C-LyNCwu.js +0 -2
  36. package/dist/client/assets/terminal-B3oT0xJm.js +0 -2
  37. package/dist/client/assets/terminal-EfiQ0Ote.js +0 -1
package/dist/server.js CHANGED
@@ -20748,7 +20748,7 @@ var Declaration = class Declaration extends Base {
20748
20748
  * @category models
20749
20749
  * @since 4.0.0
20750
20750
  */
20751
- var Null = class extends Base {
20751
+ var Null$1 = class extends Base {
20752
20752
  _tag = "Null";
20753
20753
  /** @internal */
20754
20754
  getParser() {
@@ -20759,7 +20759,7 @@ var Null = class extends Base {
20759
20759
  return "null";
20760
20760
  }
20761
20761
  };
20762
- const null_ = /*#__PURE__*/ new Null();
20762
+ const null_ = /*#__PURE__*/ new Null$1();
20763
20763
  /**
20764
20764
  * AST node matching the `undefined` value.
20765
20765
  *
@@ -33331,6 +33331,14 @@ const Any = /*#__PURE__*/ make$35(any);
33331
33331
  */
33332
33332
  const Unknown = /*#__PURE__*/ make$35(unknown);
33333
33333
  /**
33334
+ * Schema for the `null` literal. Validates that the input is strictly `null`.
33335
+ *
33336
+ * @see {@link NullOr} for a union with another schema.
33337
+ * @category schemas
33338
+ * @since 3.10.0
33339
+ */
33340
+ const Null = /*#__PURE__*/ make$35(null_);
33341
+ /**
33334
33342
  * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
33335
33343
  *
33336
33344
  * @see {@link UndefinedOr} for a union with another schema.
@@ -33536,6 +33544,13 @@ function Literals(literals) {
33536
33544
  });
33537
33545
  }
33538
33546
  /**
33547
+ * Creates a union schema of `S | null`.
33548
+ *
33549
+ * @category constructors
33550
+ * @since 3.10.0
33551
+ */
33552
+ const NullOr = /*#__PURE__*/ lambda((self) => Union([self, Null]));
33553
+ /**
33539
33554
  * Creates a union schema of `S | undefined`.
33540
33555
  *
33541
33556
  * @category constructors
@@ -52257,6 +52272,22 @@ var GitHubReviewThread = class extends Class("GitHubReviewThread")({
52257
52272
  side: optional(Literals(["additions", "deletions"])),
52258
52273
  url: optional(String$1)
52259
52274
  }) {};
52275
+ const GitHubRepositoryResponse = Struct({
52276
+ name: String$1,
52277
+ owner: Struct({ login: String$1 })
52278
+ });
52279
+ const GitHubReviewThreadsResponse = Struct({ data: optional(Struct({ repository: optional(Struct({ pullRequest: optional(Struct({ reviewThreads: optional(Struct({ nodes: ArraySchema(Struct({
52280
+ comments: Struct({ nodes: ArraySchema(Struct({
52281
+ body: String$1,
52282
+ line: optional(NullOr(Number$1)),
52283
+ originalLine: optional(NullOr(Number$1)),
52284
+ path: String$1,
52285
+ url: optional(String$1)
52286
+ })) }),
52287
+ diffSide: optional(String$1),
52288
+ id: String$1,
52289
+ isResolved: Boolean$1
52290
+ })) })) })) })) })) });
52260
52291
  var GitRepository = class extends Class("GitRepository")({
52261
52292
  gitDirectory: String$1,
52262
52293
  root: String$1
@@ -52570,6 +52601,26 @@ const makeGitExecutor = gen(function* () {
52570
52601
  })
52571
52602
  };
52572
52603
  });
52604
+ function toArgs(to) {
52605
+ return to.type === "ref" ? [to.ref] : empty$13();
52606
+ }
52607
+ function segmentsByFile(segments) {
52608
+ return reduce(segments, empty$6(), (groups, segment) => modifyAt(groups, segment.filePath, (current) => some$1(append$1(getOrElse$1(current, () => empty$13()), segment))));
52609
+ }
52610
+ function diffFromPatchChunk(chunk, segments) {
52611
+ const deleted = /^deleted file mode /mu.test(chunk);
52612
+ 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] ?? "";
52613
+ 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"));
52614
+ return new GitDiff({
52615
+ filePath,
52616
+ patch: chunk,
52617
+ segments: getOrElse$1(get$1(segments, filePath), () => empty$13()),
52618
+ status
52619
+ });
52620
+ }
52621
+ function isWipSubject(subject) {
52622
+ return subject === "wip" || startsWith("wip: ")(subject);
52623
+ }
52573
52624
  var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", { make: gen(function* () {
52574
52625
  const execString = yield* ChildProcessSpawner.useSync((spawner) => spawner.string);
52575
52626
  const git = yield* makeGitExecutor;
@@ -52615,25 +52666,28 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52615
52666
  const collectRepositoriesFromRoots = fnUntraced(function* (roots, repositories) {
52616
52667
  return yield* match$3(roots, {
52617
52668
  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
- }))
52669
+ onNonEmpty: (remainingRoots) => {
52670
+ const root = remainingRoots[0];
52671
+ return pipe(fs.readDirectory(root), orElseSucceed(() => empty$13()), flatMap$2((entries) => {
52672
+ if (contains(entries, ".git")) return pipe(git.string(root, [
52673
+ "rev-parse",
52674
+ "--path-format=absolute",
52675
+ "--git-common-dir"
52676
+ ]), map$4(trim), map$4((gitDirectory) => succeed$7(new GitRepository({
52677
+ gitDirectory,
52678
+ root
52679
+ }))), orElseSucceed(() => failVoid), flatMap$2((repository) => collectRepositoriesFromRoots(drop$1(remainingRoots, 1), append$1(repositories, repository))));
52680
+ return pipe(entries, filter$2((entry) => !(new Set([
52681
+ ".git",
52682
+ ".next",
52683
+ ".turbo",
52684
+ "build",
52685
+ "coverage",
52686
+ "dist",
52687
+ "node_modules"
52688
+ ]).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$2(isNonEmpty$1), appendAll(drop$1(roots, 1))), repositories)));
52689
+ }));
52690
+ }
52637
52691
  });
52638
52692
  });
52639
52693
  const listWorktrees = fnUntraced(function* (cwd) {
@@ -52694,7 +52748,11 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52694
52748
  yield* set(projects, yield* listProjectsFrom(home));
52695
52749
  });
52696
52750
  yield* refreshProjects();
52697
- yield* acquireRelease(sync(() => NFS.watch(home, () => run(refreshProjects()))), (watcher) => sync(() => watcher.close()));
52751
+ yield* acquireRelease(sync(() => NFS.watch(home, () => {
52752
+ run(refreshProjects());
52753
+ })), (watcher) => sync(() => {
52754
+ watcher.close();
52755
+ }));
52698
52756
  return {
52699
52757
  branches: fnUntraced(function* (cwd) {
52700
52758
  return new GitBranchesSnapshot({
@@ -52816,7 +52874,7 @@ var GitWorkspace = class extends Service()("@deslop/git/service/GitWorkspace", {
52816
52874
  ...input.force ? ["--force"] : [],
52817
52875
  input.cwd
52818
52876
  ]), asVoid);
52819
- if (worktree.branch !== void 0) yield* pipe(git.string(worktree.mainRoot, [
52877
+ if (isNotUndefined(worktree.branch)) yield* pipe(git.string(worktree.mainRoot, [
52820
52878
  "branch",
52821
52879
  "-D",
52822
52880
  worktree.branch
@@ -52845,23 +52903,6 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52845
52903
  "HEAD"
52846
52904
  ]), map$4(trim));
52847
52905
  });
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
52906
  function diffsFromPatch(patch, segments) {
52866
52907
  const groupedSegments = segmentsByFile(segments);
52867
52908
  return pipe(patch.split(/(?=^diff --git )/mu), filter$2(isNonEmpty$1), map$7((chunk) => diffFromPatchChunk(chunk, groupedSegments)));
@@ -52913,9 +52954,9 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52913
52954
  `${input.from}..${input.to}`
52914
52955
  ])).split("\0DESLOP-COMMIT\0"), filter$2(isNonEmpty$1), flatMap$5((entry) => {
52915
52956
  const lines = split$1("\n")(entry);
52916
- const header = lines[0] ?? "";
52957
+ const header = lines[0];
52917
52958
  const parts = split$1("\0")(header);
52918
- const commit = parts[0] ?? "";
52959
+ const commit = parts[0];
52919
52960
  const id = `${pipe(parts[1] ?? "", split$1(" "), filter$2(isNonEmpty$1))[0] ?? `${commit}^`}->${commit}`;
52920
52961
  return pipe(drop$1(lines, 1), filter$2(isNonEmpty$1), map$7((filePath) => new GitDiffSegment({
52921
52962
  filePath,
@@ -52993,14 +53034,11 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
52993
53034
  "--jq",
52994
53035
  ".url"
52995
53036
  ]), 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
53037
  function commitFromLogLine(line) {
53000
53038
  const parts = split$1("\0")(line);
53001
53039
  const subject = parts[2] ?? "";
53002
53040
  return new GitCommit({
53003
- hash: parts[0] ?? "",
53041
+ hash: parts[0],
53004
53042
  parents: pipe(parts[3] ?? "", split$1(" "), filter$2(isNonEmpty$1)),
53005
53043
  shortHash: parts[1] ?? "",
53006
53044
  subject,
@@ -53085,7 +53123,10 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53085
53123
  "view",
53086
53124
  "--json",
53087
53125
  "owner,name"
53088
- ]), map$4((output) => JSON.parse(output)));
53126
+ ]), flatMap$2(decodeUnknownEffect(fromJsonString(GitHubRepositoryResponse))), mapError$2((cause) => new GitError({
53127
+ cause,
53128
+ message: "Failed to parse GitHub repository."
53129
+ })));
53089
53130
  const response = yield* ghString([
53090
53131
  "api",
53091
53132
  "graphql",
@@ -53120,12 +53161,15 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53120
53161
  "-F",
53121
53162
  `number=${pr}`
53122
53163
  ]);
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 ?? "",
53164
+ return pipe((yield* pipe(decodeUnknownEffect(fromJsonString(GitHubReviewThreadsResponse))(response), mapError$2((cause) => new GitError({
53165
+ cause,
53166
+ message: "Failed to parse GitHub review threads."
53167
+ })))).data?.repository?.pullRequest?.reviewThreads?.nodes ?? [], flatMap$5((thread) => pipe(thread.comments.nodes, map$7((comment) => new GitHubReviewThread({
53168
+ body: comment.body,
53169
+ filePath: comment.path,
53170
+ id: thread.id,
53127
53171
  lineNumber: comment.line ?? comment.originalLine ?? 1,
53128
- resolved: thread.isResolved === true,
53172
+ resolved: thread.isResolved,
53129
53173
  side: thread.diffSide === "LEFT" ? "deletions" : "additions",
53130
53174
  url: comment.url
53131
53175
  })))));
@@ -53155,7 +53199,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53155
53199
  createWipCommit: fnUntraced(function* (message) {
53156
53200
  if (!(yield* hasWorktreeChanges)) return yield* new GitError({ message: "No changes to commit." });
53157
53201
  yield* pipe(git.string(config.cwd, ["add", "-A"]), asVoid);
53158
- const subject = pipe(message, trim, (message) => isEmpty$1(message) ? "wip" : `wip: ${message}`);
53202
+ const subject = pipe(message, trim, (value) => isEmpty$1(value) ? "wip" : `wip: ${value}`);
53159
53203
  yield* pipe(git.string(config.cwd, [
53160
53204
  "commit",
53161
53205
  "-m",
@@ -53231,7 +53275,7 @@ var GitWorktree = class extends Service()("@deslop/git/service/GitWorktree", { m
53231
53275
  filePath
53232
53276
  ]), asVoid);
53233
53277
  }),
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)))
53278
+ 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
53279
  };
53236
53280
  }) }) {
53237
53281
  static layer = flow(this.make, effect(this));
@@ -53264,7 +53308,7 @@ const discover = fnUntraced(function* (cwd, input) {
53264
53308
  "package.json",
53265
53309
  "**/package.json"
53266
53310
  ], { 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_({
53311
+ return yield* pipe(pipe(split$1("\n")(output), filter$2((packagePath) => packagePath === "package.json" || endsWith("/package.json")(packagePath))), map$7((packagePath) => pipe(fs.readFileString(path.join(cwd, packagePath)), flatMap$2((source) => try_({
53268
53312
  catch: (error) => error,
53269
53313
  try: () => pipe(JSON.parse(source), decodeUnknownOption(PackageJson))
53270
53314
  })), catch_$2(() => succeed$3(none())), flatMap$2((packageJson) => {
@@ -53327,10 +53371,10 @@ const INJECTED_HEAD = `<script>
53327
53371
  if (typeof value === 'string') return value
53328
53372
  try { return JSON.stringify(value) } catch { return String(value) }
53329
53373
  }
53330
- const send = (level, message) => window.parent?.postMessage({__deslopBrowserLog: true, level, message}, '*')
53374
+ const send = (level, message) => window.parent?.postMessage({deslopBrowserLog: true, level, message}, '*')
53331
53375
  const sendFavicon = () => {
53332
53376
  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}, '*')
53377
+ window.parent?.postMessage({deslopBrowserFavicon: true, href: icon?.href}, '*')
53334
53378
  }
53335
53379
 
53336
53380
  for (const level of ['debug', 'info', 'log', 'warn', 'error']) {
@@ -53344,7 +53388,7 @@ const INJECTED_HEAD = `<script>
53344
53388
  window.addEventListener('error', event => send('error', event.message || 'Resource failed to load'), true)
53345
53389
  window.addEventListener('unhandledrejection', event => send('error', serialize(event.reason)))
53346
53390
  window.addEventListener('message', event => {
53347
- if (event.data?.__deslopBrowserClear !== true) return
53391
+ if (event.data?.deslopBrowserClear !== true) return
53348
53392
  localStorage.clear()
53349
53393
  sessionStorage.clear()
53350
53394
  document.cookie.split(';').forEach(cookie => {
@@ -53355,7 +53399,7 @@ const INJECTED_HEAD = `<script>
53355
53399
  location.reload()
53356
53400
  })
53357
53401
 
53358
- const sendLocation = () => window.parent?.postMessage({__deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
53402
+ const sendLocation = () => window.parent?.postMessage({deslopBrowserLocation: true, path: location.pathname + location.search + location.hash}, '*')
53359
53403
  const wrapHistory = name => {
53360
53404
  const original = history[name]
53361
53405
  history[name] = function(...args) {
@@ -53411,7 +53455,7 @@ const proxy = fnUntraced(function* (request, origin) {
53411
53455
  });
53412
53456
  const proxyWebSocket = fnUntraced(function* (request, origin) {
53413
53457
  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))));
53458
+ const protocols = pipe(fromUndefinedOr(request.headers["sec-websocket-protocol"]), map$9((header) => pipe(header, split$1(","), map$7(trim), filter$2(isNonEmpty$1))));
53415
53459
  const inbound = yield* request.upgrade;
53416
53460
  const upstreamUrl = new URL(origin);
53417
53461
  upstreamUrl.protocol = upstreamUrl.protocol === "https:" ? "wss:" : "ws:";
@@ -53425,7 +53469,7 @@ const proxyWebSocket = fnUntraced(function* (request, origin) {
53425
53469
  return empty();
53426
53470
  });
53427
53471
  function requestHostname(host) {
53428
- return pipe(fromUndefinedOr(host), flatMap$6((host) => pipe(host, split$1(":"), head)));
53472
+ return pipe(fromUndefinedOr(host), flatMap$6((value) => pipe(value, split$1(":"), head)));
53429
53473
  }
53430
53474
  function isLocalHostname(hostname) {
53431
53475
  return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "[::1]";
@@ -53455,11 +53499,11 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
53455
53499
  const existing = ports.get(key);
53456
53500
  if (existing !== void 0) return existing;
53457
53501
  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;
53502
+ for (let candidatePort = 4e3; candidatePort <= 4999; candidatePort += 1) {
53503
+ const occupied = yield* pipe(tryPromise(() => fetch(`http://127.0.0.1:${candidatePort}`, { signal: AbortSignal.timeout(100) })), as(true), catch_$2(() => succeed$3(false)));
53504
+ if (!reserved.has(candidatePort) && !occupied) {
53505
+ ports.set(key, candidatePort);
53506
+ return candidatePort;
53463
53507
  }
53464
53508
  }
53465
53509
  throw new Error("no portless app ports available");
@@ -53472,7 +53516,7 @@ var Portless = class Portless extends Service()("@deslop/portless/Portless", { m
53472
53516
  port: (sessionId) => port(`${cwd}:${sessionId}`)
53473
53517
  }), tap((discovered) => sync(() => {
53474
53518
  for (const route of discovered) routes.set(route.host, `http://127.0.0.1:${route.port}`);
53475
- })), map$4((routes) => routes.map((route) => ({
53519
+ })), map$4((discovered) => discovered.map((route) => ({
53476
53520
  host: route.host,
53477
53521
  port: route.port,
53478
53522
  script: {
@@ -53617,7 +53661,7 @@ function adjacentGroups(items, sameGroup, merge) {
53617
53661
  return pipe(items, reduce(empty$13(), (groups, item) => {
53618
53662
  const next = groups;
53619
53663
  const previous = groups.at(-1);
53620
- if (!(previous && sameGroup(previous, item))) {
53664
+ if (previous === void 0 || !sameGroup(previous, item)) {
53621
53665
  next.push(item);
53622
53666
  return next;
53623
53667
  }
@@ -53676,11 +53720,11 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53676
53720
  scrollback: 1e4
53677
53721
  });
53678
53722
  const serialize = new SerializeModule.SerializeAddon();
53679
- const progress = new import_addon_progress.ProgressAddon();
53723
+ const progressAddon = new import_addon_progress.ProgressAddon();
53680
53724
  screen.loadAddon(serialize);
53681
- screen.loadAddon(progress);
53725
+ screen.loadAddon(progressAddon);
53682
53726
  const publish$1 = fnUntraced(function* (data) {
53683
- const sequence = yield* updateAndGet(eventSequenceRef, (sequence) => sequence + 1);
53727
+ const sequence = yield* updateAndGet(eventSequenceRef, (current) => current + 1);
53684
53728
  yield* publish(events, {
53685
53729
  data,
53686
53730
  sequence,
@@ -53700,10 +53744,10 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53700
53744
  state
53701
53745
  }));
53702
53746
  }
53703
- function setProgressState(progress) {
53747
+ function setProgressState(progressState) {
53704
53748
  return update(stateRef, (current) => {
53705
53749
  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"));
53750
+ const state = pipe(progressState.state, value, when(0, () => "idle"), when(2, () => "failed"), when(4, () => "waiting"), orElse(() => "running"));
53707
53751
  return {
53708
53752
  ...current,
53709
53753
  state
@@ -53733,7 +53777,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53733
53777
  runFork(setTitle(title));
53734
53778
  return false;
53735
53779
  });
53736
- progress.onChange((nextProgress) => {
53780
+ progressAddon.onChange((nextProgress) => {
53737
53781
  runFork(setProgressState(nextProgress));
53738
53782
  });
53739
53783
  const interruptProcess = fnUntraced(function* (subprocess, signal) {
@@ -53752,7 +53796,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53752
53796
  if ((yield* get$3(screenGenerationRef)) !== input.generation) return;
53753
53797
  yield* withPermit(screenLock, pipe(callback$1((resume) => {
53754
53798
  screen.write(input.data, () => {
53755
- resume(void_$1);
53799
+ resume(succeed$3(void 0));
53756
53800
  });
53757
53801
  }), andThen(gen(function* () {
53758
53802
  if ((yield* get$3(screenGenerationRef)) === input.generation) yield* set$4(parsedSequenceRef, yield* publish$1(input.data));
@@ -53776,7 +53820,7 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53776
53820
  if (state) yield* setState(state);
53777
53821
  });
53778
53822
  const spawnProcess = fnUntraced(function* () {
53779
- const generation = yield* updateAndGet(screenGenerationRef, (generation) => generation + 1);
53823
+ const generation = yield* updateAndGet(screenGenerationRef, (current) => current + 1);
53780
53824
  yield* withPermit(screenLock, pipe(sync(() => {
53781
53825
  screen.reset();
53782
53826
  }), andThen(publish$1(terminalReset)), tap((sequence) => set$4(parsedSequenceRef, sequence))));
@@ -53800,9 +53844,9 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53800
53844
  })
53801
53845
  });
53802
53846
  const handle = {
53803
- data: subprocess.onData((data) => {
53847
+ data: subprocess.onData((chunk) => {
53804
53848
  offerUnsafe(dataQueue, {
53805
- data,
53849
+ data: chunk,
53806
53850
  generation
53807
53851
  });
53808
53852
  }),
@@ -53839,7 +53883,9 @@ var Terminal = class extends Service()("@deslop/terminal/service/Terminal", { ma
53839
53883
  shutdown(screenQueue),
53840
53884
  shutdown(writeQueue),
53841
53885
  shutdown(resizeQueue),
53842
- sync(() => screen.dispose())
53886
+ sync(() => {
53887
+ screen.dispose();
53888
+ })
53843
53889
  ], {
53844
53890
  concurrency: "unbounded",
53845
53891
  discard: true
@@ -53945,6 +53991,29 @@ const AgentSessionKey = Struct({
53945
53991
  cwd: String$1,
53946
53992
  uuid: String$1
53947
53993
  });
53994
+ function terminalSessionInput(session) {
53995
+ if ("args" in session || "env" in session) return {
53996
+ command: session.command === void 0 ? void 0 : make$40(session.command, session.args ?? [], { env: session.env }),
53997
+ cwd: session.cwd,
53998
+ sessionId: session.sessionId
53999
+ };
54000
+ if (typeof session.command === "string") return {
54001
+ command: make$40(session.command),
54002
+ cwd: session.cwd,
54003
+ sessionId: session.sessionId
54004
+ };
54005
+ return {
54006
+ command: session.command,
54007
+ cwd: session.cwd,
54008
+ sessionId: session.sessionId
54009
+ };
54010
+ }
54011
+ function commentKey(input) {
54012
+ return `${input.filePath}:${input.side ?? "additions"}:${input.lineNumber}`;
54013
+ }
54014
+ function markKey(input) {
54015
+ return `${input.filePath}:${input.segmentId}:${input.fingerprint}`;
54016
+ }
53948
54017
  const TerminalSessions = make$46({
53949
54018
  idleTimeToLive: infinity,
53950
54019
  lookup: fnUntraced(function* (config) {
@@ -54000,24 +54069,7 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54000
54069
  sessionId: script.sessionId
54001
54070
  };
54002
54071
  });
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) {
54072
+ const getTerminal = fnUntraced(function* (input) {
54021
54073
  return yield* pipe(terminalSession(input), map$4(terminalSessionInput), flatMap$2((session) => get$6(terminals, session)));
54022
54074
  });
54023
54075
  const reviewStateKey = fnUntraced(function* (input) {
@@ -54043,17 +54095,11 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54043
54095
  yield* reviewStore.set(`review-state/${key}`, state);
54044
54096
  })), mapError$2((cause) => new GitError({ cause })));
54045
54097
  });
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
54098
  const agents = yield* make$3(empty$6());
54053
54099
  return RpcContracts.of({
54054
54100
  "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 = {
54101
+ const labelCount = pipe(fromIterable$2(values(yield* get(agents))), filter$2((agentSession) => agentSession.cwd === payload.cwd && agentSession.command === payload.command), length);
54102
+ const agentSession = {
54057
54103
  args: [...payload.args],
54058
54104
  command: payload.command,
54059
54105
  cwd: payload.cwd,
@@ -54062,21 +54108,21 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54062
54108
  uuid: randomUUID()
54063
54109
  };
54064
54110
  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
54111
+ cwd: agentSession.cwd,
54112
+ uuid: agentSession.uuid
54113
+ }), agentSession));
54114
+ const sessionTerminal = yield* terminalSession(TerminalSessionKey.make({
54115
+ args: agentSession.args,
54116
+ command: agentSession.command,
54117
+ cwd: agentSession.cwd,
54118
+ sessionId: agentSession.uuid
54119
+ })).pipe(map$4(terminalSessionInput), flatMap$2((input) => get$6(terminals, input)));
54120
+ yield* sessionTerminal.restart();
54121
+ yield* pipe(sessionTerminal.stateUpdates, map$2((state) => state.state), filter((state) => state === "exited" || state === "failed" || state === "stopped"), take(1), runDrain, andThen(update(agents, (sessions) => remove$2(sessions, AgentSessionKey.make({
54122
+ cwd: agentSession.cwd,
54123
+ uuid: agentSession.uuid
54078
54124
  })))), forkDetach);
54079
- return session;
54125
+ return agentSession;
54080
54126
  }),
54081
54127
  "agents.remove": (payload) => update(agents, (current) => remove$2(current, AgentSessionKey.make({
54082
54128
  cwd: payload.cwd,
@@ -54135,15 +54181,15 @@ const RpcHandlers = RpcContracts.toLayer(gen(function* () {
54135
54181
  to: payload.to
54136
54182
  })))),
54137
54183
  "runs.portless": (payload) => get$6(portlessWorktrees, payload.cwd),
54138
- "terminal.resize": (payload) => pipe(terminal(TerminalSessionKey.make(payload)), flatMap$2((terminal) => terminal.resize({
54184
+ "terminal.resize": (payload) => pipe(getTerminal(TerminalSessionKey.make(payload)), flatMap$2((sessionTerminal) => sessionTerminal.resize({
54139
54185
  cols: payload.cols,
54140
54186
  rows: payload.rows
54141
54187
  }))),
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)))
54188
+ "terminal.restart": (payload) => flatMap$2(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.restart()),
54189
+ "terminal.state.watch": (payload) => unwrap$1(map$4(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.stateUpdates)),
54190
+ "terminal.stop": (payload) => flatMap$2(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.stop()),
54191
+ "terminal.watch": (payload) => unwrap$1(map$4(getTerminal(TerminalSessionKey.make(payload)), (sessionTerminal) => sessionTerminal.updates)),
54192
+ "terminal.write": (payload) => pipe(getTerminal(TerminalSessionKey.make(payload)), flatMap$2((sessionTerminal) => sessionTerminal.write(payload.data)))
54147
54193
  });
54148
54194
  }));
54149
54195
  //#endregion
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "sideEffects": false,
4
4
  "name": "@deslop/workbench",
5
- "version": "0.0.327",
5
+ "version": "0.0.330",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
@@ -1 +0,0 @@
1
- import{n as e,t}from"./compiler-runtime-rGeCHUuX.js";import{Jo as n,Vs as r,ba as i,eo as a}from"./button-fe_R2wzr.js";import{g as o,h as s,l as c,n as l,s as u,t as d}from"./state-C-LyNCwu.js";import{t as f}from"./agent-DYjX-Pzl.js";import{t as p}from"./terminal-DgodR87i.js";var m=t(),h=e();function g(){let e=(0,m.c)(16),t=f.useParams(),s=f.useSearch(),c;e[0]===t.worktree?c=e[1]:(c=d(t.worktree),e[0]=t.worktree,e[1]=c);let u=o(c),p=u.value.activeWorktree?.root??``,g;e[2]===p?g=e[3]:(g=l(p),e[2]=p,e[3]=g);let v=o(g);if(!u.value.activeWorktree){let t;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,h.jsx)(r,{to:`/`,replace:!0}),e[4]=t):t=e[4],t}let y;if(e[5]!==s||e[6]!==v.value){let t;e[8]===s?t=e[9]:(t=e=>e.uuid===s.agentId,e[8]=s,e[9]=t),y=n(v.value,i(t),a),e[5]=s,e[6]=v.value,e[7]=y}else y=e[7];let b=y;if(!b){let t;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,h.jsx)(r,{to:`/`,replace:!0}),e[10]=t):t=e[10],t}let x;return e[11]!==u.value.activeWorktree.root||e[12]!==s.agentId||e[13]!==b.args||e[14]!==b.command?(x=(0,h.jsx)(_,{args:b.args,command:b.command,cwd:u.value.activeWorktree.root,sessionId:s.agentId}),e[11]=u.value.activeWorktree.root,e[12]=s.agentId,e[13]=b.args,e[14]=b.command,e[15]=x):x=e[15],x}function _(e){let t=(0,m.c)(23),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=c.mutation(`terminal.resize`),t[0]=n):n=t[0];let r=s(n),i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=c.mutation(`terminal.write`),t[1]=i):i=t[1];let a=s(i),l;t[2]===e?l=t[3]:(l=u(e),t[2]=e,t[3]=l);let d=o(l),f;t[4]!==e.args||t[5]!==e.command||t[6]!==e.cwd||t[7]!==e.sessionId||t[8]!==a?(f=t=>a({payload:{args:e.args,command:e.command,cwd:e.cwd,data:t,sessionId:e.sessionId}}),t[4]=e.args,t[5]=e.command,t[6]=e.cwd,t[7]=e.sessionId,t[8]=a,t[9]=f):f=t[9];let g;t[10]!==e.args||t[11]!==e.command||t[12]!==e.cwd||t[13]!==e.sessionId||t[14]!==r?(g=t=>r({payload:{args:e.args,cols:t.cols,command:e.command,cwd:e.cwd,rows:t.rows,sessionId:e.sessionId}}),t[10]=e.args,t[11]=e.command,t[12]=e.cwd,t[13]=e.sessionId,t[14]=r,t[15]=g):g=t[15];let _;return t[16]!==e.sessionId||t[17]!==f||t[18]!==g||t[19]!==d.value.data||t[20]!==d.value.frame||t[21]!==d.value.state.state?(_=(0,h.jsx)(`div`,{className:`bg-background h-full min-h-0 min-w-0`,children:(0,h.jsx)(p,{className:`h-full min-h-0 w-full min-w-0 overflow-hidden`,data:d.value.data,frame:d.value.frame,onData:f,onResize:g,state:d.value.state.state},e.sessionId)}),t[16]=e.sessionId,t[17]=f,t[18]=g,t[19]=d.value.data,t[20]=d.value.frame,t[21]=d.value.state.state,t[22]=_):_=t[22],_}export{g as component};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/agent-CRsoHYEG.js","assets/state-C-LyNCwu.js","assets/chunk-QTnfLwEv.js","assets/button-fe_R2wzr.js","assets/compiler-runtime-rGeCHUuX.js","assets/terminal-DgodR87i.js","assets/fallbacks-DZ7ciusO.js"])))=>i.map(i=>d[i]);
2
- import{$o as e,J as t,Qo as n,Y as r,gt as i}from"./button-fe_R2wzr.js";import{t as a}from"./preload-helper-CjdClQve.js";var o=e(`/(home)/$worktree/agent`)({component:n(()=>a(()=>import(`./agent-CRsoHYEG.js`),__vite__mapDeps([0,1,2,3,4,5,6])),`component`),validateSearch:i(r({agentId:t}))});export{o as t};