@bivy/bivy 0.21.2-staging.8 → 0.21.2-staging.9

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 (102) hide show
  1. package/bin/archive-install.mjs +150 -0
  2. package/bin/bivy.mjs +63 -6
  3. package/dist/node-update.js +26 -1
  4. package/dist/server.js +3 -2
  5. package/package.json +1 -1
  6. package/web/assets/{AutomationsView-Bp-HZ65a.js → AutomationsView-BKdWg31u.js} +1 -1
  7. package/web/assets/{ChangesCard-DFkhox3t.js → ChangesCard-BXTFioad.js} +1 -1
  8. package/web/assets/{LibraryView-CSLPfv5K.js → LibraryView-DkytoYzU.js} +1 -1
  9. package/web/assets/{ProviderConnect-CtL9cvxa.js → ProviderConnect-Dar07HSg.js} +1 -1
  10. package/web/assets/{SessionList-BCi3h43J.js → SessionList-DSwBLrLK.js} +1 -1
  11. package/web/assets/{Settings-DK6hW6gA.js → Settings-Cttrq6Hu.js} +3 -3
  12. package/web/assets/{Sheet-BloTT0aC.js → Sheet-BWjIuEvT.js} +1 -1
  13. package/web/assets/{Terminal-BetexAxv.js → Terminal-CLTlfYfL.js} +1 -1
  14. package/web/assets/{VoiceSettings-BwZqtXiE.js → VoiceSettings-5wRzbaip.js} +1 -1
  15. package/web/assets/{abnfDiagram-VCTEODGH-CGnTIYqf.js → abnfDiagram-VCTEODGH-CqEKXBpr.js} +1 -1
  16. package/web/assets/architecture-7GRP2DOG-csjxIzux.js +1 -0
  17. package/web/assets/{architectureDiagram-5GKGNRK7-CZbDBX1c.js → architectureDiagram-5GKGNRK7-65ApDutk.js} +1 -1
  18. package/web/assets/{blockDiagram-I7D4REHJ-IMnC-O4j.js → blockDiagram-I7D4REHJ-C_hHirkL.js} +1 -1
  19. package/web/assets/{c4Diagram-7LVT6UL2-CDF8uCW5.js → c4Diagram-7LVT6UL2-B5W_rZdc.js} +1 -1
  20. package/web/assets/channel-BiEVxt04.js +1 -0
  21. package/web/assets/{chunk-4HAMMTFA-C070Ayo1.js → chunk-4HAMMTFA-DQ9e55tV.js} +1 -1
  22. package/web/assets/{chunk-75Z2AOVW-BnJiwQUF.js → chunk-75Z2AOVW-CnVrxdF0.js} +1 -1
  23. package/web/assets/{chunk-DU6HZSFF-CWX9IZ6R.js → chunk-DU6HZSFF-CBXacbPq.js} +1 -1
  24. package/web/assets/{chunk-F27PBJKO-DdehTY5Q.js → chunk-F27PBJKO-BuQoorsp.js} +1 -1
  25. package/web/assets/{chunk-GMAD6QVW-DSf5Exzk.js → chunk-GMAD6QVW-BdokXHOz.js} +1 -1
  26. package/web/assets/{chunk-GVQU2GXP-CxGa5utF.js → chunk-GVQU2GXP-DF2U9QdV.js} +1 -1
  27. package/web/assets/{chunk-IMKFNOWR-BtqBNRtx.js → chunk-IMKFNOWR-3k4GQuZc.js} +1 -1
  28. package/web/assets/{chunk-L3NEJ4N5-CfE7BEqy.js → chunk-L3NEJ4N5-Bo9LSvX2.js} +1 -1
  29. package/web/assets/{chunk-OSK3NFVY-SwPwNiwG.js → chunk-OSK3NFVY-CiHrpprI.js} +1 -1
  30. package/web/assets/{chunk-P2QGCYS3-DFgzzikQ.js → chunk-P2QGCYS3-DRblecLw.js} +1 -1
  31. package/web/assets/{chunk-POPQ4Y6H-eoTWfUqf.js → chunk-POPQ4Y6H-DeS-pBCd.js} +1 -1
  32. package/web/assets/{chunk-PWAF6VOD-DT2enbgY.js → chunk-PWAF6VOD-qX7Vudvg.js} +1 -1
  33. package/web/assets/{chunk-SHT3W25Y-i_ffrzQc.js → chunk-SHT3W25Y-Dwaucw-l.js} +1 -1
  34. package/web/assets/{chunk-SVP7TREG-D1Etpdb3.js → chunk-SVP7TREG-B_T5y6kq.js} +1 -1
  35. package/web/assets/{chunk-TICWLB2K-TXKbYJhN.js → chunk-TICWLB2K-CT9mkxqr.js} +1 -1
  36. package/web/assets/classDiagram-ZZMXUADV-Bd98Z0Bi.js +1 -0
  37. package/web/assets/classDiagram-v2-VYDZK3BY-Bd98Z0Bi.js +1 -0
  38. package/web/assets/{cynefin-OW5HDTMX-Ctu1STR5.js → cynefin-OW5HDTMX-CLIX1FQD.js} +1 -1
  39. package/web/assets/{cynefinDiagram-5FMLGOSQ-ClAc9r-T.js → cynefinDiagram-5FMLGOSQ-CMsv6adS.js} +1 -1
  40. package/web/assets/{dagre-GXQ25YYZ-D0EWYgg5.js → dagre-GXQ25YYZ-DAGYJdFd.js} +1 -1
  41. package/web/assets/{diagram-S7CK7UJ4-BiipaUO8.js → diagram-S7CK7UJ4-CsisyJcS.js} +1 -1
  42. package/web/assets/{diagram-UQ7AKVKN-BhN0ykZd.js → diagram-UQ7AKVKN-BwRe_HTu.js} +1 -1
  43. package/web/assets/{diagram-VSXAHHWV-EEyU7vKc.js → diagram-VSXAHHWV-CcUMlRc8.js} +1 -1
  44. package/web/assets/{diagram-VX7I27RA-D88LIczs.js → diagram-VX7I27RA-DwfrFboX.js} +1 -1
  45. package/web/assets/{diagram-Z3DM3KII-DcjKFRA3.js → diagram-Z3DM3KII-BcQ73Mpu.js} +1 -1
  46. package/web/assets/{ebnfDiagram-PWID7BFC-Dld91CPU.js → ebnfDiagram-PWID7BFC-CC-NQnEb.js} +1 -1
  47. package/web/assets/{erDiagram-RLTQ6QDP-Dke5zyoN.js → erDiagram-RLTQ6QDP-amg2k4kY.js} +1 -1
  48. package/web/assets/eventmodeling-NTZA5JFV-DjC9XhMC.js +1 -0
  49. package/web/assets/flowDiagram-HODETNUW-4yojXHxH.js +1 -0
  50. package/web/assets/{ganttDiagram-EL5Y4UJY-92XTPE2E.js → ganttDiagram-EL5Y4UJY-Btlsv3mU.js} +1 -1
  51. package/web/assets/{gitGraph-4MIJSDKK-CceHBPWG.js → gitGraph-4MIJSDKK-hsg4HYS9.js} +1 -1
  52. package/web/assets/{gitGraphDiagram-WWUBYQGX-CGITcXnL.js → gitGraphDiagram-WWUBYQGX-U7dHHcXK.js} +1 -1
  53. package/web/assets/{index-DWcM232K.js → index-BNyAZ52N.js} +2 -2
  54. package/web/assets/{info-A6RAGUB7-By211Ha_.js → info-A6RAGUB7-BtNsvOob.js} +1 -1
  55. package/web/assets/{infoDiagram-27XIBGKW-DhBVAEon.js → infoDiagram-27XIBGKW-Bp4J2HyM.js} +1 -1
  56. package/web/assets/{ishikawaDiagram-5VMMS53U-C6_FPoW0.js → ishikawaDiagram-5VMMS53U-ctIX0r6X.js} +1 -1
  57. package/web/assets/{journeyDiagram-3NMN7TZE-DrdNmmZF.js → journeyDiagram-3NMN7TZE-FXtnTpcI.js} +1 -1
  58. package/web/assets/{kanban-definition-UXKFOSKX-o1DNenyU.js → kanban-definition-UXKFOSKX-BaJFiS7T.js} +1 -1
  59. package/web/assets/{mermaid-parser.core-BQnVm5jd.js → mermaid-parser.core-bHQmSZkw.js} +3 -3
  60. package/web/assets/{mermaid.core-BWfiTYvq.js → mermaid.core-jwZj_MwN.js} +4 -4
  61. package/web/assets/{mindmap-definition-YA3MSWOX-Dh0xlNLH.js → mindmap-definition-YA3MSWOX-CVANQJvM.js} +1 -1
  62. package/web/assets/{mount-B3PVqBpm.js → mount-p_C2u8PG.js} +5 -5
  63. package/web/assets/{packet-AYTQ26CC-B6ApCnkv.js → packet-AYTQ26CC-DPrM2ZD7.js} +1 -1
  64. package/web/assets/{pegDiagram-XKGWAZYB-BsP-vwvf.js → pegDiagram-XKGWAZYB-VmazBajj.js} +1 -1
  65. package/web/assets/{pie-WAS4IAKB-C8unmtvR.js → pie-WAS4IAKB-260IRQiz.js} +1 -1
  66. package/web/assets/{pieDiagram-E7YTZNPT-BMWm91U0.js → pieDiagram-E7YTZNPT-DbPpzs2H.js} +1 -1
  67. package/web/assets/{quadrantDiagram-AXDQQJYC-BkrX0DR9.js → quadrantDiagram-AXDQQJYC-CNrmxA_-.js} +1 -1
  68. package/web/assets/{radar-RG4KPBEZ-D20T5D7F.js → radar-RG4KPBEZ-D3Ldnx09.js} +1 -1
  69. package/web/assets/{railroad-74A4TZTK-DuVZOQKB.js → railroad-74A4TZTK-CG-7nL_E.js} +1 -1
  70. package/web/assets/railroad-abnf-HS5TGJTU-lAb9-7Xp.js +1 -0
  71. package/web/assets/railroad-ebnf-LZEXJU2U-Cm_HkRcz.js +1 -0
  72. package/web/assets/railroad-peg-WCYAUIDC-BcOdVWM6.js +1 -0
  73. package/web/assets/{railroadDiagram-O6MQD6OU-CLw2M5gA.js → railroadDiagram-O6MQD6OU-_kJGLUPE.js} +1 -1
  74. package/web/assets/{requirementDiagram-BXWQKSXE-6gC4_6su.js → requirementDiagram-BXWQKSXE-nfScnZcQ.js} +1 -1
  75. package/web/assets/{sankeyDiagram-P5KCCOFB-B7_hfAB2.js → sankeyDiagram-P5KCCOFB-ASes9Uc0.js} +1 -1
  76. package/web/assets/{sequenceDiagram-WJ2MYXX4-XMnSOSb1.js → sequenceDiagram-WJ2MYXX4-D3Wq2IBM.js} +1 -1
  77. package/web/assets/{settingsRoute-BpkKRupt.js → settingsRoute-DX7j6eFs.js} +1 -1
  78. package/web/assets/{stateDiagram-D77RDMKH-C-dCsknn.js → stateDiagram-D77RDMKH-BNgsWpiq.js} +1 -1
  79. package/web/assets/stateDiagram-v2-MP3YSRHH-BvMxq8rN.js +1 -0
  80. package/web/assets/{swimlanes-42K2YHIH-DxdL4g6P.js → swimlanes-42K2YHIH-CtNrMpgE.js} +1 -1
  81. package/web/assets/swimlanesDiagram-VR7AAH4N-B-fVqAnK.js +8 -0
  82. package/web/assets/{timeline-definition-24CTP7MA-C8yYrVk4.js → timeline-definition-24CTP7MA-BAm0LrKX.js} +1 -1
  83. package/web/assets/{treeView-Q6P3EWNA-U7tICjnw.js → treeView-Q6P3EWNA-CsOctNbs.js} +1 -1
  84. package/web/assets/{treemap-WGGIJYW6-CeqLHNx1.js → treemap-WGGIJYW6-CJJBpHZv.js} +1 -1
  85. package/web/assets/{useStore-D6rFmW1r.js → useStore-DMCaltTO.js} +1 -1
  86. package/web/assets/{vennDiagram-4TSXK5OY-0ua8yYeP.js → vennDiagram-4TSXK5OY-CcWN3ED_.js} +1 -1
  87. package/web/assets/{wardley-WFR3VGLG-n42lqOB-.js → wardley-WFR3VGLG-CfyXmogb.js} +1 -1
  88. package/web/assets/{wardleyDiagram-VM6X3IG4-7ZTL48wy.js → wardleyDiagram-VM6X3IG4-JpKCXIvF.js} +1 -1
  89. package/web/assets/{xychartDiagram-S5SC5T6Z-5DzEhyKU.js → xychartDiagram-S5SC5T6Z-BMAMhnxx.js} +1 -1
  90. package/web/index.html +1 -1
  91. package/web/sw.js +1 -1
  92. package/web/assets/architecture-7GRP2DOG-elUq8en7.js +0 -1
  93. package/web/assets/channel-ReO_vby5.js +0 -1
  94. package/web/assets/classDiagram-ZZMXUADV-GifUKhyJ.js +0 -1
  95. package/web/assets/classDiagram-v2-VYDZK3BY-GifUKhyJ.js +0 -1
  96. package/web/assets/eventmodeling-NTZA5JFV-DgIydH2w.js +0 -1
  97. package/web/assets/flowDiagram-HODETNUW-Dq-CiyRM.js +0 -1
  98. package/web/assets/railroad-abnf-HS5TGJTU-BQ1laAxo.js +0 -1
  99. package/web/assets/railroad-ebnf-LZEXJU2U-CgxiPtiF.js +0 -1
  100. package/web/assets/railroad-peg-WCYAUIDC-OXcc352W.js +0 -1
  101. package/web/assets/stateDiagram-v2-MP3YSRHH-DKwrEyPr.js +0 -1
  102. package/web/assets/swimlanesDiagram-VR7AAH4N-Cr8Qlu3l.js +0 -8
