agenticmail 0.3.9 → 0.3.11

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 +66 -19
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import { createInterface as createInterface2, emitKeypressEvents } from "readline";
4
+ import { createInterface as createInterface2, emitKeypressEvents as emitKeypressEvents2 } from "readline";
5
5
  import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync, realpathSync } from "fs";
6
6
  import { join, dirname } from "path";
7
7
  import { fileURLToPath } from "url";
@@ -13,7 +13,7 @@ import {
13
13
  } from "@agenticmail/core";
14
14
 
15
15
  // src/shell.ts
16
- import { createInterface } from "readline";
16
+ import { createInterface, emitKeypressEvents } from "readline";
17
17
  import { readFileSync, writeFileSync, existsSync } from "fs";
18
18
  import { basename } from "path";
19
19
  var c = {
@@ -3303,6 +3303,10 @@ ${orig.text || ""}`;
3303
3303
  } catch {
3304
3304
  }
3305
3305
  rl.__chatMode = true;
3306
+ rl.pause();
3307
+ emitKeypressEvents(process.stdin);
3308
+ if (process.stdin.isTTY) process.stdin.setRawMode(true);
3309
+ process.stdin.resume();
3306
3310
  process.stdout.write("\x1B[3A\r\x1B[J");
3307
3311
  log(hr());
3308
3312
  log(` ${c.bold(c.cyan("\u{1F380} Agent Chat"))} ${c.dim("| Esc to leave | Enter to send | \\\\ + Enter for new line")}`);
@@ -3365,6 +3369,8 @@ ${c.dim(boxChar.bl + boxChar.h.repeat(bWidth) + boxChar.br)}`);
3365
3369
  log("");
3366
3370
  }
3367
3371
  chat.close();
3372
+ if (process.stdin.isTTY) process.stdin.setRawMode(false);
3373
+ rl.resume();
3368
3374
  rl.__chatMode = false;
3369
3375
  log("");
3370
3376
  log(` ${c.dim("Chat ended")}`);
@@ -4210,21 +4216,6 @@ async function cmdSetup() {
4210
4216
  await new Promise((r) => setTimeout(r, 800));
4211
4217
  log2(` ${c2.bold("Step 4 of 4")} ${c2.dim("\u2014")} ${c2.bold("Connect your email")}`);
4212
4218
  log2("");
4213
- log2(` How should your AI agent send and receive email?`);
4214
- log2("");
4215
- log2(` ${c2.cyan("1.")} Use my Gmail or Outlook`);
4216
- log2(` ${c2.dim("Easiest option \u2014 connect your existing email account.")}`);
4217
- log2(` ${c2.dim("Your agent emails as you+agent@gmail.com")}`);
4218
- log2("");
4219
- log2(` ${c2.cyan("2.")} Use my own domain`);
4220
- log2(` ${c2.dim("Your agent gets a custom address like agent@yourcompany.com")}`);
4221
- log2(` ${c2.dim("Requires a Cloudflare account and a domain.")}`);
4222
- log2("");
4223
- log2(` ${c2.cyan("3.")} Skip for now`);
4224
- log2(` ${c2.dim("You can always set this up later.")}`);
4225
- log2("");
4226
- const choice = await pick(` ${c2.magenta(">")} `, ["1", "2", "3"]);
4227
- log2("");
4228
4219
  const serverSpinner = new Spinner("server", "Starting the server...");
4229
4220
  serverSpinner.start();
4230
4221
  let serverReady = false;
@@ -4275,6 +4266,62 @@ async function cmdSetup() {
4275
4266
  serverSpinner.fail(`Could not start server: ${err.message}`);
4276
4267
  }
4277
4268
  }
