arisa 2.2.5 → 2.2.7

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/arisa.js +24 -14
  2. package/package.json +1 -1
package/bin/arisa.js CHANGED
@@ -414,7 +414,7 @@ function arisaUserExists() {
414
414
  }
415
415
 
416
416
  function isProvisioned() {
417
- return arisaUserExists() && existsSync("/home/arisa/.bun/bin/bun");
417
+ return arisaUserExists() && existsSync("/home/arisa/.bun/bin/bun") && existsSync(SHARED_ARISA_ROOT);
418
418
  }
419
419
 
420
420
  function isArisaConfigured() {
@@ -438,6 +438,8 @@ function step(ok, msg) {
438
438
  }
439
439
 
440
440
  const ARISA_BUN_ENV = 'export BUN_INSTALL=/home/arisa/.bun && export PATH=/home/arisa/.bun/bin:$PATH';
441
+ const SHARED_ARISA_ROOT = "/opt/arisa/node_modules/arisa";
442
+ const sharedDaemonEntry = join(SHARED_ARISA_ROOT, "src", "daemon", "index.ts");
441
443
 
442
444
  function runAsInherit(cmd) {
443
445
  return spawnSync("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && ${cmd}`], {
@@ -483,9 +485,13 @@ function provisionArisaUser() {
483
485
  spawnSync("chown", ["arisa:arisa", profilePath], { stdio: "ignore" });
484
486
  }
485
487
 
486
- // 3. Ensure pkgRoot is readable by arisa user (run from global install, no copy)
487
- spawnSync("chmod", ["-R", "o+rX", pkgRoot], { stdio: "ignore" });
488
- step(true, `Arisa will run from ${pkgRoot}`);
488
+ // 3. Copy global node_modules to shared location (lightweight cp, no bun)
489
+ const sharedDir = "/opt/arisa";
490
+ const globalModules = resolve(pkgRoot, "..");
491
+ mkdirSync(sharedDir, { recursive: true });
492
+ spawnSync("cp", ["-r", globalModules, join(sharedDir, "node_modules")], { stdio: "pipe" });
493
+ spawnSync("chown", ["-R", "arisa:arisa", sharedDir], { stdio: "pipe" });
494
+ step(true, "Arisa copied to /opt/arisa");
489
495
 
490
496
  // 4. Migrate data
491
497
  const rootArisa = "/root/.arisa";
@@ -510,11 +516,11 @@ Wants=network-online.target
510
516
  [Service]
511
517
  Type=simple
512
518
  User=arisa
513
- WorkingDirectory=${pkgRoot}
514
- ExecStart=/home/arisa/.bun/bin/bun ${daemonEntry}
519
+ WorkingDirectory=${SHARED_ARISA_ROOT}
520
+ ExecStart=/home/arisa/.bun/bin/bun ${sharedDaemonEntry}
515
521
  Restart=always
516
522
  RestartSec=5
517
- Environment=ARISA_PROJECT_DIR=${pkgRoot}
523
+ Environment=ARISA_PROJECT_DIR=${SHARED_ARISA_ROOT}
518
524
  Environment=BUN_INSTALL=/home/arisa/.bun
519
525
  Environment=PATH=/home/arisa/.bun/bin:/usr/local/bin:/usr/bin:/bin
520
526
 
@@ -574,10 +580,14 @@ function canUseSystemdSystem() {
574
580
  }
575
581
 
576
582
  function runArisaForeground() {
577
- const su = spawnSync("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && export ARISA_PROJECT_DIR=${pkgRoot} && /home/arisa/.bun/bin/bun ${daemonEntry}`], {
583
+ // Detach child + exit parent immediately to free parent bun memory (~50-100MB).
584
+ // On 1GB VPS, two bun processes trigger OOM.
585
+ const child = spawn("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && export ARISA_PROJECT_DIR=${SHARED_ARISA_ROOT} && exec /home/arisa/.bun/bin/bun ${sharedDaemonEntry}`], {
578
586
  stdio: "inherit",
587
+ detached: true,
579
588
  });
580
- return su.status ?? 1;
589
+ child.unref();
590
+ process.exit(0);
581
591
  }
582
592
 
583
593
  // ── Root guard ──────────────────────────────────────────────────────
@@ -593,7 +603,7 @@ if (isRoot()) {
593
603
  }
594
604
 
595
605
  process.stdout.write("\nStarting interactive setup as user arisa...\n\n");
596
- process.exit(runArisaForeground());
606
+ runArisaForeground(); // exits parent process internally
597
607
  }
598
608
 
599
609
  // Already provisioned — route commands
@@ -612,7 +622,7 @@ if (isRoot()) {
612
622
  if (isDefaultInvocation) {
613
623
  if (!isArisaConfigured()) {
614
624
  process.stdout.write("Arisa is not configured yet. Starting interactive setup...\n\n");
615
- process.exit(runArisaForeground());
625
+ runArisaForeground(); // exits parent process internally
616
626
  }
617
627
  if (hasSystemd) {
618
628
  if (isSystemdActive()) {
@@ -622,13 +632,13 @@ if (isRoot()) {
622
632
  }
623
633
  }
624
634
  // No systemd → foreground
625
- process.exit(runArisaForeground());
635
+ runArisaForeground(); // exits parent process internally
626
636
  }
627
637
 
628
638
  switch (command) {
629
639
  case "start":
630
640
  if (hasSystemd) process.exit(startSystemdSystem());
631
- process.exit(runArisaForeground());
641
+ runArisaForeground(); // exits parent process internally
632
642
  break;
633
643
  case "stop":
634
644
  if (hasSystemd) process.exit(stopSystemdSystem());
@@ -647,7 +657,7 @@ if (isRoot()) {
647
657
  break;
648
658
  case "daemon":
649
659
  case "run":
650
- process.exit(runArisaForeground());
660
+ runArisaForeground(); // exits parent process internally
651
661
  default:
652
662
  process.stderr.write(`Unknown command: ${command}\n\n`);
653
663
  printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "Arisa - dynamic agent runtime with daemon/core architecture that evolves through user interaction",
5
5
  "preferGlobal": true,
6
6
  "bin": {