@@ -0,0 +1,150 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Copyright (c) 2026 Petter André Sjulstad
3
+ /**
4
+ * Install and update from the self-contained GitHub release archives
5
+ * (scripts/release-archives.mjs). Layout under the install root
6
+ * (default ~/.local/share/bivy):
7
+ *
8
+ * versions/<version>-<target>/ one extracted archive each
9
+ * current -> versions/… the active one, swapped atomically
10
+ *
11
+ * The launcher (current/bin/bivy) passes its unresolved `current` path as
12
+ * BIVY_ARCHIVE_ROOT, so a service unit or shim written through it keeps
13
+ * working after `current` moves to a new version.
14
+ */
15
+ import fs from "node:fs";
16
+ import path from "node:path";
17
+ import crypto from "node:crypto";
18
+ import { spawnSync } from "node:child_process";
19
+
20
+ export const RELEASES_URL = "https://github.com/bivysh/bivy/releases";
21
+ export const ARCHIVE_INFO = "bivy-archive.json";
22
+ /** Versions kept on disk: the active one and the one before it, for rollback. */
23
+ const KEEP = 2;
24
+
25
+ /** "linux-x64" etc.: the archive target for this machine, or undefined. */
26
+ export function archiveTarget(platform = process.platform, arch = process.arch) {
27
+ return ["linux", "darwin"].includes(platform) && ["x64", "arm64"].includes(arch) ? `${platform}-${arch}` : undefined;
28
+ }
29
+
30
+ /** Where a channel's manifest and archives live. `latest` is the newest stable release. */
31
+ export function channelUrls(channel, base = process.env.BIVY_RELEASES_URL || RELEASES_URL) {
32
+ const dir = channel === "latest" ? `${base}/latest/download` : `${base}/download/${encodeURIComponent(channel)}`;
33
+ return {
34
+ manifest: `${dir}/manifest.json`,
35
+ // Stable archives are fetched from their own tag, so a release published
36
+ // mid-update can't swap the file under a manifest read a moment earlier.
37
+ archive: (manifest, file) => (channel === "latest" ? `${base}/download/v${manifest.version}/${file}` : `${dir}/${file}`),
38
+ };
39
+ }
40
+
41
+ /**
42
+ * The archive install this CLI runs from, or null. `archiveRoot` is the
43
+ * launcher's BIVY_ARCHIVE_ROOT; it only counts when it really is the install
44
+ * holding `appRoot`, so a value inherited into some other checkout is ignored.
45
+ */
46
+ export function archiveInstall(archiveRoot, appRoot) {
47
+ if (!archiveRoot) return null;
48
+ try {
49
+ if (fs.realpathSync(path.join(archiveRoot, "app")) !== fs.realpathSync(appRoot)) return null;
50
+ const info = JSON.parse(fs.readFileSync(path.join(archiveRoot, ARCHIVE_INFO), "utf8"));
51
+ // Run as current/bin/bivy or as versions/<v>/bin/bivy, the install root is
52
+ // the same, and `current` is the path worth writing down.
53
+ const parent = path.dirname(archiveRoot);
54
+ const installRoot = path.basename(archiveRoot) === "current" ? parent : path.basename(parent) === "versions" ? path.dirname(parent) : undefined;
55
+ // An archive unpacked anywhere else runs, but has no install to update.
56
+ const current = path.join(installRoot ?? "", "current");
57
+ if (!installRoot || !fs.existsSync(current)) return null;
58
+ // Run through `current`, write `current`; a specific version (say, a new one
59
+ // being checked before the swap) stays itself.
60
+ const root = fs.realpathSync(archiveRoot) === fs.realpathSync(current) ? current : archiveRoot;
61
+ return { root, installRoot, version: info.version, target: info.target };
62
+ } catch {
63
+ return null;
64
+ }
65
+ }
66
+
67
+ export async function fetchManifest(url, fetchImpl = fetch) {
68
+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(15_000) });
69
+ if (!res.ok) throw new Error(`Could not read the release manifest (${res.status} from ${url})`);
70
+ const manifest = await res.json();
71
+ if (typeof manifest?.version !== "string" || !manifest.archives) throw new Error(`${url} is not a Bivy release manifest`);
72
+ return manifest;
73
+ }
74
+
75
+ /**
76
+ * Fetch a large file with curl. Node's fetch can abort the process on an
77
+ * assertion when a server closes the connection while the body is paused
78
+ * for backpressure; curl is on every machine install.sh runs on.
79
+ */
80
+ export function curlDownload(url, dest) {
81
+ const res = spawnSync("curl", ["-fsSL", "--retry", "2", "-o", dest, url], { encoding: "utf8" });
82
+ if (res.status !== 0) throw new Error(`Could not download ${url}: ${(res.stderr || "").trim() || `curl exit ${res.status}`}`);
83
+ }
84
+
85
+ /**
86
+ * Download, verify and extract one archive into versions/. Returns its
87
+ * directory. Nothing outside versions/ changes, so a failure here leaves the
88
+ * running install untouched.
89
+ */
90
+ export async function stageArchive({ installRoot, manifest, target, archiveUrl, download = curlDownload }) {
91
+ const entry = manifest.archives[target];
92
+ if (!entry) throw new Error(`Bivy ${manifest.version} has no archive for ${target}`);
93
+ const versions = path.join(installRoot, "versions");
94
+ fs.mkdirSync(versions, { recursive: true });
95
+ const work = fs.mkdtempSync(path.join(versions, ".stage-"));
96
+ try {
97
+ const tarball = path.join(work, entry.file);
98
+ await download(archiveUrl(manifest, entry.file), tarball);
99
+ const sha256 = crypto.createHash("sha256").update(fs.readFileSync(tarball)).digest("hex");
100
+ if (sha256 !== entry.sha256) throw new Error(`${entry.file} failed verification: sha256 ${sha256}, the manifest says ${entry.sha256}`);
101
+
102
+ const tar = spawnSync("tar", ["-xzf", tarball, "-C", work], { encoding: "utf8" });
103
+ if (tar.status !== 0) throw new Error(`Could not extract ${entry.file}: ${tar.stderr}`);
104
+ const extracted = path.join(work, entry.file.replace(/\.tar\.gz$/, ""));
105
+ const info = JSON.parse(fs.readFileSync(path.join(extracted, ARCHIVE_INFO), "utf8"));
106
+ if (info.version !== manifest.version || info.target !== target) throw new Error(`${entry.file} holds ${info.version} ${info.target}, not ${manifest.version} ${target}`);
107
+
108
+ const dest = path.join(versions, `${manifest.version}-${target}`);
109
+ // Re-staging a version (a reinstall) must not replace the directory `current`
110
+ // points at while it runs; move it aside first and drop it afterwards.
111
+ const aside = fs.existsSync(dest) ? `${dest}.old-${process.pid}` : undefined;
112
+ if (aside) fs.renameSync(dest, aside);
113
+ fs.renameSync(extracted, dest);
114
+ if (aside) fs.rmSync(aside, { recursive: true, force: true });
115
+ return dest;
116
+ } finally {
117
+ fs.rmSync(work, { recursive: true, force: true });
118
+ }
119
+ }
120
+
121
+ /** The version directory `current` points at, or undefined. */
122
+ export function activeVersion(installRoot) {
123
+ try {
124
+ return path.resolve(installRoot, fs.readlinkSync(path.join(installRoot, "current")));
125
+ } catch {
126
+ return undefined;
127
+ }
128
+ }
129
+
130
+ /** Point `current` at a version directory atomically. Returns what it pointed at before. */
131
+ export function activate(installRoot, versionDir) {
132
+ const previous = activeVersion(installRoot);
133
+ const link = path.join(installRoot, "current");
134
+ const next = `${link}.next-${process.pid}`;
135
+ fs.rmSync(next, { force: true });
136
+ fs.symlinkSync(path.relative(installRoot, versionDir), next);
137
+ fs.renameSync(next, link);
138
+ return previous;
139
+ }
140
+
141
+ /** Remove version directories other than the newest KEEP, never the active one. */
142
+ export function prune(installRoot, keep = []) {
143
+ const versions = path.join(installRoot, "versions");
144
+ const active = activeVersion(installRoot);
145
+ const kept = new Set([...new Set([active, ...keep].filter(Boolean).map((p) => path.resolve(p)))].slice(0, KEEP));
146
+ for (const name of fs.readdirSync(versions)) {
147
+ const dir = path.join(versions, name);
148
+ if (!kept.has(dir)) fs.rmSync(dir, { recursive: true, force: true });
149
+ }
150
+ }
package/bin/bivy.mjs CHANGED
@@ -45,11 +45,16 @@ import { parseTailscaleStatus, serveConflict, serveFailureHint, serveOffArgs, se
45
45
  import { resolveAttachSessionId } from "./attach-session-id.mjs";
46
46
  import { detectInstallKind as classifyInstallKind, managedInstall, npmGlobalPrefix } from "./install-kind.mjs";
47
47
  import { hasConfiguredService as configuredServiceExists } from "./service-state.mjs";
48
+ import { activate, activeVersion, archiveInstall, archiveTarget, channelUrls, fetchManifest, prune, stageArchive } from "./archive-install.mjs";
48
49
  import { COMMANDS, EXIT, cliError, completionWords, describeCli, describeCommand, describeTools, renderHelp, resolveCommand, subcommandTable, suggestCommands, toolArgv, wantsJson } from "./cli-commands.mjs";
49
50
 
50
- const selfScript = fileURLToPath(import.meta.url);
51
- const __dirname = path.dirname(selfScript);
52
- const repoRoot = path.resolve(__dirname, "..");
51
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
52
+ // A GitHub release archive install runs through its launcher, which names the
53
+ // install's `current` path. Paths written to disk (service unit, shims) use it,
54
+ // so they stay valid when an update points `current` at a new version.
55
+ const archive = archiveInstall(process.env.BIVY_ARCHIVE_ROOT, path.resolve(__dirname, ".."));
56
+ const repoRoot = archive ? path.join(archive.root, "app") : path.resolve(__dirname, "..");
57
+ const selfScript = path.join(repoRoot, "bin", "bivy.mjs");
53
58
  // Mutable node state (config, relay E2E keys, sessions, logs) must live in a
54
59
  // stable, user-owned directory that survives reinstalls. Pick it by install type:
55
60
  // - BIVY_DATA_DIR set -> honor it (explicit override)
@@ -77,10 +82,11 @@ process.env.BIVY_DATA_DIR = appDir;
77
82
  // - "git" dev checkout (has .git)
78
83
  // - "npx" ephemeral `npx bivy` run (repoRoot under an npm _npx cache)
79
84
  // - "npm-global" `npm i -g @bivy/bivy` (repoRoot is below node_modules/@bivy)
85
+ // - "archive" a GitHub release archive under ~/.local/share/bivy (install.sh)
80
86
  // - "packaged" install.sh tarball tree (user-owned, self-preserving)
81
87
  // - "managed" a system package (the AUR's `bivy`), updated by its manager
82
88
  function detectInstallKind() {
83
- return classifyInstallKind(repoRoot);
89
+ return archive ? "archive" : classifyInstallKind(repoRoot);
84
90
  }
85
91
  const cliConfigPath = path.join(appDir, "cli.json");
86
92
  const canonicalConfigPath = path.join(appDir, "config.yaml");
@@ -185,7 +191,7 @@ const mcpProxyEntry = path.join(repoRoot, packaged ? "dist/harness/mcp-proxy-cli
185
191
  const mcpServeEntry = path.join(repoRoot, packaged ? "dist/harness/mcp-serve-cli.js" : "src/harness/mcp-serve-cli.ts");
186
192
  const qrEntry = path.join(repoRoot, "public", "qr.js");
187
193
  const tsxCli = packaged ? "" : path.join(repoRoot, "node_modules", "tsx", "dist", "cli.mjs");
188
- const nodeBin = process.execPath;
194
+ const nodeBin = archive ? path.join(archive.root, "runtime", "bin", "node") : process.execPath;
189
195
  const nodeScriptArgs = (entry) => (tsxCli ? [tsxCli, entry] : [entry]);
190
196
 
191
197
  // Resolve the baked-in hosted endpoints (app/relay/client URLs). Imported lazily
@@ -230,7 +236,7 @@ function commandPath(extraPath = "") {
230
236
  process.env.PATH || "",
231
237
  // npm global executables normally live beside the Node binary (including
232
238
  // nvm/fnm installs). Services need this even without shell initialization.
233
- path.dirname(process.execPath),
239
+ path.dirname(nodeBin),
234
240
  ].filter(Boolean);
235
241
  return [...new Set(parts.flatMap((part) => String(part).split(path.delimiter)).filter(Boolean))].join(path.delimiter);
236
242
  }
@@ -4065,6 +4071,7 @@ function plistContent(config) {
4065
4071
  PORT: String(config.port),
4066
4072
  BIVY_WORKSPACE: config.workspace,
4067
4073
  BIVY_DATA_DIR: appDir,
4074
+ ...(archive ? { BIVY_ARCHIVE_ROOT: archive.root } : {}),
4068
4075
  ...config.env,
4069
4076
  PATH: commandPath(config.env?.PATH),
4070
4077
  })
