@ghostpaw/email 0.2.3 → 0.4.0
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 +96 -4
- package/SKILL.md +89 -241
- package/dist/cli.js +10052 -8116
- package/dist/database-Rfe-wn1C.d.cts +20 -0
- package/dist/database-Rfe-wn1C.d.ts +20 -0
- package/dist/index.cjs +75 -13
- package/dist/index.d.cts +40 -21
- package/dist/index.d.ts +40 -21
- package/dist/index.js +71 -9
- package/dist/mcp-server.js +6396 -0
- package/dist/mcp.cjs +6325 -0
- package/dist/mcp.d.cts +89 -0
- package/dist/mcp.d.ts +89 -0
- package/dist/mcp.js +6295 -0
- package/package.json +43 -10
- package/skills/email/SKILL.md +131 -0
- package/skills/email/references/attachment-workflow.md +25 -0
- package/skills/email/references/cli.md +283 -0
- package/skills/email/references/compose-and-send.md +30 -0
- package/skills/email/references/connect-and-sync.md +29 -0
- package/skills/email/references/organize-bulk.md +33 -0
- package/skills/email/references/read-and-reply.md +29 -0
- package/skills/email/references/recover-from-disruption.md +29 -0
- package/skills/email/references/search-and-act.md +33 -0
- package/skills/email/references/triage-inbox.md +30 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Recover from Disruption
|
|
2
|
+
|
|
3
|
+
Primary tools:
|
|
4
|
+
- `mail_sync`
|
|
5
|
+
- `mail_read`
|
|
6
|
+
|
|
7
|
+
Steps:
|
|
8
|
+
1. When any tool returns `outcome: "error"` with a message suggesting a connection problem (e.g. "connection lost", "socket closed", "IMAP session not active"), use `mail_sync { action: "reconnect" }` as the first recovery step.
|
|
9
|
+
2. `reconnect` applies exponential back-off internally: 1s → 2s → 4s → 8s … capped at 30s, up to 5 attempts. Wait for it to resolve before proceeding — do not call it in a loop.
|
|
10
|
+
3. After a successful reconnect, run `mail_sync { action: "sync" }` to reconcile local state. New messages or flag changes may have arrived during the downtime.
|
|
11
|
+
4. Retry the original failed operation once sync completes.
|
|
12
|
+
5. If `reconnect` exhausts all attempts (returns `outcome: "error"`), surface the error clearly: include the account host, the last error message, and suggest checking network connectivity and credentials.
|
|
13
|
+
6. If a UIDVALIDITY reset appears in the sync result after reconnecting, explain to the user that the folder's local cache was rebuilt — this is normal after a server migration or maintenance event.
|
|
14
|
+
|
|
15
|
+
Distinguishing error types:
|
|
16
|
+
- **Transient / network errors** (connection refused, timeout, TLS handshake failure) → use `reconnect`.
|
|
17
|
+
- **Auth errors** (EmailAuthError: invalid credentials, token expired) → do NOT use `reconnect`. Surface the auth failure immediately and prompt for credential update / token refresh.
|
|
18
|
+
- **Protocol errors** (server-side NO / BAD response to a command) → the session may still be alive; retry the specific command once before reconnecting.
|
|
19
|
+
- **SMTP failures** are independent of IMAP — an IMAP reconnect does not fix SMTP. Handle them separately.
|
|
20
|
+
|
|
21
|
+
Outcome handling:
|
|
22
|
+
- `reconnect` returning `success` means a fresh TCP/TLS connection and re-authentication completed.
|
|
23
|
+
- Sync after reconnect returning `totalNew > 0` means messages arrived during the disruption — run `triage-inbox` to process them.
|
|
24
|
+
- If the SMTP session was interrupted mid-send (message partially sent), do not retry automatically — check the Sent folder first to avoid duplicate sends.
|
|
25
|
+
|
|
26
|
+
Failure handling:
|
|
27
|
+
- Do not assume a connection error means invalid credentials — always attempt `reconnect` once before asking the user for new credentials.
|
|
28
|
+
- Do not queue multiple operations while the session is down — wait for reconnect to succeed before retrying.
|
|
29
|
+
- If both IMAP and SMTP fail simultaneously, the problem is likely at the network level, not the credentials.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Search and Act
|
|
2
|
+
|
|
3
|
+
Primary tools:
|
|
4
|
+
- `mail_search`
|
|
5
|
+
- `mail_read`
|
|
6
|
+
- `mail_organize`
|
|
7
|
+
- `mail_compose`
|
|
8
|
+
|
|
9
|
+
Steps:
|
|
10
|
+
1. Start with `mail_search { query, mode: "local" }` — FTS is fast, works offline, and searches subjects, body text, and sender fields simultaneously.
|
|
11
|
+
- Add `folder` to restrict to a specific mailbox.
|
|
12
|
+
- Add `since` / `before` (ISO date strings) to narrow by date range.
|
|
13
|
+
- Add `hasAttachments: true` or `unreadOnly: true` for quick filters.
|
|
14
|
+
2. If local results are insufficient (too few hits, or you expect newer unsynced mail), upgrade to `mail_search { query, mode: "remote", folder }` to run IMAP SEARCH on the server.
|
|
15
|
+
- Remote search requires an active IMAP session — run `mail_sync { action: "connect" }` first if not connected.
|
|
16
|
+
- Remote search returns UIDs only — always follow up with `mail_read { view: "message" }` to get content.
|
|
17
|
+
3. Before acting, use `mail_read { view: "message", folder, uid }` on the top candidates to confirm the right messages are targeted — search queries can match multiple threads.
|
|
18
|
+
4. Decide action based on what you found:
|
|
19
|
+
- Organize → `mail_organize` with the appropriate action (archive, move, star, mark_read, etc.).
|
|
20
|
+
- Reply → hand off to the `read-and-reply` skill.
|
|
21
|
+
- Forward → `mail_compose { action: "forward", folder, uid, input }`.
|
|
22
|
+
- Present only → return the entity list with subjects and UIDs.
|
|
23
|
+
|
|
24
|
+
Outcome handling:
|
|
25
|
+
- Empty local results do not mean the mail doesn't exist — always try remote search before concluding there are no matches.
|
|
26
|
+
- Remote search returns UIDs, not message content; reading before acting is not optional.
|
|
27
|
+
- If both local and remote searches return 0 results, the mail genuinely doesn't exist — or the query terms are too specific. Try a broader query.
|
|
28
|
+
- FTS queries support stemming and phrase matching; if an exact term fails, try a root word or shorter phrase.
|
|
29
|
+
|
|
30
|
+
Failure handling:
|
|
31
|
+
- Do not act on search results without reading the target first — subject-only matches can mislead.
|
|
32
|
+
- Do not run remote search in a loop — one local attempt and one remote attempt is sufficient before widening or abandoning the query.
|
|
33
|
+
- If `mode: "remote"` fails because there is no active session, surface the connection error and suggest `connect-and-sync` first.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Triage Inbox
|
|
2
|
+
|
|
3
|
+
Primary tools:
|
|
4
|
+
- `mail_sync`
|
|
5
|
+
- `mail_read`
|
|
6
|
+
- `mail_search`
|
|
7
|
+
- `mail_organize`
|
|
8
|
+
|
|
9
|
+
Steps:
|
|
10
|
+
1. Use `mail_sync { action: "sync" }` first to pull the latest messages. If the account is not connected, run `mail_sync { action: "connect" }` before syncing. If offline, skip sync and continue with local state — note results may be stale.
|
|
11
|
+
2. Use `mail_read { view: "queue", folder: "INBOX", limit: 50 }` to get the current message list. Add `unreadOnly: true` when the inbox is large and only new mail needs attention.
|
|
12
|
+
3. Scan subjects and senders from the queue. For messages that need a decision, fetch the full body with `mail_read { view: "message", folder, uid }`.
|
|
13
|
+
4. For messages that are part of an ongoing thread, use `mail_read { view: "thread", threadId }` to see the full conversation before deciding.
|
|
14
|
+
5. Categorise each message:
|
|
15
|
+
- Needs a reply → hand off to the `read-and-reply` skill.
|
|
16
|
+
- Contains an attachment → hand off to the `attachment-workflow` skill.
|
|
17
|
+
- Informational / done → `mail_organize { action: "archive", folder, uids }`.
|
|
18
|
+
- Spam / junk → `mail_organize { action: "junk", folder, uids }`.
|
|
19
|
+
- Important but deferred → `mail_organize { action: "star", folder, uids }`.
|
|
20
|
+
6. Apply bulk flag operations before disposition: `mark_read` first, then `archive`/`trash`/`move` in separate calls.
|
|
21
|
+
|
|
22
|
+
Outcome handling:
|
|
23
|
+
- If sync returns `totalNew: 0`, the inbox is already current — proceed directly to the queue read.
|
|
24
|
+
- If a message body fetch is slow or fails, it means the body is not yet cached — run `mail_sync { action: "sync" }` with the specific folder, then retry.
|
|
25
|
+
- If a thread has many messages, read only the most recent before deciding; fetch earlier messages only when context is explicitly needed.
|
|
26
|
+
|
|
27
|
+
Failure handling:
|
|
28
|
+
- Do not archive without reading when the message is from a known sender with an active thread.
|
|
29
|
+
- Do not bulk-trash without confirming the source folder is correct — junk detection and legit mail can look similar.
|
|
30
|
+
- Do not triage in one pass if the inbox has more than 50 messages — paginate with `limit` and `offset` to avoid missing messages.
|