@repo-os/repoos 0.5.95 → 0.5.97

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 (99) hide show
  1. package/README.md +3 -3
  2. package/dist/.build-info.json +2 -2
  3. package/dist/.build-stamp.json +1 -1
  4. package/dist/cli/help.js +4 -1
  5. package/dist/commands/servers.d.ts +4 -0
  6. package/dist/commands/servers.js +34 -3
  7. package/dist/commands/upgrade.d.ts +5 -0
  8. package/dist/commands/upgrade.js +49 -13
  9. package/dist/core/tailnet-servers.d.ts +4 -2
  10. package/dist/core/tailnet-servers.js +7 -4
  11. package/dist/server/routes/servers.d.ts +2 -0
  12. package/dist/server/routes/servers.js +34 -3
  13. package/dist/server/server.js +5 -3
  14. package/dist/server/system.d.ts +1 -1
  15. package/dist/server/system.js +47 -12
  16. package/dist/ui/assets/{ChecksView-BhIXC45z.js → ChecksView-CULwA_TL.js} +0 -0
  17. package/dist/ui/assets/{ContextView-CNCxybL_.js → ContextView-DqBHoosr.js} +2 -2
  18. package/dist/ui/assets/{DashboardView-DlIGbJ3n.js → DashboardView-BTdy_ySp.js} +1 -1
  19. package/dist/ui/assets/{DependencyChip-C0Vx0pXo.js → DependencyChip-C5VNY7gl.js} +1 -1
  20. package/dist/ui/assets/{DeploymentsView-Ds-pLQ08.js → DeploymentsView-BDfarOn-.js} +1 -1
  21. package/dist/ui/assets/{DevView-DazKc5XZ.js → DevView-ntdUzHkE.js} +1 -1
  22. package/dist/ui/assets/{DiffView-J0o7NRq_.js → DiffView-Cf2p3rFC.js} +1 -1
  23. package/dist/ui/assets/{InputsView-OoTYW1KQ.js → InputsView-D255PNzL.js} +1 -1
  24. package/dist/ui/assets/{LoginView-Slf4kTEd.js → LoginView-S0jogm1Y.js} +1 -1
  25. package/dist/ui/assets/{ReleasesView-C88j24ds.js → ReleasesView-D6lg-AWs.js} +1 -1
  26. package/dist/ui/assets/{SecretsView-CeQPCNS_.js → SecretsView-DOQmVf4V.js} +1 -1
  27. package/dist/ui/assets/{SettingsView-BC7-g8QG.js → SettingsView-BjHI0gdq.js} +2 -2
  28. package/dist/ui/assets/{StoriesView-sHbi4VGc.js → StoriesView-2kWYWs5P.js} +1 -1
  29. package/dist/ui/assets/{WorkView-DMTmK-Se.js → WorkView-CGtQZOnz.js} +1 -1
  30. package/dist/ui/assets/{abnfDiagram-VCTEODGH-d-MVY_Ya.js → abnfDiagram-VCTEODGH-D2A7SHug.js} +1 -1
  31. package/dist/ui/assets/{architectureDiagram-5GKGNRK7-CnWWiGwO.js → architectureDiagram-5GKGNRK7-Cou8SIPE.js} +1 -1
  32. package/dist/ui/assets/{blockDiagram-I7D4REHJ-Bcg-XeCf.js → blockDiagram-I7D4REHJ-SXNhhko2.js} +1 -1
  33. package/dist/ui/assets/{c4Diagram-7LVT6UL2-DPUc--cN.js → c4Diagram-7LVT6UL2-B-tpBfOx.js} +1 -1
  34. package/dist/ui/assets/channel-BEgkbNvj.js +1 -0
  35. package/dist/ui/assets/{chunk-2E4U76K2-BmfJHEYb.js → chunk-2E4U76K2-lmPqZMXN.js} +1 -1
  36. package/dist/ui/assets/{chunk-4HAMMTFA-nV5dBuKR.js → chunk-4HAMMTFA-C0tgf_1t.js} +1 -1
  37. package/dist/ui/assets/{chunk-75Z2AOVW-Bv79iNlv.js → chunk-75Z2AOVW-bSsW-KGE.js} +1 -1
  38. package/dist/ui/assets/{chunk-CLGD4ZFX-DYP6FTQd.js → chunk-CLGD4ZFX-VoCTMgMr.js} +1 -1
  39. package/dist/ui/assets/{chunk-DU6HZSFF-B6KGKg64.js → chunk-DU6HZSFF-DIqGroIg.js} +1 -1
  40. package/dist/ui/assets/{chunk-F27PBJKO-BrNr5GgL.js → chunk-F27PBJKO-DvA7R4Rh.js} +1 -1
  41. package/dist/ui/assets/{chunk-GMAD6QVW-BFea9tAC.js → chunk-GMAD6QVW-DEJGSb2v.js} +1 -1
  42. package/dist/ui/assets/{chunk-GVQU2GXP-4LrBgq22.js → chunk-GVQU2GXP-CazbgFu6.js} +1 -1
  43. package/dist/ui/assets/{chunk-IMKFNOWR--S7Q99JN.js → chunk-IMKFNOWR-DUtbLTE_.js} +1 -1
  44. package/dist/ui/assets/{chunk-L3NEJ4N5-DgyS4KZW.js → chunk-L3NEJ4N5-BVAy2-6E.js} +1 -1
  45. package/dist/ui/assets/{chunk-OSK3NFVY-CRSgeovc.js → chunk-OSK3NFVY-DqV-eD0o.js} +1 -1
  46. package/dist/ui/assets/{chunk-P2QGCYS3-yM5OTcCG.js → chunk-P2QGCYS3-NPQHSWha.js} +1 -1
  47. package/dist/ui/assets/{chunk-POPQ4Y6H-CXdSGWMk.js → chunk-POPQ4Y6H-Cbc2glFe.js} +1 -1
  48. package/dist/ui/assets/{chunk-PWAF6VOD-BjUqYYzZ.js → chunk-PWAF6VOD-E4hoWYnt.js} +1 -1
  49. package/dist/ui/assets/{chunk-SHT3W25Y-CkVKKjWI.js → chunk-SHT3W25Y-DbVXy1vA.js} +1 -1
  50. package/dist/ui/assets/{chunk-SVP7TREG-BZ2yerfk.js → chunk-SVP7TREG-VDz53lWo.js} +1 -1
  51. package/dist/ui/assets/{chunk-TICWLB2K-D2YLXcbV.js → chunk-TICWLB2K-Dp7_7G3W.js} +1 -1
  52. package/dist/ui/assets/{chunk-TLUHSLCS-D6_kCKKM.js → chunk-TLUHSLCS-RqBvuYFY.js} +2 -2
  53. package/dist/ui/assets/classDiagram-ZZMXUADV-Ca2957Wr.js +1 -0
  54. package/dist/ui/assets/classDiagram-v2-VYDZK3BY-Ca2957Wr.js +1 -0
  55. package/dist/ui/assets/{cynefinDiagram-5FMLGOSQ-C84hNxpr.js → cynefinDiagram-5FMLGOSQ-i8WRiMqt.js} +1 -1
  56. package/dist/ui/assets/{dagre-GXQ25YYZ-DTKWr0Ei.js → dagre-GXQ25YYZ-BJcNLyqh.js} +1 -1
  57. package/dist/ui/assets/{diagram-S7CK7UJ4-VGq4JrLk.js → diagram-S7CK7UJ4-BLliM3ye.js} +1 -1
  58. package/dist/ui/assets/{diagram-UQ7AKVKN-B8h2_6TT.js → diagram-UQ7AKVKN-Da1Hf0Hg.js} +1 -1
  59. package/dist/ui/assets/{diagram-VSXAHHWV-C5N42KUs.js → diagram-VSXAHHWV-RznGP5Tf.js} +1 -1
  60. package/dist/ui/assets/{diagram-VX7I27RA-CAu2OvU2.js → diagram-VX7I27RA-B8-ud1br.js} +1 -1
  61. package/dist/ui/assets/{diagram-Z3DM3KII-B9mdLYds.js → diagram-Z3DM3KII-DATmbaeB.js} +1 -1
  62. package/dist/ui/assets/{ebnfDiagram-PWID7BFC-Dov_WTug.js → ebnfDiagram-PWID7BFC-CUSxehdi.js} +1 -1
  63. package/dist/ui/assets/{erDiagram-RLTQ6QDP-CEY5uG1a.js → erDiagram-RLTQ6QDP-BYJ4oCZC.js} +1 -1
  64. package/dist/ui/assets/flowDiagram-HODETNUW-CUAGxYpY.js +1 -0
  65. package/dist/ui/assets/{ganttDiagram-EL5Y4UJY-B20eomMW.js → ganttDiagram-EL5Y4UJY-DyqNeerc.js} +1 -1
  66. package/dist/ui/assets/{gitGraphDiagram-WWUBYQGX-CMWlwcmC.js → gitGraphDiagram-WWUBYQGX-CY9iSA1O.js} +1 -1
  67. package/dist/ui/assets/{index-CIykDeE5.js → index-BX3Of6Ah.js} +3 -3
  68. package/dist/ui/assets/{infoDiagram-27XIBGKW-M6P4Hij8.js → infoDiagram-27XIBGKW-DMSn1eG4.js} +1 -1
  69. package/dist/ui/assets/{ishikawaDiagram-5VMMS53U-DYjDKPZN.js → ishikawaDiagram-5VMMS53U-mRPtZREa.js} +1 -1
  70. package/dist/ui/assets/{journeyDiagram-3NMN7TZE-BAWrVYw3.js → journeyDiagram-3NMN7TZE-S6tmN6FP.js} +1 -1
  71. package/dist/ui/assets/{kanban-definition-UXKFOSKX-Drymb6P2.js → kanban-definition-UXKFOSKX-CgjJlpFi.js} +1 -1
  72. package/dist/ui/assets/{line-Iw5WJt3F.js → line-DwXI6Hdc.js} +1 -1
  73. package/dist/ui/assets/{mermaid-parser.core-BmeI8qnP.js → mermaid-parser.core-DRyKTzV4.js} +1 -1
  74. package/dist/ui/assets/{mermaid.core-Pihow7Fd.js → mermaid.core-BPwYCwp1.js} +3 -3
  75. package/dist/ui/assets/{mindmap-definition-YA3MSWOX-Du7W46mq.js → mindmap-definition-YA3MSWOX-DX0qTdHQ.js} +1 -1
  76. package/dist/ui/assets/{pegDiagram-XKGWAZYB-BfxabksV.js → pegDiagram-XKGWAZYB-Bj8oYxfJ.js} +1 -1
  77. package/dist/ui/assets/{pieDiagram-E7YTZNPT-JvUYp_dn.js → pieDiagram-E7YTZNPT-D1pTO3_Q.js} +1 -1
  78. package/dist/ui/assets/{quadrantDiagram-AXDQQJYC-D8xbaohN.js → quadrantDiagram-AXDQQJYC-DGHdMJli.js} +1 -1
  79. package/dist/ui/assets/{railroadDiagram-O6MQD6OU-aZqYW-W4.js → railroadDiagram-O6MQD6OU-qnjLV-GN.js} +1 -1
  80. package/dist/ui/assets/{requirementDiagram-BXWQKSXE-BrUJ7eU0.js → requirementDiagram-BXWQKSXE-DFUkcL9F.js} +1 -1
  81. package/dist/ui/assets/{sankeyDiagram-P5KCCOFB-BLUUknwN.js → sankeyDiagram-P5KCCOFB-CIeQiPEH.js} +1 -1
  82. package/dist/ui/assets/{sequenceDiagram-WJ2MYXX4-CdGGwT3w.js → sequenceDiagram-WJ2MYXX4-D0cPk33G.js} +1 -1
  83. package/dist/ui/assets/{stateDiagram-D77RDMKH-D7BYLYEP.js → stateDiagram-D77RDMKH-b0dqXAMh.js} +1 -1
  84. package/dist/ui/assets/stateDiagram-v2-MP3YSRHH-OVe8wPLf.js +1 -0
  85. package/dist/ui/assets/{swimlanes-42K2YHIH-CIqdzNRN.js → swimlanes-42K2YHIH-Bc8GCCgs.js} +1 -1
  86. package/dist/ui/assets/swimlanesDiagram-VR7AAH4N-C8DnFsZY.js +8 -0
  87. package/dist/ui/assets/{timeline-definition-24CTP7MA-3LWWSIxv.js → timeline-definition-24CTP7MA-CigSMiUW.js} +1 -1
  88. package/dist/ui/assets/{vennDiagram-4TSXK5OY-D_MtyQqt.js → vennDiagram-4TSXK5OY-X3cL2aG1.js} +1 -1
  89. package/dist/ui/assets/{wardleyDiagram-VM6X3IG4-D7Pz_X6D.js → wardleyDiagram-VM6X3IG4-DrkrQT3-.js} +1 -1
  90. package/dist/ui/assets/{xychartDiagram-S5SC5T6Z-CsSUrPu6.js → xychartDiagram-S5SC5T6Z-rlQw2eQM.js} +1 -1
  91. package/dist/ui/index.html +1 -1
  92. package/dist/ui/sw.js +2 -2
  93. package/package.json +1 -1
  94. package/dist/ui/assets/channel-Gh-gAaek.js +0 -1
  95. package/dist/ui/assets/classDiagram-ZZMXUADV-CfJSdpvd.js +0 -1
  96. package/dist/ui/assets/classDiagram-v2-VYDZK3BY-CfJSdpvd.js +0 -1
  97. package/dist/ui/assets/flowDiagram-HODETNUW-CghwXXTC.js +0 -1
  98. package/dist/ui/assets/stateDiagram-v2-MP3YSRHH-jNlO3fWh.js +0 -1
  99. package/dist/ui/assets/swimlanesDiagram-VR7AAH4N-BfvAL3WJ.js +0 -8
