@bivy/bivy 0.15.0-staging.52 → 0.15.0-staging.54

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 (2) hide show
  1. package/bin/bivy.mjs +44 -0
  2. package/package.json +1 -1
package/bin/bivy.mjs CHANGED
@@ -3543,11 +3543,55 @@ function terminalQr(text) {
3543
3543
 
3544
3544
  // --- commands ---------------------------------------------------------------
3545
3545
 
3546
+ async function cmdTokenSetup() {
3547
+ // A token-bearing installer command is an explicit "add this machine" flow,
3548
+ // not a request to walk through first-run preferences. In particular, do not
3549
+ // consume the account token after presenting the agent and login wizards:
3550
+ // those prompts made the Connect a Machine command unusable on headless
3551
+ // machines and made it look as if the token had been ignored.
3552
+ if (!(await ensureDeps())) process.exit(1);
3553
+
3554
+ const config = loadConfig();
3555
+ if (!config.workspace || config.workspace === repoRoot) {
3556
+ config.workspace = firstSetupWorkspace(config);
3557
+ if (!fs.existsSync(config.workspace)) fs.mkdirSync(config.workspace, { recursive: true });
3558
+ }
3559
+ const explicitPort = Number(process.env.PORT);
3560
+ config.port = explicitPort || await findAvailablePort(Number(config.port) || 4317, nodeBindHost());
3561
+ config.env = { ...config.env, BIVY_RUNTIME: config.env?.BIVY_RUNTIME || "pi" };
3562
+ saveConfig(config);
3563
+
3564
+ const code = await run(nodeBin, [...nodeScriptArgs(relaySetupEntry)], {
3565
+ cwd: repoRoot,
3566
+ env: startEnv(config),
3567
+ });
3568
+ if (code !== 0) {
3569
+ console.error(c.red("Machine enrollment failed; the token was not accepted."));
3570
+ process.exitCode = code || 1;
3571
+ return;
3572
+ }
3573
+
3574
+ console.log(c.dim("\nInstalling the background service so the node keeps running…"));
3575
+ const started = await installService(config);
3576
+ if (!started) {
3577
+ console.log(`Finish with ${c.cyan("bivy service install")} or start it with ${c.cyan("bivy start")}.`);
3578
+ return;
3579
+ }
3580
+ console.log(c.bold(c.green("\n✓ Machine added and running. No interactive setup was needed.")));
3581
+ }
3582
+
3546
3583
  async function cmdSetup(args = []) {
3547
3584
  if (args.includes("-h") || args.includes("--help")) {
3548
3585
  console.log("Usage: bivy setup\n\nFirst-run wizard: agent choice, model login, remote access + sign-in, and background service. Workspace and port get safe defaults. Re-run later to change the default agent or remote access.");
3549
3586
  return;
3550
3587
  }
3588
+ // install.sh supplies these only for the Connect a Machine command. Keep
3589
+ // this branch before creating a readline prompter: there may be no TTY.
3590
+ if (process.env.BIVY_SESSION_TOKEN || process.env.BIVY_NODE_CLAIM_CODE) {
3591
+ await cmdTokenSetup();
3592
+ return;
3593
+ }
3594
+
3551
3595
  console.log(c.bold("\n Bivy — node setup\n"));
3552
3596
  if (process.getuid?.() === 0) {
3553
3597
  console.log(c.yellow("You are running setup as root. For a real node, create a normal user (e.g. 'bivy') and install there."));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.15.0-staging.52",
3
+ "version": "0.15.0-staging.54",
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.",