indieclaw-agent 1.1.6 → 1.1.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/index.js +28 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -503,16 +503,37 @@ function handleSystemUpdate(ws, { id }) {
503
503
  const { spawn } = require('child_process');
504
504
  const platform = os.platform();
505
505
 
506
- // Build an update script that runs after the agent exits
507
- const script = platform === 'win32'
508
- ? `@echo off
506
+ // Resolve the full path to npm so detached scripts can find it
507
+ let npmPath = 'npm';
508
+ try {
509
+ npmPath = execSync('which npm', { timeout: 3000 }).toString().trim();
510
+ } catch {}
511
+
512
+ let script;
513
+ if (platform === 'win32') {
514
+ script = `@echo off
509
515
  timeout /t 2 /nobreak >nul
510
516
  npm install -g indieclaw-agent@latest
511
- start "" indieclaw-agent`
512
- : `#!/bin/bash
517
+ start "" indieclaw-agent`;
518
+ } else {
519
+ // Detect restart method: systemd service, launchd, or nohup fallback
520
+ script = `#!/bin/bash
521
+ exec > /tmp/indieclaw-update.log 2>&1
522
+ echo "[$(date)] Starting agent update..."
513
523
  sleep 2
514
- npm install -g indieclaw-agent@latest
515
- nohup indieclaw-agent > /tmp/indieclaw-agent.log 2>&1 &`;
524
+ ${npmPath} install -g indieclaw-agent@latest
525
+ echo "[$(date)] Install complete, restarting..."
526
+ if [ -f /etc/systemd/system/indieclaw-agent.service ]; then
527
+ systemctl restart indieclaw-agent
528
+ echo "[$(date)] Restarted via systemctl"
529
+ elif launchctl list com.indieclaw.agent &>/dev/null 2>&1; then
530
+ launchctl kickstart -k gui/$(id -u)/com.indieclaw.agent
531
+ echo "[$(date)] Restarted via launchctl"
532
+ else
533
+ nohup indieclaw-agent > /tmp/indieclaw-agent.log 2>&1 &
534
+ echo "[$(date)] Restarted via nohup (pid $!)"
535
+ fi`;
536
+ }
516
537
 
517
538
  const ext = platform === 'win32' ? '.bat' : '.sh';
518
539
  const scriptPath = path.join(os.tmpdir(), `indieclaw-update${ext}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indieclaw-agent",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Manage your server from your phone. Agent for the IndieClaw mobile app.",
5
5
  "main": "index.js",
6
6
  "bin": {