package/README.md CHANGED
@@ -204,7 +204,7 @@ your task files, and serves a JSON API plus a live event stream. It adds no new
204
204
  business logic — it's a transport layer over the same core the CLI uses.
205
205
 
206
206
  ```bash
207
- repoos serve # http://127.0.0.1:7171 (or your Tailscale IP, if detected)
207
+ repoos serve # prints this project's address (or your Tailscale IP, if detected)
208
208
  repoos serve --port 8080 # custom port
209
209
  repoos serve --host 0.0.0.0 # listen on all interfaces
210
210
  repoos serve --quiet # no terminal activity log
@@ -277,8 +277,8 @@ won't clobber a body edit an agent made a moment earlier.
277
277
 
278
278
  ## The web UI
279
279
 
280
- `repoos serve` also serves a web UI at the root URL — open `http://127.0.0.1:7171`
281
- in a browser. It's a live control plane: a dashboard, the work board, an Agents
280
+ `repoos serve` also serves a web UI at the root URL. Open the address printed
281
+ at startup in a browser; each project has its own stable port. It's a live control plane: a dashboard, the work board, an Agents
282
282
  page for configuring and running coding agents, a context-docs viewer with
283
283
  skills, and settings. All reading from the API and updating in real time via the
284
284
  SSE stream. Edit a task file in your editor (or let an agent edit it) and the