@@ -4109,6 +4116,7 @@ function systemdContent(config) {
4109
4116
  PORT: String(config.port),
4110
4117
  BIVY_WORKSPACE: config.workspace,
4111
4118
  BIVY_DATA_DIR: appDir,
4119
+ ...(archive ? { BIVY_ARCHIVE_ROOT: archive.root } : {}),
4112
4120
  ...config.env,
4113
4121
  PATH: commandPath(config.env?.PATH),
4114
4122
  })
@@ -5515,6 +5523,49 @@ async function cmdUpdate(args = []) {
5515
5523
  await runUpdate(args);
5516
5524
  }
5517
5525
 
5526
+ /**
5527
+ * Update a GitHub release archive install: stage the channel's archive beside
5528
+ * the running one, point `current` at it, restart, and point `current` back if
5529
+ * the node doesn't come up. The version before stays on disk for that.
5530
+ */
5531
+ async function updateArchiveInstall(channel, { skipWait, force }) {
5532
+ const urls = channelUrls(channel);
5533
+ const target = archiveTarget();
5534
+ console.log(c.dim(`Checking ${urls.manifest} (channel: ${channel})…`));
5535
+ const manifest = await fetchManifest(urls.manifest);
5536
+ if (manifest.version === archive.version && !force) {
5537
+ console.log(c.green(`Bivy ${archive.version} is the newest on ${channel}.`));
5538
+ return;
5539
+ }
5540
+ console.log(c.dim(`Downloading Bivy ${manifest.version} for ${target}…`));
5541
+ const staged = await stageArchive({ installRoot: archive.installRoot, manifest, target, archiveUrl: urls.archive });
5542
+ const probe = runQuiet(path.join(staged, "bin", "bivy"), ["--version"]);
5543
+ if (probe.code !== 0 || probe.stdout.trim() !== manifest.version) {
5544
+ throw new Error(`The downloaded Bivy ${manifest.version} does not run here (${(probe.stderr || probe.stdout).trim() || `exit ${probe.code}`}); kept ${archive.version}.`);
5545
+ }
5546
+ const config = loadConfig();
5547
+ await waitForIdleSessions(config, { skip: skipWait });
5548
+ const previous = activate(archive.installRoot, staged);
5549
+ if (!hasConfiguredService(config)) {
5550
+ prune(archive.installRoot, [staged, previous]);
5551
+ console.log(c.green(`Updated to ${manifest.version}. Run 'bivy start' to use it.`));
5552
+ return;
5553
+ }
5554
+ if ((await restartServiceReconciled(config)) && (await verifyNodeCameUp(config))) {
5555
+ prune(archive.installRoot, [staged, previous]);
5556
+ console.log(c.green(`Updated ${archive.version} → ${manifest.version} and restarted the background service.`));
5557
+ return;
5558
+ }
5559
+ if (previous && previous !== activeVersion(archive.installRoot)) {
5560
+ activate(archive.installRoot, previous);
5561
+ await restartServiceReconciled(config);
5562
+ console.log(c.red(`⚠ Bivy ${manifest.version} did not come up, so ${archive.version} is back in place.`));
5563
+ } else {
5564
+ reportNodeDidNotStart();
5565
+ }
5566
+ process.exitCode = 1;
5567
+ }
5568
+
5518
5569
  async function runUpdate(args = []) {
5519
5570
  const skipWait = args.includes("--force") || args.includes("--no-wait");
5520
5571
  const kind = detectInstallKind();
@@ -5564,6 +5615,12 @@ async function runUpdate(args = []) {
5564
5615
  return;
5565
5616
  }
5566
5617
 
5618
+ if (kind === "archive") {
5619
+ await updateArchiveInstall(channel, { skipWait, force: args.includes("--force") });
5620
+ console.log(c.dim(`=== bivy update finished ${new Date().toISOString()} ===`));
5621
+ return;
5622
+ }
5623
+
5567
5624
  if (kind === "packaged") {
5568
5625
  console.log(c.dim(`Updating packaged Bivy install (channel: ${channel})…`));
5569
5626
  // The actual restart happens inside install.sh, which shells out to
@@ -18,7 +18,28 @@ export function managedInstall(packageRoot) {
18
18
  }
19
19
  return null;
20
20
  }
21
- export function updateRegistryUrl(appDir, override) {
21
+ /**
22
+ * True when this daemon runs from a GitHub release archive install: the
23
+ * launcher's BIVY_ARCHIVE_ROOT names the install holding `packageRoot` (the
24
+ * same check bin/archive-install.mjs makes for the CLI).
25
+ */
26
+ export function isArchiveInstall(packageRoot, archiveRoot = process.env.BIVY_ARCHIVE_ROOT) {
27
+ if (!archiveRoot)
28
+ return false;
29
+ try {
30
+ return fs.realpathSync(path.join(archiveRoot, "app")) === fs.realpathSync(packageRoot)
31
+ && fs.existsSync(path.join(archiveRoot, "bivy-archive.json"));
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ }
37
+ /**
38
+ * Where to look for a newer version on the install's recorded channel: the npm
39
+ * registry, or for an archive install the channel's GitHub release manifest
40
+ * (URLs as in bin/archive-install.mjs). Both answer with `{ version }`.
41
+ */
42
+ export function updateRegistryUrl(appDir, override, archive = false) {
22
43
  if (override)
23
44
  return override;
24
45
  let channel = "latest";
@@ -28,6 +49,10 @@ export function updateRegistryUrl(appDir, override) {
28
49
  channel = recorded;
29
50
  }
30
51
  catch { /* Existing installs track stable. */ }
52
+ if (archive) {
53
+ const releases = process.env.BIVY_RELEASES_URL || "https://github.com/bivysh/bivy/releases";
54
+ return channel === "latest" ? `${releases}/latest/download/manifest.json` : `${releases}/download/${encodeURIComponent(channel)}/manifest.json`;
55
+ }
31
56
  return `https://registry.npmjs.org/%40bivy%2Fbivy/${encodeURIComponent(channel)}`;
32
57
  }
33
58
  /** Running version is fixed for this process, never re-read after an install. */
package/dist/server.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // First: drop agent-session markers the node inherited before anything reads them.
4
4
  import "./node-env.js";
5
5
  import fs from "node:fs";
6
- import { createNodeUpdateChecker, managedInstall, updateRegistryUrl } from "./node-update.js";
6
+ import { createNodeUpdateChecker, isArchiveInstall, managedInstall, updateRegistryUrl } from "./node-update.js";
7
7
  import { createRemoteSessionAdmission, RemoteSessionAdmissionError } from "./session/remote-session-admission.js";
8
8
  import { requiresExistingSession, resolveTargetSession } from "./session/target-session.js";
9
9
  import path from "node:path";
@@ -824,9 +824,10 @@ const sessionRunPolicy = {
824
824
  if (process.env.BIVY_SESSION_MODEL_FALLBACK) {
825
825
  console.log(`[policy] in-session model reroute enabled: ${process.env.BIVY_SESSION_MODEL_FALLBACK}`);
826
826
  }
827
+ const archiveInstalled = isArchiveInstall(repoRoot);
827
828
  const nodeUpdates = createNodeUpdateChecker({
828
829
  current: currentVersion() ?? "",
829
- registryUrl: () => updateRegistryUrl(appDir, process.env.BIVY_UPDATE_REGISTRY_URL),
830
+ registryUrl: () => updateRegistryUrl(appDir, process.env.BIVY_UPDATE_REGISTRY_URL, archiveInstalled),
830
831
  publish: (state) => broadcast(state),
831
832
  });
832
833
  function runtimeSummary(rt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.21.2-staging.8",
3
+ "version": "0.21.2-staging.9",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "Run coding agents on machines you own. Open-source, self-hostable agent workspace.",