agenticmail 0.5.0 → 0.5.2

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 (3) hide show
  1. package/README.md +61 -0
  2. package/dist/cli.js +138 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -76,6 +76,66 @@ Agent emails use proper addresses like `secretary@yourdomain.com`.
76
76
 
77
77
  ---
78
78
 
79
+ ## CLI Commands
80
+
81
+ All commands are available via `agenticmail <command>` or `npx agenticmail@latest <command>`.
82
+
83
+ ### Core Commands
84
+
85
+ | Command | Description |
86
+ |---------|-------------|
87
+ | `agenticmail` | **Start the server.** Runs setup first if not initialized, then starts all services and opens the interactive shell. This is the default — just run `agenticmail` with no arguments. |
88
+ | `agenticmail setup` | **Run the setup wizard.** Walks you through system checks, account creation, service startup, email connection, phone number setup, and OpenClaw integration. Safe to re-run anytime. |
89
+ | `agenticmail start` | **Start the server and open the interactive shell.** Ensures Docker is running, Stalwart is up, and the API server is reachable. Automatically installs the auto-start service. |
90
+ | `agenticmail stop` | **Stop the server.** Kills the background API server process. If auto-start is enabled, it will restart on next boot. |
91
+ | `agenticmail status` | **Show what's running.** Displays Docker, Stalwart, API server, email connection, and auto-start service status. |
92
+
93
+ ### Integration Commands
94
+
95
+ | Command | Description |
96
+ |---------|-------------|
97
+ | `agenticmail openclaw` | **Set up AgenticMail for OpenClaw.** Starts infrastructure, creates an agent, configures the plugin, enables agent auto-spawn via hooks, and restarts the OpenClaw gateway. |
98
+
99
+ ### Service Management (Auto-Start on Boot)
100
+
101
+ AgenticMail installs a system service so your email server starts automatically when your computer boots — no manual intervention needed.
102
+
103
+ | Command | Description |
104
+ |---------|-------------|
105
+ | `agenticmail service` | **Show auto-start status.** Whether the service is installed and running. |
106
+ | `agenticmail service install` | **Install the auto-start service.** On boot, the startup script waits up to 10 minutes for Docker, checks Stalwart (starts it if needed), then launches the API server. |
107
+ | `agenticmail service uninstall` | **Remove the auto-start service.** AgenticMail will no longer start on boot. |
108
+ | `agenticmail service reinstall` | **Reinstall the service.** Use after config changes or updates to refresh the service file. |
109
+
110
+ **How auto-start works on reboot:**
111
+ 1. Computer starts → Docker Desktop launches (its own auto-start)
112
+ 2. Stalwart mail server starts (`restart: unless-stopped` in Docker)
113
+ 3. AgenticMail startup script waits for Docker to be ready (up to 10 min)
114
+ 4. Script verifies Stalwart is running (auto-starts it if needed)
115
+ 5. API server starts and begins accepting requests
116
+ 6. If the server crashes, the system service automatically restarts it
117
+
118
+ On macOS this uses a LaunchAgent (`~/Library/LaunchAgents/com.agenticmail.server.plist`). On Linux it uses a systemd user service (`~/.config/systemd/user/agenticmail.service`).
119
+
120
+ ### Maintenance Commands
121
+
122
+ | Command | Description |
123
+ |---------|-------------|
124
+ | `agenticmail update` | **Update to the latest version.** Checks npm, updates the CLI and OpenClaw plugin, and restarts the gateway. |
125
+ | `agenticmail help` | **Show available commands.** |
126
+
127
+ ### Logs
128
+
129
+ Server logs are stored in `~/.agenticmail/logs/`:
130
+
131
+ | File | Contents |
132
+ |------|----------|
133
+ | `server.log` | API server stdout |
134
+ | `server.err.log` | API server stderr |
135
+ | `startup.log` | Boot sequence log — Docker wait times, Stalwart checks, startup events |
136
+
137
+ ---
138
+
79
139
  ## Starting the Server
80
140
 
81
141
  `agenticmail start` does three things:
@@ -98,6 +158,7 @@ If the server crashes, you get clear error output showing what went wrong.
98
158
  - **Account setup** — whether the config file and database exist
99
159
  - **Server health** — API server connectivity and Stalwart reachability
100
160
  - **Email gateway** — current mode (relay or domain), provider name, domain name, polling status
161
+ - **Auto-start** — whether the system service is installed and running
101
162
 
102
163
  ---
103
164
 
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.2",
4
4
  "description": "Email infrastructure for AI agents — send and receive real email programmatically",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",