@ghostpaw/email 0.5.7 → 0.5.8
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 +6 -2
- package/SKILL.md +48 -13
- package/dist/cli.js +166 -51
- package/dist/index.cjs +42 -5
- package/dist/index.js +42 -5
- package/dist/mcp-server.js +54 -13
- package/dist/mcp.cjs +46 -12
- package/dist/mcp.js +47 -13
- package/package.json +1 -1
- package/skills/email/SKILL.md +48 -13
package/README.md
CHANGED
|
@@ -77,6 +77,10 @@ The surface database defaults to `~/.ghostpaw/email.db`; point `--db` at an
|
|
|
77
77
|
existing account cache to read it. Each network call opens and closes its IMAP
|
|
78
78
|
session. Connection commands do not retain a session between calls.
|
|
79
79
|
|
|
80
|
+
On POSIX, new accounts files and SQLite caches (including WAL/SHM sidecars) use mode `0600`, and newly created storage directories use `0700`. Existing permissions are preserved, except rewriting `accounts.json` sets it to `0600`.
|
|
81
|
+
|
|
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
|
+
|
|
80
84
|
## Noun-verb CLI
|
|
81
85
|
|
|
82
86
|
Both `email` and `ghostpaw-email` accept this additive command tree. Existing
|
|
@@ -191,7 +195,7 @@ irm https://raw.githubusercontent.com/GhostPawJS/email/main/install.ps1 | iex
|
|
|
191
195
|
Pinned to a release:
|
|
192
196
|
|
|
193
197
|
```sh
|
|
194
|
-
curl -fsSL https://raw.githubusercontent.com/GhostPawJS/email/main/install.sh | sh -s -- --target linux-x64 --version 0.5.
|
|
198
|
+
curl -fsSL https://raw.githubusercontent.com/GhostPawJS/email/main/install.sh | sh -s -- --target linux-x64 --version 0.5.8 && export PATH="$HOME/.local/bin:$PATH"
|
|
195
199
|
```
|
|
196
200
|
|
|
197
201
|
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):
|
|
@@ -208,7 +212,7 @@ $env:GHOSTPAW_NO_MODIFY_PATH=1; irm https://raw.githubusercontent.com/GhostPawJS
|
|
|
208
212
|
|
|
209
213
|
```text
|
|
210
214
|
$ ghostpaw-email --version
|
|
211
|
-
email 0.5.
|
|
215
|
+
email 0.5.8 (binary, linux-x64)
|
|
212
216
|
```
|
|
213
217
|
|
|
214
218
|
Scripts that compare versions should use `--version --short` or `--version --json`.
|
package/SKILL.md
CHANGED
|
@@ -25,6 +25,8 @@ 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
|
+
For the compact cheat sheet, run `ghostpaw-email skill --short`.
|
|
29
|
+
|
|
28
30
|
## Calling tools
|
|
29
31
|
|
|
30
32
|
MCP: connect to ghostpaw-email, then call a tool by name with its JSON arguments.
|
|
@@ -47,7 +49,7 @@ Nested requirements apply within the parent for the selected action.
|
|
|
47
49
|
|
|
48
50
|
| Parameter | Type | Required | Values / description |
|
|
49
51
|
| --- | --- | --- | --- |
|
|
50
|
-
| view | string | yes |
|
|
52
|
+
| view | string | yes | eml. What to read. |
|
|
51
53
|
| folder | string | no | Folder path (required for queue/message/attachment/eml). |
|
|
52
54
|
| uid | integer | no | Message UID (required for message/attachment/eml). |
|
|
53
55
|
| threadId | string | no | Thread ID (required for thread view). |
|
|
@@ -105,12 +107,45 @@ Nested requirements apply within the parent for the selected action.
|
|
|
105
107
|
|
|
106
108
|
| Parameter | Type | Required | Values / description |
|
|
107
109
|
| --- | --- | --- | --- |
|
|
108
|
-
| action | string | yes |
|
|
110
|
+
| action | string | yes | send_draft. string value. |
|
|
109
111
|
| folder | string | no | Source folder (required for reply/forward). |
|
|
110
112
|
| uid | integer | no | Source message UID (required for reply/forward/update_draft/send_draft). |
|
|
111
113
|
| input | object | no | ComposeInput / ReplyInput / ForwardInput payload. |
|
|
114
|
+
| input.from | object | no | Object: address (required), name. |
|
|
115
|
+
| input.from.address | string | yes | Email address. |
|
|
116
|
+
| input.from.name | string | no | Display name. |
|
|
117
|
+
| input.sender | object | no | Object: address (required), name. |
|
|
118
|
+
| input.sender.address | string | yes | Email address. |
|
|
119
|
+
| input.sender.name | string | no | Display name. |
|
|
120
|
+
| input.envelopeFrom | object | no | Object: address (required), name. |
|
|
121
|
+
| input.envelopeFrom.address | string | yes | Email address. |
|
|
122
|
+
| input.envelopeFrom.name | string | no | Display name. |
|
|
123
|
+
| input.replyTo | object | no | Object: address (required), name. |
|
|
124
|
+
| input.replyTo.address | string | yes | Email address. |
|
|
125
|
+
| input.replyTo.name | string | no | Display name. |
|
|
112
126
|
| input.to | array | yes | Recipient addresses. |
|
|
127
|
+
| input.to[].address | string | yes | Email address. |
|
|
128
|
+
| input.to[].name | string | no | Display name. |
|
|
129
|
+
| input.cc | array | no | Recipient addresses. |
|
|
130
|
+
| input.cc[].address | string | yes | Email address. |
|
|
131
|
+
| input.cc[].name | string | no | Display name. |
|
|
132
|
+
| input.bcc | array | no | Recipient addresses. |
|
|
133
|
+
| input.bcc[].address | string | yes | Email address. |
|
|
134
|
+
| input.bcc[].name | string | no | Display name. |
|
|
113
135
|
| input.subject | string | yes | Message subject. |
|
|
136
|
+
| input.text | string | no | Plain text body. |
|
|
137
|
+
| input.html | string | no | HTML body. |
|
|
138
|
+
| input.replyAll | boolean | no | Reply to all original recipients. |
|
|
139
|
+
| input.mode | string | no | inline, attachment. string value. |
|
|
140
|
+
| input.attachments | array | no | Message attachments. |
|
|
141
|
+
| input.attachments[].filename | string | yes | string value. |
|
|
142
|
+
| input.attachments[].content | any | yes | Attachment bytes (Buffer in library calls). |
|
|
143
|
+
| input.attachments[].mimeType | string | no | string value. |
|
|
144
|
+
| input.attachments[].inline | boolean | no | boolean value. |
|
|
145
|
+
| input.attachments[].contentId | string | no | string value. |
|
|
146
|
+
| input.inReplyTo | string | no | string value. |
|
|
147
|
+
| input.references | array | no | Array of string. |
|
|
148
|
+
| input.headers | object | no | object value. |
|
|
114
149
|
|
|
115
150
|
Examples:
|
|
116
151
|
|
|
@@ -134,7 +169,7 @@ Nested requirements apply within the parent for the selected action.
|
|
|
134
169
|
|
|
135
170
|
| Parameter | Type | Required | Values / description |
|
|
136
171
|
| --- | --- | --- | --- |
|
|
137
|
-
| action | string | yes |
|
|
172
|
+
| action | string | yes | unsubscribe_folder. string value. |
|
|
138
173
|
| folder | string | no | Source folder (required for message actions). |
|
|
139
174
|
| uids | array | no | Message UIDs to act on. |
|
|
140
175
|
| destination | string | no | Destination folder (required for copy/move). |
|
|
@@ -165,7 +200,7 @@ Nested requirements apply within the parent for the selected action.
|
|
|
165
200
|
|
|
166
201
|
| Parameter | Type | Required | Values / description |
|
|
167
202
|
| --- | --- | --- | --- |
|
|
168
|
-
| action | string | yes | connect, disconnect, reconnect, sync, refresh_folders, watch.
|
|
203
|
+
| action | string | yes | connect, disconnect, reconnect, sync, refresh_folders, watch. string value. |
|
|
169
204
|
| folders | array | no | Folders to sync or watch (optional — defaults to all subscribed folders). |
|
|
170
205
|
| bodies | string | no | none, missing, all. Body fetch strategy for sync (default: missing). |
|
|
171
206
|
|
|
@@ -179,15 +214,15 @@ ghostpaw-email call mail_sync '{"action":"reconnect"}'
|
|
|
179
214
|
|
|
180
215
|
## Workflow guides
|
|
181
216
|
|
|
182
|
-
- `ghostpaw-email skill triage-inbox
|
|
183
|
-
- `ghostpaw-email skill read-and-reply
|
|
184
|
-
- `ghostpaw-email skill connect-and-sync
|
|
185
|
-
- `ghostpaw-email skill search-and-act
|
|
186
|
-
- `ghostpaw-email skill compose-and-send
|
|
187
|
-
- `ghostpaw-email skill organize-bulk
|
|
188
|
-
- `ghostpaw-email skill attachment-workflow
|
|
189
|
-
- `ghostpaw-email skill recover-from-disruption
|
|
190
|
-
- `ghostpaw-email skill cli
|
|
217
|
+
- `ghostpaw-email skill triage-inbox`: Process a full inbox from scratch: sync to get latest state, read message queue, selectively fetch bodies for decisions, then bulk-organize by priority.
|
|
218
|
+
- `ghostpaw-email skill read-and-reply`: Read a message with full thread context, then compose and send a properly-threaded reply with quoted attribution.
|
|
219
|
+
- `ghostpaw-email skill connect-and-sync`: Establish or restore an IMAP connection, refresh the folder list, and pull new messages — handling first-run vs incremental scenarios.
|
|
220
|
+
- `ghostpaw-email skill search-and-act`: Find messages matching criteria (local FTS first, remote IMAP SEARCH as fallback), verify targets, then act — organize, reply, or present.
|
|
221
|
+
- `ghostpaw-email skill compose-and-send`: Full draft lifecycle — save, review, update, then send — plus direct send, reply, and forward with proper threading and forwarded-header blocks.
|
|
222
|
+
- `ghostpaw-email skill organize-bulk`: Bulk organize messages across folders — flagging, moving, archiving, labelling — and manage the folder hierarchy as part of the flow.
|
|
223
|
+
- `ghostpaw-email skill attachment-workflow`: Discover, inspect, and fetch email attachments on demand; embed attachments in outbound messages; and export or import full .eml files.
|
|
224
|
+
- `ghostpaw-email skill recover-from-disruption`: Detect and recover from connection loss or IMAP/SMTP failures — reconnect with back-off, re-sync to reconcile state, and handle auth vs transient errors distinctly.
|
|
225
|
+
- `ghostpaw-email skill cli`: Complete existing email CLI guide.
|
|
191
226
|
|
|
192
227
|
## Principles
|
|
193
228
|
|
package/dist/cli.js
CHANGED
|
@@ -4,9 +4,9 @@ import f from 'node:readline';
|
|
|
4
4
|
import * as tty from 'node:tty';
|
|
5
5
|
import { WriteStream } from 'node:tty';
|
|
6
6
|
import { isSea } from 'node:sea';
|
|
7
|
-
import { mkdirSync,
|
|
7
|
+
import { readFileSync, mkdirSync, closeSync, openSync, chmodSync, fchmodSync, ftruncateSync, writeFileSync, statSync } from 'node:fs';
|
|
8
8
|
import { homedir } from 'node:os';
|
|
9
|
-
import { sep,
|
|
9
|
+
import { sep, join, dirname, basename, extname } from 'node:path';
|
|
10
10
|
import { EventEmitter } from 'node:events';
|
|
11
11
|
import * as net from 'node:net';
|
|
12
12
|
import * as tls from 'node:tls';
|
|
@@ -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.8";
|
|
812
812
|
}
|
|
813
813
|
});
|
|
814
814
|
function getConfigDir() {
|
|
@@ -830,10 +830,10 @@ function dbPathForAccount(slug) {
|
|
|
830
830
|
return join(getDataDir(), `${slug}.db`);
|
|
831
831
|
}
|
|
832
832
|
function ensureConfigDir() {
|
|
833
|
-
mkdirSync(getConfigDir(), { recursive: true });
|
|
833
|
+
mkdirSync(getConfigDir(), { recursive: true, mode: 448 });
|
|
834
834
|
}
|
|
835
835
|
function ensureDataDir() {
|
|
836
|
-
mkdirSync(getDataDir(), { recursive: true });
|
|
836
|
+
mkdirSync(getDataDir(), { recursive: true, mode: 448 });
|
|
837
837
|
}
|
|
838
838
|
function loadAccounts() {
|
|
839
839
|
let raw2;
|
|
@@ -853,7 +853,14 @@ function loadAccounts() {
|
|
|
853
853
|
}
|
|
854
854
|
function saveAccounts(data) {
|
|
855
855
|
ensureConfigDir();
|
|
856
|
-
|
|
856
|
+
const fd = openSync(accountsFilePath(), "a", 384);
|
|
857
|
+
try {
|
|
858
|
+
if (process.platform !== "win32") fchmodSync(fd, 384);
|
|
859
|
+
ftruncateSync(fd, 0);
|
|
860
|
+
writeFileSync(fd, JSON.stringify(data, null, " ") + "\n", "utf-8");
|
|
861
|
+
} finally {
|
|
862
|
+
closeSync(fd);
|
|
863
|
+
}
|
|
857
864
|
}
|
|
858
865
|
function validateAccounts(data) {
|
|
859
866
|
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
@@ -6094,6 +6101,42 @@ var init_read = __esm({
|
|
|
6094
6101
|
init_store();
|
|
6095
6102
|
}
|
|
6096
6103
|
});
|
|
6104
|
+
function preparePrivateStorage(path) {
|
|
6105
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
6106
|
+
const created = [];
|
|
6107
|
+
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6108
|
+
try {
|
|
6109
|
+
closeSync(openSync(file, "wx", 384));
|
|
6110
|
+
created.push(file);
|
|
6111
|
+
} catch (error) {
|
|
6112
|
+
if (error.code !== "EEXIST") throw error;
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
return () => {
|
|
6116
|
+
if (process.platform !== "win32")
|
|
6117
|
+
for (const file of created) {
|
|
6118
|
+
try {
|
|
6119
|
+
chmodSync(file, 384);
|
|
6120
|
+
} catch (error) {
|
|
6121
|
+
if (error.code !== "ENOENT") throw error;
|
|
6122
|
+
}
|
|
6123
|
+
}
|
|
6124
|
+
};
|
|
6125
|
+
}
|
|
6126
|
+
function withPrivateCreation(operation, secure) {
|
|
6127
|
+
if (process.platform === "win32") return operation();
|
|
6128
|
+
const previous = process.umask(63);
|
|
6129
|
+
try {
|
|
6130
|
+
return operation();
|
|
6131
|
+
} finally {
|
|
6132
|
+
process.umask(previous);
|
|
6133
|
+
secure?.();
|
|
6134
|
+
}
|
|
6135
|
+
}
|
|
6136
|
+
var init_private_storage = __esm({
|
|
6137
|
+
"src/private_storage.ts"() {
|
|
6138
|
+
}
|
|
6139
|
+
});
|
|
6097
6140
|
|
|
6098
6141
|
// src/schema/create_fts.ts
|
|
6099
6142
|
function createFts(db) {
|
|
@@ -7442,6 +7485,39 @@ var init_cli_commands = __esm({
|
|
|
7442
7485
|
}
|
|
7443
7486
|
});
|
|
7444
7487
|
|
|
7488
|
+
// src/surfaces/parameter_rows.ts
|
|
7489
|
+
function parameterRows(schema, prefix = "") {
|
|
7490
|
+
const rows = [];
|
|
7491
|
+
const properties = { ...schema.properties };
|
|
7492
|
+
for (const branch of schema.oneOf ?? []) Object.assign(properties, branch.properties);
|
|
7493
|
+
for (const [name, property] of Object.entries(properties)) {
|
|
7494
|
+
const alternatives = [property, ...property.oneOf ?? []];
|
|
7495
|
+
for (const branch of schema.oneOf ?? []) {
|
|
7496
|
+
const nested2 = branch.properties?.[name];
|
|
7497
|
+
if (nested2) alternatives.push(nested2, ...nested2.oneOf ?? []);
|
|
7498
|
+
}
|
|
7499
|
+
const nested = { properties: {}, required: [] };
|
|
7500
|
+
for (const alternative of alternatives) {
|
|
7501
|
+
Object.assign(nested.properties ?? {}, alternative.properties);
|
|
7502
|
+
nested.required = [.../* @__PURE__ */ new Set([...nested.required ?? [], ...alternative.required ?? []])];
|
|
7503
|
+
}
|
|
7504
|
+
const keys = Object.keys(nested.properties ?? {});
|
|
7505
|
+
const type = property.type ?? property.oneOf?.map((branch) => branch.type ?? "any").join(" / ") ?? "any";
|
|
7506
|
+
const fallback = keys.length ? `Object: ${keys.map((key) => key + (nested.required?.includes(key) ? " (required)" : "")).join(", ")}.` : property.items ? `Array of ${property.items.type ?? "values"}.` : `${type} value.`;
|
|
7507
|
+
const description = ((property.enum ? `${property.enum.join(", ")}. ` : "") + (property.description?.trim() || fallback)).replaceAll("|", "\\|").replaceAll("\n", " ");
|
|
7508
|
+
rows.push(
|
|
7509
|
+
`| ${prefix}${name} | ${type} | ${schema.required?.includes(name) ? "yes" : "no"} | ${description} |`
|
|
7510
|
+
);
|
|
7511
|
+
if (keys.length) rows.push(...parameterRows(nested, `${prefix}${name}.`));
|
|
7512
|
+
if (property.items) rows.push(...parameterRows(property.items, `${prefix}${name}[].`));
|
|
7513
|
+
}
|
|
7514
|
+
return rows;
|
|
7515
|
+
}
|
|
7516
|
+
var init_parameter_rows = __esm({
|
|
7517
|
+
"src/surfaces/parameter_rows.ts"() {
|
|
7518
|
+
}
|
|
7519
|
+
});
|
|
7520
|
+
|
|
7445
7521
|
// src/surfaces/surface_types.ts
|
|
7446
7522
|
function isErrorResult(result) {
|
|
7447
7523
|
return typeof result === "object" && result !== null && "ok" in result && result.ok === false;
|
|
@@ -7542,11 +7618,7 @@ Not for: ${tool.whenNotToUse ?? ""}
|
|
|
7542
7618
|
Read only: ${tool.readOnly ?? false}
|
|
7543
7619
|
|
|
7544
7620
|
Parameter | Type | Required | Description
|
|
7545
|
-
${
|
|
7546
|
-
tool.inputSchema.properties ?? {}
|
|
7547
|
-
).map(
|
|
7548
|
-
([key, schema]) => `${key} | ${schema.type ?? "oneOf"} | ${tool.inputSchema.required?.includes(key) ?? false} | ${schema.description ?? ""}`
|
|
7549
|
-
).join("\n")}
|
|
7621
|
+
${parameterRows(tool.inputSchema).join("\n")}
|
|
7550
7622
|
|
|
7551
7623
|
${JSON.stringify(tool.inputSchema, null, 2)}
|
|
7552
7624
|
`
|
|
@@ -7636,6 +7708,7 @@ var init_cli = __esm({
|
|
|
7636
7708
|
"src/surfaces/cli.ts"() {
|
|
7637
7709
|
init_cli_version();
|
|
7638
7710
|
init_cli_commands();
|
|
7711
|
+
init_parameter_rows();
|
|
7639
7712
|
init_surface_types();
|
|
7640
7713
|
init_validate_input();
|
|
7641
7714
|
}
|
|
@@ -8307,6 +8380,56 @@ var init_email_skills = __esm({
|
|
|
8307
8380
|
}
|
|
8308
8381
|
});
|
|
8309
8382
|
|
|
8383
|
+
// src/surface/email_skill_short.ts
|
|
8384
|
+
var emailSkillShort;
|
|
8385
|
+
var init_email_skill_short = __esm({
|
|
8386
|
+
"src/surface/email_skill_short.ts"() {
|
|
8387
|
+
init_version();
|
|
8388
|
+
emailSkillShort = `# ghostpaw-email cheat sheet
|
|
8389
|
+
Version: ${emailVersion}
|
|
8390
|
+
|
|
8391
|
+
Install (Node 24+):
|
|
8392
|
+
npm install -g @ghostpaw/email
|
|
8393
|
+
Check version:
|
|
8394
|
+
ghostpaw-email --version
|
|
8395
|
+
|
|
8396
|
+
Configure an account:
|
|
8397
|
+
ghostpaw-email account add --name work --imap-host imap.example.com --imap-port 993 --smtp-host smtp.example.com --smtp-port 587 --user reader@example.com --pass PASSWORD
|
|
8398
|
+
Connect and synchronize:
|
|
8399
|
+
ghostpaw-email sync connect
|
|
8400
|
+
List folders:
|
|
8401
|
+
ghostpaw-email read folders
|
|
8402
|
+
Search cached mail:
|
|
8403
|
+
ghostpaw-email mail search "meeting"
|
|
8404
|
+
Save a draft:
|
|
8405
|
+
ghostpaw-email compose draft --save --to reader@example.com --subject Hello --body Hello
|
|
8406
|
+
Mark a message read:
|
|
8407
|
+
ghostpaw-email organize mark-read --folder INBOX --uids 1
|
|
8408
|
+
List tool names:
|
|
8409
|
+
ghostpaw-email tools
|
|
8410
|
+
Inspect a tool and its parameters:
|
|
8411
|
+
ghostpaw-email describe mail_search
|
|
8412
|
+
Call a tool with JSON:
|
|
8413
|
+
ghostpaw-email call mail_search '{"query":"meeting"}'
|
|
8414
|
+
Start the MCP server:
|
|
8415
|
+
ghostpaw-email mcp
|
|
8416
|
+
Select a cache:
|
|
8417
|
+
ghostpaw-email --db ./email.sqlite tools
|
|
8418
|
+
|
|
8419
|
+
List workflow guides:
|
|
8420
|
+
ghostpaw-email skill --list
|
|
8421
|
+
Read a guide:
|
|
8422
|
+
ghostpaw-email skill cli
|
|
8423
|
+
Read the full tool reference:
|
|
8424
|
+
ghostpaw-email skill
|
|
8425
|
+
Show this compact cheat sheet:
|
|
8426
|
+
ghostpaw-email skill --short
|
|
8427
|
+
Show skill command help:
|
|
8428
|
+
ghostpaw-email skill --help
|
|
8429
|
+
`;
|
|
8430
|
+
}
|
|
8431
|
+
});
|
|
8432
|
+
|
|
8310
8433
|
// src/surface/email_surface_tools.ts
|
|
8311
8434
|
var emailMcpTools, emailSurfaceTools;
|
|
8312
8435
|
var init_email_surface_tools = __esm({
|
|
@@ -8414,20 +8537,23 @@ async function openEmailDb(path) {
|
|
|
8414
8537
|
} finally {
|
|
8415
8538
|
process.emitWarning = original;
|
|
8416
8539
|
}
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8540
|
+
const secure = path !== ":memory:" ? preparePrivateStorage(path) : void 0;
|
|
8541
|
+
return withPrivateCreation(() => {
|
|
8542
|
+
const db = new sqlite.DatabaseSync(path);
|
|
8543
|
+
try {
|
|
8544
|
+
db.exec("PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;");
|
|
8545
|
+
const context = db;
|
|
8546
|
+
initSchema(context);
|
|
8547
|
+
return context;
|
|
8548
|
+
} catch (error) {
|
|
8549
|
+
db.close();
|
|
8550
|
+
throw error;
|
|
8551
|
+
}
|
|
8552
|
+
}, secure);
|
|
8428
8553
|
}
|
|
8429
8554
|
var init_open_email_db = __esm({
|
|
8430
8555
|
"src/surface/open_email_db.ts"() {
|
|
8556
|
+
init_private_storage();
|
|
8431
8557
|
init_schema();
|
|
8432
8558
|
}
|
|
8433
8559
|
});
|
|
@@ -8690,7 +8816,7 @@ var skill_markdown_exports = {};
|
|
|
8690
8816
|
__export(skill_markdown_exports, {
|
|
8691
8817
|
renderSkillMarkdown: () => renderSkillMarkdown
|
|
8692
8818
|
});
|
|
8693
|
-
function renderSkillMarkdown(spec, { referencesBase = "references" } = {}) {
|
|
8819
|
+
function renderSkillMarkdown(spec, { referencesBase: _referencesBase = "references" } = {}) {
|
|
8694
8820
|
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(spec.name) || spec.name.length > 64)
|
|
8695
8821
|
throw new Error("Invalid skill name");
|
|
8696
8822
|
if (!spec.description.trim() || spec.description.length > 1024 || !spec.description.includes("Use when"))
|
|
@@ -8728,6 +8854,8 @@ function renderSkillMarkdown(spec, { referencesBase = "references" } = {}) {
|
|
|
8728
8854
|
"",
|
|
8729
8855
|
spec.about,
|
|
8730
8856
|
"",
|
|
8857
|
+
"For the compact cheat sheet, run `ghostpaw-email skill --short`.",
|
|
8858
|
+
"",
|
|
8731
8859
|
"## Calling tools",
|
|
8732
8860
|
"",
|
|
8733
8861
|
`MCP: connect to ${spec.server}, then call a tool by name with its JSON arguments.`,
|
|
@@ -8754,27 +8882,7 @@ function renderSkillMarkdown(spec, { referencesBase = "references" } = {}) {
|
|
|
8754
8882
|
"| Parameter | Type | Required | Values / description |",
|
|
8755
8883
|
"| --- | --- | --- | --- |"
|
|
8756
8884
|
);
|
|
8757
|
-
|
|
8758
|
-
const fields = (schema, prefix = "") => {
|
|
8759
|
-
const properties = Object.entries(schema.properties ?? {});
|
|
8760
|
-
for (const [name, property] of properties) {
|
|
8761
|
-
if (prefix && properties.length > 8 && !schema.required?.includes(name)) continue;
|
|
8762
|
-
lines.push(row(`${prefix}${name}`, property, schema.required?.includes(name) ?? false));
|
|
8763
|
-
const objects = [property, ...property.oneOf ?? []].filter((s4) => s4.properties);
|
|
8764
|
-
if (!objects.length)
|
|
8765
|
-
for (const branch of tool.inputSchema.oneOf ?? []) {
|
|
8766
|
-
const nested = branch.properties?.[name];
|
|
8767
|
-
if (nested?.properties) objects.push(nested);
|
|
8768
|
-
}
|
|
8769
|
-
const merged = { properties: {}, required: [] };
|
|
8770
|
-
for (const object of objects) {
|
|
8771
|
-
Object.assign(merged.properties ?? {}, object.properties);
|
|
8772
|
-
merged.required = [.../* @__PURE__ */ new Set([...merged.required ?? [], ...object.required ?? []])];
|
|
8773
|
-
}
|
|
8774
|
-
if (objects.length) fields(merged, `${prefix}${name}.`);
|
|
8775
|
-
}
|
|
8776
|
-
};
|
|
8777
|
-
fields(tool.inputSchema);
|
|
8885
|
+
lines.push(...parameterRows(tool.inputSchema));
|
|
8778
8886
|
lines.push("", "Examples:", "", "```sh");
|
|
8779
8887
|
const actions = tool.inputSchema.properties?.action?.enum?.slice(0, 3) ?? [void 0];
|
|
8780
8888
|
for (const action of actions) {
|
|
@@ -8788,7 +8896,7 @@ function renderSkillMarkdown(spec, { referencesBase = "references" } = {}) {
|
|
|
8788
8896
|
"## Workflow guides",
|
|
8789
8897
|
"",
|
|
8790
8898
|
...spec.workflows.map(
|
|
8791
|
-
(workflow) => `- \`${spec.bin} skill ${workflow.name}
|
|
8899
|
+
(workflow) => `- \`${spec.bin} skill ${workflow.name}\`: ${workflow.description}`
|
|
8792
8900
|
),
|
|
8793
8901
|
"",
|
|
8794
8902
|
"## Principles",
|
|
@@ -8809,6 +8917,7 @@ function renderSkillMarkdown(spec, { referencesBase = "references" } = {}) {
|
|
|
8809
8917
|
}
|
|
8810
8918
|
var init_skill_markdown = __esm({
|
|
8811
8919
|
"src/surfaces/skill_markdown.ts"() {
|
|
8920
|
+
init_parameter_rows();
|
|
8812
8921
|
init_schema_example();
|
|
8813
8922
|
}
|
|
8814
8923
|
});
|
|
@@ -8854,6 +8963,7 @@ var init_email_cli_options = __esm({
|
|
|
8854
8963
|
init_cli_guide();
|
|
8855
8964
|
init_email_skills();
|
|
8856
8965
|
init_version();
|
|
8966
|
+
init_email_skill_short();
|
|
8857
8967
|
init_email_surface_tools();
|
|
8858
8968
|
emailCliOptions = {
|
|
8859
8969
|
bin: "ghostpaw-email",
|
|
@@ -8881,8 +8991,9 @@ var init_email_cli_options = __esm({
|
|
|
8881
8991
|
},
|
|
8882
8992
|
skill: async (args = []) => {
|
|
8883
8993
|
const guides = [...emailSkills, cliGuide];
|
|
8994
|
+
if (args.length === 1 && args[0] === "--short") return emailSkillShort;
|
|
8884
8995
|
if (args[0] === "--help" || args[0] === "-h")
|
|
8885
|
-
return "Usage: ghostpaw-email skill\n ghostpaw-email skill --list\n ghostpaw-email skill <guide>\n";
|
|
8996
|
+
return "Usage: ghostpaw-email skill\n ghostpaw-email skill --short (compact cheat sheet)\n ghostpaw-email skill --list\n ghostpaw-email skill <guide>\n";
|
|
8886
8997
|
if (args[0] === "--list")
|
|
8887
8998
|
return `${guides.map((guide) => `${guide.name} ${guide.description.replace(/\s+/g, " ")}`).join("\n")}
|
|
8888
8999
|
`;
|
|
@@ -10714,15 +10825,19 @@ init_network();
|
|
|
10714
10825
|
init_read();
|
|
10715
10826
|
|
|
10716
10827
|
// src/runtime.ts
|
|
10828
|
+
init_private_storage();
|
|
10717
10829
|
init_schema();
|
|
10718
10830
|
function init2(config) {
|
|
10719
10831
|
const dbPath = config.storage ?? ":memory:";
|
|
10720
10832
|
const { DatabaseSync } = process.getBuiltinModule("node:sqlite");
|
|
10721
|
-
const
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10833
|
+
const secure = dbPath !== ":memory:" ? preparePrivateStorage(dbPath) : void 0;
|
|
10834
|
+
return withPrivateCreation(() => {
|
|
10835
|
+
const db = new DatabaseSync(dbPath);
|
|
10836
|
+
if (dbPath !== ":memory:") db.exec("PRAGMA journal_mode=WAL");
|
|
10837
|
+
db.exec("PRAGMA busy_timeout=5000");
|
|
10838
|
+
initSchema(db);
|
|
10839
|
+
return { db };
|
|
10840
|
+
}, secure);
|
|
10726
10841
|
}
|
|
10727
10842
|
|
|
10728
10843
|
// src/mailbox.ts
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,8 @@ var node_events = require('node:events');
|
|
|
4
4
|
var net = require('node:net');
|
|
5
5
|
var tls = require('node:tls');
|
|
6
6
|
var zlib = require('node:zlib');
|
|
7
|
+
var node_fs = require('node:fs');
|
|
8
|
+
var node_path = require('node:path');
|
|
7
9
|
var node_crypto = require('node:crypto');
|
|
8
10
|
|
|
9
11
|
function _interopNamespace(e) {
|
|
@@ -3720,6 +3722,38 @@ var runtime_exports = {};
|
|
|
3720
3722
|
__export(runtime_exports, {
|
|
3721
3723
|
init: () => init
|
|
3722
3724
|
});
|
|
3725
|
+
function preparePrivateStorage(path) {
|
|
3726
|
+
node_fs.mkdirSync(node_path.dirname(path), { recursive: true, mode: 448 });
|
|
3727
|
+
const created = [];
|
|
3728
|
+
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
3729
|
+
try {
|
|
3730
|
+
node_fs.closeSync(node_fs.openSync(file, "wx", 384));
|
|
3731
|
+
created.push(file);
|
|
3732
|
+
} catch (error) {
|
|
3733
|
+
if (error.code !== "EEXIST") throw error;
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
return () => {
|
|
3737
|
+
if (process.platform !== "win32")
|
|
3738
|
+
for (const file of created) {
|
|
3739
|
+
try {
|
|
3740
|
+
node_fs.chmodSync(file, 384);
|
|
3741
|
+
} catch (error) {
|
|
3742
|
+
if (error.code !== "ENOENT") throw error;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
};
|
|
3746
|
+
}
|
|
3747
|
+
function withPrivateCreation(operation, secure) {
|
|
3748
|
+
if (process.platform === "win32") return operation();
|
|
3749
|
+
const previous = process.umask(63);
|
|
3750
|
+
try {
|
|
3751
|
+
return operation();
|
|
3752
|
+
} finally {
|
|
3753
|
+
process.umask(previous);
|
|
3754
|
+
secure?.();
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3723
3757
|
|
|
3724
3758
|
// src/schema/index.ts
|
|
3725
3759
|
var schema_exports = {};
|
|
@@ -3870,11 +3904,14 @@ function initSchema(db) {
|
|
|
3870
3904
|
function init(config) {
|
|
3871
3905
|
const dbPath = config.storage ?? ":memory:";
|
|
3872
3906
|
const { DatabaseSync } = process.getBuiltinModule("node:sqlite");
|
|
3873
|
-
const
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3907
|
+
const secure = dbPath !== ":memory:" ? preparePrivateStorage(dbPath) : void 0;
|
|
3908
|
+
return withPrivateCreation(() => {
|
|
3909
|
+
const db = new DatabaseSync(dbPath);
|
|
3910
|
+
if (dbPath !== ":memory:") db.exec("PRAGMA journal_mode=WAL");
|
|
3911
|
+
db.exec("PRAGMA busy_timeout=5000");
|
|
3912
|
+
initSchema(db);
|
|
3913
|
+
return { db };
|
|
3914
|
+
}, secure);
|
|
3878
3915
|
}
|
|
3879
3916
|
|
|
3880
3917
|
// src/write.ts
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import * as net from 'node:net';
|
|
3
3
|
import * as tls from 'node:tls';
|
|
4
4
|
import * as zlib from 'node:zlib';
|
|
5
|
+
import { mkdirSync, closeSync, openSync, chmodSync } from 'node:fs';
|
|
6
|
+
import { dirname } from 'node:path';
|
|
5
7
|
import { randomUUID } from 'node:crypto';
|
|
6
8
|
|
|
7
9
|
var __defProp = Object.defineProperty;
|
|
@@ -3696,6 +3698,38 @@ var runtime_exports = {};
|
|
|
3696
3698
|
__export(runtime_exports, {
|
|
3697
3699
|
init: () => init
|
|
3698
3700
|
});
|
|
3701
|
+
function preparePrivateStorage(path) {
|
|
3702
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
3703
|
+
const created = [];
|
|
3704
|
+
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
3705
|
+
try {
|
|
3706
|
+
closeSync(openSync(file, "wx", 384));
|
|
3707
|
+
created.push(file);
|
|
3708
|
+
} catch (error) {
|
|
3709
|
+
if (error.code !== "EEXIST") throw error;
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
return () => {
|
|
3713
|
+
if (process.platform !== "win32")
|
|
3714
|
+
for (const file of created) {
|
|
3715
|
+
try {
|
|
3716
|
+
chmodSync(file, 384);
|
|
3717
|
+
} catch (error) {
|
|
3718
|
+
if (error.code !== "ENOENT") throw error;
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
};
|
|
3722
|
+
}
|
|
3723
|
+
function withPrivateCreation(operation, secure) {
|
|
3724
|
+
if (process.platform === "win32") return operation();
|
|
3725
|
+
const previous = process.umask(63);
|
|
3726
|
+
try {
|
|
3727
|
+
return operation();
|
|
3728
|
+
} finally {
|
|
3729
|
+
process.umask(previous);
|
|
3730
|
+
secure?.();
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3699
3733
|
|
|
3700
3734
|
// src/schema/index.ts
|
|
3701
3735
|
var schema_exports = {};
|
|
@@ -3846,11 +3880,14 @@ function initSchema(db) {
|
|
|
3846
3880
|
function init(config) {
|
|
3847
3881
|
const dbPath = config.storage ?? ":memory:";
|
|
3848
3882
|
const { DatabaseSync } = process.getBuiltinModule("node:sqlite");
|
|
3849
|
-
const
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3883
|
+
const secure = dbPath !== ":memory:" ? preparePrivateStorage(dbPath) : void 0;
|
|
3884
|
+
return withPrivateCreation(() => {
|
|
3885
|
+
const db = new DatabaseSync(dbPath);
|
|
3886
|
+
if (dbPath !== ":memory:") db.exec("PRAGMA journal_mode=WAL");
|
|
3887
|
+
db.exec("PRAGMA busy_timeout=5000");
|
|
3888
|
+
initSchema(db);
|
|
3889
|
+
return { db };
|
|
3890
|
+
}, secure);
|
|
3854
3891
|
}
|
|
3855
3892
|
|
|
3856
3893
|
// src/write.ts
|
package/dist/mcp-server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { readFileSync, mkdirSync, closeSync, openSync, chmodSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join, dirname } from 'node:path';
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
@@ -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.8";
|
|
320
320
|
}
|
|
321
321
|
});
|
|
322
322
|
|
|
@@ -6343,6 +6343,42 @@ var init_email_mcp_options = __esm({
|
|
|
6343
6343
|
init_email_surface_tools();
|
|
6344
6344
|
}
|
|
6345
6345
|
});
|
|
6346
|
+
function preparePrivateStorage(path) {
|
|
6347
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
6348
|
+
const created = [];
|
|
6349
|
+
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6350
|
+
try {
|
|
6351
|
+
closeSync(openSync(file, "wx", 384));
|
|
6352
|
+
created.push(file);
|
|
6353
|
+
} catch (error) {
|
|
6354
|
+
if (error.code !== "EEXIST") throw error;
|
|
6355
|
+
}
|
|
6356
|
+
}
|
|
6357
|
+
return () => {
|
|
6358
|
+
if (process.platform !== "win32")
|
|
6359
|
+
for (const file of created) {
|
|
6360
|
+
try {
|
|
6361
|
+
chmodSync(file, 384);
|
|
6362
|
+
} catch (error) {
|
|
6363
|
+
if (error.code !== "ENOENT") throw error;
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
};
|
|
6367
|
+
}
|
|
6368
|
+
function withPrivateCreation(operation, secure) {
|
|
6369
|
+
if (process.platform === "win32") return operation();
|
|
6370
|
+
const previous = process.umask(63);
|
|
6371
|
+
try {
|
|
6372
|
+
return operation();
|
|
6373
|
+
} finally {
|
|
6374
|
+
process.umask(previous);
|
|
6375
|
+
secure?.();
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
var init_private_storage = __esm({
|
|
6379
|
+
"src/private_storage.ts"() {
|
|
6380
|
+
}
|
|
6381
|
+
});
|
|
6346
6382
|
|
|
6347
6383
|
// src/schema/create_fts.ts
|
|
6348
6384
|
function createFts(db) {
|
|
@@ -6505,6 +6541,8 @@ var init_schema = __esm({
|
|
|
6505
6541
|
init_init_schema();
|
|
6506
6542
|
}
|
|
6507
6543
|
});
|
|
6544
|
+
|
|
6545
|
+
// src/surface/open_email_db.ts
|
|
6508
6546
|
async function openEmailDb(path) {
|
|
6509
6547
|
const original = process.emitWarning;
|
|
6510
6548
|
process.emitWarning = ((warning, ...args2) => {
|
|
@@ -6520,20 +6558,23 @@ async function openEmailDb(path) {
|
|
|
6520
6558
|
} finally {
|
|
6521
6559
|
process.emitWarning = original;
|
|
6522
6560
|
}
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6561
|
+
const secure = path !== ":memory:" ? preparePrivateStorage(path) : void 0;
|
|
6562
|
+
return withPrivateCreation(() => {
|
|
6563
|
+
const db = new sqlite.DatabaseSync(path);
|
|
6564
|
+
try {
|
|
6565
|
+
db.exec("PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;");
|
|
6566
|
+
const context = db;
|
|
6567
|
+
initSchema(context);
|
|
6568
|
+
return context;
|
|
6569
|
+
} catch (error) {
|
|
6570
|
+
db.close();
|
|
6571
|
+
throw error;
|
|
6572
|
+
}
|
|
6573
|
+
}, secure);
|
|
6534
6574
|
}
|
|
6535
6575
|
var init_open_email_db = __esm({
|
|
6536
6576
|
"src/surface/open_email_db.ts"() {
|
|
6577
|
+
init_private_storage();
|
|
6537
6578
|
init_schema();
|
|
6538
6579
|
}
|
|
6539
6580
|
});
|
package/dist/mcp.cjs
CHANGED
|
@@ -5007,7 +5007,7 @@ var init_network = __esm({
|
|
|
5007
5007
|
});
|
|
5008
5008
|
|
|
5009
5009
|
// src/version.ts
|
|
5010
|
-
var emailVersion = "0.5.
|
|
5010
|
+
var emailVersion = "0.5.8";
|
|
5011
5011
|
|
|
5012
5012
|
// src/surface/email_mcp_instructions.ts
|
|
5013
5013
|
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,6 +6129,38 @@ function emailMcpOptions(context) {
|
|
|
6129
6129
|
})
|
|
6130
6130
|
};
|
|
6131
6131
|
}
|
|
6132
|
+
function preparePrivateStorage(path) {
|
|
6133
|
+
node_fs.mkdirSync(node_path.dirname(path), { recursive: true, mode: 448 });
|
|
6134
|
+
const created = [];
|
|
6135
|
+
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6136
|
+
try {
|
|
6137
|
+
node_fs.closeSync(node_fs.openSync(file, "wx", 384));
|
|
6138
|
+
created.push(file);
|
|
6139
|
+
} catch (error) {
|
|
6140
|
+
if (error.code !== "EEXIST") throw error;
|
|
6141
|
+
}
|
|
6142
|
+
}
|
|
6143
|
+
return () => {
|
|
6144
|
+
if (process.platform !== "win32")
|
|
6145
|
+
for (const file of created) {
|
|
6146
|
+
try {
|
|
6147
|
+
node_fs.chmodSync(file, 384);
|
|
6148
|
+
} catch (error) {
|
|
6149
|
+
if (error.code !== "ENOENT") throw error;
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
6152
|
+
};
|
|
6153
|
+
}
|
|
6154
|
+
function withPrivateCreation(operation, secure) {
|
|
6155
|
+
if (process.platform === "win32") return operation();
|
|
6156
|
+
const previous = process.umask(63);
|
|
6157
|
+
try {
|
|
6158
|
+
return operation();
|
|
6159
|
+
} finally {
|
|
6160
|
+
process.umask(previous);
|
|
6161
|
+
secure?.();
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6132
6164
|
|
|
6133
6165
|
// src/schema/create_fts.ts
|
|
6134
6166
|
function createFts(db) {
|
|
@@ -6282,17 +6314,19 @@ async function openEmailDb(path) {
|
|
|
6282
6314
|
} finally {
|
|
6283
6315
|
process.emitWarning = original;
|
|
6284
6316
|
}
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6317
|
+
const secure = path !== ":memory:" ? preparePrivateStorage(path) : void 0;
|
|
6318
|
+
return withPrivateCreation(() => {
|
|
6319
|
+
const db = new sqlite.DatabaseSync(path);
|
|
6320
|
+
try {
|
|
6321
|
+
db.exec("PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;");
|
|
6322
|
+
const context = db;
|
|
6323
|
+
initSchema(context);
|
|
6324
|
+
return context;
|
|
6325
|
+
} catch (error) {
|
|
6326
|
+
db.close();
|
|
6327
|
+
throw error;
|
|
6328
|
+
}
|
|
6329
|
+
}, secure);
|
|
6296
6330
|
}
|
|
6297
6331
|
function resolveEmailDbPath(options = {}) {
|
|
6298
6332
|
return options.flag ?? ((options.env ?? process.env).GHOSTPAW_EMAIL_DB || node_path.join(node_os.homedir(), ".ghostpaw", "email.db"));
|
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, mkdirSync } from 'node:fs';
|
|
1
|
+
import { readFileSync, mkdirSync, closeSync, openSync, chmodSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
4
|
import { EventEmitter } from 'node:events';
|
|
@@ -4983,7 +4983,7 @@ var init_network = __esm({
|
|
|
4983
4983
|
});
|
|
4984
4984
|
|
|
4985
4985
|
// src/version.ts
|
|
4986
|
-
var emailVersion = "0.5.
|
|
4986
|
+
var emailVersion = "0.5.8";
|
|
4987
4987
|
|
|
4988
4988
|
// src/surface/email_mcp_instructions.ts
|
|
4989
4989
|
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,6 +6105,38 @@ function emailMcpOptions(context) {
|
|
|
6105
6105
|
})
|
|
6106
6106
|
};
|
|
6107
6107
|
}
|
|
6108
|
+
function preparePrivateStorage(path) {
|
|
6109
|
+
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
6110
|
+
const created = [];
|
|
6111
|
+
for (const file of [path, `${path}-wal`, `${path}-shm`]) {
|
|
6112
|
+
try {
|
|
6113
|
+
closeSync(openSync(file, "wx", 384));
|
|
6114
|
+
created.push(file);
|
|
6115
|
+
} catch (error) {
|
|
6116
|
+
if (error.code !== "EEXIST") throw error;
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
return () => {
|
|
6120
|
+
if (process.platform !== "win32")
|
|
6121
|
+
for (const file of created) {
|
|
6122
|
+
try {
|
|
6123
|
+
chmodSync(file, 384);
|
|
6124
|
+
} catch (error) {
|
|
6125
|
+
if (error.code !== "ENOENT") throw error;
|
|
6126
|
+
}
|
|
6127
|
+
}
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
function withPrivateCreation(operation, secure) {
|
|
6131
|
+
if (process.platform === "win32") return operation();
|
|
6132
|
+
const previous = process.umask(63);
|
|
6133
|
+
try {
|
|
6134
|
+
return operation();
|
|
6135
|
+
} finally {
|
|
6136
|
+
process.umask(previous);
|
|
6137
|
+
secure?.();
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6108
6140
|
|
|
6109
6141
|
// src/schema/create_fts.ts
|
|
6110
6142
|
function createFts(db) {
|
|
@@ -6258,17 +6290,19 @@ async function openEmailDb(path) {
|
|
|
6258
6290
|
} finally {
|
|
6259
6291
|
process.emitWarning = original;
|
|
6260
6292
|
}
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6293
|
+
const secure = path !== ":memory:" ? preparePrivateStorage(path) : void 0;
|
|
6294
|
+
return withPrivateCreation(() => {
|
|
6295
|
+
const db = new sqlite.DatabaseSync(path);
|
|
6296
|
+
try {
|
|
6297
|
+
db.exec("PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;");
|
|
6298
|
+
const context = db;
|
|
6299
|
+
initSchema(context);
|
|
6300
|
+
return context;
|
|
6301
|
+
} catch (error) {
|
|
6302
|
+
db.close();
|
|
6303
|
+
throw error;
|
|
6304
|
+
}
|
|
6305
|
+
}, secure);
|
|
6272
6306
|
}
|
|
6273
6307
|
function resolveEmailDbPath(options = {}) {
|
|
6274
6308
|
return options.flag ?? ((options.env ?? process.env).GHOSTPAW_EMAIL_DB || join(homedir(), ".ghostpaw", "email.db"));
|
package/package.json
CHANGED
package/skills/email/SKILL.md
CHANGED
|
@@ -25,6 +25,8 @@ 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
|
+
For the compact cheat sheet, run `ghostpaw-email skill --short`.
|
|
29
|
+
|
|
28
30
|
## Calling tools
|
|
29
31
|
|
|
30
32
|
MCP: connect to ghostpaw-email, then call a tool by name with its JSON arguments.
|
|
@@ -47,7 +49,7 @@ Nested requirements apply within the parent for the selected action.
|
|
|
47
49
|
|
|
48
50
|
| Parameter | Type | Required | Values / description |
|
|
49
51
|
| --- | --- | --- | --- |
|
|
50
|
-
| view | string | yes |
|
|
52
|
+
| view | string | yes | eml. What to read. |
|
|
51
53
|
| folder | string | no | Folder path (required for queue/message/attachment/eml). |
|
|
52
54
|
| uid | integer | no | Message UID (required for message/attachment/eml). |
|
|
53
55
|
| threadId | string | no | Thread ID (required for thread view). |
|
|
@@ -105,12 +107,45 @@ Nested requirements apply within the parent for the selected action.
|
|
|
105
107
|
|
|
106
108
|
| Parameter | Type | Required | Values / description |
|
|
107
109
|
| --- | --- | --- | --- |
|
|
108
|
-
| action | string | yes |
|
|
110
|
+
| action | string | yes | send_draft. string value. |
|
|
109
111
|
| folder | string | no | Source folder (required for reply/forward). |
|
|
110
112
|
| uid | integer | no | Source message UID (required for reply/forward/update_draft/send_draft). |
|
|
111
113
|
| input | object | no | ComposeInput / ReplyInput / ForwardInput payload. |
|
|
114
|
+
| input.from | object | no | Object: address (required), name. |
|
|
115
|
+
| input.from.address | string | yes | Email address. |
|
|
116
|
+
| input.from.name | string | no | Display name. |
|
|
117
|
+
| input.sender | object | no | Object: address (required), name. |
|
|
118
|
+
| input.sender.address | string | yes | Email address. |
|
|
119
|
+
| input.sender.name | string | no | Display name. |
|
|
120
|
+
| input.envelopeFrom | object | no | Object: address (required), name. |
|
|
121
|
+
| input.envelopeFrom.address | string | yes | Email address. |
|
|
122
|
+
| input.envelopeFrom.name | string | no | Display name. |
|
|
123
|
+
| input.replyTo | object | no | Object: address (required), name. |
|
|
124
|
+
| input.replyTo.address | string | yes | Email address. |
|
|
125
|
+
| input.replyTo.name | string | no | Display name. |
|
|
112
126
|
| input.to | array | yes | Recipient addresses. |
|
|
127
|
+
| input.to[].address | string | yes | Email address. |
|
|
128
|
+
| input.to[].name | string | no | Display name. |
|
|
129
|
+
| input.cc | array | no | Recipient addresses. |
|
|
130
|
+
| input.cc[].address | string | yes | Email address. |
|
|
131
|
+
| input.cc[].name | string | no | Display name. |
|
|
132
|
+
| input.bcc | array | no | Recipient addresses. |
|
|
133
|
+
| input.bcc[].address | string | yes | Email address. |
|
|
134
|
+
| input.bcc[].name | string | no | Display name. |
|
|
113
135
|
| input.subject | string | yes | Message subject. |
|
|
136
|
+
| input.text | string | no | Plain text body. |
|
|
137
|
+
| input.html | string | no | HTML body. |
|
|
138
|
+
| input.replyAll | boolean | no | Reply to all original recipients. |
|
|
139
|
+
| input.mode | string | no | inline, attachment. string value. |
|
|
140
|
+
| input.attachments | array | no | Message attachments. |
|
|
141
|
+
| input.attachments[].filename | string | yes | string value. |
|
|
142
|
+
| input.attachments[].content | any | yes | Attachment bytes (Buffer in library calls). |
|
|
143
|
+
| input.attachments[].mimeType | string | no | string value. |
|
|
144
|
+
| input.attachments[].inline | boolean | no | boolean value. |
|
|
145
|
+
| input.attachments[].contentId | string | no | string value. |
|
|
146
|
+
| input.inReplyTo | string | no | string value. |
|
|
147
|
+
| input.references | array | no | Array of string. |
|
|
148
|
+
| input.headers | object | no | object value. |
|
|
114
149
|
|
|
115
150
|
Examples:
|
|
116
151
|
|
|
@@ -134,7 +169,7 @@ Nested requirements apply within the parent for the selected action.
|
|
|
134
169
|
|
|
135
170
|
| Parameter | Type | Required | Values / description |
|
|
136
171
|
| --- | --- | --- | --- |
|
|
137
|
-
| action | string | yes |
|
|
172
|
+
| action | string | yes | unsubscribe_folder. string value. |
|
|
138
173
|
| folder | string | no | Source folder (required for message actions). |
|
|
139
174
|
| uids | array | no | Message UIDs to act on. |
|
|
140
175
|
| destination | string | no | Destination folder (required for copy/move). |
|
|
@@ -165,7 +200,7 @@ Nested requirements apply within the parent for the selected action.
|
|
|
165
200
|
|
|
166
201
|
| Parameter | Type | Required | Values / description |
|
|
167
202
|
| --- | --- | --- | --- |
|
|
168
|
-
| action | string | yes | connect, disconnect, reconnect, sync, refresh_folders, watch.
|
|
203
|
+
| action | string | yes | connect, disconnect, reconnect, sync, refresh_folders, watch. string value. |
|
|
169
204
|
| folders | array | no | Folders to sync or watch (optional — defaults to all subscribed folders). |
|
|
170
205
|
| bodies | string | no | none, missing, all. Body fetch strategy for sync (default: missing). |
|
|
171
206
|
|
|
@@ -179,15 +214,15 @@ ghostpaw-email call mail_sync '{"action":"reconnect"}'
|
|
|
179
214
|
|
|
180
215
|
## Workflow guides
|
|
181
216
|
|
|
182
|
-
- `ghostpaw-email skill triage-inbox
|
|
183
|
-
- `ghostpaw-email skill read-and-reply
|
|
184
|
-
- `ghostpaw-email skill connect-and-sync
|
|
185
|
-
- `ghostpaw-email skill search-and-act
|
|
186
|
-
- `ghostpaw-email skill compose-and-send
|
|
187
|
-
- `ghostpaw-email skill organize-bulk
|
|
188
|
-
- `ghostpaw-email skill attachment-workflow
|
|
189
|
-
- `ghostpaw-email skill recover-from-disruption
|
|
190
|
-
- `ghostpaw-email skill cli
|
|
217
|
+
- `ghostpaw-email skill triage-inbox`: Process a full inbox from scratch: sync to get latest state, read message queue, selectively fetch bodies for decisions, then bulk-organize by priority.
|
|
218
|
+
- `ghostpaw-email skill read-and-reply`: Read a message with full thread context, then compose and send a properly-threaded reply with quoted attribution.
|
|
219
|
+
- `ghostpaw-email skill connect-and-sync`: Establish or restore an IMAP connection, refresh the folder list, and pull new messages — handling first-run vs incremental scenarios.
|
|
220
|
+
- `ghostpaw-email skill search-and-act`: Find messages matching criteria (local FTS first, remote IMAP SEARCH as fallback), verify targets, then act — organize, reply, or present.
|
|
221
|
+
- `ghostpaw-email skill compose-and-send`: Full draft lifecycle — save, review, update, then send — plus direct send, reply, and forward with proper threading and forwarded-header blocks.
|
|
222
|
+
- `ghostpaw-email skill organize-bulk`: Bulk organize messages across folders — flagging, moving, archiving, labelling — and manage the folder hierarchy as part of the flow.
|
|
223
|
+
- `ghostpaw-email skill attachment-workflow`: Discover, inspect, and fetch email attachments on demand; embed attachments in outbound messages; and export or import full .eml files.
|
|
224
|
+
- `ghostpaw-email skill recover-from-disruption`: Detect and recover from connection loss or IMAP/SMTP failures — reconnect with back-off, re-sync to reconcile state, and handle auth vs transient errors distinctly.
|
|
225
|
+
- `ghostpaw-email skill cli`: Complete existing email CLI guide.
|
|
191
226
|
|
|
192
227
|
## Principles
|
|
193
228
|
|