@@ -1,5 +1,5 @@
1
1
  {
2
- "hash": "38ef16f2c33e40bd60aceca50693e61c60656fcef7c07bdf8a27fdca3d92a32a",
3
- "version": "0.5.95",
2
+ "hash": "73962853f88c640b294fb55118107af2b61f5805f4bcad8ba3b2899072fa4d2d",
3
+ "version": "0.5.97",
4
4
  "devUi": false
5
5
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "generatedAt": "2026-11-28T03:50:42.774Z"
2
+ "generatedAt": "2026-11-30T19:53:51.644Z"
3
3
  }
package/dist/cli/help.js CHANGED
@@ -450,7 +450,10 @@ const EXAMPLES = [
450
450
  { cmd: "repoos status", comment: "one-screen health snapshot" },
451
451
  { cmd: "repoos status --json", comment: "machine-readable, for agents/tools" },
452
452
  { cmd: "repoos index --json", comment: "machine-readable, for agents/tools" },
453
- { cmd: "repoos serve", comment: "live API + SSE at http://127.0.0.1:7171" },
453
+ {
454
+ cmd: "repoos serve",
455
+ comment: "live API + SSE at the project-specific address printed at startup",
456
+ },
454
457
  ];
455
458
  /** Command aliases accepted by the dispatcher (`src/cli/index.ts`). */