4269
+ let existingEmail = null;
4270
+ let existingProvider = null;
4271
+ if (serverReady) {
4272
+ try {
4273
+ const base = `http://${result.config.api.host}:${result.config.api.port}`;
4274
+ const statusResp = await fetch(`${base}/api/agenticmail/gateway/status`, {
4275
+ headers: { "Authorization": `Bearer ${result.config.masterKey}` },
4276
+ signal: AbortSignal.timeout(5e3)
4277
+ });
4278
+ if (statusResp.ok) {
4279
+ const status = await statusResp.json();
4280
+ if (status.mode === "relay" && status.relay?.email) {
4281
+ existingEmail = status.relay.email;
4282
+ existingProvider = status.relay.provider || "custom";
4283
+ }
4284
+ }
4285
+ } catch {
4286
+ }
4287
+ }
4288
+ let choice;
4289
+ if (existingEmail) {
4290
+ const provLabel = existingProvider === "gmail" ? "Gmail" : existingProvider === "outlook" ? "Outlook" : existingProvider;
4291
+ log2("");
4292
+ ok2(`Email already connected: ${c2.cyan(existingEmail)} ${c2.dim(`(${provLabel})`)}`);
4293
+ log2("");
4294
+ log2(` ${c2.cyan("1.")} Keep current email`);
4295
+ log2(` ${c2.cyan("2.")} Remove and connect a different email`);
4296
+ log2(` ${c2.cyan("3.")} Set up a custom domain instead`);
4297
+ log2("");
4298
+ const existChoice = await pick(` ${c2.magenta(">")} `, ["1", "2", "3"]);
4299
+ if (existChoice === "1") {
4300
+ choice = "3";
4301
+ log2("");
4302
+ ok2(`Keeping ${c2.cyan(existingEmail)}`);
4303
+ } else if (existChoice === "3") {
4304
+ choice = "2";
4305
+ } else {
4306
+ choice = "1";
4307
+ }
4308
+ } else {
4309
+ log2(` How should your AI agent send and receive email?`);
4310
+ log2("");
4311
+ log2(` ${c2.cyan("1.")} Use my Gmail or Outlook`);
4312
+ log2(` ${c2.dim("Easiest option \u2014 connect your existing email account.")}`);
4313
+ log2(` ${c2.dim("Your agent emails as you+agent@gmail.com")}`);
4314
+ log2("");
4315
+ log2(` ${c2.cyan("2.")} Use my own domain`);
4316
+ log2(` ${c2.dim("Your agent gets a custom address like agent@yourcompany.com")}`);
4317
+ log2(` ${c2.dim("Requires a Cloudflare account and a domain.")}`);
4318
+ log2("");
4319
+ log2(` ${c2.cyan("3.")} Skip for now`);
4320
+ log2(` ${c2.dim("You can always set this up later.")}`);
4321
+ log2("");
4322
+ choice = await pick(` ${c2.magenta(">")} `, ["1", "2", "3"]);
4323
+ }
4324
+ log2("");
4278
4325
  if (choice === "1" || choice === "2") {
4279
4326
  if (!serverReady) {
4280
4327
  info2("You can configure email later by running: agenticmail setup");
@@ -4288,7 +4335,7 @@ async function cmdSetup() {
4288
4335
  } else {
4289
4336
  await setupDomain(result.config);
4290
4337
  }
4291
- } else {
4338
+ } else if (!existingEmail) {
4292
4339
  info2("No problem! You can set up email anytime by running this again.");
4293
4340
  }
4294
4341
  printSummary(result, false);
@@ -4883,7 +4930,7 @@ async function cmdOpenClaw() {
4883
4930
  const selectedIdx = await new Promise((resolve) => {
4884
4931
  let sel = 0;
4885
4932
  const totalOpts = options.length;
4886
- emitKeypressEvents(process.stdin);
4933
+ emitKeypressEvents2(process.stdin);
4887
4934
  if (process.stdin.isTTY) process.stdin.setRawMode(true);
4888
4935
  const renderList = () => {
4889
4936
  const totalLines = totalOpts + 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agenticmail",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Email infrastructure for AI agents — send and receive real email programmatically",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",