@ghostpaw/email 0.5.10 → 0.5.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.
package/README.md CHANGED
@@ -81,6 +81,31 @@ On POSIX, new accounts files and SQLite caches (including WAL/SHM sidecars) use
81
81
 
82
82
  Use `ghostpaw-email skill --short` for a compact command cheat sheet, `ghostpaw-email skill` for the full reference, and `ghostpaw-email skill --list` to list guides.
83
83
 
84
+
85
+ ## Running inside sandboxed agent harnesses
86
+
87
+ Inside a Codex CLI `--sandbox workspace-write` session, the database and its
88
+ parent directory must be inside a writable root, including SQLite's `-wal` and
89
+ `-shm` side files. A default DB under `~/.ghostpaw` outside those roots can fail
90
+ with `SQLITE_CANTOPEN` or `EPERM` (often exit 70; directory creation failures
91
+ may exit 2), even when normal shell permissions allow access. Put the DB inside the workspace with `--db ./state/email.db`,
92
+ or set `GHOSTPAW_EMAIL_DB="$PWD/state/email.db"` for CLI/MCP use.
93
+
94
+ To use an external DB directory, add it when starting the OpenAI Codex CLI
95
+ (replace `<dir-with-db>` with its absolute path):
96
+
97
+ ```sh
98
+ codex exec --sandbox workspace-write --add-dir <dir-with-db> "Run the GhostPaw CLI"
99
+ ```
100
+
101
+ Alternatively, set `sandbox_workspace_write.writable_roots` in
102
+ `~/.codex/config.toml` before starting the session:
103
+
104
+ ```toml
105
+ [sandbox_workspace_write]
106
+ writable_roots = ["/absolute/dir-with-db"]
107
+ ```
108
+
84
109
  ## Noun-verb CLI
85
110
 
86
111
  Both `email` and `ghostpaw-email` accept this additive command tree. Existing
