open-agents-ai 0.187.319 → 0.187.321

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.
@@ -3,8 +3,8 @@
3
3
  // Safe, best-effort, idempotent. Skips if systemd --user is unavailable.
4
4
 
5
5
  const { execSync } = require('node:child_process');
6
- const { mkdirSync, writeFileSync } = require('node:fs');
7
- const { join } = require('node:path');
6
+ const { mkdirSync, writeFileSync, existsSync } = require('node:fs');
7
+ const { join, resolve } = require('node:path');
8
8
 
9
9
  function hasSystemdUser() {
10
10
  try { execSync('systemctl --user --version', { stdio: 'pipe' }); return true; } catch { return false; }
@@ -96,4 +96,71 @@ function migrate() {
96
96
  }
97
97
 
98
98
  try { migrate(); } catch {}
99
+
100
+ // After install: force-restart the OA daemon so the new version is active.
101
+ // 1) Prefer systemd --user: restart open-agents-daemon.service if present
102
+ // 2) Fallback: launch the freshly installed CLI's launcher in daemon mode
103
+ // using this package's dist/launcher.cjs (absolute path), detached.
104
+ // 3) If the unit is missing, write a sane user service pointing to this
105
+ // package's launcher and enable it.
106
+ function ensureSystemdUnit() {
107
+ try {
108
+ if (!hasSystemdUser()) return false;
109
+ const unitDir = join(process.env.HOME || process.env.USERPROFILE || '.', '.config', 'systemd', 'user');
110
+ mkdirSync(unitDir, { recursive: true });
111
+ const unitPath = join(unitDir, 'open-agents-daemon.service');
112
+ const nodeBin = process.execPath; // current Node used for this install
113
+ const launcher = resolve(__dirname, 'launcher.cjs');
114
+ const svc = [
115
+ '[Unit]',
116
+ 'Description=Open Agents API Daemon',
117
+ 'After=default.target',
118
+ '',
119
+ '[Service]',
120
+ 'Type=simple',
121
+ `ExecStart=${JSON.stringify(nodeBin)} ${JSON.stringify(launcher)} serve --daemon --quiet`,
122
+ `WorkingDirectory=${JSON.stringify(process.env.HOME || process.cwd())}`,
123
+ 'Restart=always',
124
+ 'RestartSec=2',
125
+ 'Environment=OA_DAEMON=1',
126
+ '',
127
+ '[Install]',
128
+ 'WantedBy=default.target',
129
+ ''
130
+ ].join('\n');
131
+ writeFileSync(unitPath, svc);
132
+ try {
133
+ execSync('systemctl --user daemon-reload', { stdio: 'pipe' });
134
+ execSync('systemctl --user enable --now open-agents-daemon.service', { stdio: 'pipe' });
135
+ } catch {}
136
+ return true;
137
+ } catch { return false; }
138
+ }
139
+
140
+ function restartDaemon() {
141
+ try {
142
+ if (hasSystemdUser()) {
143
+ // If service missing, create it first
144
+ try { execSync('systemctl --user cat open-agents-daemon.service >/dev/null 2>&1'); }
145
+ catch { try { ensureSystemdUnit(); } catch {} }
146
+ // Restart via systemd
147
+ try { execSync('systemctl --user restart open-agents-daemon.service', { stdio: 'pipe' }); return; } catch {}
148
+ }
149
+ } catch {}
150
+ try {
151
+ const { spawn } = require('node:child_process');
152
+ const la = resolve(__dirname, 'launcher.cjs');
153
+ // Best-effort: kill any old OA daemon owned by this user
154
+ try { execSync("pkill -f 'open-agents-ai.*serve' || true", { stdio: 'pipe' }); } catch {}
155
+ const nodeBin = process.execPath;
156
+ const child = spawn(nodeBin, [la, 'serve', '--daemon', '--quiet'], {
157
+ detached: true,
158
+ stdio: 'ignore',
159
+ env: Object.assign({}, process.env, { OA_DAEMON: '' })
160
+ });
161
+ child.unref();
162
+ } catch {}
163
+ }
164
+
165
+ try { restartDaemon(); } catch {}
99
166
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.319",
3
+ "version": "0.187.321",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",