@agenticmail/cli 0.5.62 → 0.6.0

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 +68 -0
  2. package/dist/cli.js +120 -0
  3. package/package.json +6 -3
package/README.md CHANGED
@@ -95,6 +95,7 @@ All commands are available via `agenticmail <command>` or `npx @agenticmail/cli@
95
95
  | Command | Description |
96
96
  |---------|-------------|
97
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
+ | `agenticmail claudecode` | **Set up AgenticMail for Claude Code.** ✨ NEW — wires AgenticMail into Claude Code so every agent (Fola, John, …) becomes a callable subagent via the `Agent` tool, AND wakes automatically on incoming mail or tasks. No separate Anthropic key needed — workers ride on your existing Claude OAuth. See the [Claude Code Integration](#claude-code-integration) section below. |
98
99
 
99
100
  ### Service Management (Auto-Start on Boot)
100
101
 
@@ -352,6 +353,73 @@ The `call_agent` tool intelligently spawns sub-agents with:
352
353
 
353
354
  ---
354
355
 
356
+ ## Claude Code Integration
357
+
358
+ > ✨ **New in 0.6** — `@agenticmail/claudecode` brings the full AgenticMail multi-agent platform inside [Claude Code](https://claude.com/claude-code). Every AgenticMail agent becomes a callable Claude Code subagent, and agents auto-wake on incoming mail or tasks. **No separate Anthropic API key required — workers reuse your existing Claude OAuth.**
359
+
360
+ ```bash
361
+ agenticmail claudecode # install
362
+ agenticmail claudecode --status # check
363
+ agenticmail claudecode --remove # uninstall
364
+ ```
365
+
366
+ ### What it gives you
367
+
368
+ - **Every AgenticMail agent is callable from Claude Code via the native `Agent` tool.**
369
+ Inside any Claude Code session: `Agent { subagent_type: "agenticmail-fola", prompt: "..." }` — the subagent IS Fola, reads Fola's real inbox, sends mail from `fola@localhost`.
370
+
371
+ - **All 62 AgenticMail MCP tools available in Claude Code.**
372
+ `mcp__agenticmail__send_email`, `call_agent`, `list_inbox`, `sms_send`, … — works in any Claude Code session, no further setup.
373
+
374
+ - **Auto-wake on inbox / task events.**
375
+ Send an email to `fola@localhost`, post a `/tasks/rpc` for Fola, or `CC` her on a thread — a background dispatcher daemon (managed by PM2) spawns a Claude-powered worker to handle it. The worker submits results / replies; threads keep flowing.
376
+
377
+ - **Multi-agent coordination on email threads.**
378
+ Because every cross-agent reply lands in the recipient's inbox and wakes them, fan-out (CC three teammates) and reply chains "just work." No new infrastructure to learn — it's email.
379
+
380
+ - **Provision agents on the fly.**
381
+ `mcp__agenticmail__create_account({ name: "worker-7" })` — the new agent's API key is resolved on-demand by the MCP server, and the dispatcher picks it up within ~1 minute. No restart required.
382
+
383
+ - **Headless HTTP install endpoint** at `POST /api/agenticmail/integrations/claudecode/install`.
384
+ Lets an agent (or any script) wire itself in with a single curl. No master key needed for the install endpoint — see security model in the [package README](https://www.npmjs.com/package/@agenticmail/claudecode).
385
+
386
+ ### The "Claude Code is the brain" architecture
387
+
388
+ Each AgenticMail agent is a mailbox + persistent state + identity inside AgenticMail. This integration supplies the *thinking* by spawning a fresh Claude Code session for each wake — that session uses Claude Code's own Claude OAuth (the same auth `claude` itself uses), operates the target agent's mailbox via MCP tools scoped with `_account: "<name>"`, and exits when done.
389
+
390
+ ```
391
+ Anyone (you, an agent, a curl):
392
+ send mail to fola@localhost POST /tasks/rpc { target: "Fola", task: ... }
393
+ │ │
394
+ ▼ ▼
395
+ AgenticMail master API ──── task event ────→ dispatcher daemon (PM2)
396
+ │ │
397
+ │ SSE for fola's inbox ▼
398
+ └──────────────────────────────→ spawns worker via Claude Agent SDK
399
+
400
+
401
+ Worker IS Fola for this turn:
402
+ - reads inbox / claims task
403
+ - sends mail / submits result
404
+ - exits
405
+ ```
406
+
407
+ One Anthropic connection (your Claude OAuth). Many AgenticMail identities. Real email between them, real task RPC, real persistence.
408
+
409
+ ### Quick example
410
+
411
+ After `agenticmail claudecode`, restart Claude Code and try in any session:
412
+
413
+ ```
414
+ Agent { subagent_type: "agenticmail-fola", prompt: "Use call_agent to ask the 'researcher' agent to summarise AgenticMail in two sentences, then email me the summary." }
415
+ ```
416
+
417
+ Fola will use the AgenticMail RPC pipeline to delegate to `researcher`, get a structured result back, and email the summary to her caller — all powered by Claude Code's OAuth, no separate keys, no broken enterprise dependencies.
418
+
419
+ See [`@agenticmail/claudecode` on npm](https://www.npmjs.com/package/@agenticmail/claudecode) for the full design doc, security model, and HTTP API reference.
420
+
421
+ ---
422
+
355
423
  ## Programmatic Usage
356
424
 
357
425
  The package re-exports everything from `@agenticmail/core`, so you can use it as an SDK:
package/dist/cli.js CHANGED
@@ -5591,6 +5591,117 @@ function mergePluginConfig(existing, apiUrl, masterKey, agentApiKey, pluginDir)
5591
5591
  }
5592
5592
  return result;
5593
5593
  }
5594
+ async function cmdClaudeCode() {
5595
+ const sub = process.argv.slice(3);
5596
+ if (sub.includes("--help") || sub.includes("-h") || sub.includes("help")) {
5597
+ log2("");
5598
+ log2(` ${c2.pinkBg(" \u{1F380} AgenticMail for Claude Code ")}`);
5599
+ log2("");
5600
+ log2(` ${c2.bold("Usage:")} agenticmail claudecode [flags]`);
5601
+ log2("");
5602
+ log2(" Registers AgenticMail with Claude Code so every Claude Code session");
5603
+ log2(" can call AgenticMail agents (Fola, John, \u2026) the same way it calls");
5604
+ log2(" native subagents via the Agent tool.");
5605
+ log2("");
5606
+ log2(" Specifically, this command:");
5607
+ log2(` ${c2.dim("1.")} Provisions a dedicated "claudecode" AgenticMail agent (Claude Code's identity)`);
5608
+ log2(` ${c2.dim("2.")} Writes an MCP server entry into ~/.claude.json`);
5609
+ log2(` ${c2.dim("3.")} Generates one Claude Code subagent file per AgenticMail agent`);
5610
+ log2(` (in ${c2.cyan("~/.claude/agents/agenticmail-<name>.md")})`);
5611
+ log2("");
5612
+ log2(` ${c2.bold("Flags:")}`);
5613
+ log2(` ${c2.green("--status")} Show what's currently installed and exit`);
5614
+ log2(` ${c2.green("--remove")} Uninstall (keeps the bridge agent by default)`);
5615
+ log2(` ${c2.green("--purge-bridge")} When used with --remove, also delete the bridge agent`);
5616
+ log2(` ${c2.green("-h, --help")} Show this help and exit`);
5617
+ log2("");
5618
+ log2(` After install, restart Claude Code so it picks up the new MCP server.`);
5619
+ log2("");
5620
+ return;
5621
+ }
5622
+ let mod;
5623
+ try {
5624
+ mod = await import("@agenticmail/claudecode");
5625
+ } catch (err) {
5626
+ fail2(`Could not load @agenticmail/claudecode: ${err.message}`);
5627
+ log2("");
5628
+ info2(`Install it with: ${c2.green("npm install -g @agenticmail/claudecode")}`);
5629
+ process.exit(1);
5630
+ return;
5631
+ }
5632
+ if (sub.includes("--status")) {
5633
+ const s = await mod.status();
5634
+ log2("");
5635
+ log2(` ${c2.pinkBg(" \u{1F380} AgenticMail for Claude Code ")}`);
5636
+ log2("");
5637
+ const stateLabel = s.state === "installed" ? c2.green("installed") : s.state === "partial" ? c2.yellow("partial") : c2.dim("not installed");
5638
+ log2(` Status: ${stateLabel}`);
5639
+ log2(` MCP server registered: ${s.mcpInstalled ? c2.green("yes") : c2.dim("no")}`);
5640
+ log2(` Bridge agent in AgenticMail: ${s.bridgeAgentExists ? c2.green("yes") : c2.dim("no")}`);
5641
+ log2(` Subagent files: ${s.subagents.length > 0 ? c2.green(String(s.subagents.length)) : c2.dim("0")}`);
5642
+ if (s.subagents.length > 0) for (const name of s.subagents) info2(` \u2022 ${name}`);
5643
+ if (s.notes.length > 0) {
5644
+ log2("");
5645
+ log2(` ${c2.bold("Notes:")}`);
5646
+ for (const n of s.notes) info2(` \u2022 ${n}`);
5647
+ }
5648
+ log2("");
5649
+ process.exit(s.state === "installed" ? 0 : 1);
5650
+ }
5651
+ if (sub.includes("--remove") || sub.includes("--uninstall")) {
5652
+ log2("");
5653
+ log2(` ${c2.pinkBg(" \u{1F380} Removing AgenticMail from Claude Code ")}`);
5654
+ log2("");
5655
+ const purgeBridge = sub.includes("--purge-bridge");
5656
+ const result2 = await mod.uninstall({ purgeBridgeAgent: purgeBridge });
5657
+ if (result2.mcpBlockRemoved) ok2("Removed MCP server entry from Claude Code config");
5658
+ else info2("No MCP server entry was registered.");
5659
+ if (result2.removedSubagents.length > 0) ok2(`Removed ${result2.removedSubagents.length} subagent file(s)`);
5660
+ else info2("No subagent files were registered.");
5661
+ if (result2.bridgeAgentDeleted) ok2("Deleted bridge agent from AgenticMail");
5662
+ else if (purgeBridge) info2("Bridge agent could not be deleted (already gone or AgenticMail unreachable).");
5663
+ log2("");
5664
+ if (!result2.changed) info2("Nothing to remove.");
5665
+ log2("");
5666
+ return;
5667
+ }
5668
+ log2("");
5669
+ log2(` ${c2.pinkBg(" \u{1F380} AgenticMail for Claude Code ")}`);
5670
+ log2("");
5671
+ log2(` ${c2.bold("Wiring AgenticMail into Claude Code.")} This will:`);
5672
+ log2(` ${c2.dim("1.")} Provision a "claudecode" agent inside AgenticMail`);
5673
+ log2(` ${c2.dim("2.")} Add an MCP server entry to ~/.claude.json`);
5674
+ log2(` ${c2.dim("3.")} Generate one Claude Code subagent file per AgenticMail agent`);
5675
+ log2("");
5676
+ const spinner = new Spinner("general", "Talking to AgenticMail\u2026");
5677
+ spinner.start();
5678
+ let result;
5679
+ try {
5680
+ result = await mod.install();
5681
+ spinner.succeed("Integration installed");
5682
+ } catch (err) {
5683
+ spinner.fail(`Install failed: ${err.message}`);
5684
+ log2("");
5685
+ if (err.status === 0) {
5686
+ info2(`Is the AgenticMail server running? Try: ${c2.green("agenticmail start")}`);
5687
+ }
5688
+ log2("");
5689
+ process.exit(1);
5690
+ return;
5691
+ }
5692
+ ok2(`Bridge agent ${c2.bold(result.bridgeAgent.name)} ${c2.dim("(" + result.bridgeAgent.email + ")")}`);
5693
+ ok2(`MCP server registered in ${c2.cyan(result.claudeConfigPath)}`);
5694
+ ok2(`${result.registeredAgents.length} Claude Code subagent${result.registeredAgents.length === 1 ? "" : "s"} written to ${c2.cyan(result.agentsDir)}`);
5695
+ for (const a of result.registeredAgents) info2(` \u2022 agenticmail-${a.name.toLowerCase()} \u2192 ${a.email}`);
5696
+ log2("");
5697
+ if (!result.changed) {
5698
+ info2("Already up to date \u2014 no files were modified.");
5699
+ } else {
5700
+ log2(` ${c2.bold("Next:")} restart Claude Code so it picks up the new MCP server.`);
5701
+ info2(`Try inside Claude Code: ${c2.green('Agent { subagent_type: "agenticmail-fola", prompt: "hi" }')}`);
5702
+ }
5703
+ log2("");
5704
+ }
5594
5705
  async function cmdOpenClaw() {
5595
5706
  const sub = process.argv.slice(3);
5596
5707
  if (sub.includes("--help") || sub.includes("-h") || sub.includes("help")) {
@@ -6732,6 +6843,14 @@ switch (command) {
6732
6843
  process.exit(1);
6733
6844
  });
6734
6845
  break;
6846
+ case "claudecode":
6847
+ case "claude-code":
6848
+ case "claude":
6849
+ cmdClaudeCode().catch((err) => {
6850
+ console.error(err);
6851
+ process.exit(1);
6852
+ });
6853
+ break;
6735
6854
  case "service":
6736
6855
  cmdService().then(() => {
6737
6856
  process.exit(0);
@@ -6774,6 +6893,7 @@ switch (command) {
6774
6893
  log2(` ${c2.green("agenticmail stop")} Stop the server`);
6775
6894
  log2(` ${c2.green("agenticmail status")} See what's running`);
6776
6895
  log2(` ${c2.green("agenticmail openclaw")} Set up AgenticMail for OpenClaw`);
6896
+ log2(` ${c2.green("agenticmail claudecode")} Set up AgenticMail for Claude Code`);
6777
6897
  log2(` ${c2.green("agenticmail service")} Manage auto-start (install/uninstall/status)`);
6778
6898
  log2(` ${c2.green("agenticmail update")} Update to the latest version`);
6779
6899
  log2("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/cli",
3
- "version": "0.5.62",
3
+ "version": "0.6.0",
4
4
  "description": "Email and SMS infrastructure for AI agents — the first platform to give agents real email addresses and phone numbers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,16 +22,19 @@
22
22
  "LICENSE"
23
23
  ],
24
24
  "scripts": {
25
- "build": "tsup src/index.ts src/cli.ts --format esm --dts --clean",
25
+ "build": "tsup src/index.ts src/cli.ts --format esm --dts --clean --external @agenticmail/claudecode",
26
26
  "test": "vitest run --passWithNoTests",
27
27
  "preuninstall": "node scripts/uninstall.mjs",
28
28
  "prepublishOnly": "npm run build"
29
29
  },
30
30
  "dependencies": {
31
- "@agenticmail/api": "^0.5.62",
31
+ "@agenticmail/api": "^0.6.0",
32
32
  "@agenticmail/core": "^0.5.61",
33
33
  "json5": "^2.2.3"
34
34
  },
35
+ "optionalDependencies": {
36
+ "@agenticmail/claudecode": "^0.1.0"
37
+ },
35
38
  "devDependencies": {
36
39
  "tsup": "^8.4.0",
37
40
  "typescript": "^5.7.0",