agenticmail 0.3.21 → 0.3.23
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 +62 -3
- 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");
|
|
@@ -4454,8 +4489,32 @@ async function registerWithOpenClaw(config) {
|
|
|
4454
4489
|
} catch {
|
|
4455
4490
|
}
|
|
4456
4491
|
if (!agentApiKey) {
|
|
4457
|
-
|
|
4458
|
-
|
|
4492
|
+
const createSpinner = new Spinner("config", "Creating default agent...");
|
|
4493
|
+
createSpinner.start();
|
|
4494
|
+
try {
|
|
4495
|
+
const base = `http://${config.api.host}:${config.api.port}`;
|
|
4496
|
+
const createResp = await fetch(`${base}/api/agenticmail/accounts`, {
|
|
4497
|
+
method: "POST",
|
|
4498
|
+
headers: {
|
|
4499
|
+
"Authorization": `Bearer ${config.masterKey}`,
|
|
4500
|
+
"Content-Type": "application/json"
|
|
4501
|
+
},
|
|
4502
|
+
body: JSON.stringify({ name: "secretary", role: "secretary" }),
|
|
4503
|
+
signal: AbortSignal.timeout(1e4)
|
|
4504
|
+
});
|
|
4505
|
+
if (createResp.ok) {
|
|
4506
|
+
const agent = await createResp.json();
|
|
4507
|
+
agentApiKey = agent.apiKey;
|
|
4508
|
+
createSpinner.succeed(`Default agent ${c2.bold('"secretary"')} created`);
|
|
4509
|
+
} else {
|
|
4510
|
+
const errText = await createResp.text();
|
|
4511
|
+
createSpinner.fail(`Could not create agent: ${errText}`);
|
|
4512
|
+
return;
|
|
4513
|
+
}
|
|
4514
|
+
} catch (err) {
|
|
4515
|
+
createSpinner.fail(`Could not create agent: ${err.message}`);
|
|
4516
|
+
return;
|
|
4517
|
+
}
|
|
4459
4518
|
}
|
|
4460
4519
|
const apiUrl = `http://${config.api.host}:${config.api.port}`;
|
|
4461
4520
|
const updated = mergePluginConfig(existing, apiUrl, config.masterKey, agentApiKey, pluginDir);
|