agenticmail 0.3.20 → 0.3.22
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 +50 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4195,7 +4195,42 @@ async function cmdSetup() {
|
|
|
4195
4195
|
process.exit(1);
|
|
4196
4196
|
}
|
|
4197
4197
|
} else {
|
|
4198
|
-
|
|
4198
|
+
try {
|
|
4199
|
+
const authCheck = await fetch(`${result.config.stalwart.url}/api/principal`, {
|
|
4200
|
+
headers: {
|
|
4201
|
+
"Authorization": "Basic " + Buffer.from(`${result.config.stalwart.adminUser}:${result.config.stalwart.adminPassword}`).toString("base64")
|
|
4202
|
+
},
|
|
4203
|
+
signal: AbortSignal.timeout(5e3)
|
|
4204
|
+
});
|
|
4205
|
+
if (authCheck.status === 401) {
|
|
4206
|
+
const spinner = new Spinner("stalwart", "Resetting mail server (stale credentials)...");
|
|
4207
|
+
spinner.start();
|
|
4208
|
+
try {
|
|
4209
|
+
const { execFileSync } = await import("child_process");
|
|
4210
|
+
execFileSync("docker", ["rm", "-f", "agenticmail-stalwart"], { timeout: 15e3, stdio: "ignore" });
|
|
4211
|
+
try {
|
|
4212
|
+
const volumes = execFileSync(
|
|
4213
|
+
"docker",
|
|
4214
|
+
["volume", "ls", "-q", "--filter", "name=stalwart-data"],
|
|
4215
|
+
{ timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }
|
|
4216
|
+
).toString().trim();
|
|
4217
|
+
for (const vol of volumes.split("\n").filter(Boolean)) {
|
|
4218
|
+
execFileSync("docker", ["volume", "rm", vol], { timeout: 1e4, stdio: "ignore" });
|
|
4219
|
+
}
|
|
4220
|
+
} catch {
|
|
4221
|
+
}
|
|
4222
|
+
await setup.ensureStalwart();
|
|
4223
|
+
spinner.succeed(`${c2.bold("Mail Server")} \u2014 recreated with fresh credentials`);
|
|
4224
|
+
} catch (err) {
|
|
4225
|
+
spinner.fail(`Couldn't reset mail server: ${err.message}`);
|
|
4226
|
+
process.exit(1);
|
|
4227
|
+
}
|
|
4228
|
+
} else {
|
|
4229
|
+
ok2(`${c2.bold("Mail Server")} ${c2.dim("\u2014 already running")}`);
|
|
4230
|
+
}
|
|
4231
|
+
} catch {
|
|
4232
|
+
ok2(`${c2.bold("Mail Server")} ${c2.dim("\u2014 already running")}`);
|
|
4233
|
+
}
|
|
4199
4234
|
await new Promise((r) => setTimeout(r, 300));
|
|
4200
4235
|
}
|
|
4201
4236
|
const cf = deps.find((d) => d.name === "cloudflared");
|
|
@@ -4333,10 +4368,19 @@ async function cmdSetup() {
|
|
|
4333
4368
|
return;
|
|
4334
4369
|
}
|
|
4335
4370
|
log2("");
|
|
4371
|
+
let emailOk = false;
|
|
4336
4372
|
if (choice === "1") {
|
|
4337
|
-
await setupRelay(result.config);
|
|
4373
|
+
emailOk = await setupRelay(result.config);
|
|
4338
4374
|
} else {
|
|
4339
4375
|
await setupDomain(result.config);
|
|
4376
|
+
emailOk = true;
|
|
4377
|
+
}
|
|
4378
|
+
if (!emailOk) {
|
|
4379
|
+
log2("");
|
|
4380
|
+
info2("Email setup did not complete. Run " + c2.green("npx agenticmail setup") + " again to retry.");
|
|
4381
|
+
cleanupChild();
|
|
4382
|
+
printSummary(result, true);
|
|
4383
|
+
return;
|
|
4340
4384
|
}
|
|
4341
4385
|
} else if (!existingEmail) {
|
|
4342
4386
|
info2("No problem! You can set up email anytime by running this again.");
|
|
@@ -4539,7 +4583,7 @@ async function setupRelay(config) {
|
|
|
4539
4583
|
log2("");
|
|
4540
4584
|
info2("Double-check your email and app password, then run: agenticmail setup");
|
|
4541
4585
|
}
|
|
4542
|
-
return;
|
|
4586
|
+
return false;
|
|
4543
4587
|
}
|
|
4544
4588
|
const data = await response.json();
|
|
4545
4589
|
spinner.succeed("Email connected!");
|
|
@@ -4552,12 +4596,13 @@ async function setupRelay(config) {
|
|
|
4552
4596
|
info2("People can email your agent at the address above.");
|
|
4553
4597
|
await sendWelcomeEmail(apiBase, data.agent.apiKey, email, data.agent.name, data.agent.subAddress);
|
|
4554
4598
|
}
|
|
4555
|
-
return;
|
|
4599
|
+
return true;
|
|
4556
4600
|
} catch (err) {
|
|
4557
4601
|
spinner.fail(`Couldn't connect: ${err.message}`);
|
|
4558
|
-
return;
|
|
4602
|
+
return false;
|
|
4559
4603
|
}
|
|
4560
4604
|
}
|
|
4605
|
+
return false;
|
|
4561
4606
|
}
|
|
4562
4607
|
function parseFriendlyError(rawText) {
|
|
4563
4608
|
try {
|