@sealant/mend 0.36.0 → 0.37.0-next.1096

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 (96) hide show
  1. package/dist/{chunk-MY3TCM3Q.js → chunk-AG3LQFVW.js} +693 -252
  2. package/dist/{dashboard-7QWLVA5J.js → dashboard-WREOSGDV.js} +1 -1
  3. package/dist/main.js +251 -120
  4. package/man/mend-accounts.1 +1 -1
  5. package/man/mend-adopt.1 +1 -1
  6. package/man/mend-agent-logins.1 +1 -1
  7. package/man/mend-attach.1 +1 -1
  8. package/man/mend-codex.1 +1 -1
  9. package/man/mend-completions.1 +1 -1
  10. package/man/mend-connect-pi.1 +1 -1
  11. package/man/mend-connect.1 +4 -4
  12. package/man/mend-continue.1 +1 -1
  13. package/man/mend-doctor.1 +1 -1
  14. package/man/mend-dotfiles-repo.1 +1 -1
  15. package/man/mend-dotfiles-sync.1 +1 -1
  16. package/man/mend-dotfiles.1 +1 -1
  17. package/man/mend-env-cluster.1 +1 -1
  18. package/man/mend-env-load.1 +2 -2
  19. package/man/mend-env-show.1 +1 -1
  20. package/man/mend-folder-create.1 +1 -1
  21. package/man/mend-folder-list.1 +1 -1
  22. package/man/mend-folder-push.1 +1 -1
  23. package/man/mend-folder-rm.1 +1 -1
  24. package/man/mend-git-author.1 +1 -1
  25. package/man/mend-handoff.1 +1 -1
  26. package/man/mend-help.1 +1 -1
  27. package/man/mend-invite.1 +1 -1
  28. package/man/mend-keys-init.1 +1 -1
  29. package/man/mend-keys-mode.1 +1 -1
  30. package/man/mend-keys-share.1 +1 -1
  31. package/man/mend-keys-show.1 +1 -1
  32. package/man/mend-land.1 +1 -1
  33. package/man/mend-login.1 +1 -1
  34. package/man/mend-logout.1 +1 -1
  35. package/man/mend-logs.1 +1 -1
  36. package/man/mend-man.1 +1 -1
  37. package/man/mend-members.1 +1 -1
  38. package/man/mend-memory-import.1 +1 -1
  39. package/man/mend-memory-rm.1 +1 -1
  40. package/man/mend-memory-show.1 +1 -1
  41. package/man/mend-memory.1 +1 -1
  42. package/man/mend-models.1 +1 -1
  43. package/man/mend-operator-exposure.1 +1 -1
  44. package/man/mend-operator-gate.1 +1 -1
  45. package/man/mend-operator-grant-owner.1 +1 -1
  46. package/man/mend-operator-org-create.1 +1 -1
  47. package/man/mend-operator-org-invite-owner.1 +1 -1
  48. package/man/mend-operator-org-list.1 +1 -1
  49. package/man/mend-operator-org-rename.1 +1 -1
  50. package/man/mend-operator-reset-link.1 +1 -1
  51. package/man/mend-pair.1 +1 -1
  52. package/man/mend-projects.1 +1 -1
  53. package/man/mend-pull.1 +1 -1
  54. package/man/mend-refresh.1 +1 -1
  55. package/man/mend-rejoin.1 +1 -1
  56. package/man/mend-resume.1 +1 -1
  57. package/man/mend-run.1 +1 -1
  58. package/man/mend-secrets-add.1 +1 -1
  59. package/man/mend-secrets-rm.1 +1 -1
  60. package/man/mend-secrets.1 +1 -1
  61. package/man/mend-server-logs.1 +1 -1
  62. package/man/mend-server-restart.1 +1 -1
  63. package/man/mend-server-setup.1 +1 -1
  64. package/man/mend-server-start.1 +1 -1
  65. package/man/mend-server-status.1 +1 -1
  66. package/man/mend-server-stop.1 +1 -1
  67. package/man/mend-server-upgrade.1 +1 -1
  68. package/man/mend-server.1 +1 -1
  69. package/man/mend-service-add.1 +1 -1
  70. package/man/mend-service-connect.1 +1 -1
  71. package/man/mend-service-init.1 +1 -1
  72. package/man/mend-service-list.1 +1 -1
  73. package/man/mend-service-logs.1 +1 -1
  74. package/man/mend-service-restart.1 +1 -1
  75. package/man/mend-service-run.1 +1 -1
  76. package/man/mend-service-stop.1 +1 -1
  77. package/man/mend-session-share.1 +1 -1
  78. package/man/mend-sessions.1 +1 -1
  79. package/man/mend-shell.1 +1 -1
  80. package/man/mend-skills-push.1 +1 -1
  81. package/man/mend-skills.1 +1 -1
  82. package/man/mend-snake.1 +1 -1
  83. package/man/mend-ssh-keys-remove.1 +1 -1
  84. package/man/mend-ssh-keys.1 +1 -1
  85. package/man/mend-ssh-setup.1 +1 -1
  86. package/man/mend-ssh.1 +1 -1
  87. package/man/mend-stop.1 +1 -1
  88. package/man/mend-ui.1 +1 -1
  89. package/man/mend-uninstall.1 +1 -1
  90. package/man/mend-version.1 +1 -1
  91. package/man/mend-wait.1 +1 -1
  92. package/man/mend-workspace-replace.1 +1 -1
  93. package/man/mend-worktrees-rm.1 +1 -1
  94. package/man/mend-worktrees.1 +1 -1
  95. package/man/mend.1 +1 -1
  96. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -53,6 +53,7 @@ import {
53
53
  hostUserNamespacesFixLine,
54
54
  hostUserNamespacesOf,
55
55
  hostUserNamespacesSysctlLines,
56
+ isChosenDefault,
56
57
  isDetachChunk,
57
58
  isEnvPath,
58
59
  isFlag,
@@ -61,6 +62,7 @@ import {
61
62
  landingFactLine,
62
63
  landingFactsFromWire,
63
64
  launcherNameOf,
65
+ loginChoiceOf,
64
66
  matchProjectByCwd,
65
67
  mayStillBeWorking,
66
68
  narrowCredential,
@@ -88,10 +90,12 @@ import {
88
90
  sharedControlQuestion,
89
91
  shellWord,
90
92
  spoken,
93
+ storedSecretNameRefusal,
91
94
  takeFlagValue,
92
95
  takesHandoffs,
93
96
  terminalReadOnlyLine,
94
97
  trackBracketedPaste,
98
+ unchosenLoginSummary,
95
99
  validatePiProfile,
96
100
  validateSecretFilePath,
97
101
  workspaceLineList,
@@ -99,14 +103,13 @@ import {
99
103
  workspaceRetirementLine,
100
104
  worktreeJoinLine,
101
105
  worktreeListsPeople
102
- } from "./chunk-MY3TCM3Q.js";
106
+ } from "./chunk-AG3LQFVW.js";
103
107
 
104
108
  // src/main.ts
105
109
  import { spawn as spawn3, spawnSync as spawnSync8 } from "node:child_process";
106
110
  import * as crypto from "node:crypto";
107
111
  import * as fs24 from "node:fs";
108
112
  import { createRequire } from "node:module";
109
- import * as net6 from "node:net";
110
113
  import * as os16 from "node:os";
111
114
  import * as path24 from "node:path";
112
115
 
@@ -340,6 +343,87 @@ var startAgentShare = (options) => {
340
343
  };
341
344
  };
342
345
 
346
+ // ../../packages/network/src/tunnel-client.ts
347
+ import * as net2 from "node:net";
348
+ var SEND_HIGH_WATER_BYTES = 1024 * 1024;
349
+ var HELD_RETRY_MS = 10;
350
+ var pumpConnection = (socket, url, options = {}) => {
351
+ socket.pause();
352
+ socket.on("error", () => {
353
+ });
354
+ void url.then(
355
+ (target) => {
356
+ if (socket.destroyed) return null;
357
+ const ws = new WebSocket(target);
358
+ ws.binaryType = "arraybuffer";
359
+ let opened = false;
360
+ let held = null;
361
+ const resumeOnceSent = () => {
362
+ if (socket.destroyed) {
363
+ held = null;
364
+ return;
365
+ }
366
+ if (ws.bufferedAmount > SEND_HIGH_WATER_BYTES) {
367
+ held = setTimeout(resumeOnceSent, HELD_RETRY_MS);
368
+ return;
369
+ }
370
+ held = null;
371
+ socket.resume();
372
+ };
373
+ ws.addEventListener(
374
+ "open",
375
+ () => {
376
+ opened = true;
377
+ socket.resume();
378
+ },
379
+ { once: true }
380
+ );
381
+ ws.addEventListener("message", (event) => {
382
+ if (event.data instanceof ArrayBuffer) socket.write(Buffer.from(event.data));
383
+ });
384
+ ws.addEventListener(
385
+ "close",
386
+ (event) => {
387
+ if (held !== null) clearTimeout(held);
388
+ if (event.code === 1e3) {
389
+ socket.end();
390
+ return;
391
+ }
392
+ if (opened) options.onClosed?.(event.code, event.reason);
393
+ if (!socket.destroyed) socket.resetAndDestroy();
394
+ },
395
+ { once: true }
396
+ );
397
+ ws.addEventListener(
398
+ "error",
399
+ () => {
400
+ if (socket.destroyed) return;
401
+ if (opened) socket.resetAndDestroy();
402
+ else socket.destroy();
403
+ },
404
+ { once: true }
405
+ );
406
+ socket.on("data", (chunk) => {
407
+ ws.send(new Uint8Array(chunk));
408
+ if (held === null && ws.bufferedAmount > SEND_HIGH_WATER_BYTES) {
409
+ socket.pause();
410
+ held = setTimeout(resumeOnceSent, HELD_RETRY_MS);
411
+ }
412
+ });
413
+ socket.on("end", () => {
414
+ if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ t: "eof" }));
415
+ });
416
+ socket.on("close", () => ws.close());
417
+ return null;
418
+ },
419
+ () => socket.destroy()
420
+ );
421
+ };
422
+ var tunnelListener = (tunnelUrl, options = {}) => net2.createServer({ allowHalfOpen: true }, (socket) => {
423
+ options.onConnection?.(socket);
424
+ pumpConnection(socket, tunnelUrl(), options);
425
+ });
426
+
343
427
  // src/agent-logins.ts
