agenticmail 0.5.0 → 0.5.1

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 +138 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -9,7 +9,8 @@ import { createRequire } from "module";
9
9
  import { homedir } from "os";
10
10
  import JSON5 from "json5";
11
11
  import {
12
- SetupManager
12
+ SetupManager,
13
+ ServiceManager
13
14
  } from "@agenticmail/core";
14
15
 
15
16
  // src/shell.ts
@@ -4428,6 +4429,10 @@ async function startApiServer(config) {
4428
4429
  const { spawn } = await import("child_process");
4429
4430
  const apiEntry = resolveApiEntry();
4430
4431
  const env = configToEnv(config);
4432
+ try {
4433
+ new ServiceManager().cacheApiEntryPath(apiEntry);
4434
+ } catch {
4435
+ }
4431
4436
  const child = spawn(process.execPath, [apiEntry], {
4432
4437
  detached: true,
4433
4438
  stdio: "ignore",
@@ -4879,6 +4884,23 @@ async function cmdSetup() {
4879
4884
  log2("");
4880
4885
  await registerWithOpenClaw(result.config);
4881
4886
  }
4887
+ if (serverReady) {
4888
+ const svcSpinner = new Spinner("general", "Setting up auto-start...");
4889
+ svcSpinner.start();
4890
+ try {
4891
+ const svc = new ServiceManager();
4892
+ const svcResult = svc.install();
4893
+ if (svcResult.installed) {
4894
+ svcSpinner.succeed(`${c2.bold("Auto-start")} \u2014 AgenticMail will start on boot`);
4895
+ } else {
4896
+ svcSpinner.fail(`Auto-start: ${svcResult.message}`);
4897
+ info2("You can set this up later with: agenticmail service install");
4898
+ }
4899
+ } catch (err) {
4900
+ svcSpinner.fail(`Auto-start: ${err.message}`);
4901
+ }
4902
+ await new Promise((r) => setTimeout(r, 300));
4903
+ }
4882
4904
  printSummary(result, false);
4883
4905
  if (serverReady) {
4884
4906
  await interactiveShell({ config: result.config, onExit: () => {
@@ -6223,6 +6245,23 @@ async function cmdStatus() {
6223
6245
  info2("Can't check email status \u2014 server isn't running");
6224
6246
  }
6225
6247
  log2("");
6248
+ log2(` ${c2.bold("Auto-Start:")}`);
6249
+ try {
6250
+ const svc = new ServiceManager();
6251
+ const svcStatus = svc.status();
6252
+ if (svcStatus.installed) {
6253
+ if (svcStatus.running) {
6254
+ ok2(`Enabled ${c2.dim(`(${svcStatus.platform}) \u2014 starts on boot`)}`);
6255
+ } else {
6256
+ ok2(`Installed ${c2.dim(`(${svcStatus.platform})`)} \u2014 ${c2.yellow("not currently running")}`);
6257
+ }
6258
+ } else {
6259
+ fail2(`Not installed ${c2.dim("\u2014 run: agenticmail service install")}`);
6260
+ }
6261
+ } catch {
6262
+ info2("Could not check auto-start status");
6263
+ }
6264
+ log2("");
6226
6265
  }
6227
6266
  async function cmdStart() {
6228
6267
  const setup = new SetupManager();
@@ -6273,19 +6312,107 @@ async function cmdStart() {
6273
6312
  serverSpinner.fail(`Couldn't start the server: ${err.message}`);
6274
6313
  process.exit(1);
6275
6314
  }
6315
+ try {
6316
+ const svc = new ServiceManager();
6317
+ const svcStatus = svc.status();
6318
+ if (!svcStatus.installed) {
6319
+ const svcResult = svc.install();
6320
+ if (svcResult.installed) {
6321
+ ok2(`${c2.bold("Auto-start")} enabled \u2014 survives reboots`);
6322
+ }
6323
+ }
6324
+ } catch {
6325
+ }
6276
6326
  await interactiveShell({ config, onExit: () => {
6277
6327
  } });
6278
6328
  }
6279
6329
  async function cmdStop() {
6280
6330
  log2("");
6281
6331
  const stopped = stopApiServer();
6282
- if (stopped) {
6332
+ const svc = new ServiceManager();
6333
+ const svcStatus = svc.status();
6334
+ if (svcStatus.installed && svcStatus.running) {
6335
+ try {
6336
+ if (svcStatus.platform === "launchd") {
6337
+ const { execFileSync } = await import("child_process");
6338
+ execFileSync("launchctl", ["unload", svcStatus.servicePath], { timeout: 1e4, stdio: "ignore" });
6339
+ } else if (svcStatus.platform === "systemd") {
6340
+ const { execFileSync } = await import("child_process");
6341
+ execFileSync("systemctl", ["--user", "stop", "agenticmail.service"], { timeout: 1e4, stdio: "ignore" });
6342
+ }
6343
+ } catch {
6344
+ }
6345
+ }
6346
+ if (stopped || svcStatus.installed && svcStatus.running) {
6283
6347
  ok2("AgenticMail server stopped");
6348
+ if (svcStatus.installed) {
6349
+ info2("Auto-start is still enabled. It will restart on next boot.");
6350
+ info2(`To disable: ${c2.green("agenticmail service uninstall")}`);
6351
+ }
6284
6352
  } else {
6285
6353
  info2("Server is not running");
6286
6354
  }
6287
6355
  log2("");
6288
6356
  }
6357
+ async function cmdService() {
6358
+ const subCmd = process.argv[3] || "status";
6359
+ const svc = new ServiceManager();
6360
+ log2("");
6361
+ switch (subCmd) {
6362
+ case "install": {
6363
+ const result = svc.install();
6364
+ if (result.installed) {
6365
+ ok2(`Auto-start service installed`);
6366
+ info2(result.message);
6367
+ info2("AgenticMail will now start automatically when your computer boots.");
6368
+ } else {
6369
+ fail2(result.message);
6370
+ }
6371
+ break;
6372
+ }
6373
+ case "uninstall":
6374
+ case "remove": {
6375
+ const result = svc.uninstall();
6376
+ if (result.removed) {
6377
+ ok2("Auto-start service removed");
6378
+ info2("AgenticMail will no longer start on boot.");
6379
+ } else {
6380
+ fail2(result.message);
6381
+ }
6382
+ break;
6383
+ }
6384
+ case "reinstall": {
6385
+ const result = svc.reinstall();
6386
+ if (result.installed) {
6387
+ ok2("Auto-start service reinstalled");
6388
+ info2(result.message);
6389
+ } else {
6390
+ fail2(result.message);
6391
+ }
6392
+ break;
6393
+ }
6394
+ case "status":
6395
+ default: {
6396
+ const status = svc.status();
6397
+ log2(` ${c2.bold("Auto-Start Service")}`);
6398
+ log2("");
6399
+ if (status.installed) {
6400
+ ok2(`Installed ${c2.dim(`(${status.platform})`)}`);
6401
+ if (status.running) {
6402
+ ok2(`Running`);
6403
+ } else {
6404
+ fail2(`Not running ${c2.dim("\u2014 will start on next boot or: agenticmail service reinstall")}`);
6405
+ }
6406
+ info2(`Service file: ${status.servicePath}`);
6407
+ } else {
6408
+ fail2("Not installed");
6409
+ info2(`Install with: ${c2.green("agenticmail service install")}`);
6410
+ }
6411
+ break;
6412
+ }
6413
+ }
6414
+ log2("");
6415
+ }
6289
6416
  async function cmdUpdate() {
6290
6417
  const { execSync } = await import("child_process");
6291
6418
  log2("");
@@ -6410,6 +6537,14 @@ switch (command) {
6410
6537
  process.exit(1);
6411
6538
  });
6412
6539
  break;
6540
+ case "service":
6541
+ cmdService().then(() => {
6542
+ process.exit(0);
6543
+ }).catch((err) => {
6544
+ console.error(err);
6545
+ process.exit(1);
6546
+ });
6547
+ break;
6413
6548
  case "update":
6414
6549
  cmdUpdate().catch((err) => {
6415
6550
  console.error(err);
@@ -6429,6 +6564,7 @@ switch (command) {
6429
6564
  log2(` ${c2.green("agenticmail stop")} Stop the server`);
6430
6565
  log2(` ${c2.green("agenticmail status")} See what's running`);
6431
6566
  log2(` ${c2.green("agenticmail openclaw")} Set up AgenticMail for OpenClaw`);
6567
+ log2(` ${c2.green("agenticmail service")} Manage auto-start (install/uninstall/status)`);
6432
6568
  log2(` ${c2.green("agenticmail update")} Update to the latest version`);
6433
6569
  log2("");
6434
6570
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenticmail",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Email infrastructure for AI agents — send and receive real email programmatically",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",