@@ -109,9 +134,9 @@ stdin and `@@text` passes `@text`; help marks them `(@file, @- stdin, @@ literal
109
134
  empty or unreadable path exits 2. A single `-` reads stdin JSON;
110
135
  explicit flags override stdin fields. `--` ends option parsing.
111
136
 
112
- Global flags for the new commands: `--db <path>`, `--json`, `--quiet`,
137
+ Global flags for the new commands: `--db <path>`, `--json`, `-q, --quiet`,
113
138
  `--compact`, `--help`/`-h`, `--version`/`-V`/`-v`, `--no-color`.
114
- Output is JSON when piped or when `--json` is set. `--quiet` suppresses stdout.
139
+ Output is JSON when piped or when `--json` is set. `-q, --quiet` suppresses stdout.
115
140
  `completions bash|zsh|fish` prints shell completion setup; `version` prints
116
141
  the version and installation variant. The existing `tools [--json]`, `describe <tool>`,
117
142
  `call <tool> [JSON|-]`, flat `mail_<tool> --parameter value`, `mcp` and `skill`
package/SKILL.md CHANGED
@@ -25,6 +25,31 @@ Run tools as `ghostpaw-email ...`; use `~/.local/bin/ghostpaw-email` if it is no
25
25
 
26
26
  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.
27
27
 
28
+ ## Running inside sandboxed agent harnesses
29
+
30
+ Inside a Codex CLI `--sandbox workspace-write` session, the database and its
31
+ parent directory must be inside a writable root, including SQLite's `-wal` and
32
+ `-shm` side files. A default DB under `~/.ghostpaw` outside those roots can fail
33
+ with `SQLITE_CANTOPEN` or `EPERM` (often exit 70; directory creation failures
34
+ may exit 2), even when normal shell permissions allow access. Put the DB inside the workspace with `--db ./state/email.db`,
35
+ or set `GHOSTPAW_EMAIL_DB="$PWD/state/email.db"` for CLI/MCP use.
36
+
37
+ To use an external DB directory, add it when starting the OpenAI Codex CLI
38
+ (replace `<dir-with-db>` with its absolute path):
39
+
40
+ ```sh
41
+ codex exec --sandbox workspace-write --add-dir <dir-with-db> "Run the GhostPaw CLI"
42
+ ```
43
+
44
+ Alternatively, set `sandbox_workspace_write.writable_roots` in
45
+ `~/.codex/config.toml` before starting the session:
46
+
47
+ ```toml
48
+ [sandbox_workspace_write]
49
+ writable_roots = ["/absolute/dir-with-db"]
50
+ ```
51
+
52
+
28
53
  For the compact cheat sheet, run `ghostpaw-email skill --short`.
29
54
 
30
55
  ## Calling tools
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.10";
811
+ emailVersion = "0.5.11";
812
812
  }
813
813
  });
814
814
  function getConfigDir() {
@@ -1114,6 +1114,120 @@ var init_errors = __esm({
1114
1114
  };
1115
1115
  }
1116
1116
  });
1117
+ function readFileValue(raw2, name) {
1118
+ if (!raw2.startsWith("@")) return raw2;
1119
+ if (raw2.startsWith("@@")) return raw2.slice(1);
1120
+ const path = raw2.slice(1);
1121
+ if (!path) throw new CliUsageError(`Empty file path for ${name}; use @@ for a literal leading @`);
1122
+ try {
1123
+ return readFileSync(path === "-" ? 0 : path, "utf8");
1124
+ } catch {
1125
+ throw new CliUsageError(
1126
+ `Cannot read value file for ${name}: ${path} (use @@ for a literal leading @)`
1127
+ );
1128
+ }
1129
+ }
1130
+ function parseCliArgs(argv2, spec) {
1131
+ const values = {};
1132
+ const positions = [];
1133
+ const flags = spec.flags ?? [];
1134
+ const convert = (raw2, arg) => {
1135
+ const value = arg.file ? readFileValue(raw2, arg.name) : raw2;
1136
+ let result = value;
1137
+ if (arg.type === "number" || arg.type === "integer") {
1138
+ result = Number(value);
1139
+ if (!value.trim() || !Number.isFinite(result) || arg.type === "integer" && !Number.isInteger(result))
1140
+ throw new CliUsageError(`Expected ${arg.type} for ${arg.name}: ${value}`);
1141
+ } else if (arg.type === "boolean") {
1142
+ if (!["true", "false"].includes(value))
1143
+ throw new CliUsageError(`Expected boolean for ${arg.name}`);
1144
+ result = value === "true";
1145
+ } else if (arg.type === "json") {
1146
+ try {
1147
+ result = JSON.parse(value);
1148
+ } catch {
1149
+ throw new CliUsageError(`Invalid JSON for ${arg.name}`);
1150
+ }
1151
+ }
1152
+ if (arg.enum && !arg.enum.includes(result))
1153
+ throw new CliUsageError(`${arg.name} must be one of: ${arg.enum.join(", ")}`);
1154
+ return result;
1155
+ };
1156
+ let ended = false;
1157
+ for (let i2 = 0; i2 < argv2.length; i2++) {
1158
+ const token = argv2[i2];
1159
+ if (!ended && token === "--") {
1160
+ ended = true;
1161
+ continue;
1162
+ }
1163
+ if (ended || token === "-" || !token.startsWith("-")) {
1164
+ positions.push(token);
1165
+ continue;
1166
+ }
1167
+ const [flag, inline] = token.split(/=(.*)/s);
1168
+ const negative = flag?.startsWith("--no-");
1169
+ const name = flag?.replace(/^--?/, "").replace(/^no-/, "");
1170
+ const arg = flags.find(
1171
+ (entry) => entry.name === name || keyOf(entry.name) === name || entry.short === name
1172
+ );
1173
+ if (!arg) {
1174
+ const prefix = (name ?? "").slice(0, 3);
1175
+ const suggestion = prefix ? flags.find((entry) => entry.name.startsWith(prefix)) : void 0;
1176
+ throw new CliUsageError(
1177
+ `Unknown flag: ${flag}${suggestion ? `; did you mean --${suggestion.name}?` : ""}`
1178
+ );
1179
+ }
1180
+ if (negative && arg.type !== "boolean")
1181
+ throw new CliUsageError(`--no-${arg.name} requires a boolean flag`);
1182
+ let raw2 = inline;
1183
+ if (arg.type === "boolean" && raw2 === void 0) raw2 = negative ? "false" : "true";
1184
+ if (raw2 === void 0) {
1185
+ const next = argv2[i2 + 1];
1186
+ if (next === void 0 || /^--[a-z]/i.test(next))
1187
+ throw new CliUsageError(`Missing value: --${arg.name}`);
1188
+ raw2 = next;
1189
+ i2++;
1190
+ }
1191
+ const key = keyOf(arg.name);
1192
+ if (arg.type === "array") {
1193
+ const item = convert(raw2, { ...arg, type: arg.itemType ?? "string" });
1194
+ values[key] = [...values[key] ?? [], item];
1195
+ } else values[key] = convert(raw2, arg);
1196
+ }
1197
+ let index = 0;
1198
+ for (const arg of spec.positionals ?? []) {
1199
+ if (index >= positions.length) continue;
1200
+ values[keyOf(arg.name)] = arg.variadic ? positions.slice(index).map((value) => convert(value, { ...arg, type: arg.itemType ?? arg.type })) : convert(positions[index], arg);
1201
+ index = arg.variadic ? positions.length : index + 1;
1202
+ }
1203
+ if (index < positions.length)
1204
+ throw new CliUsageError(`Unexpected positional: ${positions[index]}`);
1205
+ for (const arg of [...flags, ...spec.positionals ?? []]) {
1206
+ if (arg.required && values[keyOf(arg.name)] === void 0)
1207
+ throw new CliUsageError(`Missing required argument: ${arg.name}`);
1208
+ }
1209
+ return values;
1210
+ }
1211
+ function renderCliHelp(spec) {
1212
+ const describe = (arg) => `${arg.type}${arg.enum ? ` (${arg.enum.join("|")})` : ""}${arg.required ? " required" : ""}${arg.file ? " (@file, @- stdin, @@ literal @)" : ""} ${arg.description ?? ""}`;
1213
+ return `Usage: ${spec.command} ${(spec.positionals ?? []).map((arg) => `<${arg.name}${arg.variadic ? "..." : ""}>`).join(" ")} [flags]
1214
+ ${spec.description ?? ""}
1215
+
1216
+ Positionals:
1217
+ ${(spec.positionals ?? []).map((arg) => ` ${arg.name} ${describe(arg)}`).join("\n")}
1218
+ Flags:
1219
+ ${(spec.flags ?? []).map((arg) => ` --${arg.name}${arg.short ? `, -${arg.short}` : ""} ${describe(arg)}`).join("\n")}
1220
+ `;
1221
+ }
1222
+ var CliUsageError, keyOf;
1223
+ var init_cli_args = __esm({
1224
+ "src/surfaces/cli_args.ts"() {
1225
+ CliUsageError = class extends Error {
1226
+ exitCode = 2;
1227
+ };
1228
+ keyOf = (name) => name.replace(/-([a-z])/g, (_3, c3) => c3.toUpperCase());
1229
+ }
1230
+ });
1117
1231
 
1118
1232
  // src/cli/output.ts
1119
1233
  function isTTY() {
@@ -1150,7 +1264,7 @@ var init_output = __esm({
1150
1264
 
1151
1265
  // src/cli/errors.ts
1152
1266
  function handleCliError(err) {
1153
- if (err instanceof CliError) {
1267
+ if (err instanceof CliError || err instanceof CliUsageError) {
1154
1268
  return { exitCode: err.exitCode, message: err.message };
1155
1269
  }
1156
1270
  if (err instanceof ConfigError) {
@@ -1212,6 +1326,7 @@ var EXIT_CODES, CliError;
1212
1326
  var init_errors2 = __esm({
1213
1327
  "src/cli/errors.ts"() {
1214
1328
  init_errors();
1329
+ init_cli_args();
1215
1330
  init_config();
1216
1331
  init_output();
1217
1332
  EXIT_CODES = {
@@ -1243,120 +1358,6 @@ var init_errors2 = __esm({
1243
1358
  };
1244
1359
  }
1245
1360
  });
1246
- function readFileValue(raw2, name) {
1247
- if (!raw2.startsWith("@")) return raw2;
1248
- if (raw2.startsWith("@@")) return raw2.slice(1);
1249
- const path = raw2.slice(1);
1250
- if (!path) throw new CliUsageError(`Empty file path for ${name}; use @@ for a literal leading @`);
1251
- try {
1252
- return readFileSync(path === "-" ? 0 : path, "utf8");
1253
- } catch {
1254
- throw new CliUsageError(
1255
- `Cannot read value file for ${name}: ${path} (use @@ for a literal leading @)`
1256
- );
1257
- }
1258
- }
1259
- function parseCliArgs(argv2, spec) {
1260
- const values = {};
1261
- const positions = [];
1262
- const flags = spec.flags ?? [];
1263
- const convert = (raw2, arg) => {
1264
- const value = arg.file ? readFileValue(raw2, arg.name) : raw2;
1265
- let result = value;
1266
- if (arg.type === "number" || arg.type === "integer") {
1267
- result = Number(value);
1268
- if (!value.trim() || !Number.isFinite(result) || arg.type === "integer" && !Number.isInteger(result))
1269
- throw new CliUsageError(`Expected ${arg.type} for ${arg.name}: ${value}`);
1270
- } else if (arg.type === "boolean") {
1271
- if (!["true", "false"].includes(value))
1272
- throw new CliUsageError(`Expected boolean for ${arg.name}`);
1273
- result = value === "true";
1274
- } else if (arg.type === "json") {
1275
- try {
1276
- result = JSON.parse(value);
1277
- } catch {
1278
- throw new CliUsageError(`Invalid JSON for ${arg.name}`);
1279
- }
1280
- }
1281
- if (arg.enum && !arg.enum.includes(result))
1282
- throw new CliUsageError(`${arg.name} must be one of: ${arg.enum.join(", ")}`);
1283
- return result;
1284
- };
1285
- let ended = false;
1286
- for (let i2 = 0; i2 < argv2.length; i2++) {
1287
- const token = argv2[i2];
1288
- if (!ended && token === "--") {
1289
- ended = true;
1290
- continue;
1291
- }
1292
- if (ended || token === "-" || !token.startsWith("-")) {
1293
- positions.push(token);
1294
- continue;
1295
- }
1296
- const [flag, inline] = token.split(/=(.*)/s);
1297
- const negative = flag?.startsWith("--no-");
1298
- const name = flag?.replace(/^--?/, "").replace(/^no-/, "");
1299
- const arg = flags.find(
1300
- (entry) => entry.name === name || keyOf(entry.name) === name || entry.short === name
1301
- );
1302
- if (!arg) {
1303
- const prefix = (name ?? "").slice(0, 3);
1304
- const suggestion = prefix ? flags.find((entry) => entry.name.startsWith(prefix)) : void 0;
1305
- throw new CliUsageError(
1306
- `Unknown flag: ${flag}${suggestion ? `; did you mean --${suggestion.name}?` : ""}`
1307
- );
1308
- }
1309
- if (negative && arg.type !== "boolean")
1310
- throw new CliUsageError(`--no-${arg.name} requires a boolean flag`);
1311
- let raw2 = inline;
1312
- if (arg.type === "boolean" && raw2 === void 0) raw2 = negative ? "false" : "true";
1313
- if (raw2 === void 0) {
1314
- const next = argv2[i2 + 1];
1315
- if (next === void 0 || /^--[a-z]/i.test(next))
1316
- throw new CliUsageError(`Missing value: --${arg.name}`);
1317
- raw2 = next;
1318
- i2++;
1319
- }
1320
- const key = keyOf(arg.name);
1321
- if (arg.type === "array") {
1322
- const item = convert(raw2, { ...arg, type: arg.itemType ?? "string" });
1323
- values[key] = [...values[key] ?? [], item];
1324
- } else values[key] = convert(raw2, arg);
1325
- }
1326
- let index = 0;
1327
- for (const arg of spec.positionals ?? []) {
1328
- if (index >= positions.length) continue;
1329
- values[keyOf(arg.name)] = arg.variadic ? positions.slice(index).map((value) => convert(value, { ...arg, type: arg.itemType ?? arg.type })) : convert(positions[index], arg);
1330
- index = arg.variadic ? positions.length : index + 1;
1331
- }
1332
- if (index < positions.length)
1333
- throw new CliUsageError(`Unexpected positional: ${positions[index]}`);
1334
- for (const arg of [...flags, ...spec.positionals ?? []]) {
1335
- if (arg.required && values[keyOf(arg.name)] === void 0)
1336
- throw new CliUsageError(`Missing required argument: ${arg.name}`);
1337
- }
1338
- return values;
1339
- }
1340
- function renderCliHelp(spec) {
1341
- const describe = (arg) => `${arg.type}${arg.enum ? ` (${arg.enum.join("|")})` : ""}${arg.required ? " required" : ""}${arg.file ? " (@file, @- stdin, @@ literal @)" : ""} ${arg.description ?? ""}`;
1342
- return `Usage: ${spec.command} ${(spec.positionals ?? []).map((arg) => `<${arg.name}${arg.variadic ? "..." : ""}>`).join(" ")} [flags]
1343
- ${spec.description ?? ""}
1344
-
1345
- Positionals:
1346
- ${(spec.positionals ?? []).map((arg) => ` ${arg.name} ${describe(arg)}`).join("\n")}
1347
- Flags:
1348
- ${(spec.flags ?? []).map((arg) => ` --${arg.name}${arg.short ? `, -${arg.short}` : ""} ${describe(arg)}`).join("\n")}
1349
- `;
1350
- }
1351
- var CliUsageError, keyOf;
1352
- var init_cli_args = __esm({
1353
- "src/surfaces/cli_args.ts"() {
1354
- CliUsageError = class extends Error {
1355
- exitCode = 2;
1356
- };
1357
- keyOf = (name) => name.replace(/-([a-z])/g, (_3, c3) => c3.toUpperCase());
1358
- }
1359
- });
1360
1361
 
1361
1362
  // src/surfaces/schema_example.ts
1362
1363
  function schemaExample(schema, seed = {}) {
@@ -6217,7 +6218,14 @@ var init_read = __esm({
6217
6218
  }
6218
6219
  });
6219
6220
  function preparePrivateStorage(path) {
6220
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
6221
+ const directory = dirname(path);
6222
+ try {
6223
+ mkdirSync(directory, { recursive: true, mode: 448 });
6224
+ } catch (error) {
6225
+ const code = error.code;
6226
+ const reason = code === "ENOTDIR" || code === "EEXIST" ? "a path component is not a directory" : code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EROFS" ? "read-only file system" : code;
6227
+ throw new CliUsageError(`Cannot create database directory ${directory}: ${reason}`);
6228
+ }
6221
6229
  const created = [];
6222
6230
  for (const file of [path, `${path}-wal`, `${path}-shm`]) {
6223
6231
  try {
@@ -6250,6 +6258,7 @@ function withPrivateCreation(operation, secure) {
6250
6258
  }
6251
6259
  var init_private_storage = __esm({
6252
6260
  "src/private_storage.ts"() {
6261
+ init_cli_args();
6253
6262
  }
6254
6263
  });
6255
6264
 
@@ -7297,7 +7306,8 @@ async function runCliCommand(argv2, options) {
7297
7306
  const stdin2 = options.stdin ?? process.stdin;
7298
7307
  const args = [...argv2];
7299
7308
  const tree = cliCommands(options.tools);
7300
- let json = argv2.includes("--json"), quiet = argv2.includes("--quiet"), compact = false, help = false;
7309
+ const isQuiet = (arg) => arg === "--quiet" || arg === "-q";
7310
+ let json = argv2.includes("--json"), quiet = argv2.some(isQuiet), compact = false, help = false;
7301
7311
  let db;
7302
7312
  const fail = (message, code) => {
7303
7313
  stderr.write(`${message}