456
459
  const ALIASES = {
@@ -1,4 +1,5 @@
1
1
  import { collectTailnetServers } from "../core/tailnet-servers.js";
2
+ import { getServiceStatus, listServices } from "../core/service-manager.js";
2
3
  export { collectTailnetServers, parseTailnetPeers, remoteFailureReason, remoteShellCommand, remoteShellScript, serversSshArgs, shellQuote, } from "../core/tailnet-servers.js";
3
4
  export type { ListedServer, RemoteExec } from "../core/tailnet-servers.js";
4
5
  /** Human-readable fallback line when the local Tailscale status is unavailable. */
@@ -8,5 +9,8 @@ export interface ServersCommandDeps {
8
9
  root?: string;
9
10
  /** Test seam: replace tailnet collection (the CLI path has no network seam). */
10
11
  collect?: typeof collectTailnetServers;
12
+ /** Test seams for installed service discovery and live status. */
13
+ listServices?: typeof listServices;
14
+ getServiceStatus?: typeof getServiceStatus;
11
15
  }
12
16
  export declare function cmdServers(argv: string[], deps?: ServersCommandDeps): Promise<void>;
@@ -1,9 +1,11 @@
1
1
  /** `repoos servers` — list registered RepoOS control-plane processes. */
2
2
  import { findRepoRoot, loadConfig } from "../core/config.js";
3
3
  import { resolveRemoteHosts } from "../core/remote-hosts.js";
4
- import { listValidatedServerRegistry, pruneStaleServerRegistryEntries, } from "../core/server-registry.js";
4
+ import { listValidatedServerRegistry, pruneStaleServerRegistryEntries, canonicalRegistryRoot, } from "../core/server-registry.js";
5
5
  import { collectTailnetServers } from "../core/tailnet-servers.js";
6
6
  import { c } from "../cli/colors.js";
7
+ import { existsSync } from "node:fs";
8
+ import { getServiceStatus, listServices } from "../core/service-manager.js";
7
9
  // Re-exported for callers (and tests) that used to import these from the CLI
8
10
  // command before tailnet discovery moved into `src/core/tailnet-servers.ts` so
9
11
  // the server endpoint can share it.
@@ -70,6 +72,25 @@ export async function cmdServers(argv, deps = {}) {
70
72
  if (prune)
71
73
  pruned = await pruneStaleServerRegistryEntries();
72
74
  const localRows = await listValidatedServerRegistry();
75
+ const activeRows = localRows.filter((row) => row.valid);
76
+ const inactiveServices = [];
77
+ let staleCount = localRows.filter((row) => !row.valid).length;
78
+ if (!tailscale) {
79
+ const installed = (deps.listServices ?? listServices)().services;
80
+ const runningRoots = new Set(activeRows.map((row) => canonicalRegistryRoot(row.entry.root)));
81
+ for (const service of installed) {
82
+ if (!existsSync(service.root) || runningRoots.has(canonicalRegistryRoot(service.root)))
83
+ continue;
84
+ const live = await (deps.getServiceStatus ?? getServiceStatus)(service.root);
85
+ if (!live || live.status !== "running") {
86
+ inactiveServices.push({
87
+ name: service.id.replace(/-[a-f0-9]{8}$/, ""),
88
+ port: service.port,
89
+ root: service.root,
90
+ });
91
+ }
92
+ }
93
+ }
73
94
  const local = localRows.map((row) => ({
74
95
  host: "local",
75
96
  port: row.entry.port,
@@ -110,7 +131,7 @@ export async function cmdServers(argv, deps = {}) {
110
131
  console.log(c.yellow(tailnetFallbackNotice(remoteHosts.map((host) => host.host))));
111
132
  }
112
133
  if (!tailscale && !prune && pruned === undefined) {
113
- if (localRows.length === 0) {
134
+ if (localRows.length === 0 && inactiveServices.length === 0) {
114
135
  console.log(c.dim(" No registered RepoOS servers."));
115
136
  console.log(c.dim(" Control-plane `repoos serve` processes register under ") +
116
137
  c.cyan("~/.repoos/servers/") +
@@ -118,8 +139,18 @@ export async function cmdServers(argv, deps = {}) {
118
139
  return;
119
140
  }
120
141
  console.log(c.bold(" Registered RepoOS servers:\n"));
121
- for (const row of localRows)
142
+ console.log(c.bold(" Running:\n"));
143
+ for (const row of activeRows)
122
144
  printLocalRow(row);
145
+ console.log(c.bold("\n Inactive:\n"));
146
+ if (!inactiveServices.length)
147
+ console.log(c.dim(" None."));
148
+ for (const service of inactiveServices) {
149
+ console.log(` ${c.cyan(String(service.port).padStart(5))} ${c.dim("inactive")} ${c.bold(service.name)}`);
150
+ console.log(` ${c.dim(service.root)}`);
151
+ }
152
+ if (staleCount)
153
+ console.log(c.yellow(`\n ${staleCount} stale registry entr${staleCount === 1 ? "y" : "ies"}; run repoos servers --prune to remove.`));
123
154
  return;
124
155
  }
125
156
  console.log(c.bold(tailscale ? " RepoOS servers by host:\n" : " Registered RepoOS servers:\n"));
@@ -1,4 +1,9 @@
1
1
  export { launcherScript } from "../core/launcher-runtime.js";
2
+ /** Keep in sync with install.sh's PAYLOAD_NAMES. */
3
+ export declare const INSTALL_PAYLOAD_NAMES: string[];
4
+ export declare function isLegacyStateInstall(root: string, home?: string): boolean;
5
+ /** Swap an extracted build while carrying every non-program entry forward. */
6
+ export declare function swapInstall(root: string, staged: string): void;
2
7
  /** Upgrade completion note when the server is still serving an older build. */
3
8
  export declare function upgradeRestartReminder(runningVersion: string | null, installedVersion: string): string | null;
4
9
  /**
@@ -7,7 +7,7 @@
7
7
  * command can give an actionable, source-specific instruction.
8
8
  */
9
9
  import { execFileSync } from "node:child_process";
10
- import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
10
+ import { chmodSync, cpSync, existsSync, readdirSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
11
11
  import { homedir } from "node:os";
12
12
  import { dirname, join } from "node:path";
13
13
  import { fileURLToPath } from "node:url";
@@ -18,6 +18,37 @@ import { boardRoot } from "../core/config.js";
18
18
  import { locateRepoServer } from "../core/server-locate.js";
19
19
  export { launcherScript } from "../core/launcher-runtime.js";
20
20
  const REPO = "repo-os/repoos";
21
+ /** Keep in sync with install.sh's PAYLOAD_NAMES. */
22
+ export const INSTALL_PAYLOAD_NAMES = [
23
+ "cli",
24
+ "commands",
25
+ "core",
26
+ "server",
27
+ "ui",
28
+ ".build-info.json",
29
+ ];
30
+ export function isLegacyStateInstall(root, home = homedir()) {
31
+ return root === join(home, ".repoos");
32
+ }
33
+ /** Swap an extracted build while carrying every non-program entry forward. */
34
+ export function swapInstall(root, staged) {
35
+ for (const name of readdirSync(root)) {
36
+ if (!INSTALL_PAYLOAD_NAMES.includes(name))
37
+ cpSync(join(root, name), join(staged, name), { recursive: true, errorOnExist: true });
38
+ }
39
+ const displaced = `${root}.upgrade-old`;
40
+ if (existsSync(displaced))
41
+ throw new Error(`Upgrade backup already exists: ${displaced}`);
42
+ renameSync(root, displaced);
43
+ try {
44
+ renameSync(staged, root);
45
+ }
46
+ catch (error) {
47
+ renameSync(displaced, root);
48
+ throw error;
49
+ }
50
+ rmSync(displaced, { recursive: true, force: true });
51
+ }
21
52
  /** Upgrade completion note when the server is still serving an older build. */
22
53
  export function upgradeRestartReminder(runningVersion, installedVersion) {
23
54
  if (!runningVersion || runningVersion === installedVersion)
@@ -231,11 +262,13 @@ export async function cmdUpgrade(args) {
231
262
  return;
232
263
  }
233
264
  }
234
- const root = installRoot();
265
+ const installedRoot = installRoot();
266
+ const legacy = isLegacyStateInstall(installedRoot);
267
+ const root = legacy ? join(homedir(), ".local", "share", "repoos") : installedRoot;
235
268
  const channel = parseChannel(args);
236
269
  const instruction = upgradeInstruction({
237
- installRoot: root,
238
- version: readInstallVersion(root),
270
+ installRoot: installedRoot,
271
+ version: readInstallVersion(installedRoot),
239
272
  channel,
240
273
  });
241
274
  if (instruction.installKind === "package-manager") {
@@ -252,7 +285,7 @@ export async function cmdUpgrade(args) {
252
285
  console.log(c.dim(` Update it with: ${instruction.command}`));
253
286
  return;
254
287
  }
255
- const current = readInstallVersion(root);
288
+ const current = readInstallVersion(installedRoot);
256
289
  console.log(c.dim(` Current version: v${current}`));
257
290
  console.log(c.dim(channel ? ` Checking latest "${channel}" release…` : " Checking latest release…"));
258
291
  let release;
@@ -283,8 +316,7 @@ export async function cmdUpgrade(args) {
283
316
  // final swap is a plain rename.
284
317
  const work = `${root}.upgrade-download`;
285
318
  const staged = `${root}.upgrade-staged`;
286
- const displaced = `${root}.upgrade-old`;
287
- for (const dir of [work, staged, displaced]) {
319
+ for (const dir of [work, staged]) {
288
320
  if (existsSync(dir))
289
321
  rmSync(dir, { recursive: true, force: true });
290
322
  }
@@ -295,15 +327,17 @@ export async function cmdUpgrade(args) {
295
327
  mkdirSync(staged, { recursive: true });
296
328
  execFileSync("tar", ["-xzf", tmpTar, "-C", staged]);
297
329
  execFileSync("chmod", ["+x", join(staged, "cli", "index.js")]);
298
- renameSync(root, displaced);
299
- try {
330
+ if (legacy) {
331
+ if (existsSync(root))
332
+ throw new Error(`Install destination already exists: ${root}`);
333
+ mkdirSync(dirname(root), { recursive: true });
300
334
  renameSync(staged, root);
335
+ for (const name of INSTALL_PAYLOAD_NAMES)
336
+ rmSync(join(installedRoot, name), { recursive: true, force: true });
301
337
  }
302
- catch (e) {
303
- renameSync(displaced, root);
304
- throw e;
338
+ else {
339
+ swapInstall(root, staged);
305
340
  }
306
- rmSync(displaced, { recursive: true, force: true });
307
341
  }
308
342
  finally {
309
343
  rmSync(work, { recursive: true, force: true });
@@ -311,6 +345,8 @@ export async function cmdUpgrade(args) {
311
345
  rmSync(staged, { recursive: true, force: true });
312
346
  }
313
347
  regenerateLauncher(root);
348
+ if (legacy)
349
+ console.log(c.green(` Moved the legacy install to ${root}; kept machine state in ${installedRoot}.`));
314
350
  console.log(c.green(` Upgraded to v${latest}.`));
315
351
  try {
316
352
  const server = await locateRepoServer(boardRoot().root);
@@ -1,8 +1,8 @@
1
1
  import type { RemoteValidationConfig, RemoteValidationHost } from "./types.js";
2
2
  /** Per-command budget for one remote host. */
3
- export declare const HOST_TIMEOUT_MS = 8000;
3
+ export declare const HOST_TIMEOUT_MS = 3500;
4
4
  /** Whole-request budget for one discovery pass; slow hosts become `unreachable`. */
5
- export declare const DISCOVERY_DEADLINE_MS = 25000;
5
+ export declare const DISCOVERY_DEADLINE_MS = 4800;
6
6
  /** Machine-level HTTP endpoint bound directly to the Tailscale interface. */
7
7
  export declare const TAILNET_DISCOVERY_PORT = 41641;
8
8
  export interface ListedServer {
@@ -146,6 +146,8 @@ export interface CollectTailnetOptions {
146
146
  annotateUrls?: boolean;
147
147
  /** Test seam for the deadline clock. */
148
148
  now?: () => number;
149
+ /** Called as each peer finishes; local rows are emitted first. */
150
+ onPeerResult?: (rows: ListedServer[]) => void;
149
151
  }
150
152
  export declare function defaultHttpDiscovery(peer: TailnetPeer, timeoutMs: number): Promise<string | null>;
151
153
  export interface TailnetCollection {
@@ -14,13 +14,13 @@ import { promisify } from "node:util";
14
14
  import { remoteHostUser } from "./remote-hosts.js";
15
15
  const execFileAsync = promisify(execFile);
16
16
  /** Per-command budget for one remote host. */
17
- export const HOST_TIMEOUT_MS = 8_000;
17
+ export const HOST_TIMEOUT_MS = 3_500;
18
18
  /** Whole-request budget for one discovery pass; slow hosts become `unreachable`. */
19
- export const DISCOVERY_DEADLINE_MS = 25_000;
19
+ export const DISCOVERY_DEADLINE_MS = 4_800;
20
20
  /** Machine-level HTTP endpoint bound directly to the Tailscale interface. */
21
21
  export const TAILNET_DISCOVERY_PORT = 41641;
22
22
  /** Leave time for the peer listener's local Tailscale URL enrichment. */
23
- const HTTP_DISCOVERY_TIMEOUT_MS = 7_000;
23
+ const HTTP_DISCOVERY_TIMEOUT_MS = 1_800;
24
24
  /** `tailscale status --json` is local and cheap; never let it hold a request. */
25
25
  const TAILSCALE_STATUS_TIMEOUT_MS = 2_000;
26
26
  /** URL enrichment is a nicety; a slow `serve status` must not hide servers. */
@@ -502,6 +502,7 @@ export async function collectTailnetServers(local, options = {}) {
502
502
  }),
503
503
  }))
504
504
  : local;
505
+ options.onPeerResult?.(localRows);
505
506
  const remoteExec = options.remoteExec ?? defaultRemoteExec;
506
507
  const configuredByHost = new Map((options.remoteHosts ?? []).map((host) => [host.host, host]));
507
508
  const remotes = await Promise.all(peers.map(async (peer) => {
@@ -585,9 +586,11 @@ export async function collectTailnetServers(local, options = {}) {
585
586
  ];
586
587
  }
587
588
  };
588
- return within(work(), deadlineAt - now(), () => [
589
+ const rows = await within(work(), deadlineAt - now(), () => [
589
590
  { host: peer.host, ...displayFields, unreachable: true, reason: "timed out" },
590
591
  ]);
592
+ options.onPeerResult?.(rows);
593
+ return rows;
591
594
  }));
592
595
  return {
593
596
  servers: [...localRows, ...remotes.flat()],
@@ -31,12 +31,14 @@ export interface TailnetDiscoveryDeps {
31
31
  httpDiscovery?: CollectTailnetOptions["httpDiscovery"];
32
32
  deadlineMs?: number;
33
33
  now?: () => number;
34
+ onPeerResult?: (rows: ListedServer[]) => void;
34
35
  }
35
36
  /**
36
37
  * Build the endpoint's response. Exported separately from the route handler so
37
38
  * tests can fake the Tailscale CLI and SSH without a live server or network.
38
39
  */
39
40
  export declare function buildTailnetDiscoveryPayload(config: Pick<RepoOSConfig, "remoteValidation" | "tailnetDiscovery">, deps?: TailnetDiscoveryDeps): Promise<TailnetDiscoveryPayload>;
41
+ export declare function createTailnetServersHandler(discoveryDeps?: TailnetDiscoveryDeps): RouteHandler;
40
42
  export declare const getTailnetServers: RouteHandler;
41
43
  /** Validate the direct socket address; forwarded or loopback requests are never trusted. */
42
44
  export declare function isTailnetPeerDiscoveryRequest(req: IncomingMessage): boolean;
@@ -65,6 +65,7 @@ export async function buildTailnetDiscoveryPayload(config, deps = {}) {
65
65
  ...(deps.remoteExec ? { remoteExec: deps.remoteExec } : {}),
66
66
  ...(deps.httpDiscovery ? { httpDiscovery: deps.httpDiscovery } : {}),
67
67
  ...(deps.now ? { now: deps.now } : {}),
68
+ ...(deps.onPeerResult ? { onPeerResult: deps.onPeerResult } : {}),
68
69
  });
69
70
  return {
70
71
  ok: true,
@@ -73,9 +74,39 @@ export async function buildTailnetDiscoveryPayload(config, deps = {}) {
73
74
  discoverySource: result.source,
74
75
  };
75
76
  }
76
- export const getTailnetServers = async (ctx, _req, res) => {
77
- return json(res, 200, await buildTailnetDiscoveryPayload(ctx.config));
78
- };
77
+ export function createTailnetServersHandler(discoveryDeps = {}) {
78
+ return async (ctx, req, res) => {
79
+ if (!new URL(req.url ?? "/", "http://localhost").searchParams.has("stream"))
80
+ return json(res, 200, await buildTailnetDiscoveryPayload(ctx.config, discoveryDeps));
81
+ res.writeHead(200, {
82
+ "Content-Type": "text/event-stream",
83
+ "Cache-Control": "no-cache",
84
+ Connection: "keep-alive",
85
+ "X-Accel-Buffering": "no",
86
+ });
87
+ try {
88
+ const payload = await buildTailnetDiscoveryPayload(ctx.config, {
89
+ ...discoveryDeps,
90
+ onPeerResult(rows) {
91
+ discoveryDeps.onPeerResult?.(rows);
92
+ if (!res.writableEnded)
93
+ res.write(`event: peer\ndata: ${JSON.stringify({ servers: rows })}\n\n`);
94
+ },
95
+ });
96
+ if (!res.writableEnded) {
97
+ res.write(`event: done\ndata: ${JSON.stringify(payload)}\n\n`);
98
+ res.end();
99
+ }
100
+ }
101
+ catch {
102
+ if (!res.writableEnded) {
103
+ res.write(`event: error\ndata: ${JSON.stringify({ reason: "Tailnet discovery stopped before it finished." })}\n\n`);
104
+ res.end();
105
+ }
106
+ }
107
+ };
108
+ }
109
+ export const getTailnetServers = createTailnetServersHandler();
79
110
  function normalizedAddress(value) {
80
111
  return (value ?? "")
81
112
  .trim()
@@ -337,7 +337,9 @@ async function tunnelReadiness(root, port) {
337
337
  present: existsSync(certPath),
338
338
  usable: usableOriginCertificate(certPath),
339
339
  };
340
- const originListening = typeof port === "number" && Number.isInteger(port) ? await portListening(port) : null;
340
+ const serveDefaultPort = resolveServePort(root, loadConfig(root));
341
+ const originPort = port ?? serveDefaultPort;
342
+ const originListening = await portListening(originPort);
341
343
  return {
342
344
  cloudflared: { installed: !!bin, version },
343
345
  originCertificate,
@@ -347,8 +349,8 @@ async function tunnelReadiness(root, port) {
347
349
  tunnelId: tunnel.tunnelId || null,
348
350
  baseDomain: tunnel.domain || null,
349
351
  },
350
- localOrigin: { port: port ?? null, listening: originListening },
351
- serveDefaultPort: resolveServePort(root, loadConfig(root)),
352
+ localOrigin: { port: originPort, listening: originListening },
353
+ serveDefaultPort,
352
354
  running: (await tunnelProcessRunning()) || (await serviceRunning()),
353
355
  publishedHostnames: Object.values(allApps)
354
356
  .map((app) => app.hostname)
@@ -215,7 +215,7 @@ export declare function parseServePort(command: string): number | null;
215
215
  *
216
216
  * Exported for testing so classification can be exercised without spawning servers.
217
217
  */
218
- export declare function parseServeScan(output: string, serverPid: number, knownPids: Set<number>, rootExists: (root: string | null) => boolean, ownRoot?: string): ServeScan;
218
+ export declare function parseServeScan(output: string, serverPid: number, knownPids: Set<number>, rootExists: (root: string | null) => boolean, ownRoot?: string, actualRoots?: ReadonlyMap<number, string>, registeredPids?: ReadonlySet<number>): ServeScan;
219
219
  /**
220
220
  * Census live `repoos serve` processes. Cached — `ps ax` lists every process on
221
221
  * the machine, which is much heavier than the targeted per-PID sample.
@@ -7,13 +7,14 @@
7
7
  * ppid is no longer the server's pid, is marked orphaned.
8
8
  */
9
9
  import { execFile } from "node:child_process";
10
- import { existsSync, readFileSync, realpathSync, statSync, writeFileSync, mkdirSync, } from "node:fs";
10
+ import { existsSync, readFileSync, readlinkSync, realpathSync, statSync, writeFileSync, mkdirSync, } from "node:fs";
11
11
  import { basename, join } from "node:path";
12
12
  import { cpus, totalmem, freemem, loadavg, platform } from "node:os";
13
13
  import { withOrphanedRunProcesses, } from "../core/pressure-guard.js";
14
14
  import { localCheckLockRoot } from "../core/cross-process-slots.js";
15
15
  import { registeredEngineerCount } from "../core/global-engineers.js";
16
16
  import { getGitWorker, gitWorkerInFlight } from "./git-worker.js";
17
+ import { listServerRegistryEntries } from "../core/server-registry.js";
17
18
  const OWNERSHIP_FILE = "repoos-ownership.json";
18
19
  const KB = 1024;
19
20
  function safeExecFile(cmd, args) {
@@ -296,7 +297,7 @@ export function parseServePort(command) {
296
297
  *
297
298
  * Exported for testing so classification can be exercised without spawning servers.
298
299
  */
299
- export function parseServeScan(output, serverPid, knownPids, rootExists, ownRoot) {
300
+ export function parseServeScan(output, serverPid, knownPids, rootExists, ownRoot, actualRoots = new Map(), registeredPids = new Set()) {
300
301
  const rows = [];
301
302
  const livePids = new Set();
302
303
  for (const line of output.split("\n")) {
@@ -311,7 +312,7 @@ export function parseServeScan(output, serverPid, knownPids, rootExists, ownRoot
311
312
  for (const { pid, ppid, command } of rows) {
312
313
  if (!SERVE_CMD_RE.test(command))
313
314
  continue;
314
- const root = parseServeRoot(command);
315
+ const root = actualRoots.has(pid) ? actualRoots.get(pid) || null : parseServeRoot(command);
315
316
  const rootIsLive = rootExists(root);
316
317
  // A parent of 1 means the process was reparented after its spawner died.
317
318
  const supervised = ppid !== 1 && livePids.has(ppid);
@@ -319,14 +320,18 @@ export function parseServeScan(output, serverPid, knownPids, rootExists, ownRoot
319
320
  ? "control-plane"
320
321
  : knownPids.has(pid)
321
322
  ? "known-preview"
322
- : supervised
323
- ? "in-flight"
324
- : // A detached serve for another repo whose root still exists is that
325
- // repo's control plane (also ppid 1) — not ours to touch. Only an
326
- // orphan of OUR root, or one whose root is gone, is a real stray.
327
- ownRoot && root && rootIsLive && !sameRoot(root, ownRoot)
328
- ? "foreign"
329
- : "stray";
323
+ : registeredPids.has(pid)
324
+ ? "foreign"
325
+ : supervised
326
+ ? "in-flight"
327
+ : // A detached serve for another repo whose root still exists is that
328
+ // repo's control plane (also ppid 1) — not ours to touch. Only an
329
+ // orphan of OUR root, or one whose root is gone, is a real stray.
330
+ ownRoot && root && rootIsLive && !sameRoot(root, ownRoot)
331
+ ? "foreign"
332
+ : !root
333
+ ? "foreign"
334
+ : "stray";
330
335
  processes.push({
331
336
  pid,
332
337
  ppid,
@@ -362,7 +367,36 @@ export async function scanServeProcesses(serverPid, knownPids, ownRoot) {
362
367
  const output = await safeExecFile("ps", ["ax", "-o", "pid=,ppid=,command="]);
363
368
  if (output === null)
364
369
  return serveScanCache?.scan ?? null;
365
- const scan = parseServeScan(output, serverPid, knownPids, (root) => root !== null && existsSync(root), ownRoot);
370
+ const actualRoots = new Map();
371
+ const registeredPids = new Set();
372
+ for (const entry of listServerRegistryEntries()) {
373
+ if (entry.pid > 0)
374
+ registeredPids.add(entry.pid);
375
+ }
376
+ const candidates = output.split("\n").flatMap((line) => {
377
+ const m = line.trim().match(/^(\d+)\s+\d+\s+(.*)$/);
378
+ return m && SERVE_CMD_RE.test(m[2]) ? [Number(m[1])] : [];
379
+ });
380
+ // The CLI path can be shared by every linked project. Resolve each serve's
381
+ // cwd (the project it serves) instead; unavailable cwd remains unknown and
382
+ // is conservatively preserved by parseServeScan.
383
+ for (const pid of candidates) {
384
+ actualRoots.set(pid, "");
385
+ try {
386
+ const cwd = process.platform === "linux"
387
+ ? readlinkSync(`/proc/${pid}/cwd`).replace(/ \(deleted\)$/, "")
388
+ : (await safeExecFile("lsof", ["-a", "-p", String(pid), "-d", "cwd", "-Fn"]))
389
+ ?.split("\n")
390
+ .find((part) => part.startsWith("n"))
391
+ ?.slice(1);
392
+ if (cwd)
393
+ actualRoots.set(pid, cwd);
394
+ }
395
+ catch {
396
+ /* best effort */
397
+ }
398
+ }
399
+ const scan = parseServeScan(output, serverPid, knownPids, (root) => root !== null && existsSync(root), ownRoot, actualRoots, registeredPids);
366
400
  serveScanCache = { at: now, scan };
367
401
  return scan;
368
402
  }
@@ -402,6 +436,7 @@ export async function reapStrayServeProcesses(serverPid, knownPids, kill = proce
402
436
  continue;
403
437
  try {
404
438
  kill(p.pid, "SIGTERM");
439
+ console.warn(`serve-reaper: stopping pid=${p.pid} port=${p.port ?? "?"} root=${p.root ?? "unknown"} reason=orphaned serve process`);
405
440
  reaped++;
406
441
  }
407
442
  catch {