344
428
  var parseAgentLoginsArgs = (args) => {
345
429
  if (args.length === 0) return { kind: "show" };
@@ -879,7 +963,7 @@ import * as os4 from "node:os";
879
963
  import * as path6 from "node:path";
880
964
 
881
965
  // src/server-edge.ts
882
- import * as net2 from "node:net";
966
+ import * as net3 from "node:net";
883
967
 
884
968
  // src/server-edge-files.ts
885
969
  var EDGE_COMPOSE_OVERLAY = [
@@ -966,6 +1050,43 @@ var EDGE_CADDYFILE = [
966
1050
  "# Everything goes to Mend's web tier, which proxies /api, the event stream and every WebSocket on",
967
1051
  "# this one origin. Nothing else is routed: not the API, not Sealant, not the session channel, not",
968
1052
  "# the bucket.",
1053
+ "#",
1054
+ "# What a log line about a request holds. Mend's site names its log `mend`, and only that log keeps",
1055
+ "# a path: never a query or a fragment, whatever route it names (sockets and the phone's embed carry",
1056
+ "# a single-use ticket there, pairing a code), nor a target's userinfo, in the uri or a Location.",
1057
+ "# Every other line holds no uri and no Location: the t3code gateway's (an asset URL's path is its",
1058
+ "# token and file name), and every line Caddy does not name for Mend's site. Caddy names a line's",
1059
+ "# log by the exact Host, so a Host in another case or with a trailing dot, the port-80 redirect for",
1060
+ "# it, and a module's own lines (reverse_proxy's for a response cut short) fall to `default`.",
1061
+ "# Caddy already redacts Authorization, Cookie and Set-Cookie; Referer is dropped.",
1062
+ "(uri-free) {",
1063
+ " format filter {",
1064
+ " fields {",
1065
+ " request>uri replace REDACTED",
1066
+ " resp_headers>Location delete",
1067
+ " request>headers>Referer delete",
1068
+ " }",
1069
+ " }",
1070
+ "}",
1071
+ "",
1072
+ "{",
1073
+ " log default {",
1074
+ " output stdout",
1075
+ " import uri-free",
1076
+ " }",
1077
+ " log mend {",
1078
+ " include http.log.access.mend http.log.error.mend",
1079
+ " output stdout",
1080
+ " format filter {",
1081
+ " fields {",
1082
+ ' request>uri regexp "(^|[A-Za-z][A-Za-z0-9+.-]*://)[^/?#]*(@)|([?#])[\\s\\S]*" "${1}${3}REDACTED${2}"',
1083
+ ' resp_headers>Location regexp "(^|[A-Za-z][A-Za-z0-9+.-]*://)[^/?#]*(@)|([?#])[\\s\\S]*" "${1}${3}REDACTED${2}"',
1084
+ " request>headers>Referer delete",
1085
+ " }",
1086
+ " }",
1087
+ " }",
1088
+ "}",
1089
+ "",
969
1090
  "{$MEND_EDGE_HOST} {",
970
1091
  " encode zstd gzip",
971
1092
  "",
@@ -977,31 +1098,7 @@ var EDGE_CADDYFILE = [
977
1098
  " flush_interval -1",
978
1099
  " }",
979
1100
  "",
980
- " log {",
981
- " output stdout",
982
- " # The terminal, tunnel and key bridge sockets and the phone's embed carry a single-use",
983
- " # ticket in the query, and pairing carries a code. A log holds none of them. Caddy already",
984
- " # redacts Authorization, Cookie and Set-Cookie.",
985
- " format filter {",
986
- " # Absolute-form request URLs can carry userinfo before the host. Filter that separately",
987
- " # from query parameters, retaining the scheme, host, path and ordinary query values.",
988
- " wrap filter {",
989
- " wrap json",
990
- " fields {",
991
- " # The query filter forwards the selected uri as a leaf to this wrapped encoder.",
992
- ' uri regexp "^([A-Za-z][A-Za-z0-9+.-]*://)[^/?#]*@" "${1}REDACTED@"',
993
- " }",
994
- " }",
995
- " fields {",
996
- " request>uri query {",
997
- " replace ticket REDACTED",
998
- " replace token REDACTED",
999
- " replace code REDACTED",
1000
- " }",
1001
- " request>headers>Referer delete",
1002
- " }",
1003
- " }",
1004
- " }",
1101
+ " log mend",
1005
1102
  "}",
1006
1103
  "",
1007
1104
  "# Sites beside Mend's own origin, one file each. `mend server setup --t3-gateway-origin <host>`",
@@ -1444,9 +1541,9 @@ var DECLARABLE_ITEMS = [
1444
1541
  "t3code-gateway"
1445
1542
  ];
1446
1543
  var isDeclarableItem = (value) => DECLARABLE_ITEMS.some((item) => item === value);
1447
- var publishedAddress = (address, port) => `${net2.isIP(address) === 6 ? `[${address}]` : address}:${port}`;
1544
+ var publishedAddress = (address, port) => `${net3.isIP(address) === 6 ? `[${address}]` : address}:${port}`;
1448
1545
  var isLoopbackBindAddress = (address) => address === "::1" || address.startsWith("127.");
1449
- var urlHostOf = (address) => address === "0.0.0.0" ? "127.0.0.1" : address === "::" ? "[::1]" : net2.isIP(address) === 6 ? `[${address}]` : address;
1546
+ var urlHostOf = (address) => address === "0.0.0.0" ? "127.0.0.1" : address === "::" ? "[::1]" : net3.isIP(address) === 6 ? `[${address}]` : address;
1450
1547
  var t3GatewayPlacement = (posture) => {
1451
1548
  const port = posture.t3GatewayPort;
1452
1549
  if (port === void 0) return void 0;
@@ -1479,7 +1576,7 @@ var parseEdgeHost = (value) => {
1479
1576
  const host = value.trim().toLowerCase().replace(/\.$/, "");
1480
1577
  const labels = host.split(".");
1481
1578
  const label = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
1482
- if (host.length === 0 || host.length > 253 || labels.length < 2 || !labels.every((part) => label.test(part)) || net2.isIP(host) !== 0) {
1579
+ if (host.length === 0 || host.length > 253 || labels.length < 2 || !labels.every((part) => label.test(part)) || net3.isIP(host) !== 0) {
1483
1580
  return null;
1484
1581
  }
1485
1582
  return host;
@@ -1502,7 +1599,7 @@ var t3GatewayEnvLines = (posture) => {
1502
1599
  if (placement === void 0) return [];
1503
1600
  return [
1504
1601
  `MEND_T3_GATEWAY_PORT=${placement.port}`,
1505
- `MEND_T3_GATEWAY_BIND_HOST=${net2.isIP(placement.bind) === 6 ? `[${placement.bind}]` : placement.bind}`,
1602
+ `MEND_T3_GATEWAY_BIND_HOST=${net3.isIP(placement.bind) === 6 ? `[${placement.bind}]` : placement.bind}`,
1506
1603
  `MEND_T3_GATEWAY_PUBLISHED=${publishedAddress(placement.bind, placement.port)}`,
1507
1604
  `MEND_T3_GATEWAY_URL=${placement.url}`,
1508
1605
  ...placement.edgeHost === void 0 ? [] : [`MEND_T3_GATEWAY_EDGE_HOST=${placement.edgeHost}`]
@@ -1577,25 +1674,12 @@ var T3_GATEWAY_CADDYFILE = [
1577
1674
  " flush_interval -1",
1578
1675
  " }",
1579
1676
  "",
1580
- " log {",
1677
+ " # No uri and no Location: an asset URL's path is its token and file name. uri-free is the",
1678
+ " # Caddyfile's snippet; Caddy's error lines about these requests go to its default log, which",
1679
+ " # holds neither.",
1680
+ " log t3code-gateway {",
1581
1681
  " output stdout",
1582
- " format filter {",
1583
- " # Keep absolute URL userinfo out of access logs, alongside the query filter below.",
1584
- " wrap filter {",
1585
- " wrap json",
1586
- " fields {",
1587
- " # The query filter forwards the selected uri as a leaf to this wrapped encoder.",
1588
- ' uri regexp "^([A-Za-z][A-Za-z0-9+.-]*://)[^/?#]*@" "${1}REDACTED@"',
1589
- " }",
1590
- " }",
1591
- " fields {",
1592
- " request>uri query {",
1593
- " replace wsTicket REDACTED",
1594
- " replace token REDACTED",
1595
- " }",
1596
- " request>headers>Referer delete",
1597
- " }",
1598
- " }",
1682
+ " import uri-free",
1599
1683
  " }",
1600
1684
  "}",
1601
1685
  ""
@@ -2434,7 +2518,7 @@ var COMMANDS = [
2434
2518
  section: "start",
2435
2519
  summary: "send this machine's provider credential to the platform",
2436
2520
  synopsis: [
2437
- "<claude|codex|github> [--use-my-login] [--from-stdin] [--remove]",
2521
+ "<claude|codex|github> [--use-my-login] [--from-stdin] [--remove [<name>]]",
2438
2522
  "pi [--dir <path>] [--dry-run] [--remove]"
2439
2523
  ],
2440
2524
  description: [
@@ -2448,7 +2532,10 @@ var COMMANDS = [
2448
2532
  text: "claude, codex: send the login this machine already uses; both sides then share it"
2449
2533
  },
2450
2534
  { flag: "--from-stdin", text: "paste a credential instead of reading the provider's file" },
2451
- { flag: "--remove", text: "disconnect the provider" }
2535
+ {
2536
+ flag: "--remove [<name>]",
2537
+ text: "disconnect the provider's chosen login, or the account of that name"
2538
+ }
2452
2539
  ],
2453
2540
  examples: [
2454
2541
  { command: "mend connect claude", text: "a Claude login of Mend's own, through the browser" },
@@ -3123,7 +3210,7 @@ var COMMANDS = [
3123
3210
  summary: "load a .env into the project",
3124
3211
  synopsis: ["[file] [--project <p>] [--secret [A,B]]"],
3125
3212
  description: [
3126
- "Ordinary names become configuration. Secret-shaped names (KEY, TOKEN, PASSWORD, and the like) become secrets, which Mend stores encrypted and never shows again. Sessions receive both at launch. Default file: .env in the current directory."
3213
+ "Ordinary names become configuration. Secret-shaped names (KEY, TOKEN, PASSWORD, and the like) become secrets, which Mend stores encrypted and never shows again. Sessions receive both at launch. A provider's login name, such as ANTHROPIC_API_KEY or OPENAI_API_KEY, is refused: it is a Claude or Codex login, which you connect in Settings \u2192 Connected accounts. Default file: .env in the current directory."
3127
3214
  ],
3128
3215
  options: [
3129
3216
  project(),
@@ -5052,14 +5139,17 @@ var runChecks = async (config, probes) => {
5052
5139
  });
5053
5140
  }
5054
5141
  const identity = signedIn ? await getJson(config, "/me/sealant") : null;
5055
- const platform = identity === null ? null : identity.value;
5142
+ const accounts = identity?.value?.accounts.map((account) => ({
5143
+ ...account,
5144
+ isDefault: isChosenDefault(account)
5145
+ })) ?? null;
5056
5146
  for (const { provider } of HARNESS_CLIS) {
5057
- if (platform === null) {
5147
+ if (accounts === null) {
5058
5148
  checks.push(notChecked(provider));
5059
5149
  continue;
5060
5150
  }
5061
- const account = platform.accounts.find((row) => row.provider === provider && row.name === "default") ?? platform.accounts.find((row) => row.provider === provider);
5062
- if (account === void 0) {
5151
+ const choice = loginChoiceOf(accounts, provider);
5152
+ if (choice._tag === "none") {
5063
5153
  checks.push({
5064
5154
  label: provider,
5065
5155
  state: "todo",
@@ -5068,6 +5158,17 @@ var runChecks = async (config, probes) => {
5068
5158
  });
5069
5159
  continue;
5070
5160
  }
5161
+ if (choice._tag === "unchosen") {
5162
+ const summary = unchosenLoginSummary(provider, choice.accounts.length);
5163
+ checks.push({
5164
+ label: provider,
5165
+ state: "todo",
5166
+ detail: `${summary.words} \xB7 ${summary.count} connected`,
5167
+ fix: summary.firstCommand
5168
+ });
5169
+ continue;
5170
+ }
5171
+ const account = choice.account;
5071
5172
  const who = identityOf(account);
5072
5173
  checks.push(
5073
5174
  account.status === "active" ? {
@@ -8737,7 +8838,7 @@ import { createHmac, randomBytes } from "node:crypto";
8737
8838
  import * as dns from "node:dns/promises";
8738
8839
  import * as fs19 from "node:fs";
8739
8840
  import { readFile } from "node:fs/promises";
8740
- import * as net4 from "node:net";
8841
+ import * as net5 from "node:net";
8741
8842
  import * as os12 from "node:os";
8742
8843
  import * as path19 from "node:path";
8743
8844
 
@@ -9816,7 +9917,7 @@ var claimServerDockerVolumes = (runtime, input) => ownership(runtime, input, "cl
9816
9917
  var verifyServerDockerVolumes = (runtime, input) => ownership(runtime, input, "verify");
9817
9918
 
9818
9919
  // src/server-setup-guide.ts
9819
- import * as net3 from "node:net";
9920
+ import * as net4 from "node:net";
9820
9921
 
9821
9922
  // ../../packages/network/src/address-kind.ts
9822
9923
  var octets = (address) => {
@@ -9847,7 +9948,7 @@ var addressKindOf = (address, family) => {
9847
9948
  // src/server-setup-guide.ts
9848
9949
  var LOOPBACK = "127.0.0.1";
9849
9950
  var isLoopbackAddress = (address) => address === "::1" || address.startsWith("127.");
9850
- var kindOfAddress = (address) => addressKindOf(address, net3.isIPv6(address) ? "IPv6" : "IPv4");
9951
+ var kindOfAddress = (address) => addressKindOf(address, net4.isIPv6(address) ? "IPv6" : "IPv4");
9851
9952
  var isPublicAddress = (address) => address !== "0.0.0.0" && address !== "::" && kindOfAddress(address) === "public";
9852
9953
  var isPrivateNetworkAddress = (address) => {
9853
9954
  const kind = kindOfAddress(address);
@@ -10002,8 +10103,8 @@ var tailscaleFactsOf = (status, serve) => {
10002
10103
  const dns2 = self.get("DNSName");
10003
10104
  const ips = self.get("TailscaleIPs");
10004
10105
  const addresses = Array.isArray(ips) ? ips.filter((ip) => typeof ip === "string") : [];
10005
- const ipv4 = addresses.find((ip) => net3.isIPv4(ip));
10006
- const ipv6 = addresses.find((ip) => net3.isIPv6(ip));
10106
+ const ipv4 = addresses.find((ip) => net4.isIPv4(ip));
10107
+ const ipv6 = addresses.find((ip) => net4.isIPv6(ip));
10007
10108
  const serveFields = fieldsOf(parseJson3(serve));
10008
10109
  const funnel = fieldsOf(serveFields.get("AllowFunnel"));
10009
10110
  const routes = [...fieldsOf(serveFields.get("Web")).entries()].flatMap(([hostPort, web]) => {
@@ -10151,7 +10252,7 @@ var tailscaleOnce = (observe) => {
10151
10252
  return () => facts ??= observe.tailscale();
10152
10253
  };
10153
10254
  var tailnetAddress = (tailscale) => tailscale?.running === true ? tailscale.ipv4 ?? tailscale.ipv6 : null;
10154
- var urlHost = (address) => net3.isIPv6(address) ? `[${address}]` : address;
10255
+ var urlHost = (address) => net4.isIPv6(address) ? `[${address}]` : address;
10155
10256
  var settled2 = (settings) => ({
10156
10257
  ...settings,
10157
10258
  sshBind: settings.sshBind === settings.bind ? void 0 : settings.sshBind,
@@ -10169,7 +10270,7 @@ var toThisMachine = (settings) => ({
10169
10270
  exposure: "loopback",
10170
10271
  declared: without(settings.declared, "workspace-ssh")
10171
10272
  });
10172
- var publicAddressesHere = (asked) => asked.context.observe.localAddresses().filter((address) => net3.isIPv4(address) && isPublicAddress(address));
10273
+ var publicAddressesHere = (asked) => asked.context.observe.localAddresses().filter((address) => net4.isIPv4(address) && isPublicAddress(address));
10173
10274
  var listed = (addresses) => addresses.length === 1 ? `${addresses[0]} is a public address` : `${addresses.join(", ")} are public addresses`;
10174
10275
  var askNetwork = async (asked, settings) => {
10175
10276
  const { io } = asked;
@@ -10184,7 +10285,7 @@ var askNetwork = async (asked, settings) => {
10184
10285
  );
10185
10286
  const tailnet = tailnetAddress(tailscale);
10186
10287
  const others = asked.context.observe.localAddresses().filter(
10187
- (address) => net3.isIPv4(address) && address !== tailnet && isPrivateNetworkAddress(address)
10288
+ (address) => net4.isIPv4(address) && address !== tailnet && isPrivateNetworkAddress(address)
10188
10289
  );
10189
10290
  const exposed = publicAddressesHere(asked);
10190
10291
  if (exposed.length > 0)
@@ -11363,13 +11464,13 @@ var validateExposure = (existing, options) => {
11363
11464
  throw setupError("--port and --ssh-port must use different ports.");
11364
11465
  }
11365
11466
  const bind = options.bind ?? existing?.bind ?? DEFAULT_BIND;
11366
- if (net4.isIP(bind) === 0) {
11467
+ if (net5.isIP(bind) === 0) {
11367
11468
  throw setupError(
11368
11469
  "--bind must be a literal IPv4 or IPv6 address, such as 127.0.0.1 or 0.0.0.0."
11369
11470
  );
11370
11471
  }
11371
11472
  const requestedSshBind = options.sshBind ?? existing?.sshBind;
11372
- if (requestedSshBind !== void 0 && net4.isIP(requestedSshBind) === 0) {
11473
+ if (requestedSshBind !== void 0 && net5.isIP(requestedSshBind) === 0) {
11373
11474
  throw setupError(
11374
11475
  "--ssh-bind must be a literal IPv4 or IPv6 address, such as 127.0.0.1 or 0.0.0.0."
11375
11476
  );
@@ -12016,7 +12117,7 @@ var renderGarage = (secrets, config) => {
12016
12117
  ];
12017
12118
  };
12018
12119
  var namespaceOf = (config) => config.bucket === "garage" ? MEND_DOCKER_NAMESPACE_WITH_GARAGE : MEND_DOCKER_NAMESPACE;
12019
- var composeHost = (address) => net4.isIP(address) === 6 ? `[${address}]` : address;
12120
+ var composeHost = (address) => net5.isIP(address) === 6 ? `[${address}]` : address;
12020
12121
  var renderSecrets = (secrets, config) => {
12021
12122
  const sshHost = parseUrl(config.appUrl, "Server config appUrl").hostname.replace(/^\[|\]$/g, "");
12022
12123
  const composeBind = composeHost(config.bind);
@@ -12290,7 +12391,7 @@ var generationFiles = (config, secrets, assets, identity = renderIdentity(secret
12290
12391
  var persistSetup = (store, config, secrets, assets) => storeValue(store.prepare(generationFiles(config, secrets, assets)));
12291
12392
  var healthOrigin = (config) => {
12292
12393
  if (config.edgeHost === void 0) return config.appUrl;
12293
- const host = net4.isIP(config.bind) === 6 ? `[${config.bind}]` : config.bind;
12394
+ const host = net5.isIP(config.bind) === 6 ? `[${config.bind}]` : config.bind;
12294
12395
  return `http://${host}:${config.appPort}`;
12295
12396
  };
12296
12397
  var reachableLine = (config) => config.edgeHost === void 0 ? `Mend ${config.serverVersion} is reachable at ${config.appUrl}` : `Mend ${config.serverVersion} answers at ${healthOrigin(config)} on this machine \xB7 the edge is set up for ${config.appUrl}`;
@@ -12358,7 +12459,7 @@ var portHolder = async (runtime, address, port, what) => {
12358
12459
  const host = connectHost(address);
12359
12460
  const answer2 = readHealth(
12360
12461
  await runtime.fetchText(
12361
- `http://${net4.isIPv6(host) ? `[${host}]` : host}:${port}/api/health`,
12462
+ `http://${net5.isIPv6(host) ? `[${host}]` : host}:${port}/api/health`,
12362
12463
  2e3
12363
12464
  )
12364
12465
  );
@@ -14103,7 +14204,7 @@ var askOnTerminal = async (prompt) => {
14103
14204
  }
14104
14205
  };
14105
14206
  var sshBannerAt = async (host, port, timeoutMs) => {
14106
- const socket = net4.connect({ host, port });
14207
+ const socket = net5.connect({ host, port });
14107
14208
  let deadline;
14108
14209
  try {
14109
14210
  return await Promise.race([
@@ -14137,13 +14238,13 @@ var isNetworkAddress = (entry) => {
14137
14238
  var reachableAddressesOf = (interfaces) => Object.entries(interfaces).filter(([name]) => !BRIDGE_INTERFACE.test(name)).flatMap(([, entries]) => entries ?? []).filter((entry) => !entry.internal && !isNetworkAddress(entry)).map((entry) => entry.address);
14138
14239
  var portTakenHere = async (port, address = "127.0.0.1") => {
14139
14240
  const bindFails = await new Promise((resolve10) => {
14140
- const server = net4.createServer();
14241
+ const server = net5.createServer();
14141
14242
  server.once("error", (error) => resolve10(error.code === "EADDRINUSE"));
14142
14243
  server.listen(port, address, () => server.close(() => resolve10(false)));
14143
14244
  });
14144
14245
  if (bindFails) return true;
14145
14246
  return new Promise((resolve10) => {
14146
- const socket = net4.connect({ host: connectHost(address), port });
14247
+ const socket = net5.connect({ host: connectHost(address), port });
14147
14248
  const done = (answered) => {
14148
14249
  socket.destroy();
14149
14250
  resolve10(answered);
@@ -14409,7 +14510,6 @@ var renderMendToml = (proposals) => {
14409
14510
  };
14410
14511
 
14411
14512
  // src/service-tunnels.ts
14412
- import * as net5 from "node:net";
14413
14513
  var attachTunnelTargets = (services, sessionId) => services.filter(
14414
14514
  (service) => service.sessionId === sessionId && service.protocol === "tcp" && service.browserScheme !== null
14415
14515
  );
@@ -14426,31 +14526,6 @@ var touchesSessionServices = (payload, sessionId) => {
14426
14526
  const session = "sessionId" in parsed ? parsed.sessionId : void 0;
14427
14527
  return (type2 === "session-process" || type2 === "session") && session === sessionId;
14428
14528
  };
14429
- var pumpConnection = (socket, url) => {
14430
- socket.pause();
14431
- socket.on("error", () => {
14432
- });
14433
- void url.then(
14434
- (target) => {
14435
- if (socket.destroyed) return null;
14436
- const ws = new WebSocket(target);
14437
- ws.binaryType = "arraybuffer";
14438
- ws.addEventListener("open", () => socket.resume(), { once: true });
14439
- ws.addEventListener("message", (event) => {
14440
- if (event.data instanceof ArrayBuffer) socket.write(Buffer.from(event.data));
14441
- });
14442
- ws.addEventListener("close", () => socket.end(), { once: true });
14443
- ws.addEventListener("error", () => socket.destroy(), { once: true });
14444
- socket.on("data", (chunk) => ws.send(new Uint8Array(chunk)));
14445
- socket.on("end", () => {
14446
- if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ t: "eof" }));
14447
- });
14448
- socket.on("close", () => ws.close());
14449
- return null;
14450
- },
14451
- () => socket.destroy()
14452
- );
14453
- };
14454
14529
  var listenLocal = (server, port, fallback) => new Promise((resolve10, reject) => {
14455
14530
  const attempt2 = (candidate, lastTry) => {
14456
14531
  const onError = (error) => {
@@ -14522,10 +14597,11 @@ var createServiceTunnels = (options) => {
14522
14597
  };
14523
14598
  const openFor = async (service) => {
14524
14599
  const sockets = /* @__PURE__ */ new Set();
14525
- const server = net5.createServer((socket) => {
14526
- sockets.add(socket);
14527
- socket.on("close", () => sockets.delete(socket));
14528
- pumpConnection(socket, options.tunnelUrl(service.id));
14600
+ const server = tunnelListener(() => options.tunnelUrl(service.id), {
14601
+ onConnection: (socket) => {
14602
+ sockets.add(socket);
14603
+ socket.on("close", () => sockets.delete(socket));
14604
+ }
14529
14605
  });
14530
14606
  let port;
14531
14607
  try {
@@ -19024,17 +19100,18 @@ var serviceInit = async (args) => {
19024
19100
  var tunnelServices = async (config, services, portOverride) => {
19025
19101
  for (const service of services) {
19026
19102
  const port = portOverride ?? service.hostPort ?? service.workspacePort;
19027
- const server = net6.createServer(
19028
- (socket) => pumpConnection(socket, tunnelUrlFor(config, service.id))
19029
- );
19103
+ const label = service.label ?? service.id.slice(0, 8);
19104
+ const server = tunnelListener(() => tunnelUrlFor(config, service.id), {
19105
+ onClosed: (code, reason) => say8(
19106
+ `${amber3("\u25CF")} ${label} ${dim8(`connection closed \xB7 ${code} ${reason || "no reason"}`)}`
19107
+ )
19108
+ });
19030
19109
  await listenLocal(server, port, false).catch(
19031
19110
  (error) => fail7(
19032
19111
  error.code === "EADDRINUSE" ? `127.0.0.1:${port} is already in use here \u2014 pick one with: mend service connect ${service.label} --port <n>` : error.message
19033
19112
  )
19034
19113
  );
19035
- say8(
19036
- `${green8("\u25CF")} ${service.label ?? service.id.slice(0, 8)} \u2192 127.0.0.1:${port} ${dim8(`(tunnel to ${config.url})`)}`
19037
- );
19114
+ say8(`${green8("\u25CF")} ${label} \u2192 127.0.0.1:${port} ${dim8(`(tunnel to ${config.url})`)}`);
19038
19115
  }
19039
19116
  say8(dim8(" connections are authenticated as you \xB7 Ctrl-C stops"));
19040
19117
  await new Promise(() => {
@@ -19268,6 +19345,10 @@ var secretsCommand = async (config, args) => {
19268
19345
  }
19269
19346
  for (const line of secretFileLines(view.files)) say8(line);
19270
19347
  };
19348
+ var sealantIdentityOf = (wire) => ({
19349
+ sealantUserId: wire.sealantUserId,
19350
+ accounts: wire.accounts.map((account) => ({ ...account, isDefault: isChosenDefault(account) }))
19351
+ });
19271
19352
  var isProvider = (value) => value === "claude" || value === "codex" || value === "github";
19272
19353
  var readIfExists = (file) => fs24.existsSync(file) ? fs24.readFileSync(file, "utf8") : null;
19273
19354
  var localCredential = (provider) => {
@@ -19291,7 +19372,7 @@ var localCredential = (provider) => {
19291
19372
  }
19292
19373
  }
19293
19374
  };
19294
- var accountLine = (account) => {
19375
+ var accountFacts = (account) => {
19295
19376
  const meta = account.metadata;
19296
19377
  const pick = (key) => typeof meta[key] === "string" ? String(meta[key]) : null;
19297
19378
  const identity = pick("login") ?? pick("email") ?? pick("accountEmail") ?? pick("accountId");
@@ -19302,16 +19383,31 @@ var accountLine = (account) => {
19302
19383
  suffix === null ? null : `\u2026${suffix}`,
19303
19384
  `since ${account.connectedAt.slice(0, 10)}`
19304
19385
  ].filter((fact) => fact !== null);
19305
- return `${account.provider.padEnd(8)} ${facts.join(" \xB7 ")}`;
19386
+ return facts.join(" \xB7 ");
19306
19387
  };
19388
+ var accountLine = (account) => `${account.provider.padEnd(8)} ${accountFacts(account)}`;
19307
19389
  var accountsLines = async (config) => {
19308
- const identity = await request(config, "GET", "/me/sealant");
19390
+ const identity = sealantIdentityOf(
19391
+ await request(config, "GET", "/me/sealant")
19392
+ );
19309
19393
  const providers = ["claude", "codex", "github"];
19310
19394
  return [
19311
19395
  `platform user ${identity.sealantUserId}`,
19312
- ...providers.map((provider) => {
19313
- const account = identity.accounts.find((row) => row.provider === provider && row.name === "default") ?? identity.accounts.find((row) => row.provider === provider);
19314
- return ` ${account === void 0 ? `${provider.padEnd(8)} not connected` : accountLine(account)}`;
19396
+ ...providers.flatMap((provider) => {
19397
+ const choice = loginChoiceOf(identity.accounts, provider);
19398
+ switch (choice._tag) {
19399
+ case "chosen":
19400
+ return [` ${accountLine(choice.account)}`];
19401
+ case "unchosen": {
19402
+ const summary = unchosenLoginSummary(provider, choice.accounts.length);
19403
+ return [
19404
+ ` ${provider.padEnd(8)} ${summary.words} \xB7 ${summary.count} connected \u2192 ${summary.firstCommand}`,
19405
+ ...choice.accounts.map((account) => ` ${account.name} \xB7 ${accountFacts(account)}`)
19406
+ ];
19407
+ }
19408
+ case "none":
19409
+ return [` ${provider.padEnd(8)} not connected`];
19410
+ }
19315
19411
  })
19316
19412
  ];
19317
19413
  };
@@ -19464,6 +19560,32 @@ var connectPi = async (config, flags) => {
19464
19560
  `
19465
19561
  );
19466
19562
  };
19563
+ var removableAccount = (provider, accounts, name) => {
19564
+ if (name !== null) {
19565
+ const named = accounts.find(
19566
+ (account) => account.provider === provider && account.name === name && account.status !== "archived"
19567
+ );
19568
+ return named ?? fail7(`${provider}: no account named ${name} \xB7 nothing removed`);
19569
+ }
19570
+ const choice = loginChoiceOf(accounts, provider);
19571
+ switch (choice._tag) {
19572
+ case "chosen":
19573
+ return choice.account;
19574
+ case "none":
19575
+ return fail7(`${provider}: nothing connected`);
19576
+ case "unchosen": {
19577
+ const [only, ...others] = choice.accounts;
19578
+ if (others.length === 0) return only;
19579
+ const summary = unchosenLoginSummary(provider, choice.accounts.length);
19580
+ return fail7(
19581
+ [
19582
+ `${provider}: ${summary.words}, so which one to remove is not known \xB7 nothing removed \u2192 ${summary.firstCommand}`,
19583
+ ...choice.accounts.map((account) => ` ${account.name} \xB7 ${accountFacts(account)}`)
19584
+ ].join("\n")
19585
+ );
19586
+ }
19587
+ }
19588
+ };
19467
19589
  var connectCommand = async (config, args) => {
19468
19590
  const [providerArg, ...flags] = args;
19469
19591
  if (providerArg === "pi") return connectPi(config, flags);
@@ -19471,10 +19593,17 @@ var connectCommand = async (config, args) => {
19471
19593
  return fail7(usageOf("connect"));
19472
19594
  }
19473
19595
  const provider = providerArg;
19474
- if (flags.includes("--remove")) {
19475
- const identity = await api(config, "GET", "/me/sealant");
19476
- const account2 = identity.accounts.find((row) => row.provider === provider);
19477
- if (account2 === void 0) return fail7(`${provider}: nothing connected`);
19596
+ const removeAt = flags.indexOf("--remove");
19597
+ if (removeAt !== -1) {
19598
+ const named = flags[removeAt + 1];
19599
+ const identity = sealantIdentityOf(
19600
+ await api(config, "GET", "/me/sealant")
19601
+ );
19602
+ const account2 = removableAccount(
19603
+ provider,
19604
+ identity.accounts,
19605
+ named === void 0 || named.startsWith("--") ? null : named
19606
+ );
19478
19607
  await api(config, "DELETE", `/me/sealant/accounts/${account2.id}`);
19479
19608
  process.stdout.write(`${provider}: disconnected
19480
19609
  `);
@@ -19987,6 +20116,8 @@ var envShow = async (config, args) => {
19987
20116
  }
19988
20117
  for (const secret of secrets.secrets) {
19989
20118
  say8(` ${secret.name.padEnd(width)} secret ${dim8("\xB7 value set, never shown")}`);
20119
+ const nameRefusal = storedSecretNameRefusal(secret.name);
20120
+ if (nameRefusal !== null) say8(amber3(` ${" ".repeat(width)} ${nameRefusal}`));
19990
20121
  }
19991
20122
  for (const name of bindingNames) {
19992
20123
  say8(
@@ -21152,7 +21283,7 @@ var dashboard = async (config, options = {}) => {
21152
21283
  );
21153
21284
  process.exit(rerun.status ?? 0);
21154
21285
  }
21155
- const { runDashboard } = await import("./dashboard-7QWLVA5J.js");
21286
+ const { runDashboard } = await import("./dashboard-WREOSGDV.js");
21156
21287
  const gitAccessMode = await readGitAccessMode(config);
21157
21288
  const agentShare = await startShareIfBridge(config, gitAccessMode);
21158
21289
  const tunnels = options.noTunnel === true || serverIsLocal(config) ? null : createServiceTunnels({