@nickduy/agent-studio 0.1.5 → 0.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.
package/README.md CHANGED
@@ -51,6 +51,10 @@ The server binds to `127.0.0.1` only. Claude Code and Playwright run on the mach
51
51
 
52
52
  ## Update
53
53
 
54
+ Agent Studio checks the registry every 15 minutes. When a newer version is published, the UI asks you to update before you can continue: **Update and restart** runs `npm install -g <package-name>@<new version>` (progress in the terminal where Agent Studio runs) and restarts it on the same port; the page reloads by itself. It waits until no job is running. If the install fails (for example, installing global packages needs admin rights), the current version starts again and the UI shows the command to run by hand.
55
+
56
+ To update by hand:
57
+
54
58
  ```bash
55
59
  npm install -g <package-name>@latest
56
60
  ```
@@ -1,9 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  // Thin launcher: check Node first (node:sqlite needs >= 22.13), then load the bundled CLI.
3
+ import { spawn } from 'node:child_process';
4
+ import { fileURLToPath } from 'node:url';
5
+
3
6
  const [maj, min] = process.versions.node.split('.').map(Number);
4
7
  if (maj < 22 || (maj === 22 && min < 13)) {
5
8
  console.error(`Agent Studio needs Node >= 22.13 (found ${process.versions.node}).`);
6
9
  process.exit(1);
7
10
  }
8
- const { main } = await import('../lib/cli.mjs');
9
- process.exit(await main(process.argv.slice(2)));
11
+ const { main, RESTART_EXIT_CODE } = await import('../lib/cli.mjs');
12
+ const argv = process.argv.slice(2);
13
+ const code = await main(argv);
14
+ if (code !== RESTART_EXIT_CODE) process.exit(code);
15
+
16
+ // Updated from the UI: start the new version (fresh process, new files from disk) in this same terminal.
17
+ // The browser tab is already open and reloads itself.
18
+ const child = spawn(process.execPath, [fileURLToPath(import.meta.url), ...argv, ...(argv.includes('--no-open') ? [] : ['--no-open'])], { stdio: 'inherit' });
19
+ for (const sig of ['SIGINT', 'SIGTERM']) process.on(sig, () => child.kill(sig));
20
+ child.on('exit', (c) => process.exit(c ?? 0));