agenticmail 0.3.5 → 0.3.7

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 +110 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -580,7 +580,7 @@ async function interactiveShell(options) {
580
580
  }
581
581
  },
582
582
  agents: {
583
- desc: "List all agents",
583
+ desc: "List agents or create a new one",
584
584
  run: async () => {
585
585
  log("");
586
586
  try {
@@ -593,7 +593,7 @@ async function interactiveShell(options) {
593
593
  const data = await resp.json();
594
594
  const agents = data.agents || data || [];
595
595
  if (agents.length === 0) {
596
- info("No agents yet. Run /setup to create one.");
596
+ info("No agents yet.");
597
597
  } else {
598
598
  for (const agent of agents) {
599
599
  const owner = agent.metadata?.ownerName;
@@ -607,6 +607,68 @@ async function interactiveShell(options) {
607
607
  info("Use /switch to change active agent");
608
608
  }
609
609
  }
610
+ log("");
611
+ log(` ${c.green("[1]")} Create new agent`);
612
+ log(` ${c.green("[2]")} Back`);
613
+ log("");
614
+ const choice = await question(` ${c.dim(">")}: `);
615
+ if (isBack(choice) || choice.trim() === "2") {
616
+ log("");
617
+ return;
618
+ }
619
+ if (choice.trim() !== "1") {
620
+ log("");
621
+ return;
622
+ }
623
+ log("");
624
+ const nameInput = await question(` ${c.cyan("Agent name:")} `);
625
+ if (isBack(nameInput) || !nameInput.trim()) {
626
+ log("");
627
+ return;
628
+ }
629
+ const agentName = nameInput.trim();
630
+ log("");
631
+ log(` ${c.bold("Role")}`);
632
+ log(` ${c.green("[1]")} secretary ${c.dim("(default)")}`);
633
+ log(` ${c.green("[2]")} assistant`);
634
+ log(` ${c.green("[3]")} researcher`);
635
+ log(` ${c.green("[4]")} writer`);
636
+ log(` ${c.green("[5]")} custom`);
637
+ log("");
638
+ const roleChoice = await question(` ${c.dim(">")}: `);
639
+ if (isBack(roleChoice)) {
640
+ log("");
641
+ return;
642
+ }
643
+ const roles = ["secretary", "assistant", "researcher", "writer", "custom"];
644
+ const roleIdx = parseInt(roleChoice.trim()) - 1;
645
+ const role = roleIdx >= 0 && roleIdx < roles.length ? roles[roleIdx] : "secretary";
646
+ log("");
647
+ info("Creating agent...");
648
+ const createResp = await apiFetch("/api/agenticmail/accounts", {
649
+ method: "POST",
650
+ body: JSON.stringify({ name: agentName, role }),
651
+ signal: AbortSignal.timeout(15e3)
652
+ });
653
+ if (!createResp.ok) {
654
+ const text = await createResp.text();
655
+ let parsed = {};
656
+ try {
657
+ parsed = JSON.parse(text);
658
+ } catch {
659
+ }
660
+ fail(parsed.error || text);
661
+ log("");
662
+ return;
663
+ }
664
+ const created = await createResp.json();
665
+ ok(`Agent ${c.bold('"' + created.name + '"')} created!`);
666
+ log(` ${c.dim("Email:")} ${c.cyan(created.email || created.subAddress || "")}`);
667
+ log(` ${c.dim("Key:")} ${c.yellow(created.apiKey)}`);
668
+ log(` ${c.dim("Role:")} ${role}`);
669
+ currentAgent = { name: created.name, email: created.email || created.subAddress, apiKey: created.apiKey };
670
+ ok(`Switched to ${c.bold(created.name)}`);
671
+ log("");
610
672
  } catch (err) {
611
673
  fail(`Error: ${errMsg(err)}`);
612
674
  }
@@ -3361,6 +3423,52 @@ ${c.dim(boxChar.bl + boxChar.h.repeat(bWidth) + boxChar.br)}`);
3361
3423
  log("");
3362
3424
  log(` ${c.bold("Email Setup")}`);
3363
3425
  log("");
3426
+ let existingEmail = null;
3427
+ let existingProvider = null;
3428
+ try {
3429
+ const statusResp = await apiFetch("/api/agenticmail/gateway/status");
3430
+ if (statusResp.ok) {
3431
+ const status = await statusResp.json();
3432
+ if (status.mode === "relay" && status.relay?.email) {
3433
+ existingEmail = status.relay.email;
3434
+ existingProvider = status.relay.provider || "custom";
3435
+ }
3436
+ }
3437
+ } catch {
3438
+ }
3439
+ if (existingEmail) {
3440
+ const provLabel = existingProvider === "gmail" ? "Gmail" : existingProvider === "outlook" ? "Outlook" : existingProvider;
3441
+ log(` ${c.dim("Currently connected:")} ${c.cyan(existingEmail)} ${c.dim(`(${provLabel})`)}`);
3442
+ log("");
3443
+ log(` ${c.green("[1]")} Keep current email`);
3444
+ log(` ${c.green("[2]")} Remove and connect a different email`);
3445
+ log(` ${c.green("[3]")} Set up a custom domain`);
3446
+ log("");
3447
+ const existChoice = await question(` ${c.dim(">")}: `);
3448
+ if (isBack(existChoice)) {
3449
+ log("");
3450
+ return;
3451
+ }
3452
+ const ec = existChoice.trim();
3453
+ if (ec === "1" || !ec) {
3454
+ ok(`Keeping ${c.cyan(existingEmail)}`);
3455
+ log("");
3456
+ return;
3457
+ }
3458
+ if (ec === "3") {
3459
+ info("Custom domain setup is available via the API.");
3460
+ info(`Run: ${c.cyan("POST /api/agenticmail/gateway/domain")}`);
3461
+ info("You need a Cloudflare account with API token and account ID.");
3462
+ log("");
3463
+ return;
3464
+ }
3465
+ if (ec !== "2") {
3466
+ fail("Invalid choice.");
3467
+ log("");
3468
+ return;
3469
+ }
3470
+ log("");
3471
+ }
3364
3472
  log(` ${c.cyan("1.")} Gmail`);
3365
3473
  log(` ${c.cyan("2.")} Outlook / Hotmail`);
3366
3474
  log(` ${c.cyan("3.")} Skip`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenticmail",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Email infrastructure for AI agents — send and receive real email programmatically",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",