@@ -7331,7 +7341,7 @@ async function runCliCommand(argv2, options) {
7331
7341
  db = flag === "--db" ? args.splice(i2 + 1, 1)[0] : flag.slice(5);
7332
7342
  if (!db || db.startsWith("--")) throw new CliUsageError("--db requires a path");
7333
7343
  } else if (flag === "--json") json = true;
7334
- else if (flag === "--quiet") quiet = true;
7344
+ else if (isQuiet(flag)) quiet = true;
7335
7345
  else if (flag === "--compact") compact = true;
7336
7346
  else if (flag === "--help" || flag === "-h") help = true;
7337
7347
  else if (["--version", "-V", "-v"].includes(flag ?? "")) {
@@ -7398,7 +7408,7 @@ Commands:
7398
7408
  ${matches.map((command) => ` ${command.path}`).join("\n")}
7399
7409
  mcp, skill, tools [--json], describe <tool>, call <tool> [JSON|-], completions <bash|zsh|fish>, version
7400
7410
  Version output: --version --short or --version --json
7401
- Global flags: --db <path>, --json, --quiet, --compact, --help/-h, --version/-V/-v, --no-color
7411
+ Global flags: --db <path>, --json, -q, --quiet, --compact, --help/-h, --version/-V/-v, --no-color
7402
7412
  `
7403
7413
  );
7404
7414
  return 0;
@@ -7699,7 +7709,10 @@ ${JSON.stringify(tool.inputSchema, null, 2)}
7699
7709
  try {
7700
7710
  context = await options.openContext(ctxOptions);
7701
7711
  } catch (cause) {
7702
- return fail(String(cause), 1);
7712
+ return fail(
7713
+ cause instanceof CliUsageError ? cause.message : String(cause),
7714
+ cause instanceof CliUsageError ? 2 : 1
7715
+ );
7703
7716
  }
7704
7717
  try {
7705
7718
  const result = await tool.handler(context, input);
@@ -7717,6 +7730,7 @@ ${JSON.stringify(tool.inputSchema, null, 2)}
7717
7730
  var init_cli = __esm({
7718
7731
  "src/surfaces/cli.ts"() {
7719
7732
  init_cli_version();
7733
+ init_cli_args();
7720
7734
  init_cli_commands();
7721
7735
  init_parameter_rows();
7722
7736
  init_surface_types();
@@ -8014,8 +8028,8 @@ email read eml --folder INBOX --uid 42 | mail -s "fwd" target@example.com
8014
8028
  # JSON pipeline
8015
8029
  email read queue --json | jq '.entities[] | select(.title | test("invoice"; "i")) | .id'
8016
8030
 
8017
- # Quiet mode \u2014 only exit code matters
8018
- email organize archive --folder INBOX --uids 42 --quiet && echo "archived"
8031
+ # -q, --quiet: exit code only
8032
+ email organize archive --folder INBOX --uids 42 -q && echo "archived"
8019
8033
  \`\`\`
8020
8034
 
8021
8035
  ---
@@ -8954,7 +8968,32 @@ var init_email_skill_spec = __esm({
8954
8968
  bin: "ghostpaw-email",
8955
8969
  packageName: "@ghostpaw/email",
8956
8970
  server: "ghostpaw-email",
8957
- about: emailMcpInstructions,
8971
+ about: `${emailMcpInstructions}
8972
+
8973
+ ## Running inside sandboxed agent harnesses
8974
+
8975
+ Inside a Codex CLI \`--sandbox workspace-write\` session, the database and its
8976
+ parent directory must be inside a writable root, including SQLite's \`-wal\` and
8977
+ \`-shm\` side files. A default DB under \`~/.ghostpaw\` outside those roots can fail
8978
+ with \`SQLITE_CANTOPEN\` or \`EPERM\` (often exit 70; directory creation failures
8979
+ may exit 2), even when normal shell permissions allow access. Put the DB inside the workspace with \`--db ./state/email.db\`,
8980
+ or set \`GHOSTPAW_EMAIL_DB="$PWD/state/email.db"\` for CLI/MCP use.
8981
+
8982
+ To use an external DB directory, add it when starting the OpenAI Codex CLI
8983
+ (replace \`<dir-with-db>\` with its absolute path):
8984
+
8985
+ \`\`\`sh
8986
+ codex exec --sandbox workspace-write --add-dir <dir-with-db> "Run the GhostPaw CLI"
8987
+ \`\`\`
8988
+
8989
+ Alternatively, set \`sandbox_workspace_write.writable_roots\` in
8990
+ \`~/.codex/config.toml\` before starting the session:
8991
+
8992
+ \`\`\`toml
8993
+ [sandbox_workspace_write]
8994
+ writable_roots = ["/absolute/dir-with-db"]
8995
+ \`\`\`
8996
+ `,
8958
8997
  tools: emailSurfaceTools,
8959
8998
  workflows: [...emailSkills, { name: "cli", description: "Complete existing email CLI guide." }],
8960
8999
  principles: [
@@ -11009,6 +11048,7 @@ var sharedArgs = {
11009
11048
  account: { type: "string", description: "Account name (overrides default)" },
11010
11049
  json: { type: "boolean", description: "Output full result as JSON", default: false },
11011
11050
  quiet: {
11051
+ alias: "q",
11012
11052
  type: "boolean",
11013
11053
  description: "Suppress all output except errors",
11014
11054
  default: false
@@ -11291,6 +11331,7 @@ var organizeCommand = defineCommand({
11291
11331
  account: { type: "string", description: "Account name (overrides default)" },
11292
11332
  json: { type: "boolean", description: "Output full result as JSON", default: false },
11293
11333
  quiet: {
11334
+ alias: "q",
11294
11335
  type: "boolean",
11295
11336
  description: "Suppress all output except errors",
11296
11337
  default: false
@@ -11487,6 +11528,7 @@ var sharedArgs2 = {
11487
11528
  account: { type: "string", description: "Account name (overrides default)" },
11488
11529
  json: { type: "boolean", description: "Output full result as JSON", default: false },
11489
11530
  quiet: {
11531
+ alias: "q",
11490
11532
  type: "boolean",
11491
11533
  description: "Suppress all output except errors",
11492
11534
  default: false
@@ -11657,6 +11699,7 @@ var searchCommand = defineCommand({
11657
11699
  account: { type: "string", description: "Account name (overrides default)" },
11658
11700
  json: { type: "boolean", description: "Output full result as JSON", default: false },
11659
11701
  quiet: {
11702
+ alias: "q",
11660
11703
  type: "boolean",
11661
11704
  description: "Suppress all output except errors",
11662
11705
  default: false
@@ -11730,6 +11773,7 @@ var syncCommand = defineCommand({
11730
11773
  account: { type: "string", description: "Account name (overrides default)" },
11731
11774
  json: { type: "boolean", description: "Output full result as JSON", default: false },
11732
11775
  quiet: {
11776
+ alias: "q",
11733
11777
  type: "boolean",
11734
11778
  description: "Suppress all output except errors",
11735
11779
  default: false
@@ -11833,14 +11877,24 @@ async function runEmailCli(args = process.argv.slice(2)) {
11833
11877
  index += 2;
11834
11878
  continue;
11835
11879
  }
11836
- if (token === "--compact" || token === "--json" || token === "--quiet" || token === "--no-color" || token?.startsWith("--db=")) {
11880
+ if (["--compact", "--json", "--quiet", "-q", "--no-color"].includes(token ?? "") || token?.startsWith("--db=")) {
11837
11881
  index++;
11838
11882
  continue;
11839
11883
  }
11840
11884
  break;
11841
11885
  }
11842
11886
  const command = args[index];
11843
- if (command && (["mcp", "tools", "call", "skill", "describe", "--version", "-v"].includes(command) || command.startsWith("mail_") || ["mail", "help", "completions", "version", "-V"].includes(command))) {
11887
+ if (command && ([
11888
+ "mcp",
11889
+ "tools",
11890
+ "call",
11891
+ "skill",
11892
+ "describe",
11893
+ "mail",
11894
+ "help",
11895
+ "completions",
11896
+ "version"
11897
+ ].includes(command) || command.startsWith("mail_"))) {
11844
11898
  const { runToolCli: runToolCli2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
11845
11899
  const { emailCliOptions: emailCliOptions2 } = await Promise.resolve().then(() => (init_email_cli_options(), email_cli_options_exports));
11846
11900
  process.exitCode = await runToolCli2(args, emailCliOptions2);
package/dist/index.cjs CHANGED
@@ -3722,8 +3722,22 @@ var runtime_exports = {};
3722
3722
  __export(runtime_exports, {
3723
3723
  init: () => init
3724
3724
  });
3725
+
3726
+ // src/surfaces/cli_args.ts
3727
+ var CliUsageError = class extends Error {
3728
+ exitCode = 2;
3729
+ };
3730
+
3731
+ // src/private_storage.ts
3725
3732
  function preparePrivateStorage(path) {
3726
- node_fs.mkdirSync(node_path.dirname(path), { recursive: true, mode: 448 });
3733
+ const directory = node_path.dirname(path);
3734
+ try {
3735
+ node_fs.mkdirSync(directory, { recursive: true, mode: 448 });
3736
+ } catch (error) {
3737
+ const code = error.code;
3738
+ const reason = code === "ENOTDIR" || code === "EEXIST" ? "a path component is not a directory" : code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EROFS" ? "read-only file system" : code;
3739
+ throw new CliUsageError(`Cannot create database directory ${directory}: ${reason}`);
3740
+ }
3727
3741
  const created = [];
3728
3742
  for (const file of [path, `${path}-wal`, `${path}-shm`]) {
3729
3743
  try {
package/dist/index.js CHANGED
@@ -3698,8 +3698,22 @@ var runtime_exports = {};
3698
3698
  __export(runtime_exports, {
3699
3699
  init: () => init
3700
3700
  });
3701
+
3702
+ // src/surfaces/cli_args.ts
3703
+ var CliUsageError = class extends Error {
3704
+ exitCode = 2;
3705
+ };
3706
+
3707
+ // src/private_storage.ts
3701
3708
  function preparePrivateStorage(path) {
3702
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
3709
+ const directory = dirname(path);
3710
+ try {
3711
+ mkdirSync(directory, { recursive: true, mode: 448 });
3712
+ } catch (error) {
3713
+ const code = error.code;
3714
+ const reason = code === "ENOTDIR" || code === "EEXIST" ? "a path component is not a directory" : code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EROFS" ? "read-only file system" : code;
3715
+ throw new CliUsageError(`Cannot create database directory ${directory}: ${reason}`);
3716
+ }
3703
3717
  const created = [];
3704
3718
  for (const file of [path, `${path}-wal`, `${path}-shm`]) {
3705
3719
  try {
@@ -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.10";
319
+ emailVersion = "0.5.11";
320
320
  }
321
321
  });
322
322
 
@@ -2267,6 +2267,16 @@ var init_config = __esm({
2267
2267
  }
2268
2268
  });
2269
2269
 
2270
+ // src/surfaces/cli_args.ts
2271
+ var CliUsageError;
2272
+ var init_cli_args = __esm({
2273
+ "src/surfaces/cli_args.ts"() {
2274
+ CliUsageError = class extends Error {
2275
+ exitCode = 2;
2276
+ };
2277
+ }
2278
+ });
2279
+
2270
2280
  // src/cli/errors.ts
2271
2281
  var EXIT_CODES, CliError;
2272
2282
  var init_errors2 = __esm({
@@ -6345,7 +6355,14 @@ var init_email_mcp_options = __esm({
6345
6355
  }
6346
6356
  });
6347
6357
  function preparePrivateStorage(path) {
6348
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
6358
+ const directory = dirname(path);
6359
+ try {
6360
+ mkdirSync(directory, { recursive: true, mode: 448 });
6361
+ } catch (error) {
6362
+ const code = error.code;
6363
+ const reason = code === "ENOTDIR" || code === "EEXIST" ? "a path component is not a directory" : code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EROFS" ? "read-only file system" : code;
6364
+ throw new CliUsageError(`Cannot create database directory ${directory}: ${reason}`);
6365
+ }
6349
6366
  const created = [];
6350
6367
  for (const file of [path, `${path}-wal`, `${path}-shm`]) {
6351
6368
  try {
@@ -6378,6 +6395,7 @@ function withPrivateCreation(operation, secure) {
6378
6395
  }
6379
6396
  var init_private_storage = __esm({
6380
6397
  "src/private_storage.ts"() {
6398
+ init_cli_args();
6381
6399
  }
6382
6400
  });
6383
6401
 
package/dist/mcp.cjs CHANGED
@@ -1020,6 +1020,16 @@ var init_config = __esm({
1020
1020
  }
1021
1021
  });
1022
1022
 
1023
+ // src/surfaces/cli_args.ts
1024
+ var CliUsageError;
1025
+ var init_cli_args = __esm({
1026
+ "src/surfaces/cli_args.ts"() {
1027
+ CliUsageError = class extends Error {
1028
+ exitCode = 2;
1029
+ };
1030
+ }
1031
+ });
1032
+
1023
1033
  // src/cli/errors.ts
1024
1034
  var EXIT_CODES, CliError;
1025
1035
  var init_errors2 = __esm({
@@ -5008,7 +5018,7 @@ var init_network = __esm({
5008
5018
  });
5009
5019
 
5010
5020
  // src/version.ts
5011
- var emailVersion = "0.5.10";
5021
+ var emailVersion = "0.5.11";
5012
5022
 
5013
5023
  // src/surface/email_mcp_instructions.ts
5014
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.";
@@ -6130,8 +6140,18 @@ function emailMcpOptions(context) {
6130
6140
  })
6131
6141
  };
6132
6142
  }
6143
+
6144
+ // src/private_storage.ts
6145
+ init_cli_args();
6133
6146
  function preparePrivateStorage(path) {
6134
- node_fs.mkdirSync(node_path.dirname(path), { recursive: true, mode: 448 });
6147
+ const directory = node_path.dirname(path);
6148
+ try {
6149
+ node_fs.mkdirSync(directory, { recursive: true, mode: 448 });
6150
+ } catch (error) {
6151
+ const code = error.code;
6152
+ const reason = code === "ENOTDIR" || code === "EEXIST" ? "a path component is not a directory" : code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EROFS" ? "read-only file system" : code;
6153
+ throw new CliUsageError(`Cannot create database directory ${directory}: ${reason}`);
6154
+ }
6135
6155
  const created = [];
6136
6156
  for (const file of [path, `${path}-wal`, `${path}-shm`]) {
6137
6157
  try {
package/dist/mcp.js CHANGED
@@ -996,6 +996,16 @@ var init_config = __esm({
996
996
  }
997
997
  });
998
998
 
999
+ // src/surfaces/cli_args.ts
1000
+ var CliUsageError;
1001
+ var init_cli_args = __esm({
1002
+ "src/surfaces/cli_args.ts"() {
1003
+ CliUsageError = class extends Error {
1004
+ exitCode = 2;
1005
+ };
1006
+ }
1007
+ });
1008
+
999
1009
  // src/cli/errors.ts
1000
1010
  var EXIT_CODES, CliError;
1001
1011
  var init_errors2 = __esm({
@@ -4984,7 +4994,7 @@ var init_network = __esm({
4984
4994
  });
4985
4995
 
4986
4996
  // src/version.ts
4987
- var emailVersion = "0.5.10";
4997
+ var emailVersion = "0.5.11";
4988
4998
 
4989
4999
  // src/surface/email_mcp_instructions.ts
4990
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.";
@@ -6106,8 +6116,18 @@ function emailMcpOptions(context) {
6106
6116
  })
6107
6117
  };
6108
6118
  }
6119
+
6120
+ // src/private_storage.ts
6121
+ init_cli_args();
6109
6122
  function preparePrivateStorage(path) {
6110
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
6123
+ const directory = dirname(path);
6124
+ try {
6125
+ mkdirSync(directory, { recursive: true, mode: 448 });
6126
+ } catch (error) {
6127
+ const code = error.code;
6128
+ const reason = code === "ENOTDIR" || code === "EEXIST" ? "a path component is not a directory" : code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EROFS" ? "read-only file system" : code;
6129
+ throw new CliUsageError(`Cannot create database directory ${directory}: ${reason}`);
6130
+ }
6111
6131
  const created = [];
6112
6132
  for (const file of [path, `${path}-wal`, `${path}-shm`]) {
6113
6133
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostpaw/email",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
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": {
@@ -25,6 +25,31 @@ Run tools as `ghostpaw-email ...`; use `~/.local/bin/ghostpaw-email` if it is no
25
25
 
26
26
  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.
27
27
 
28
+ ## Running inside sandboxed agent harnesses
29
+
30
+ Inside a Codex CLI `--sandbox workspace-write` session, the database and its
31
+ parent directory must be inside a writable root, including SQLite's `-wal` and
32
+ `-shm` side files. A default DB under `~/.ghostpaw` outside those roots can fail
33
+ with `SQLITE_CANTOPEN` or `EPERM` (often exit 70; directory creation failures
34
+ may exit 2), even when normal shell permissions allow access. Put the DB inside the workspace with `--db ./state/email.db`,
35
+ or set `GHOSTPAW_EMAIL_DB="$PWD/state/email.db"` for CLI/MCP use.
36
+
37
+ To use an external DB directory, add it when starting the OpenAI Codex CLI
38
+ (replace `<dir-with-db>` with its absolute path):
39
+
40
+ ```sh
41
+ codex exec --sandbox workspace-write --add-dir <dir-with-db> "Run the GhostPaw CLI"
42
+ ```
43
+
44
+ Alternatively, set `sandbox_workspace_write.writable_roots` in
45
+ `~/.codex/config.toml` before starting the session:
46
+
47
+ ```toml
48
+ [sandbox_workspace_write]
49
+ writable_roots = ["/absolute/dir-with-db"]
50
+ ```
51
+
52
+
28
53
  For the compact cheat sheet, run `ghostpaw-email skill --short`.
29
54
 
30
55
  ## Calling tools
@@ -271,8 +271,8 @@ email read eml --folder INBOX --uid 42 | mail -s "fwd" target@example.com
271
271
  # JSON pipeline
272
272
  email read queue --json | jq '.entities[] | select(.title | test("invoice"; "i")) | .id'
273
273
 
274
- # Quiet mode — only exit code matters
275
- email organize archive --folder INBOX --uids 42 --quiet && echo "archived"
274
+ # -q, --quiet: exit code only
275
+ email organize archive --folder INBOX --uids 42 -q && echo "archived"
276
276
  ```
277
277
 
278
278
  ---