agenticmail 0.3.3 → 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.
- package/dist/cli.js +112 -6
- 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: "
|
|
3359
|
+
desc: "Set up email connection",
|
|
3360
3360
|
run: async () => {
|
|
3361
3361
|
log("");
|
|
3362
|
-
|
|
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
|
},
|
|
@@ -3792,16 +3890,24 @@ var Spinner = class {
|
|
|
3792
3890
|
};
|
|
3793
3891
|
function resolveApiEntry() {
|
|
3794
3892
|
try {
|
|
3795
|
-
const
|
|
3796
|
-
return
|
|
3893
|
+
const resolved = import.meta.resolve("@agenticmail/api");
|
|
3894
|
+
return fileURLToPath(resolved);
|
|
3797
3895
|
} catch {
|
|
3798
3896
|
}
|
|
3799
3897
|
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
3800
|
-
|
|
3898
|
+
let dir = thisDir;
|
|
3899
|
+
for (let i = 0; i < 10; i++) {
|
|
3900
|
+
const candidate = join(dir, "node_modules", "@agenticmail", "api", "dist", "index.js");
|
|
3901
|
+
if (existsSync2(candidate)) return candidate;
|
|
3902
|
+
const parent = dirname(dir);
|
|
3903
|
+
if (parent === dir) break;
|
|
3904
|
+
dir = parent;
|
|
3905
|
+
}
|
|
3906
|
+
const monorepo = [
|
|
3801
3907
|
join(thisDir, "..", "..", "packages", "api", "dist", "index.js"),
|
|
3802
3908
|
join(thisDir, "..", "packages", "api", "dist", "index.js")
|
|
3803
3909
|
];
|
|
3804
|
-
for (const p of
|
|
3910
|
+
for (const p of monorepo) {
|
|
3805
3911
|
if (existsSync2(p)) return p;
|
|
3806
3912
|
}
|
|
3807
3913
|
throw new Error("Could not find @agenticmail/api. Make sure it is installed or built.");
|