@ghostpaw/email 0.5.9 → 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 +34 -5
- package/SKILL.md +25 -0
- package/dist/cli.js +211 -126
- package/dist/index.cjs +15 -1
- package/dist/index.js +15 -1
- package/dist/mcp-server.js +21 -2
- package/dist/mcp.cjs +23 -2
- package/dist/mcp.d.cts +2 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +23 -2
- package/package.json +1 -1
- package/skills/email/SKILL.md +25 -0
- package/skills/email/references/cli.md +2 -2
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
|
|
@@ -102,12 +127,16 @@ These 33 paths map to the 5 aligned tools. Action verbs set the tool's action;
|
|
|
102
127
|
`draft` sets `save_draft`. Search accepts its query as a positional argument.
|
|
103
128
|
Other fields use kebab-case flags, such as `--folder INBOX --uids 1 --uids 2`
|
|
104
129
|
and `--input @message.json` for a compose payload. Arrays accept repeated
|
|
105
|
-
flags or JSON; objects accept JSON
|
|
130
|
+
flags or JSON; objects accept JSON. Values are literal, including a leading
|
|
131
|
+
`@`. Two flags read files: `--input` on the `mail` compose verbs and `--body`
|
|
132
|
+
on `compose send|reply|draft`. On those, `@path` reads the file, `@-` reads
|
|
133
|
+
stdin and `@@text` passes `@text`; help marks them `(@file, @- stdin, @@ literal @)`. An
|
|
134
|
+
empty or unreadable path exits 2. A single `-` reads stdin JSON;
|
|
106
135
|
explicit flags override stdin fields. `--` ends option parsing.
|
|
107
136
|
|
|
108
|
-
Global flags for the new commands: `--db <path>`, `--json`,
|
|
137
|
+
Global flags for the new commands: `--db <path>`, `--json`, `-q, --quiet`,
|
|
109
138
|
`--compact`, `--help`/`-h`, `--version`/`-V`/`-v`, `--no-color`.
|
|
110
|
-
Output is JSON when piped or when `--json` is set.
|
|
139
|
+
Output is JSON when piped or when `--json` is set. `-q, --quiet` suppresses stdout.
|
|
111
140
|
`completions bash|zsh|fish` prints shell completion setup; `version` prints
|
|
112
141
|
the version and installation variant. The existing `tools [--json]`, `describe <tool>`,
|
|
113
142
|
`call <tool> [JSON|-]`, flat `mail_<tool> --parameter value`, `mcp` and `skill`
|
|
@@ -195,7 +224,7 @@ irm https://raw.githubusercontent.com/GhostPawJS/email/main/install.ps1 | iex
|
|
|
195
224
|
Pinned to a release:
|
|
196
225
|
|
|
197
226
|
```sh
|
|
198
|
-
curl -fsSL https://raw.githubusercontent.com/GhostPawJS/email/main/install.sh | sh -s -- --target linux-x64 --version 0.5.
|
|
227
|
+
curl -fsSL https://raw.githubusercontent.com/GhostPawJS/email/main/install.sh | sh -s -- --target linux-x64 --version 0.5.10 && export PATH="$HOME/.local/bin:$PATH"
|
|
199
228
|
```
|
|
200
229
|
|
|
201
230
|
Also adding ~/.local/bin to ~/.profile (edits ~/.profile once; skipped if it already mentions ~/.local/bin; zsh login shells read ~/.zprofile instead, so use that file name there):
|
|
@@ -212,7 +241,7 @@ $env:GHOSTPAW_NO_MODIFY_PATH=1; irm https://raw.githubusercontent.com/GhostPawJS
|
|
|
212
241
|
|
|
213
242
|
```text
|
|
214
243
|
$ ghostpaw-email --version
|
|
215
|
-
email 0.5.
|
|
244
|
+
email 0.5.10 (binary, linux-x64)
|
|
216
245
|
```
|
|
217
246
|
|
|
218
247
|
Scripts that compare versions should use `--version --short` or `--version --json`.
|
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.
|
|
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 = {
|
|
@@ -1228,6 +1343,7 @@ var init_errors2 = __esm({
|
|
|
1228
1343
|
missing_required_flag: 1,
|
|
1229
1344
|
invalid_flag_value: 1,
|
|
1230
1345
|
body_required: 1,
|
|
1346
|
+
invalid_file_value: 2,
|
|
1231
1347
|
unknown_subaction: 1
|
|
1232
1348
|
};
|
|
1233
1349
|
CliError = class extends Error {
|
|
@@ -6102,7 +6218,14 @@ var init_read = __esm({
|
|
|
6102
6218
|
}
|
|
6103
6219
|
});
|
|
6104
6220
|
function preparePrivateStorage(path) {
|
|
6105
|
-
|
|
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
|
+
}
|
|
6106
6229
|
const created = [];
|
|
6107
6230
|
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6108
6231
|
try {
|
|
@@ -6135,6 +6258,7 @@ function withPrivateCreation(operation, secure) {
|
|
|
6135
6258
|
}
|
|
6136
6259
|
var init_private_storage = __esm({
|
|
6137
6260
|
"src/private_storage.ts"() {
|
|
6261
|
+
init_cli_args();
|
|
6138
6262
|
}
|
|
6139
6263
|
});
|
|
6140
6264
|
|
|
@@ -7157,114 +7281,6 @@ var init_write = __esm({
|
|
|
7157
7281
|
init_store();
|
|
7158
7282
|
}
|
|
7159
7283
|
});
|
|
7160
|
-
function parseCliArgs(argv2, spec) {
|
|
7161
|
-
const values = {};
|
|
7162
|
-
const positions = [];
|
|
7163
|
-
const flags = spec.flags ?? [];
|
|
7164
|
-
const convert = (raw2, arg) => {
|
|
7165
|
-
let value = raw2;
|
|
7166
|
-
if (raw2.startsWith("@")) {
|
|
7167
|
-
try {
|
|
7168
|
-
value = readFileSync(raw2.slice(1), "utf8");
|
|
7169
|
-
} catch {
|
|
7170
|
-
throw new CliUsageError(`Cannot read value file: ${raw2.slice(1)}`);
|
|
7171
|
-
}
|
|
7172
|
-
}
|
|
7173
|
-
let result = value;
|
|
7174
|
-
if (arg.type === "number" || arg.type === "integer") {
|
|
7175
|
-
result = Number(value);
|
|
7176
|
-
if (!value.trim() || !Number.isFinite(result) || arg.type === "integer" && !Number.isInteger(result))
|
|
7177
|
-
throw new CliUsageError(`Expected ${arg.type} for ${arg.name}: ${value}`);
|
|
7178
|
-
} else if (arg.type === "boolean") {
|
|
7179
|
-
if (!["true", "false"].includes(value))
|
|
7180
|
-
throw new CliUsageError(`Expected boolean for ${arg.name}`);
|
|
7181
|
-
result = value === "true";
|
|
7182
|
-
} else if (arg.type === "json") {
|
|
7183
|
-
try {
|
|
7184
|
-
result = JSON.parse(value);
|
|
7185
|
-
} catch {
|
|
7186
|
-
throw new CliUsageError(`Invalid JSON for ${arg.name}`);
|
|
7187
|
-
}
|
|
7188
|
-
}
|
|
7189
|
-
if (arg.enum && !arg.enum.includes(result))
|
|
7190
|
-
throw new CliUsageError(`${arg.name} must be one of: ${arg.enum.join(", ")}`);
|
|
7191
|
-
return result;
|
|
7192
|
-
};
|
|
7193
|
-
let ended = false;
|
|
7194
|
-
for (let i2 = 0; i2 < argv2.length; i2++) {
|
|
7195
|
-
const token = argv2[i2];
|
|
7196
|
-
if (!ended && token === "--") {
|
|
7197
|
-
ended = true;
|
|
7198
|
-
continue;
|
|
7199
|
-
}
|
|
7200
|
-
if (ended || token === "-" || !token.startsWith("-")) {
|
|
7201
|
-
positions.push(token);
|
|
7202
|
-
continue;
|
|
7203
|
-
}
|
|
7204
|
-
const [flag, inline] = token.split(/=(.*)/s);
|
|
7205
|
-
const negative = flag?.startsWith("--no-");
|
|
7206
|
-
const name = flag?.replace(/^--?/, "").replace(/^no-/, "");
|
|
7207
|
-
const arg = flags.find(
|
|
7208
|
-
(entry) => entry.name === name || keyOf(entry.name) === name || entry.short === name
|
|
7209
|
-
);
|
|
7210
|
-
if (!arg) {
|
|
7211
|
-
const prefix = (name ?? "").slice(0, 3);
|
|
7212
|
-
const suggestion = prefix ? flags.find((entry) => entry.name.startsWith(prefix)) : void 0;
|
|
7213
|
-
throw new CliUsageError(
|
|
7214
|
-
`Unknown flag: ${flag}${suggestion ? `; did you mean --${suggestion.name}?` : ""}`
|
|
7215
|
-
);
|
|
7216
|
-
}
|
|
7217
|
-
if (negative && arg.type !== "boolean")
|
|
7218
|
-
throw new CliUsageError(`--no-${arg.name} requires a boolean flag`);
|
|
7219
|
-
let raw2 = inline;
|
|
7220
|
-
if (arg.type === "boolean" && raw2 === void 0) raw2 = negative ? "false" : "true";
|
|
7221
|
-
if (raw2 === void 0) {
|
|
7222
|
-
const next = argv2[i2 + 1];
|
|
7223
|
-
if (next === void 0 || /^--[a-z]/i.test(next))
|
|
7224
|
-
throw new CliUsageError(`Missing value: --${arg.name}`);
|
|
7225
|
-
raw2 = next;
|
|
7226
|
-
i2++;
|
|
7227
|
-
}
|
|
7228
|
-
const key = keyOf(arg.name);
|
|
7229
|
-
if (arg.type === "array") {
|
|
7230
|
-
const item = convert(raw2, { ...arg, type: arg.itemType ?? "string" });
|
|
7231
|
-
values[key] = [...values[key] ?? [], item];
|
|
7232
|
-
} else values[key] = convert(raw2, arg);
|
|
7233
|
-
}
|
|
7234
|
-
let index = 0;
|
|
7235
|
-
for (const arg of spec.positionals ?? []) {
|
|
7236
|
-
if (index >= positions.length) continue;
|
|
7237
|
-
values[keyOf(arg.name)] = arg.variadic ? positions.slice(index).map((value) => convert(value, { ...arg, type: arg.itemType ?? arg.type })) : convert(positions[index], arg);
|
|
7238
|
-
index = arg.variadic ? positions.length : index + 1;
|
|
7239
|
-
}
|
|
7240
|
-
if (index < positions.length)
|
|
7241
|
-
throw new CliUsageError(`Unexpected positional: ${positions[index]}`);
|
|
7242
|
-
for (const arg of [...flags, ...spec.positionals ?? []]) {
|
|
7243
|
-
if (arg.required && values[keyOf(arg.name)] === void 0)
|
|
7244
|
-
throw new CliUsageError(`Missing required argument: ${arg.name}`);
|
|
7245
|
-
}
|
|
7246
|
-
return values;
|
|
7247
|
-
}
|
|
7248
|
-
function renderCliHelp(spec) {
|
|
7249
|
-
const describe = (arg) => `${arg.type}${arg.enum ? ` (${arg.enum.join("|")})` : ""}${arg.required ? " required" : ""} ${arg.description ?? ""}`;
|
|
7250
|
-
return `Usage: ${spec.command} ${(spec.positionals ?? []).map((arg) => `<${arg.name}${arg.variadic ? "..." : ""}>`).join(" ")} [flags]
|
|
7251
|
-
${spec.description ?? ""}
|
|
7252
|
-
|
|
7253
|
-
Positionals:
|
|
7254
|
-
${(spec.positionals ?? []).map((arg) => ` ${arg.name} ${describe(arg)}`).join("\n")}
|
|
7255
|
-
Flags:
|
|
7256
|
-
${(spec.flags ?? []).map((arg) => ` --${arg.name}${arg.short ? `, -${arg.short}` : ""} ${describe(arg)}`).join("\n")}
|
|
7257
|
-
`;
|
|
7258
|
-
}
|
|
7259
|
-
var CliUsageError, keyOf;
|
|
7260
|
-
var init_cli_args = __esm({
|
|
7261
|
-
"src/surfaces/cli_args.ts"() {
|
|
7262
|
-
CliUsageError = class extends Error {
|
|
7263
|
-
exitCode = 2;
|
|
7264
|
-
};
|
|
7265
|
-
keyOf = (name) => name.replace(/-([a-z])/g, (_3, c3) => c3.toUpperCase());
|
|
7266
|
-
}
|
|
7267
|
-
});
|
|
7268
7284
|
|
|
7269
7285
|
// src/surfaces/cli_commands.ts
|
|
7270
7286
|
function cliCommands(tools) {
|
|
@@ -7290,7 +7306,8 @@ async function runCliCommand(argv2, options) {
|
|
|
7290
7306
|
const stdin2 = options.stdin ?? process.stdin;
|
|
7291
7307
|
const args = [...argv2];
|
|
7292
7308
|
const tree = cliCommands(options.tools);
|
|
7293
|
-
|
|
7309
|
+
const isQuiet = (arg) => arg === "--quiet" || arg === "-q";
|
|
7310
|
+
let json = argv2.includes("--json"), quiet = argv2.some(isQuiet), compact = false, help = false;
|
|
7294
7311
|
let db;
|
|
7295
7312
|
const fail = (message, code) => {
|
|
7296
7313
|
stderr.write(`${message}
|
|
@@ -7324,7 +7341,7 @@ async function runCliCommand(argv2, options) {
|
|
|
7324
7341
|
db = flag === "--db" ? args.splice(i2 + 1, 1)[0] : flag.slice(5);
|
|
7325
7342
|
if (!db || db.startsWith("--")) throw new CliUsageError("--db requires a path");
|
|
7326
7343
|
} else if (flag === "--json") json = true;
|
|
7327
|
-
else if (flag
|
|
7344
|
+
else if (isQuiet(flag)) quiet = true;
|
|
7328
7345
|
else if (flag === "--compact") compact = true;
|
|
7329
7346
|
else if (flag === "--help" || flag === "-h") help = true;
|
|
7330
7347
|
else if (["--version", "-V", "-v"].includes(flag ?? "")) {
|
|
@@ -7353,6 +7370,9 @@ async function runCliCommand(argv2, options) {
|
|
|
7353
7370
|
type: schema.type === "object" || !schema.type ? "json" : schema.type,
|
|
7354
7371
|
description: schema.description,
|
|
7355
7372
|
enum: schema.enum,
|
|
7373
|
+
...command.tool.cli?.fileArgs?.includes(
|
|
7374
|
+
name.replace(/-([a-z])/g, (_3, c3) => c3.toUpperCase())
|
|
7375
|
+
) ? { file: true } : {},
|
|
7356
7376
|
...schema.items?.type ? { itemType: schema.items.type } : {}
|
|
7357
7377
|
});
|
|
7358
7378
|
const properties = command.tool.inputSchema.properties ?? {};
|
|
@@ -7388,7 +7408,7 @@ Commands:
|
|
|
7388
7408
|
${matches.map((command) => ` ${command.path}`).join("\n")}
|
|
7389
7409
|
mcp, skill, tools [--json], describe <tool>, call <tool> [JSON|-], completions <bash|zsh|fish>, version
|
|
7390
7410
|
Version output: --version --short or --version --json
|
|
7391
|
-
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
|
|
7392
7412
|
`
|
|
7393
7413
|
);
|
|
7394
7414
|
return 0;
|
|
@@ -7689,7 +7709,10 @@ ${JSON.stringify(tool.inputSchema, null, 2)}
|
|
|
7689
7709
|
try {
|
|
7690
7710
|
context = await options.openContext(ctxOptions);
|
|
7691
7711
|
} catch (cause) {
|
|
7692
|
-
return fail(
|
|
7712
|
+
return fail(
|
|
7713
|
+
cause instanceof CliUsageError ? cause.message : String(cause),
|
|
7714
|
+
cause instanceof CliUsageError ? 2 : 1
|
|
7715
|
+
);
|
|
7693
7716
|
}
|
|
7694
7717
|
try {
|
|
7695
7718
|
const result = await tool.handler(context, input);
|
|
@@ -7707,6 +7730,7 @@ ${JSON.stringify(tool.inputSchema, null, 2)}
|
|
|
7707
7730
|
var init_cli = __esm({
|
|
7708
7731
|
"src/surfaces/cli.ts"() {
|
|
7709
7732
|
init_cli_version();
|
|
7733
|
+
init_cli_args();
|
|
7710
7734
|
init_cli_commands();
|
|
7711
7735
|
init_parameter_rows();
|
|
7712
7736
|
init_surface_types();
|
|
@@ -8004,8 +8028,8 @@ email read eml --folder INBOX --uid 42 | mail -s "fwd" target@example.com
|
|
|
8004
8028
|
# JSON pipeline
|
|
8005
8029
|
email read queue --json | jq '.entities[] | select(.title | test("invoice"; "i")) | .id'
|
|
8006
8030
|
|
|
8007
|
-
#
|
|
8008
|
-
email organize archive --folder INBOX --uids 42
|
|
8031
|
+
# -q, --quiet: exit code only
|
|
8032
|
+
email organize archive --folder INBOX --uids 42 -q && echo "archived"
|
|
8009
8033
|
\`\`\`
|
|
8010
8034
|
|
|
8011
8035
|
---
|
|
@@ -8502,6 +8526,7 @@ var init_email_surface_tools = __esm({
|
|
|
8502
8526
|
noun: "mail",
|
|
8503
8527
|
verb: tool.name.slice(5),
|
|
8504
8528
|
...tool.name === "mail_search" ? { positionals: ["query"] } : {},
|
|
8529
|
+
...tool.name === "mail_compose" ? { fileArgs: ["input"] } : {},
|
|
8505
8530
|
...tool.inputSchema.properties?.action?.enum ? {
|
|
8506
8531
|
action: {
|
|
8507
8532
|
property: "action",
|
|
@@ -8943,7 +8968,32 @@ var init_email_skill_spec = __esm({
|
|
|
8943
8968
|
bin: "ghostpaw-email",
|
|
8944
8969
|
packageName: "@ghostpaw/email",
|
|
8945
8970
|
server: "ghostpaw-email",
|
|
8946
|
-
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
|
+
`,
|
|
8947
8997
|
tools: emailSurfaceTools,
|
|
8948
8998
|
workflows: [...emailSkills, { name: "cli", description: "Complete existing email CLI guide." }],
|
|
8949
8999
|
principles: [
|
|
@@ -10755,6 +10805,9 @@ function redactAuth(auth) {
|
|
|
10755
10805
|
return { type: "sasl", mechanism: auth.mechanism, credentials: "[redacted]" };
|
|
10756
10806
|
}
|
|
10757
10807
|
|
|
10808
|
+
// src/cli/commands/compose.ts
|
|
10809
|
+
init_cli_args();
|
|
10810
|
+
|
|
10758
10811
|
// src/tools/index.ts
|
|
10759
10812
|
init_aligned();
|
|
10760
10813
|
|
|
@@ -10995,6 +11048,7 @@ var sharedArgs = {
|
|
|
10995
11048
|
account: { type: "string", description: "Account name (overrides default)" },
|
|
10996
11049
|
json: { type: "boolean", description: "Output full result as JSON", default: false },
|
|
10997
11050
|
quiet: {
|
|
11051
|
+
alias: "q",
|
|
10998
11052
|
type: "boolean",
|
|
10999
11053
|
description: "Suppress all output except errors",
|
|
11000
11054
|
default: false
|
|
@@ -11009,7 +11063,10 @@ var composeCommand = defineCommand({
|
|
|
11009
11063
|
...sharedArgs,
|
|
11010
11064
|
to: { type: "string", description: "Recipient(s), comma-separated", required: true },
|
|
11011
11065
|
subject: { type: "string", description: "Email subject", required: true },
|
|
11012
|
-
body: {
|
|
11066
|
+
body: {
|
|
11067
|
+
type: "string",
|
|
11068
|
+
description: "Email body text (or pipe via stdin) (@file, @- stdin, @@ literal @)"
|
|
11069
|
+
},
|
|
11013
11070
|
html: { type: "boolean", description: "Treat body as HTML", default: false },
|
|
11014
11071
|
cc: { type: "string", description: "CC recipient(s), comma-separated" },
|
|
11015
11072
|
bcc: { type: "string", description: "BCC recipient(s), comma-separated" },
|
|
@@ -11049,7 +11106,10 @@ var composeCommand = defineCommand({
|
|
|
11049
11106
|
...sharedArgs,
|
|
11050
11107
|
folder: { type: "string", description: "Source folder", required: true },
|
|
11051
11108
|
uid: { type: "string", description: "Source message UID", required: true },
|
|
11052
|
-
body: {
|
|
11109
|
+
body: {
|
|
11110
|
+
type: "string",
|
|
11111
|
+
description: "Reply body (or pipe via stdin) (@file, @- stdin, @@ literal @)"
|
|
11112
|
+
},
|
|
11053
11113
|
html: { type: "boolean", description: "Treat body as HTML", default: false },
|
|
11054
11114
|
to: { type: "string", description: "Override recipient(s)" },
|
|
11055
11115
|
cc: { type: "string", description: "CC recipient(s)" },
|
|
@@ -11105,7 +11165,7 @@ var composeCommand = defineCommand({
|
|
|
11105
11165
|
const args = _args;
|
|
11106
11166
|
await safeRun(_args, async () => {
|
|
11107
11167
|
const uid = parseUid(args.uid);
|
|
11108
|
-
const body = await resolveBody(args.body, false);
|
|
11168
|
+
const body = await resolveBody(args.body, false, false);
|
|
11109
11169
|
const mode = args.mode;
|
|
11110
11170
|
if (mode !== void 0 && mode !== "inline" && mode !== "attachment") {
|
|
11111
11171
|
throw new CliError("invalid_flag_value", '--mode must be "inline" or "attachment".');
|
|
@@ -11138,7 +11198,10 @@ var composeCommand = defineCommand({
|
|
|
11138
11198
|
"update-draft": { type: "string", description: "UID of draft to update" },
|
|
11139
11199
|
to: { type: "string", description: "Recipient(s), comma-separated" },
|
|
11140
11200
|
subject: { type: "string", description: "Email subject" },
|
|
11141
|
-
body: {
|
|
11201
|
+
body: {
|
|
11202
|
+
type: "string",
|
|
11203
|
+
description: "Draft body (or pipe via stdin) (@file, @- stdin, @@ literal @)"
|
|
11204
|
+
},
|
|
11142
11205
|
html: { type: "boolean", description: "Treat body as HTML", default: false },
|
|
11143
11206
|
cc: { type: "string", description: "CC recipient(s)" },
|
|
11144
11207
|
from: { type: "string", description: "From address" }
|
|
@@ -11194,8 +11257,16 @@ var composeCommand = defineCommand({
|
|
|
11194
11257
|
})
|
|
11195
11258
|
}
|
|
11196
11259
|
});
|
|
11197
|
-
|
|
11198
|
-
|
|
11260
|
+
function bodyValue(raw2) {
|
|
11261
|
+
try {
|
|
11262
|
+
return readFileValue(raw2, "body");
|
|
11263
|
+
} catch (error) {
|
|
11264
|
+
if (error instanceof CliUsageError) throw new CliError("invalid_file_value", error.message);
|
|
11265
|
+
throw error;
|
|
11266
|
+
}
|
|
11267
|
+
}
|
|
11268
|
+
async function resolveBody(flagValue, required = true, fileCapable = true) {
|
|
11269
|
+
if (flagValue !== void 0) return fileCapable ? bodyValue(flagValue) : flagValue;
|
|
11199
11270
|
if (isStdinPiped()) return readStdin();
|
|
11200
11271
|
if (required) {
|
|
11201
11272
|
throw new CliError(
|
|
@@ -11260,6 +11331,7 @@ var organizeCommand = defineCommand({
|
|
|
11260
11331
|
account: { type: "string", description: "Account name (overrides default)" },
|
|
11261
11332
|
json: { type: "boolean", description: "Output full result as JSON", default: false },
|
|
11262
11333
|
quiet: {
|
|
11334
|
+
alias: "q",
|
|
11263
11335
|
type: "boolean",
|
|
11264
11336
|
description: "Suppress all output except errors",
|
|
11265
11337
|
default: false
|
|
@@ -11456,6 +11528,7 @@ var sharedArgs2 = {
|
|
|
11456
11528
|
account: { type: "string", description: "Account name (overrides default)" },
|
|
11457
11529
|
json: { type: "boolean", description: "Output full result as JSON", default: false },
|
|
11458
11530
|
quiet: {
|
|
11531
|
+
alias: "q",
|
|
11459
11532
|
type: "boolean",
|
|
11460
11533
|
description: "Suppress all output except errors",
|
|
11461
11534
|
default: false
|
|
@@ -11626,6 +11699,7 @@ var searchCommand = defineCommand({
|
|
|
11626
11699
|
account: { type: "string", description: "Account name (overrides default)" },
|
|
11627
11700
|
json: { type: "boolean", description: "Output full result as JSON", default: false },
|
|
11628
11701
|
quiet: {
|
|
11702
|
+
alias: "q",
|
|
11629
11703
|
type: "boolean",
|
|
11630
11704
|
description: "Suppress all output except errors",
|
|
11631
11705
|
default: false
|
|
@@ -11699,6 +11773,7 @@ var syncCommand = defineCommand({
|
|
|
11699
11773
|
account: { type: "string", description: "Account name (overrides default)" },
|
|
11700
11774
|
json: { type: "boolean", description: "Output full result as JSON", default: false },
|
|
11701
11775
|
quiet: {
|
|
11776
|
+
alias: "q",
|
|
11702
11777
|
type: "boolean",
|
|
11703
11778
|
description: "Suppress all output except errors",
|
|
11704
11779
|
default: false
|
|
@@ -11802,14 +11877,24 @@ async function runEmailCli(args = process.argv.slice(2)) {
|
|
|
11802
11877
|
index += 2;
|
|
11803
11878
|
continue;
|
|
11804
11879
|
}
|
|
11805
|
-
if (
|
|
11880
|
+
if (["--compact", "--json", "--quiet", "-q", "--no-color"].includes(token ?? "") || token?.startsWith("--db=")) {
|
|
11806
11881
|
index++;
|
|
11807
11882
|
continue;
|
|
11808
11883
|
}
|
|
11809
11884
|
break;
|
|
11810
11885
|
}
|
|
11811
11886
|
const command = args[index];
|
|
11812
|
-
if (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_"))) {
|
|
11813
11898
|
const { runToolCli: runToolCli2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
|
|
11814
11899
|
const { emailCliOptions: emailCliOptions2 } = await Promise.resolve().then(() => (init_email_cli_options(), email_cli_options_exports));
|
|
11815
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
|
-
|
|
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
|
-
|
|
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 {
|
package/dist/mcp-server.js
CHANGED
|
@@ -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.
|
|
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({
|
|
@@ -2285,6 +2295,7 @@ var init_errors2 = __esm({
|
|
|
2285
2295
|
missing_required_flag: 1,
|
|
2286
2296
|
invalid_flag_value: 1,
|
|
2287
2297
|
body_required: 1,
|
|
2298
|
+
invalid_file_value: 2,
|
|
2288
2299
|
unknown_subaction: 1
|
|
2289
2300
|
};
|
|
2290
2301
|
CliError = class extends Error {
|
|
@@ -6344,7 +6355,14 @@ var init_email_mcp_options = __esm({
|
|
|
6344
6355
|
}
|
|
6345
6356
|
});
|
|
6346
6357
|
function preparePrivateStorage(path) {
|
|
6347
|
-
|
|
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
|
+
}
|
|
6348
6366
|
const created = [];
|
|
6349
6367
|
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6350
6368
|
try {
|
|
@@ -6377,6 +6395,7 @@ function withPrivateCreation(operation, secure) {
|
|
|
6377
6395
|
}
|
|
6378
6396
|
var init_private_storage = __esm({
|
|
6379
6397
|
"src/private_storage.ts"() {
|
|
6398
|
+
init_cli_args();
|
|
6380
6399
|
}
|
|
6381
6400
|
});
|
|
6382
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({
|
|
@@ -1038,6 +1048,7 @@ var init_errors2 = __esm({
|
|
|
1038
1048
|
missing_required_flag: 1,
|
|
1039
1049
|
invalid_flag_value: 1,
|
|
1040
1050
|
body_required: 1,
|
|
1051
|
+
invalid_file_value: 2,
|
|
1041
1052
|
unknown_subaction: 1
|
|
1042
1053
|
};
|
|
1043
1054
|
CliError = class extends Error {
|
|
@@ -5007,7 +5018,7 @@ var init_network = __esm({
|
|
|
5007
5018
|
});
|
|
5008
5019
|
|
|
5009
5020
|
// src/version.ts
|
|
5010
|
-
var emailVersion = "0.5.
|
|
5021
|
+
var emailVersion = "0.5.11";
|
|
5011
5022
|
|
|
5012
5023
|
// src/surface/email_mcp_instructions.ts
|
|
5013
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.";
|
|
@@ -6129,8 +6140,18 @@ function emailMcpOptions(context) {
|
|
|
6129
6140
|
})
|
|
6130
6141
|
};
|
|
6131
6142
|
}
|
|
6143
|
+
|
|
6144
|
+
// src/private_storage.ts
|
|
6145
|
+
init_cli_args();
|
|
6132
6146
|
function preparePrivateStorage(path) {
|
|
6133
|
-
|
|
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
|
+
}
|
|
6134
6155
|
const created = [];
|
|
6135
6156
|
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6136
6157
|
try {
|
package/dist/mcp.d.cts
CHANGED
|
@@ -23,6 +23,8 @@ interface SurfaceTool<TCtx> {
|
|
|
23
23
|
noun?: string;
|
|
24
24
|
verb: string;
|
|
25
25
|
positionals?: string[];
|
|
26
|
+
/** Input properties whose CLI value may be `@path`, `@-` or `@@text`; every other value is literal. */
|
|
27
|
+
fileArgs?: readonly string[];
|
|
26
28
|
action?: {
|
|
27
29
|
property: string;
|
|
28
30
|
verbs?: Record<string, string>;
|
package/dist/mcp.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ interface SurfaceTool<TCtx> {
|
|
|
23
23
|
noun?: string;
|
|
24
24
|
verb: string;
|
|
25
25
|
positionals?: string[];
|
|
26
|
+
/** Input properties whose CLI value may be `@path`, `@-` or `@@text`; every other value is literal. */
|
|
27
|
+
fileArgs?: readonly string[];
|
|
26
28
|
action?: {
|
|
27
29
|
property: string;
|
|
28
30
|
verbs?: Record<string, string>;
|
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({
|
|
@@ -1014,6 +1024,7 @@ var init_errors2 = __esm({
|
|
|
1014
1024
|
missing_required_flag: 1,
|
|
1015
1025
|
invalid_flag_value: 1,
|
|
1016
1026
|
body_required: 1,
|
|
1027
|
+
invalid_file_value: 2,
|
|
1017
1028
|
unknown_subaction: 1
|
|
1018
1029
|
};
|
|
1019
1030
|
CliError = class extends Error {
|
|
@@ -4983,7 +4994,7 @@ var init_network = __esm({
|
|
|
4983
4994
|
});
|
|
4984
4995
|
|
|
4985
4996
|
// src/version.ts
|
|
4986
|
-
var emailVersion = "0.5.
|
|
4997
|
+
var emailVersion = "0.5.11";
|
|
4987
4998
|
|
|
4988
4999
|
// src/surface/email_mcp_instructions.ts
|
|
4989
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.";
|
|
@@ -6105,8 +6116,18 @@ function emailMcpOptions(context) {
|
|
|
6105
6116
|
})
|
|
6106
6117
|
};
|
|
6107
6118
|
}
|
|
6119
|
+
|
|
6120
|
+
// src/private_storage.ts
|
|
6121
|
+
init_cli_args();
|
|
6108
6122
|
function preparePrivateStorage(path) {
|
|
6109
|
-
|
|
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
|
+
}
|
|
6110
6131
|
const created = [];
|
|
6111
6132
|
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6112
6133
|
try {
|
package/package.json
CHANGED
package/skills/email/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
|
|
@@ -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
|
-
#
|
|
275
|
-
email organize archive --folder INBOX --uids 42
|
|
274
|
+
# -q, --quiet: exit code only
|
|
275
|
+
email organize archive --folder INBOX --uids 42 -q && echo "archived"
|
|
276
276
|
```
|
|
277
277
|
|
|
278
278
|
---
|