@ghostpaw/email 0.5.4 → 0.5.5
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 +65 -22
- package/SKILL.md +81 -11
- package/dist/cli.js +1181 -619
- package/dist/index.cjs +213 -12
- package/dist/index.js +213 -12
- package/dist/mcp-server.js +189 -17
- package/dist/mcp.cjs +214 -54
- package/dist/mcp.js +214 -54
- package/package.json +1 -1
- package/skills/email/SKILL.md +81 -11
package/dist/mcp.js
CHANGED
|
@@ -1274,8 +1274,8 @@ async function authenticate(dispatcher, capabilities, config) {
|
|
|
1274
1274
|
}
|
|
1275
1275
|
if ("mechanism" in config) {
|
|
1276
1276
|
const { mechanism, credentials } = config;
|
|
1277
|
-
const
|
|
1278
|
-
const res = await dispatcher.execute("AUTHENTICATE", [mechanism,
|
|
1277
|
+
const payload2 = encodeBase64(Buffer.from(JSON.stringify(credentials), "utf8"));
|
|
1278
|
+
const res = await dispatcher.execute("AUTHENTICATE", [mechanism, payload2]);
|
|
1279
1279
|
if (res.tagged.status !== "OK") {
|
|
1280
1280
|
throw new EmailAuthError(`${mechanism} authentication failed`, mechanism);
|
|
1281
1281
|
}
|
|
@@ -2233,23 +2233,23 @@ var init_decode_bodystructure = __esm({
|
|
|
2233
2233
|
});
|
|
2234
2234
|
|
|
2235
2235
|
// src/mime/decode_encoded_words.ts
|
|
2236
|
-
function decodeQPayload(
|
|
2236
|
+
function decodeQPayload(payload2) {
|
|
2237
2237
|
const bytes = [];
|
|
2238
|
-
for (let i = 0; i <
|
|
2239
|
-
const c =
|
|
2238
|
+
for (let i = 0; i < payload2.length; i++) {
|
|
2239
|
+
const c = payload2[i];
|
|
2240
2240
|
if (c === "_") {
|
|
2241
2241
|
bytes.push(32);
|
|
2242
2242
|
continue;
|
|
2243
2243
|
}
|
|
2244
|
-
if (c === "=" && i + 2 <
|
|
2245
|
-
const h =
|
|
2244
|
+
if (c === "=" && i + 2 < payload2.length) {
|
|
2245
|
+
const h = payload2.slice(i + 1, i + 3);
|
|
2246
2246
|
if (/^[0-9A-Fa-f]{2}$/.test(h)) {
|
|
2247
2247
|
bytes.push(Number.parseInt(h, 16));
|
|
2248
2248
|
i += 2;
|
|
2249
2249
|
continue;
|
|
2250
2250
|
}
|
|
2251
2251
|
}
|
|
2252
|
-
bytes.push(
|
|
2252
|
+
bytes.push(payload2.charCodeAt(i) & 255);
|
|
2253
2253
|
}
|
|
2254
2254
|
return Buffer.from(bytes);
|
|
2255
2255
|
}
|
|
@@ -2320,9 +2320,9 @@ function parseAddressList(items) {
|
|
|
2320
2320
|
const mailbox = s2(addrArr[2]);
|
|
2321
2321
|
const host = s2(addrArr[3]);
|
|
2322
2322
|
if (!mailbox || !host) continue;
|
|
2323
|
-
const
|
|
2323
|
+
const address2 = `${mailbox}@${host}`;
|
|
2324
2324
|
const name = nameRaw ? decodeEncodedWords(nameRaw) : void 0;
|
|
2325
|
-
out.push(name ? { name, address } : { address });
|
|
2325
|
+
out.push(name ? { name, address: address2 } : { address: address2 });
|
|
2326
2326
|
}
|
|
2327
2327
|
return out;
|
|
2328
2328
|
}
|
|
@@ -4489,11 +4489,11 @@ function populateFts(db, messageId, textPlain, textHtml) {
|
|
|
4489
4489
|
if (!row) return;
|
|
4490
4490
|
const subject = row.subject != null ? String(row.subject) : "";
|
|
4491
4491
|
const sender = row.from != null ? String(row.from) : "";
|
|
4492
|
-
const
|
|
4492
|
+
const recipients2 = row.to != null ? String(row.to) : "";
|
|
4493
4493
|
db.exec(`DELETE FROM messages_fts WHERE rowid = ${messageId}`);
|
|
4494
4494
|
db.prepare(
|
|
4495
4495
|
"INSERT INTO messages_fts(rowid, subject, body_text, sender, recipients) VALUES (?, ?, ?, ?, ?)"
|
|
4496
|
-
).run(messageId, subject, bodyText, sender,
|
|
4496
|
+
).run(messageId, subject, bodyText, sender, recipients2);
|
|
4497
4497
|
}
|
|
4498
4498
|
var init_fts_populate = __esm({
|
|
4499
4499
|
"src/sync/fts_populate.ts"() {
|
|
@@ -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.5";
|
|
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.";
|
|
@@ -5064,6 +5064,192 @@ function createReadSurface(db, accountId, _options) {
|
|
|
5064
5064
|
// src/surface/email_surface_tools.ts
|
|
5065
5065
|
init_store();
|
|
5066
5066
|
|
|
5067
|
+
// src/surfaces/schema_example.ts
|
|
5068
|
+
function schemaExample(schema, seed = {}) {
|
|
5069
|
+
if (schema.oneOf) {
|
|
5070
|
+
const branch = schema.oneOf.find(
|
|
5071
|
+
(candidate) => Object.entries(seed).every(([key, value]) => {
|
|
5072
|
+
const values = candidate.properties?.[key]?.enum;
|
|
5073
|
+
return !values || values.includes(value);
|
|
5074
|
+
})
|
|
5075
|
+
);
|
|
5076
|
+
return schemaExample({ ...schema, ...branch, oneOf: void 0 }, seed);
|
|
5077
|
+
}
|
|
5078
|
+
if (schema.enum) return schema.enum[0];
|
|
5079
|
+
if (schema.type === "object") {
|
|
5080
|
+
const result = { ...seed };
|
|
5081
|
+
for (const key of schema.required ?? [])
|
|
5082
|
+
if (!(key in result)) {
|
|
5083
|
+
const property = schema.properties?.[key] ?? {};
|
|
5084
|
+
const placeholders = {
|
|
5085
|
+
folder: "INBOX",
|
|
5086
|
+
destination: "Archive",
|
|
5087
|
+
query: "invoice",
|
|
5088
|
+
subject: "Hello",
|
|
5089
|
+
path: "Projects",
|
|
5090
|
+
oldPath: "Projects",
|
|
5091
|
+
newPath: "Archive/Projects"
|
|
5092
|
+
};
|
|
5093
|
+
result[key] = property.type === "string" && !property.enum && placeholders[key] ? placeholders[key] : schemaExample(property);
|
|
5094
|
+
}
|
|
5095
|
+
return result;
|
|
5096
|
+
}
|
|
5097
|
+
if (schema.type === "array") return [schemaExample(schema.items ?? {})];
|
|
5098
|
+
if (schema.type === "integer" || schema.type === "number") return 1;
|
|
5099
|
+
if (schema.type === "boolean") return false;
|
|
5100
|
+
return schema.description?.includes("address") ? "reader@example.com" : "example";
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
// src/surfaces/validate_input.ts
|
|
5104
|
+
function validateInput(schema, input, path = "$") {
|
|
5105
|
+
const errors = validate(schema, input, path);
|
|
5106
|
+
if (path !== "$" || !errors.length) return errors;
|
|
5107
|
+
const seed = {};
|
|
5108
|
+
if (input && typeof input === "object") {
|
|
5109
|
+
for (const key of ["action", "view"])
|
|
5110
|
+
if (schema.properties?.[key]?.enum?.includes(input[key]))
|
|
5111
|
+
seed[key] = input[key];
|
|
5112
|
+
}
|
|
5113
|
+
return errors.map((error) => `${error}; pass ${JSON.stringify(schemaExample(schema, seed))}`);
|
|
5114
|
+
}
|
|
5115
|
+
function validate(schema, input, path) {
|
|
5116
|
+
const errors = [];
|
|
5117
|
+
const matchesType = (type) => {
|
|
5118
|
+
switch (type) {
|
|
5119
|
+
case "object":
|
|
5120
|
+
return typeof input === "object" && input !== null && !Array.isArray(input);
|
|
5121
|
+
case "array":
|
|
5122
|
+
return Array.isArray(input);
|
|
5123
|
+
case "integer":
|
|
5124
|
+
return typeof input === "number" && Number.isInteger(input);
|
|
5125
|
+
case "number":
|
|
5126
|
+
return typeof input === "number" && Number.isFinite(input);
|
|
5127
|
+
case "null":
|
|
5128
|
+
return input === null;
|
|
5129
|
+
default:
|
|
5130
|
+
return typeof input === type;
|
|
5131
|
+
}
|
|
5132
|
+
};
|
|
5133
|
+
if (schema.type && !(Array.isArray(schema.type) ? schema.type : [schema.type]).some(matchesType)) {
|
|
5134
|
+
return [`${path}: expected ${String(schema.type)}`];
|
|
5135
|
+
}
|
|
5136
|
+
if (schema.enum && !schema.enum.some((value) => JSON.stringify(value) === JSON.stringify(input)))
|
|
5137
|
+
errors.push(`${path}: expected one of ${JSON.stringify(schema.enum)}`);
|
|
5138
|
+
if (schema.oneOf) {
|
|
5139
|
+
const branches = schema.oneOf.map((branch) => validate(branch, input, path));
|
|
5140
|
+
if (!branches.some((errors2) => errors2.length === 0)) {
|
|
5141
|
+
const record = input && typeof input === "object" ? input : {};
|
|
5142
|
+
const selected = schema.oneOf.findIndex(
|
|
5143
|
+
(branch) => ["action", "view"].some((key) => branch.properties?.[key]?.enum?.includes(record[key]))
|
|
5144
|
+
);
|
|
5145
|
+
errors.push(...branches[selected >= 0 ? selected : 0] ?? []);
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
if (typeof input === "object" && input !== null && !Array.isArray(input)) {
|
|
5149
|
+
const record = input;
|
|
5150
|
+
for (const name of schema.required ?? [])
|
|
5151
|
+
if (!Object.hasOwn(record, name)) errors.push(`${path}.${name}: required`);
|
|
5152
|
+
for (const [name, property] of Object.entries(schema.properties ?? {}))
|
|
5153
|
+
if (Object.hasOwn(record, name))
|
|
5154
|
+
errors.push(...validate(property, record[name], `${path}.${name}`));
|
|
5155
|
+
}
|
|
5156
|
+
if (Array.isArray(input) && schema.items)
|
|
5157
|
+
input.forEach((value, index) => {
|
|
5158
|
+
errors.push(...validate(schema.items, value, `${path}[${index}]`));
|
|
5159
|
+
});
|
|
5160
|
+
return errors;
|
|
5161
|
+
}
|
|
5162
|
+
|
|
5163
|
+
// src/tools/input_schema.ts
|
|
5164
|
+
var address = {
|
|
5165
|
+
type: "object",
|
|
5166
|
+
required: ["address"],
|
|
5167
|
+
properties: {
|
|
5168
|
+
address: { type: "string", description: "Email address." },
|
|
5169
|
+
name: { type: "string", description: "Display name." }
|
|
5170
|
+
}
|
|
5171
|
+
};
|
|
5172
|
+
var recipients = {
|
|
5173
|
+
type: "array",
|
|
5174
|
+
items: address,
|
|
5175
|
+
description: "Recipient addresses."
|
|
5176
|
+
};
|
|
5177
|
+
var payload = {
|
|
5178
|
+
type: "object",
|
|
5179
|
+
properties: {
|
|
5180
|
+
from: address,
|
|
5181
|
+
sender: address,
|
|
5182
|
+
envelopeFrom: address,
|
|
5183
|
+
replyTo: address,
|
|
5184
|
+
to: recipients,
|
|
5185
|
+
cc: recipients,
|
|
5186
|
+
bcc: recipients,
|
|
5187
|
+
subject: { type: "string", description: "Message subject." },
|
|
5188
|
+
text: { type: "string", description: "Plain text body." },
|
|
5189
|
+
html: { type: "string", description: "HTML body." },
|
|
5190
|
+
replyAll: { type: "boolean", description: "Reply to all original recipients." },
|
|
5191
|
+
mode: { type: "string", enum: ["inline", "attachment"] },
|
|
5192
|
+
attachments: {
|
|
5193
|
+
type: "array",
|
|
5194
|
+
description: "Message attachments.",
|
|
5195
|
+
items: {
|
|
5196
|
+
type: "object",
|
|
5197
|
+
required: ["filename", "content"],
|
|
5198
|
+
properties: {
|
|
5199
|
+
filename: { type: "string" },
|
|
5200
|
+
content: { description: "Attachment bytes (Buffer in library calls)." },
|
|
5201
|
+
mimeType: { type: "string" },
|
|
5202
|
+
inline: { type: "boolean" },
|
|
5203
|
+
contentId: { type: "string" }
|
|
5204
|
+
}
|
|
5205
|
+
}
|
|
5206
|
+
},
|
|
5207
|
+
inReplyTo: { type: "string" },
|
|
5208
|
+
references: { type: "array", items: { type: "string" } },
|
|
5209
|
+
headers: { type: "object" }
|
|
5210
|
+
}
|
|
5211
|
+
};
|
|
5212
|
+
function emailInputSchema(name, schema) {
|
|
5213
|
+
const discriminator = name === "mail_read" ? "view" : "action";
|
|
5214
|
+
const actions = schema.properties?.[discriminator]?.enum;
|
|
5215
|
+
if (!actions || name === "mail_sync") return schema;
|
|
5216
|
+
return {
|
|
5217
|
+
...schema,
|
|
5218
|
+
oneOf: actions.map((value) => {
|
|
5219
|
+
const action = String(value);
|
|
5220
|
+
let required = [];
|
|
5221
|
+
let input;
|
|
5222
|
+
if (name === "mail_read") {
|
|
5223
|
+
if (action === "thread") required = ["threadId"];
|
|
5224
|
+
if (["message", "attachment", "eml"].includes(action)) required = ["folder", "uid"];
|
|
5225
|
+
} else if (name === "mail_compose") {
|
|
5226
|
+
if (action !== "send_draft") {
|
|
5227
|
+
required.push("input");
|
|
5228
|
+
input = {
|
|
5229
|
+
...payload,
|
|
5230
|
+
required: ["send", "save_draft", "update_draft"].includes(action) ? ["to", "subject"] : action === "forward" ? ["to"] : []
|
|
5231
|
+
};
|
|
5232
|
+
}
|
|
5233
|
+
if (["reply", "forward"].includes(action)) required.push("folder", "uid");
|
|
5234
|
+
if (["update_draft", "send_draft"].includes(action)) required.push("uid");
|
|
5235
|
+
} else if (name === "mail_organize") {
|
|
5236
|
+
required = action === "rename_folder" ? ["oldPath", "newPath"] : action.endsWith("_folder") ? ["path"] : ["folder", "uids"];
|
|
5237
|
+
if (["copy", "move"].includes(action)) required.push("destination");
|
|
5238
|
+
if (action.endsWith("_labels")) required.push("labels");
|
|
5239
|
+
}
|
|
5240
|
+
return {
|
|
5241
|
+
type: "object",
|
|
5242
|
+
required: [...schema.required ?? [], ...required],
|
|
5243
|
+
properties: {
|
|
5244
|
+
...schema.properties,
|
|
5245
|
+
[discriminator]: { ...schema.properties?.[discriminator], enum: [value] },
|
|
5246
|
+
...input ? { input } : {}
|
|
5247
|
+
}
|
|
5248
|
+
};
|
|
5249
|
+
})
|
|
5250
|
+
};
|
|
5251
|
+
}
|
|
5252
|
+
|
|
5067
5253
|
// src/tools/email_tools.ts
|
|
5068
5254
|
var emailTools = [
|
|
5069
5255
|
{
|
|
@@ -5784,6 +5970,21 @@ var emailTools = [
|
|
|
5784
5970
|
}
|
|
5785
5971
|
}
|
|
5786
5972
|
];
|
|
5973
|
+
for (const tool of emailTools) {
|
|
5974
|
+
Object.assign(tool.inputSchema, emailInputSchema(tool.name, tool.inputSchema));
|
|
5975
|
+
const handler = tool.handler;
|
|
5976
|
+
tool.handler = async (ctx, input) => {
|
|
5977
|
+
const errors = validateInput(tool.inputSchema, input);
|
|
5978
|
+
if (errors.length)
|
|
5979
|
+
return {
|
|
5980
|
+
outcome: "error",
|
|
5981
|
+
summary: errors.join("; "),
|
|
5982
|
+
entities: [],
|
|
5983
|
+
nextSteps: errors
|
|
5984
|
+
};
|
|
5985
|
+
return handler(ctx, input);
|
|
5986
|
+
};
|
|
5987
|
+
}
|
|
5787
5988
|
|
|
5788
5989
|
// src/tools/aligned.ts
|
|
5789
5990
|
var usage = {
|
|
@@ -6078,47 +6279,6 @@ function isErrorResult(result) {
|
|
|
6078
6279
|
return typeof result === "object" && result !== null && "ok" in result && result.ok === false;
|
|
6079
6280
|
}
|
|
6080
6281
|
|
|
6081
|
-
// src/surfaces/validate_input.ts
|
|
6082
|
-
function validateInput(schema, input, path = "$") {
|
|
6083
|
-
const errors = [];
|
|
6084
|
-
const matchesType = (type) => {
|
|
6085
|
-
switch (type) {
|
|
6086
|
-
case "object":
|
|
6087
|
-
return typeof input === "object" && input !== null && !Array.isArray(input);
|
|
6088
|
-
case "array":
|
|
6089
|
-
return Array.isArray(input);
|
|
6090
|
-
case "integer":
|
|
6091
|
-
return typeof input === "number" && Number.isInteger(input);
|
|
6092
|
-
case "number":
|
|
6093
|
-
return typeof input === "number" && Number.isFinite(input);
|
|
6094
|
-
case "null":
|
|
6095
|
-
return input === null;
|
|
6096
|
-
default:
|
|
6097
|
-
return typeof input === type;
|
|
6098
|
-
}
|
|
6099
|
-
};
|
|
6100
|
-
if (schema.type && !(Array.isArray(schema.type) ? schema.type : [schema.type]).some(matchesType)) {
|
|
6101
|
-
return [`${path}: expected ${String(schema.type)}`];
|
|
6102
|
-
}
|
|
6103
|
-
if (schema.enum && !schema.enum.some((value) => JSON.stringify(value) === JSON.stringify(input)))
|
|
6104
|
-
errors.push(`${path}: expected one of ${JSON.stringify(schema.enum)}`);
|
|
6105
|
-
if (schema.oneOf && !schema.oneOf.some((branch) => validateInput(branch, input, path).length === 0))
|
|
6106
|
-
errors.push(`${path}: must match at least one schema branch`);
|
|
6107
|
-
if (typeof input === "object" && input !== null && !Array.isArray(input)) {
|
|
6108
|
-
const record = input;
|
|
6109
|
-
for (const name of schema.required ?? [])
|
|
6110
|
-
if (!Object.hasOwn(record, name)) errors.push(`${path}.${name}: required`);
|
|
6111
|
-
for (const [name, property] of Object.entries(schema.properties ?? {}))
|
|
6112
|
-
if (Object.hasOwn(record, name))
|
|
6113
|
-
errors.push(...validateInput(property, record[name], `${path}.${name}`));
|
|
6114
|
-
}
|
|
6115
|
-
if (Array.isArray(input) && schema.items)
|
|
6116
|
-
input.forEach((value, index) => {
|
|
6117
|
-
errors.push(...validateInput(schema.items, value, `${path}[${index}]`));
|
|
6118
|
-
});
|
|
6119
|
-
return errors;
|
|
6120
|
-
}
|
|
6121
|
-
|
|
6122
6282
|
// src/surfaces/mcp_server.ts
|
|
6123
6283
|
var MCP_LATEST_PROTOCOL_VERSION = "2026-07-28";
|
|
6124
6284
|
var MCP_SUPPORTED_PROTOCOL_VERSIONS = [
|
package/package.json
CHANGED
package/skills/email/SKILL.md
CHANGED
|
@@ -2,18 +2,34 @@
|
|
|
2
2
|
name: email
|
|
3
3
|
description: "Read, search, compose, organize and synchronize email with a local SQLite cache. Use when managing email or searching cached messages."
|
|
4
4
|
license: "MIT"
|
|
5
|
-
compatibility: "
|
|
5
|
+
compatibility: "Release binary ghostpaw-email (no runtime needed); MCP stdio via ghostpaw-email mcp."
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# email
|
|
9
9
|
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Linux/macOS (checks SHA256SUMS and installs ~/.local/bin/ghostpaw-email):
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
curl -fsSL https://raw.githubusercontent.com/GhostPawJS/email/main/install.sh | sh
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Windows x64:
|
|
19
|
+
|
|
20
|
+
```powershell
|
|
21
|
+
irm https://raw.githubusercontent.com/GhostPawJS/email/main/install.ps1 | iex
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Run tools as `ghostpaw-email ...`; use `~/.local/bin/ghostpaw-email` if it is not on PATH.
|
|
25
|
+
|
|
10
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.
|
|
11
27
|
|
|
12
28
|
## Calling tools
|
|
13
29
|
|
|
14
30
|
MCP: connect to ghostpaw-email, then call a tool by name with its JSON arguments.
|
|
15
31
|
|
|
16
|
-
CLI: `ghostpaw-email call <tool> '<JSON object>'` or `ghostpaw-email <tool> --parameter value
|
|
32
|
+
CLI: `ghostpaw-email call <tool> '<JSON object>'` or `ghostpaw-email <tool> --parameter value`.
|
|
17
33
|
|
|
18
34
|
Inspect schemas with `ghostpaw-email describe <tool>`. Use `--db <path>` to select a database.
|
|
19
35
|
|
|
@@ -27,6 +43,8 @@ Not for: Use mail_search to find messages by query or mail_organize to change th
|
|
|
27
43
|
|
|
28
44
|
Writes: writes_state.
|
|
29
45
|
|
|
46
|
+
Nested requirements apply within the parent for the selected action.
|
|
47
|
+
|
|
30
48
|
| Parameter | Type | Required | Values / description |
|
|
31
49
|
| --- | --- | --- | --- |
|
|
32
50
|
| view | string | yes | folders, queue, thread, message, attachment, eml. What to read. |
|
|
@@ -38,6 +56,12 @@ Writes: writes_state.
|
|
|
38
56
|
| unreadOnly | boolean | no | Filter to unread messages only (queue view). |
|
|
39
57
|
| refresh | boolean | no | Fetch live folder list from server before returning (folders/queue view). |
|
|
40
58
|
|
|
59
|
+
Examples:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
ghostpaw-email call mail_read '{"view":"folders"}'
|
|
63
|
+
```
|
|
64
|
+
|
|
41
65
|
## mail_search
|
|
42
66
|
|
|
43
67
|
Search for messages locally via FTS or remotely via IMAP SEARCH. Returns matching message references.
|
|
@@ -48,6 +72,8 @@ Not for: Use mail_read when the folder and message UID are already known.
|
|
|
48
72
|
|
|
49
73
|
Writes: writes_state.
|
|
50
74
|
|
|
75
|
+
Nested requirements apply within the parent for the selected action.
|
|
76
|
+
|
|
51
77
|
| Parameter | Type | Required | Values / description |
|
|
52
78
|
| --- | --- | --- | --- |
|
|
53
79
|
| query | string | yes | Free-text search query or FTS5 expression. |
|
|
@@ -59,6 +85,12 @@ Writes: writes_state.
|
|
|
59
85
|
| unreadOnly | boolean | no | Filter to unread messages. |
|
|
60
86
|
| limit | integer | no | Maximum number of results. |
|
|
61
87
|
|
|
88
|
+
Examples:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
ghostpaw-email call mail_search '{"query":"invoice"}'
|
|
92
|
+
```
|
|
93
|
+
|
|
62
94
|
## mail_compose
|
|
63
95
|
|
|
64
96
|
Compose and send email: send new message, reply, forward, save/update/send a draft.
|
|
@@ -69,12 +101,24 @@ Not for: Use mail_read to inspect an existing message without sending or saving
|
|
|
69
101
|
|
|
70
102
|
Writes: writes_state.
|
|
71
103
|
|
|
104
|
+
Nested requirements apply within the parent for the selected action.
|
|
105
|
+
|
|
72
106
|
| Parameter | Type | Required | Values / description |
|
|
73
107
|
| --- | --- | --- | --- |
|
|
74
108
|
| action | string | yes | send, reply, forward, save_draft, update_draft, send_draft. |
|
|
75
109
|
| folder | string | no | Source folder (required for reply/forward). |
|
|
76
110
|
| uid | integer | no | Source message UID (required for reply/forward/update_draft/send_draft). |
|
|
77
111
|
| input | object | no | ComposeInput / ReplyInput / ForwardInput payload. |
|
|
112
|
+
| input.to | array | yes | Recipient addresses. |
|
|
113
|
+
| input.subject | string | yes | Message subject. |
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
ghostpaw-email call mail_compose '{"action":"send","input":{"to":[{"address":"reader@example.com"}],"subject":"Hello"}}'
|
|
119
|
+
ghostpaw-email call mail_compose '{"action":"reply","input":{},"folder":"INBOX","uid":1}'
|
|
120
|
+
ghostpaw-email call mail_compose '{"action":"forward","input":{"to":[{"address":"reader@example.com"}]},"folder":"INBOX","uid":1}'
|
|
121
|
+
```
|
|
78
122
|
|
|
79
123
|
## mail_organize
|
|
80
124
|
|
|
@@ -86,6 +130,8 @@ Not for: Use mail_read or mail_search when only inspection is requested.
|
|
|
86
130
|
|
|
87
131
|
Writes: writes_state.
|
|
88
132
|
|
|
133
|
+
Nested requirements apply within the parent for the selected action.
|
|
134
|
+
|
|
89
135
|
| Parameter | Type | Required | Values / description |
|
|
90
136
|
| --- | --- | --- | --- |
|
|
91
137
|
| action | string | yes | mark_read, mark_unread, star, unstar, mark_answered, copy, move, archive, trash, junk, not_junk, set_labels, add_labels, remove_labels, create_folder, rename_folder, delete_folder, subscribe_folder, unsubscribe_folder. |
|
|
@@ -97,6 +143,14 @@ Writes: writes_state.
|
|
|
97
143
|
| oldPath | string | no | Old folder path (required for rename_folder). |
|
|
98
144
|
| newPath | string | no | New folder path (required for rename_folder). |
|
|
99
145
|
|
|
146
|
+
Examples:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
ghostpaw-email call mail_organize '{"action":"mark_read","folder":"INBOX","uids":[1]}'
|
|
150
|
+
ghostpaw-email call mail_organize '{"action":"mark_unread","folder":"INBOX","uids":[1]}'
|
|
151
|
+
ghostpaw-email call mail_organize '{"action":"star","folder":"INBOX","uids":[1]}'
|
|
152
|
+
```
|
|
153
|
+
|
|
100
154
|
## mail_sync
|
|
101
155
|
|
|
102
156
|
Manage the IMAP connection lifecycle and sync local state: connect, disconnect, reconnect, sync folders, or refresh the folder list.
|
|
@@ -107,25 +161,41 @@ Not for: Use mail_read for cached content or the network watch stream for contin
|
|
|
107
161
|
|
|
108
162
|
Writes: writes_state.
|
|
109
163
|
|
|
164
|
+
Nested requirements apply within the parent for the selected action.
|
|
165
|
+
|
|
110
166
|
| Parameter | Type | Required | Values / description |
|
|
111
167
|
| --- | --- | --- | --- |
|
|
112
168
|
| action | string | yes | connect, disconnect, reconnect, sync, refresh_folders, watch. |
|
|
113
169
|
| folders | array | no | Folders to sync or watch (optional — defaults to all subscribed folders). |
|
|
114
170
|
| bodies | string | no | none, missing, all. Body fetch strategy for sync (default: missing). |
|
|
115
171
|
|
|
172
|
+
Examples:
|
|
173
|
+
|
|
174
|
+
```sh
|
|
175
|
+
ghostpaw-email call mail_sync '{"action":"connect"}'
|
|
176
|
+
ghostpaw-email call mail_sync '{"action":"disconnect"}'
|
|
177
|
+
ghostpaw-email call mail_sync '{"action":"reconnect"}'
|
|
178
|
+
```
|
|
179
|
+
|
|
116
180
|
## Workflow guides
|
|
117
181
|
|
|
118
|
-
- [triage-inbox](references/triage-inbox.md): Process a full inbox from scratch: sync to get latest state, read message queue, selectively fetch bodies for decisions, then bulk-organize by priority.
|
|
119
|
-
- [read-and-reply](references/read-and-reply.md): Read a message with full thread context, then compose and send a properly-threaded reply with quoted attribution.
|
|
120
|
-
- [connect-and-sync](references/connect-and-sync.md): Establish or restore an IMAP connection, refresh the folder list, and pull new messages — handling first-run vs incremental scenarios.
|
|
121
|
-
- [search-and-act](references/search-and-act.md): Find messages matching criteria (local FTS first, remote IMAP SEARCH as fallback), verify targets, then act — organize, reply, or present.
|
|
122
|
-
- [compose-and-send](references/compose-and-send.md): Full draft lifecycle — save, review, update, then send — plus direct send, reply, and forward with proper threading and forwarded-header blocks.
|
|
123
|
-
- [organize-bulk](references/organize-bulk.md): Bulk organize messages across folders — flagging, moving, archiving, labelling — and manage the folder hierarchy as part of the flow.
|
|
124
|
-
- [attachment-workflow](references/attachment-workflow.md): Discover, inspect, and fetch email attachments on demand; embed attachments in outbound messages; and export or import full .eml files.
|
|
125
|
-
- [recover-from-disruption](references/recover-from-disruption.md): 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.
|
|
126
|
-
- [cli](references/cli.md): Complete existing email CLI guide.
|
|
182
|
+
- `ghostpaw-email skill triage-inbox` ([triage-inbox](references/triage-inbox.md)): Process a full inbox from scratch: sync to get latest state, read message queue, selectively fetch bodies for decisions, then bulk-organize by priority.
|
|
183
|
+
- `ghostpaw-email skill read-and-reply` ([read-and-reply](references/read-and-reply.md)): Read a message with full thread context, then compose and send a properly-threaded reply with quoted attribution.
|
|
184
|
+
- `ghostpaw-email skill connect-and-sync` ([connect-and-sync](references/connect-and-sync.md)): Establish or restore an IMAP connection, refresh the folder list, and pull new messages — handling first-run vs incremental scenarios.
|
|
185
|
+
- `ghostpaw-email skill search-and-act` ([search-and-act](references/search-and-act.md)): Find messages matching criteria (local FTS first, remote IMAP SEARCH as fallback), verify targets, then act — organize, reply, or present.
|
|
186
|
+
- `ghostpaw-email skill compose-and-send` ([compose-and-send](references/compose-and-send.md)): Full draft lifecycle — save, review, update, then send — plus direct send, reply, and forward with proper threading and forwarded-header blocks.
|
|
187
|
+
- `ghostpaw-email skill organize-bulk` ([organize-bulk](references/organize-bulk.md)): Bulk organize messages across folders — flagging, moving, archiving, labelling — and manage the folder hierarchy as part of the flow.
|
|
188
|
+
- `ghostpaw-email skill attachment-workflow` ([attachment-workflow](references/attachment-workflow.md)): Discover, inspect, and fetch email attachments on demand; embed attachments in outbound messages; and export or import full .eml files.
|
|
189
|
+
- `ghostpaw-email skill recover-from-disruption` ([recover-from-disruption](references/recover-from-disruption.md)): 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.
|
|
190
|
+
- `ghostpaw-email skill cli` ([cli](references/cli.md)): Complete existing email CLI guide.
|
|
127
191
|
|
|
128
192
|
## Principles
|
|
129
193
|
|
|
130
194
|
- Inspect before changing messages.
|
|
131
195
|
- Confirm recipients and content before sending.
|
|
196
|
+
|
|
197
|
+
## Without the binary
|
|
198
|
+
|
|
199
|
+
For npm-based environments (Node 24+): `npx -y @ghostpaw/email ...`.
|
|
200
|
+
|
|
201
|
+
Harnesses that embed it in code can import `@ghostpaw/email` as a library.
|