nothumanallowed 14.1.16 → 14.1.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothumanallowed",
3
- "version": "14.1.16",
3
+ "version": "14.1.17",
4
4
  "description": "NotHumanAllowed — 38 AI agents, 80 tools, Studio (visual agentic workflows). Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, Alexandria E2E messaging, GitHub, Notion, Slack, voice chat, free AI (Liara), 28 languages. Zero-dependency CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/constants.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
 
8
- export const VERSION = '14.1.16';
8
+ export const VERSION = '14.1.17';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -290,32 +290,32 @@ async function handleRequest(req, res) {
290
290
  export async function startServer({ port = 3847, host = '127.0.0.1', noBrowser = false } = {}) {
291
291
  _router = await buildRouter();
292
292
  const { setupWebSocket } = await import('./ws.mjs');
293
+ const { execSync } = await import('child_process');
294
+
295
+ // Kill any existing process on the port before binding
296
+ try {
297
+ const pids = execSync(`lsof -ti tcp:${port} 2>/dev/null || true`).toString().trim();
298
+ if (pids) {
299
+ pids.split('\n').filter(Boolean).forEach((p) => {
300
+ try { process.kill(parseInt(p), 'SIGTERM'); } catch {}
301
+ });
302
+ await new Promise((r) => setTimeout(r, 900));
303
+ }
304
+ } catch {}
293
305
 
294
306
  const server = http.createServer(handleRequest);
295
- setupWebSocket(server);
296
307
 
297
- // If port is in use, kill the old process and retry once
308
+ // Attach WebSocket AFTER HTTP server is listening to avoid WS error events
298
309
  await new Promise((resolve, reject) => {
299
- server.once('error', async (err) => {
300
- if (err.code === 'EADDRINUSE') {
301
- const { execSync } = await import('child_process');
302
- try {
303
- // Find and kill the process holding the port
304
- const pid = execSync(`lsof -ti tcp:${port} 2>/dev/null || true`).toString().trim();
305
- if (pid) {
306
- pid.split('\n').forEach((p) => { try { process.kill(parseInt(p), 'SIGTERM'); } catch {} });
307
- await new Promise((r) => setTimeout(r, 800));
308
- }
309
- } catch {}
310
- // Retry
311
- server.listen(port, host, (e) => e ? reject(e) : resolve(undefined));
312
- } else {
313
- reject(err);
314
- }
310
+ server.once('error', reject);
311
+ server.listen(port, host, () => {
312
+ server.removeListener('error', reject);
313
+ resolve(undefined);
315
314
  });
316
- server.listen(port, host, () => resolve(undefined));
317
315
  });
318
316
 
317
+ setupWebSocket(server);
318
+
319
319
  const G = '\x1b[0;32m', NC = '\x1b[0m', D = '\x1b[2m', BOLD = '\x1b[1m';
320
320
  const { VERSION } = await import('../constants.mjs');
321
321
  console.log(`\n ${BOLD}${G}NHA${NC} ${D}v${VERSION}${NC}`);