agenticmail 0.3.4 → 0.3.5

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 +100 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3356,10 +3356,108 @@ ${c.dim(boxChar.bl + boxChar.h.repeat(bWidth) + boxChar.br)}`);
3356
3356
  }
3357
3357
  },
3358
3358
  setup: {
3359
- desc: "Re-run the setup wizard",
3359
+ desc: "Set up email connection",
3360
3360
  run: async () => {
3361
3361
  log("");
3362
- info("Run: agenticmail setup");
3362
+ log(` ${c.bold("Email Setup")}`);
3363
+ log("");
3364
+ log(` ${c.cyan("1.")} Gmail`);
3365
+ log(` ${c.cyan("2.")} Outlook / Hotmail`);
3366
+ log(` ${c.cyan("3.")} Skip`);
3367
+ log("");
3368
+ const provChoice = await question(` ${c.dim(">")}: `);
3369
+ if (isBack(provChoice)) {
3370
+ log("");
3371
+ return;
3372
+ }
3373
+ const ch = provChoice.trim();
3374
+ if (ch === "3") {
3375
+ info("Skipped. You can run /setup anytime.");
3376
+ log("");
3377
+ return;
3378
+ }
3379
+ let provider;
3380
+ if (ch === "1") provider = "gmail";
3381
+ else if (ch === "2") provider = "outlook";
3382
+ else {
3383
+ fail("Invalid choice.");
3384
+ log("");
3385
+ return;
3386
+ }
3387
+ const email = await question(` ${c.cyan("Your email address:")} `);
3388
+ if (isBack(email) || !email.trim()) {
3389
+ log("");
3390
+ return;
3391
+ }
3392
+ log("");
3393
+ if (provider === "gmail") {
3394
+ info("You need a Gmail App Password.");
3395
+ info(`Go to ${c.cyan("https://myaccount.google.com/apppasswords")}`);
3396
+ info("Create one and paste it below (spaces are fine).");
3397
+ } else {
3398
+ info("You need an Outlook App Password from your account security settings.");
3399
+ }
3400
+ log("");
3401
+ const agentNameInput = await question(` ${c.cyan("Agent name")} ${c.dim("(secretary)")}: `);
3402
+ if (isBack(agentNameInput)) {
3403
+ log("");
3404
+ return;
3405
+ }
3406
+ const agentName = agentNameInput.trim() || "secretary";
3407
+ for (let attempt = 1; attempt <= 3; attempt++) {
3408
+ const rawPassword = await question(` ${c.cyan("App password:")} `);
3409
+ if (isBack(rawPassword)) {
3410
+ log("");
3411
+ return;
3412
+ }
3413
+ const password = rawPassword.replace(/\s+/g, "");
3414
+ if (!password) {
3415
+ fail("Password cannot be empty.");
3416
+ continue;
3417
+ }
3418
+ log("");
3419
+ info("Connecting...");
3420
+ try {
3421
+ const resp = await apiFetch("/api/agenticmail/gateway/relay", {
3422
+ method: "POST",
3423
+ body: JSON.stringify({ provider, email: email.trim(), password, agentName }),
3424
+ signal: AbortSignal.timeout(3e4)
3425
+ });
3426
+ if (!resp.ok) {
3427
+ const text = await resp.text();
3428
+ let parsed = {};
3429
+ try {
3430
+ parsed = JSON.parse(text);
3431
+ } catch {
3432
+ }
3433
+ const error = parsed.error || text;
3434
+ const isAuth = /Username and Password not accepted|Invalid login|Authentication failed|AUTHENTICATIONFAILED|Invalid credentials|535/.test(error);
3435
+ if (isAuth && attempt < 3) {
3436
+ fail("Incorrect email or password.");
3437
+ info(`Let's try again. (attempt ${attempt} of 3)`);
3438
+ log("");
3439
+ continue;
3440
+ }
3441
+ fail(error.slice(0, 200));
3442
+ log("");
3443
+ return;
3444
+ }
3445
+ const data = await resp.json();
3446
+ ok("Email connected!");
3447
+ if (data.agent) {
3448
+ ok(`Agent ${c.bold('"' + data.agent.name + '"')} is ready!`);
3449
+ log(` ${c.dim("Email:")} ${c.cyan(data.agent.subAddress)}`);
3450
+ log(` ${c.dim("Key:")} ${c.yellow(data.agent.apiKey)}`);
3451
+ currentAgent = { name: data.agent.name, email: data.agent.email || data.agent.subAddress, apiKey: data.agent.apiKey };
3452
+ }
3453
+ log("");
3454
+ return;
3455
+ } catch (err) {
3456
+ fail(`Connection failed: ${errMsg(err)}`);
3457
+ log("");
3458
+ return;
3459
+ }
3460
+ }
3363
3461
  log("");
3364
3462
  }
3365
3463
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenticmail",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Email infrastructure for AI agents — send and receive real email programmatically",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",