@ghostpaw/email 0.5.11 → 0.5.12

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 CHANGED
@@ -808,7 +808,7 @@ var init_cli_version = __esm({
808
808
  var emailVersion;
809
809
  var init_version = __esm({
810
810
  "src/version.ts"() {
811
- emailVersion = "0.5.11";
811
+ emailVersion = "0.5.12";
812
812
  }
813
813
  });
814
814
  function getConfigDir() {
@@ -1322,6 +1322,11 @@ function reportError(err, useJson) {
1322
1322
  }
1323
1323
  return result.exitCode;
1324
1324
  }
1325
+ function intFlag(raw2, rule, max = Number.MAX_SAFE_INTEGER) {
1326
+ const n3 = /^\d+$/.test(raw2.trim()) ? Number(raw2) : 0;
1327
+ if (n3 > 0 && n3 <= max) return n3;
1328
+ throw new CliError("invalid_flag_value", `${rule}. Got: "${raw2}"`);
1329
+ }
1325
1330
  var EXIT_CODES, CliError;
1326
1331
  var init_errors2 = __esm({
1327
1332
  "src/cli/errors.ts"() {
@@ -10692,12 +10697,12 @@ var accountCommand = defineCommand({
10692
10697
  name,
10693
10698
  imap: {
10694
10699
  host: args["imap-host"],
10695
- port: parseInt(args["imap-port"] ?? "993", 10),
10700
+ port: intFlag(args["imap-port"] ?? "993", "--imap-port must be 1-65535", 65535),
10696
10701
  tls: args["imap-tls"]
10697
10702
  },
10698
10703
  smtp: {
10699
10704
  host: args["smtp-host"],
10700
- port: parseInt(args["smtp-port"] ?? "587", 10),
10705
+ port: intFlag(args["smtp-port"] ?? "587", "--smtp-port must be 1-65535", 65535),
10701
10706
  tls: args["smtp-tls"]
10702
10707
  },
10703
10708
  auth
@@ -10985,8 +10990,8 @@ async function withMailbox(account, fn) {
10985
10990
  };
10986
10991
  process.once("SIGINT", onSignal);
10987
10992
  process.once("SIGTERM", onSignal);
10988
- await mailbox.connect();
10989
10993
  try {
10994
+ await mailbox.connect();
10990
10995
  const ctx = {
10991
10996
  read: mailbox.read,
10992
10997
  write: mailbox.write,
@@ -11290,11 +11295,7 @@ function parseAddresses(raw2) {
11290
11295
  }
11291
11296
  function parseUid(raw2) {
11292
11297
  if (!raw2) throw new CliError("missing_required_flag", "--uid is required.");
11293
- const n3 = parseInt(raw2, 10);
11294
- if (!Number.isFinite(n3) || n3 <= 0) {
11295
- throw new CliError("invalid_flag_value", `--uid must be a positive integer. Got: "${raw2}"`);
11296
- }
11297
- return n3;
11298
+ return intFlag(raw2, "--uid must be a positive integer");
11298
11299
  }
11299
11300
 
11300
11301
  // src/cli/commands/organize.ts
@@ -11367,16 +11368,7 @@ function parseUids(raw2, action) {
11367
11368
  if (!raw2) {
11368
11369
  throw new CliError("missing_required_flag", `--uids is required for action: ${action}`);
11369
11370
  }
11370
- return raw2.split(",").map((s4) => {
11371
- const n3 = parseInt(s4.trim(), 10);
11372
- if (!Number.isFinite(n3) || n3 <= 0) {
11373
- throw new CliError(
11374
- "invalid_flag_value",
11375
- `--uids must be comma-separated positive integers. Got: "${s4.trim()}"`
11376
- );
11377
- }
11378
- return n3;
11379
- });
11371
+ return raw2.split(",").map((s4) => intFlag(s4.trim(), "--uids must be comma-separated positive integers"));
11380
11372
  }
11381
11373
  function requireFolder(folder, action) {
11382
11374
  if (!folder) {
@@ -11676,14 +11668,7 @@ Usage: ghostpaw-email read ${view} ${flag} <value>`
11676
11668
  }
11677
11669
  }
11678
11670
  function parseUid2(raw2, view) {
11679
- const n3 = parseInt(raw2, 10);
11680
- if (!Number.isFinite(n3) || n3 <= 0) {
11681
- throw new CliError(
11682
- "invalid_flag_value",
11683
- `--uid must be a positive integer (view: ${view}). Got: "${raw2}"`
11684
- );
11685
- }
11686
- return n3;
11671
+ return intFlag(raw2, `--uid must be a positive integer (view: ${view})`);
11687
11672
  }
11688
11673
 
11689
11674
  // src/cli/commands/search.ts
@@ -11742,16 +11727,7 @@ var searchCommand = defineCommand({
11742
11727
  if (args.before) input.before = args.before;
11743
11728
  if (args["has-attachments"]) input.hasAttachments = true;
11744
11729
  if (args["unread-only"]) input.unreadOnly = true;
11745
- if (args.limit) {
11746
- const n3 = parseInt(args.limit, 10);
11747
- if (!Number.isFinite(n3) || n3 <= 0) {
11748
- throw new CliError(
11749
- "invalid_flag_value",
11750
- `--limit must be a positive integer. Got: "${args.limit}"`
11751
- );
11752
- }
11753
- input.limit = n3;
11754
- }
11730
+ if (args.limit) input.limit = intFlag(args.limit, "--limit must be a positive integer");
11755
11731
  const account = resolveAccount(args.account);
11756
11732
  const result = await withMailbox(account, (ctx) => searchTool.handler(ctx, input));
11757
11733
  renderResult(result, { json: args.json ?? false, quiet: args.quiet ?? false });
@@ -316,7 +316,7 @@ var init_mcp_stdio = __esm({
316
316
  var emailVersion;
317
317
  var init_version = __esm({
318
318
  "src/version.ts"() {
319
- emailVersion = "0.5.11";
319
+ emailVersion = "0.5.12";
320
320
  }
321
321
  });
322
322
 
package/dist/mcp.cjs CHANGED
@@ -5018,7 +5018,7 @@ var init_network = __esm({
5018
5018
  });
5019
5019
 
5020
5020
  // src/version.ts
5021
- var emailVersion = "0.5.11";
5021
+ var emailVersion = "0.5.12";
5022
5022
 
5023
5023
  // src/surface/email_mcp_instructions.ts
5024
5024
  var emailMcpInstructions = "Read and search cached email offline. Configure live accounts with email account add before network operations. Inspect messages before replying or changing folders. Confirm recipients and content before sending; trash and folder deletion can remove mail. Credentials use the existing email CLI account configuration or EMAIL_* environment variables.";
package/dist/mcp.js CHANGED
@@ -4994,7 +4994,7 @@ var init_network = __esm({
4994
4994
  });
4995
4995
 
4996
4996
  // src/version.ts
4997
- var emailVersion = "0.5.11";
4997
+ var emailVersion = "0.5.12";
4998
4998
 
4999
4999
  // src/surface/email_mcp_instructions.ts
5000
5000
  var emailMcpInstructions = "Read and search cached email offline. Configure live accounts with email account add before network operations. Inspect messages before replying or changing folders. Confirm recipients and content before sending; trash and folder deletion can remove mail. Credentials use the existing email CLI account configuration or EMAIL_* environment variables.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostpaw/email",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "description": "Standalone IMAP/SMTP email engine for Node.js — SQLite local cache, threading, sync, zero dependencies, with a built-in LLM tool facade",
5
5
  "type": "module",
6
6
  "exports": {