@sovovs/bycli 2.1.4 → 2.1.5

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/dist/src/daemon.js +27 -0
  2. package/package.json +1 -1
@@ -20,6 +20,7 @@
20
20
  * - Listens on 127.0.0.1:19825 by default; isolated sandboxes may opt into 0.0.0.0
21
21
  */
22
22
  import { createServer } from 'node:http';
23
+ import { spawn } from 'node:child_process';
23
24
  import { WebSocketServer, WebSocket } from 'ws';
24
25
  import { DEFAULT_DAEMON_PORT } from './constants.js';
25
26
  import { EXIT_CODES } from './errors.js';
@@ -40,6 +41,7 @@ import { buildCommandDispatchFailure, buildExtensionDisconnectFailure, getRespon
40
41
  import { resolveDaemonHost } from './daemon-config.js';
41
42
  const PORT = parseInt(process.env.BYCLI_DAEMON_PORT ?? String(DEFAULT_DAEMON_PORT), 10);
42
43
  const HOST = resolveDaemonHost();
44
+ const BROWSER_RECOVERY_COMMAND = process.env.BYCLI_BROWSER_RECOVERY_COMMAND?.trim();
43
45
  // The verify runner (M6b) spawns child processes that connect back to THIS daemon for a
44
46
  // browser Page. Hand them our port (→ BYCLI_DAEMON_PORT in the child env) so the child's
45
47
  // Page reaches us, not a freshly-spawned daemon. Must run before the first /v1/verify
@@ -359,6 +361,31 @@ async function handleRequest(req, res) {
359
361
  jsonResponse(res, 200, { ok: true, data: { requestId, status: runStatus.status, result: runStatus.summary } });
360
362
  return;
361
363
  }
364
+ if (req.method === 'POST' && pathname === '/v1/browser/recover') {
365
+ if (!BROWSER_RECOVERY_COMMAND) {
366
+ jsonResponse(res, 503, {
367
+ ok: false,
368
+ errorCode: 'browser_recovery_unavailable',
369
+ error: 'Browser recovery is not configured.',
370
+ });
371
+ return;
372
+ }
373
+ try {
374
+ const child = spawn(BROWSER_RECOVERY_COMMAND, [], { detached: true, stdio: 'ignore' });
375
+ child.on('error', () => logger.warn('daemon.browser_recover', { errorCode: 'browser_recovery_spawn_failed' }));
376
+ child.unref();
377
+ jsonResponse(res, 202, { ok: true, data: { started: true } });
378
+ }
379
+ catch {
380
+ logger.warn('daemon.browser_recover', { errorCode: 'browser_recovery_spawn_failed' });
381
+ jsonResponse(res, 503, {
382
+ ok: false,
383
+ errorCode: 'browser_recovery_unavailable',
384
+ error: 'Browser recovery could not be started.',
385
+ });
386
+ }
387
+ return;
388
+ }
362
389
  if (req.method === 'GET' && pathname === '/status') {
363
390
  const uptime = process.uptime();
364
391
  const mem = process.memoryUsage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sovovs/bycli",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },