agenticmail 0.5.30 → 0.5.31

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/cli.js +26 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -4469,11 +4469,22 @@ var PID_FILE = join(homedir(), ".agenticmail", "server.pid");
4469
4469
  async function startApiServer(config) {
4470
4470
  const host = config.api.host;
4471
4471
  const port = config.api.port;
4472
+ const base = `http://${host}:${port}`;
4472
4473
  try {
4473
- const probe = await fetch(`http://${host}:${port}/api/agenticmail/health`, {
4474
+ const probe = await fetch(`${base}/api/agenticmail/health`, {
4474
4475
  signal: AbortSignal.timeout(2e3)
4475
4476
  });
4476
- if (probe.ok) return true;
4477
+ if (probe.ok) {
4478
+ const authProbe = await fetch(`${base}/api/agenticmail/gateway/status`, {
4479
+ headers: { "Authorization": `Bearer ${config.masterKey}` },
4480
+ signal: AbortSignal.timeout(2e3)
4481
+ });
4482
+ if (authProbe.ok || authProbe.status !== 401) {
4483
+ return true;
4484
+ }
4485
+ await killProcessOnPort(port);
4486
+ await new Promise((r) => setTimeout(r, 500));
4487
+ }
4477
4488
  } catch {
4478
4489
  }
4479
4490
  const { spawn } = await import("child_process");
@@ -4497,6 +4508,19 @@ async function startApiServer(config) {
4497
4508
  }
4498
4509
  return waitForApi(host, port);
4499
4510
  }
4511
+ async function killProcessOnPort(port) {
4512
+ try {
4513
+ const { execSync } = await import("child_process");
4514
+ const pids = execSync(`lsof -ti :${port}`, { timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).toString().trim().split("\n").filter(Boolean);
4515
+ for (const pid of pids) {
4516
+ try {
4517
+ process.kill(parseInt(pid, 10), "SIGTERM");
4518
+ } catch {
4519
+ }
4520
+ }
4521
+ } catch {
4522
+ }
4523
+ }
4500
4524
  function stopApiServer() {
4501
4525
  try {
4502
4526
  if (!existsSync2(PID_FILE)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenticmail",
3
- "version": "0.5.30",
3
+ "version": "0.5.31",
4
4
  "description": "Email and SMS infrastructure for AI agents \u2014 the first platform to give agents real email addresses and phone numbers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",