agenticmail 0.5.30 → 0.5.32

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 +49 -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;
@@ -6397,6 +6421,29 @@ async function cmdStart() {
6397
6421
  }
6398
6422
  } catch {
6399
6423
  }
6424
+ try {
6425
+ const base = `http://${config.api.host}:${config.api.port}`;
6426
+ const gwResp = await fetch(`${base}/api/agenticmail/gateway/status`, {
6427
+ headers: { "Authorization": `Bearer ${config.masterKey}` },
6428
+ signal: AbortSignal.timeout(5e3)
6429
+ });
6430
+ if (gwResp.ok) {
6431
+ const gwStatus = await gwResp.json();
6432
+ if (gwStatus.mode === "none" || !gwStatus.mode) {
6433
+ log2("");
6434
+ log2(` ${c2.dim("\u2500".repeat(50))}`);
6435
+ log2("");
6436
+ log2(` ${c2.yellow("!")} No email connected yet. Your agent can't send or receive email.`);
6437
+ log2("");
6438
+ const finish = await ask(` Run the setup wizard to finish? (Y/n) `);
6439
+ if (!finish.toLowerCase().startsWith("n")) {
6440
+ await cmdSetup();
6441
+ return;
6442
+ }
6443
+ }
6444
+ }
6445
+ } catch {
6446
+ }
6400
6447
  await interactiveShell({ config, onExit: () => {
6401
6448
  } });
6402
6449
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenticmail",
3
- "version": "0.5.30",
3
+ "version": "0.5.32",
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",