mirror of
https://git.openapi.site/https://github.com/desirecore/market.git
synced 2026-12-05 21:19:28 +08:00
fix(mail-operations): 按 v10.0.180 起的邮件服务行为更新技能说明(1.2.0) (#233)
- save_to 可保存任意 JSON 响应;超过输出上限时的提示与做法;messages/fetch 拿不到完整结果时改读本地缓存 - 等待上限 20 分钟,失败按请求是否送达区分;写操作失败后先核对再决定是否重试 - IMAP 其他文件夹的 id 带文件夹键,folder 只对带键 id 起核对作用;改动类操作只认本地缓存;新错误码 - IMAP 补拉只取摘要,附件 id 为 part:<n>;/api/sync 支持 imap,syncInterval 按分钟 - required_client_version 提到 10.0.180,删掉两句已过时的旧客户端说明
This commit is contained in:
3 files changed
+107
-57
No files matched your search
@@ -10,7 +10,7 @@ description: >-
|
||||
Use when 用户提到 邮件、邮箱、收件箱、发邮件、回复邮件、查邮件、Gmail、
|
||||
Outlook、QQ邮箱、163邮箱、附件、标签、草稿、自动回复、邮件规则、
|
||||
转发、抄送、未读邮件、收信、发信、邮件同步、邮件搜索。
|
||||
version: 1.1.0
|
||||
version: 1.2.0
|
||||
type: procedural
|
||||
risk_level: medium
|
||||
status: enabled
|
||||
@@ -24,7 +24,7 @@ tags:
|
||||
- smtp
|
||||
metadata:
|
||||
author: desirecore
|
||||
updated_at: '2026-10-05'
|
||||
updated_at: '2026-10-28'
|
||||
i18n:
|
||||
default_locale: en-US
|
||||
source_locale: zh-CN
|
||||
@@ -37,7 +37,7 @@ metadata:
|
||||
description: >-
|
||||
Use this skill whenever the user wants to interact with email. This includes reading inbox, sending emails, replying, searching messages, managing labels and categories, downloading attachments, setting up auto-reply rules, or triggering agents to handle incoming emails. Supports Gmail, Outlook, and IMAP/SMTP (QQ Mail, 163, Yahoo, etc.) through DesireCore's local REST API. Use when 用户提到 邮件、邮箱、收件箱、发邮件、回复邮件、查邮件、Gmail、 Outlook、QQ邮箱、163邮箱、附件、标签、草稿、自动回复、邮件规则、 转发、抄送、未读邮件、收信、发信、邮件同步、邮件搜索。
|
||||
body: ./SKILL.zh-CN.md
|
||||
source_hash: sha256:24bffbade0dc09a7
|
||||
source_hash: sha256:0f8d0c1cc15fa36e
|
||||
translated_by: human
|
||||
en-US:
|
||||
name: Email Operations
|
||||
@@ -45,9 +45,9 @@ metadata:
|
||||
description: >-
|
||||
Use this skill whenever the user wants to interact with email. This includes reading inbox, sending emails, replying, searching messages, managing labels and categories, downloading attachments, setting up auto-reply rules, or triggering agents to handle incoming emails. Supports Gmail, Outlook, and IMAP/SMTP (QQ Mail, 163, Yahoo, etc.) through DesireCore's local REST API. Use when the user mentions email, mailbox, inbox, sending email, replying, checking email, Gmail, Outlook, QQ Mail, 163 Mail, attachments, labels, drafts, auto-reply, email rules, forwarding, CC, unread email, receiving, sending, email sync, or email search.
|
||||
body: ./SKILL.md
|
||||
source_hash: sha256:ec3be525ab586e62
|
||||
source_hash: sha256:0f8d0c1cc15fa36e
|
||||
translated_by: human
|
||||
translated_at: '2026-10-05'
|
||||
translated_at: '2026-10-28'
|
||||
market:
|
||||
icon: >-
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
|
||||
@@ -63,7 +63,7 @@ market:
|
||||
name: DesireCore Official
|
||||
verified: true
|
||||
channel: latest
|
||||
required_client_version: 10.0.178
|
||||
required_client_version: 10.0.180
|
||||
---
|
||||
|
||||
# mail-operations Skill
|
||||
@@ -106,10 +106,11 @@ Users can reach the email management interface via:
|
||||
|
||||
## API Basics
|
||||
|
||||
- **How to call**: use the built-in `MailOperations` tool. Its parameters are `path` (a relative path starting with `/api/`, with query parameters appended directly to it), `method` (default `GET`), `body` (a JSON object), and `save_to` (only for attachment downloads, see section 6). The tool locates the local Mail Service and attaches the access credential automatically; the Agent neither needs nor can supply a token.
|
||||
- **How to call**: use the built-in `MailOperations` tool. Its parameters are `path` (a relative path starting with `/api/`, with query parameters appended directly to it), `method` (default `GET`), `body` (a JSON object), and `save_to` (writes the response to a file, see "Large responses and `save_to`" below; required when downloading an attachment, see section 6). The tool locates the local Mail Service and attaches the access credential automatically; the Agent neither needs nor can supply a token.
|
||||
- **Large responses and `save_to`**: the tool returns at most 100 KB. Message list, search, and `messages/fetch` responses carry the body of every message, so a few dozen messages can exceed the limit. When the limit is exceeded and no `save_to` is given, the tool shortens overlong fields (such as message bodies) and re-indents the JSON before returning it, keeping only the head and tail when it still does not fit; a leading notice states the response size, that it is "not the complete result" or which fields were shortened, the response structure (e.g. `result.messages 20 条,total 411`), and how to get the full content. When you need the complete result, call again with the same `path` / `method` / `body` plus `save_to` (e.g. `"./mail-list.json"`) and read that file with Read or a script, or page with a smaller `limit`. With `save_to`, the complete response is written to the file atomically (JSON up to 8 MB is re-indented with 2 spaces; larger responses are written as is, and the receipt says so), and the tool returns only the absolute path, byte count, SHA-256, and a structure summary; non-2xx responses are not written; a response body over 32 MB is refused, so reduce `limit`; the target path must be inside a writable working directory, missing parent directories are created, and an existing file with the same name is overwritten. The result of `messages/fetch` is already written to the local cache before it is returned: when its response exceeds the limit, read the local cache with `GET /{p}/messages` (the matching `folder`, paged by `offset` / `limit`, with `save_to` if needed) instead of running the same fetch again.
|
||||
- **Path form**: the endpoints below omit the `/api` prefix; add it when calling. For example, `/imap/messages?email=me%40example.com&limit=20` becomes `path: "/api/imap/messages?email=me%40example.com&limit=20"`. The only exception is the health check `/ping` (no `/api`).
|
||||
- **Do not connect to the port directly**: do not `curl` `https://127.0.0.1:62000`. The port is allocated dynamically starting at 62000 (when several DesireCore instances run, 62000 may belong to another instance), and in strict capability mode direct requests without the credential always return 401.
|
||||
- **Parameter location**: GET / DELETE parameters always go in the query string; for POST / PUT follow the tables below. The `email` of endpoints such as `messages/fetch`, mark as read/unread, Outlook single-message operations, and IMAP draft send must be in the query string; putting it in the body returns 400 `Missing email parameter`. For `/sync`, both `provider` and `email` must be in the query string: `provider` in the body returns 400 `Invalid provider`, and `email` alone in the body raises no parameter error but the sync does not take effect.
|
||||
- **Parameter location**: GET / DELETE parameters always go in the query string; for POST / PUT follow the tables below. The `email` of endpoints such as `messages/fetch`, mark as read/unread, Outlook single-message operations, and IMAP draft send must be in the query string; putting it in the body returns 400 `Missing email parameter`. For `/sync`, both `provider` and `email` must be in the query string: `provider` in the body returns 400 `Invalid provider`, and `email` in the body returns 400 `Email is required`. `method` defaults to `GET`; endpoints that take a request body (such as `messages/fetch`) also need `method: "POST"`, and the tool refuses a GET with a `body` before sending it.
|
||||
- **Content-Type**: `application/json` (set automatically by the tool when `body` is passed)
|
||||
- **Response format**: success `{"code": 1, "msg": "Success", "result": ...}`, failure `{"code": 0, "msg": "error message"}`; some errors also carry a stable error code field `error` (e.g. `smtp_unverified`)
|
||||
|
||||
@@ -154,7 +155,7 @@ After a write operation (send, reply, delete, mark, label change, etc.) succeeds
|
||||
|------|-------|---------|------|
|
||||
| Authorization | OAuth2 | OAuth2 (MSAL) | password / app password |
|
||||
| Provider path | `/gmail/` | `/outlook/` | `/imap/` |
|
||||
| Message detail | path param `/{id}` | query param `?id={id}` | path param `/{uid}` (the list's `imap:<uid>` or a bare numeric UID) + `?folder=` |
|
||||
| Message detail | path param `/{id}` | query param `?id={id}` | path param `/{id}` (pass the list's `id` back as is; `folder` optional) |
|
||||
| Search (local cache) | supported | supported | supported |
|
||||
| Remote fetch paging | `pageToken` (no `offset`) | `skip` / `offset` | `offset` |
|
||||
| Drafts | supported (incl. list/detail) | supported (create/update/delete/send) | supported (create/update/delete/send) |
|
||||
@@ -195,19 +196,19 @@ In the following, `{p}` denotes the provider (`gmail`, `outlook`, `imap`); `{ema
|
||||
|------|------|------|------|
|
||||
| Query local cache | GET | `/{p}/messages` | query string: `email, offset, limit, folder`; returns `{messages, total, offset, limit}` |
|
||||
| Remote sync | POST | `/{p}/messages/fetch?email=` | `email` must be in the query string; body (or query string): `folder`, `limit` (1–1000, default 20); paging: IMAP `offset`, Outlook `skip` / `offset`, Gmail `pageToken` (Gmail returns 400 for `offset`); returns `messages` plus paging info `pagination` |
|
||||
| Manually trigger sync | POST | `/sync?provider=&email=` | parameters in the query string; **gmail / outlook only** — IMAP returns 400, use `messages/fetch` instead |
|
||||
| Manually trigger sync | POST | `/sync?provider=&email=` | parameters in the query string; `provider` is `gmail`, `outlook`, or `imap`. Runs one round of the same sync as automatic sync right away: for IMAP it pulls only new INBOX mail; use `messages/fetch` to backfill older mail or other folders |
|
||||
|
||||
**IMAP remote sync is slow**: every message is downloaded and parsed in full (about 0.65 messages/second measured), so keep each batch's `limit` at 100 or less and page through older mail with `offset` (how many of the newest messages to skip).
|
||||
**IMAP remote sync**: `messages/fetch` generally fetches only each message's header fields, structure, and a length-capped body, without downloading attachments (an attachment is fetched by its part when you download it). When the body was truncated, or the HTML references inline images (`cid:`) that were not embedded, the entry carries `"bodyPartial": true`; when you need the full body, get the message detail (`GET /imap/messages/{id}`), which fetches the full message from the server and completes the local cache, and still returns the summary with `bodyPartial` set to `true` if it cannot. The attachment `size` in backfilled entries is an estimate; the download receipt gives the exact byte count. A batch can still take a long time, so keep each batch's `limit` at 100 or less and page through older mail with `offset` (how many of the newest messages to skip).
|
||||
|
||||
**folder values**:
|
||||
- Local cache list and search: `inbox, sent, drafts, trash, spam, archive, other`, case-insensitive; server names (e.g. `INBOX`, `Sent Messages`) are accepted too. IMAP custom folders are all stored locally as `other`.
|
||||
- Remote sync: generic names (`inbox`, `sent`, ...) are mapped automatically to the actual IMAP folder, the Outlook folder, or the Gmail label; for IMAP you may also pass a `path` returned by `GET /imap/folders`. Gmail has no label for `archive`, so it fetches without filtering.
|
||||
- **IMAP single-message operations** (detail on a cache miss, mark as read/unread, delete, mark as junk / not junk, reply, attachment download) pass `folder` verbatim to the IMAP server, so it must be a real `path` returned by `GET /imap/folders` (e.g. `INBOX`, `Sent Messages`); it defaults to `INBOX` when omitted. The `folder` field of a list item is a normalized value (e.g. `sent`) and cannot be used as an IMAP folder name directly.
|
||||
- **IMAP single-message operations** (detail, mark as read/unread, delete, mark as junk / not junk, reply, attachment download) do not need `folder`: the folder on the server is determined by the `id`; an `id` with a folder key (`imap:<mailboxKey>:<uid>`) uses the `imapFolder` recorded in the local cache. `folder` acts as a cross-check only for an `id` with a folder key; pass the entry's `imapFolder`, and a mismatch returns 409 `imap_folder_mismatch`. The `folder` field of a list item is a normalized value (custom folders are `other`) and cannot be used for the cross-check. For INBOX messages (`imap:<uid>`), do not pass `folder`, or pass only `INBOX`. See section 3.
|
||||
|
||||
**Response format** (message list item):
|
||||
```json
|
||||
{
|
||||
"id": "messageID (imap:<uid> for IMAP)", "provider": "gmail",
|
||||
"id": "messageID (for IMAP see below)", "provider": "gmail",
|
||||
"subject": "subject",
|
||||
"from": {"name": "...", "address": "..."},
|
||||
"toRecipients": [{"name": "...", "address": "..."}],
|
||||
@@ -218,29 +219,34 @@ In the following, `{p}` denotes the provider (`gmail`, `outlook`, `imap`); `{ema
|
||||
}
|
||||
```
|
||||
|
||||
`labelIds` appears only on Gmail messages and `categories` only on Outlook messages.
|
||||
`labelIds` appears only on Gmail messages and `categories` only on Outlook messages. An IMAP message `id` includes its folder: `imap:<uid>` for INBOX and `imap:<mailboxKey>:<uid>` for other folders (`mailboxKey` is 16 hex digits derived from the server folder name); IMAP entries also carry `imapFolder` (the folder name on the server) and `imapUidValidity`, and backfilled entries may carry `bodyPartial`.
|
||||
|
||||
### 3. Single Message Operations
|
||||
|
||||
| Operation | Gmail | Outlook | IMAP |
|
||||
|------|-------|---------|------|
|
||||
| Get detail | GET `/{id}?email=` | GET `/message?id={id}&email=` | GET `/{uid}?email=&folder=` |
|
||||
| Mark as read | POST `/{id}/read?email=` | POST `/message/read?id={id}&email=` | POST `/{uid}/read?email=&folder=` |
|
||||
| Mark as unread | POST `/{id}/unread?email=` | POST `/message/unread?id={id}&email=` | POST `/{uid}/unread?email=&folder=` |
|
||||
| Delete | DELETE `/{id}?email=` | DELETE `/message?id={id}&email=` | DELETE `/{uid}?email=&folder=` |
|
||||
| Mark as junk | POST `/{id}/spam?email=` | POST `/message/spam?id={id}&email=` | POST `/{uid}/spam?email=&folder=` |
|
||||
| Not junk | POST `/{id}/not-spam?email=` | POST `/message/not-spam?id={id}&email=` | POST `/{uid}/not-spam?email=&folder=` |
|
||||
| Get detail | GET `/{id}?email=` | GET `/message?id={id}&email=` | GET `/{id}?email=` |
|
||||
| Mark as read | POST `/{id}/read?email=` | POST `/message/read?id={id}&email=` | POST `/{id}/read?email=` |
|
||||
| Mark as unread | POST `/{id}/unread?email=` | POST `/message/unread?id={id}&email=` | POST `/{id}/unread?email=` |
|
||||
| Delete | DELETE `/{id}?email=` | DELETE `/message?id={id}&email=` | DELETE `/{id}?email=` |
|
||||
| Mark as junk | POST `/{id}/spam?email=` | POST `/message/spam?id={id}&email=` | POST `/{id}/spam?email=` |
|
||||
| Not junk | POST `/{id}/not-spam?email=` | POST `/message/not-spam?id={id}&email=` | POST `/{id}/not-spam?email=` |
|
||||
|
||||
> All paths are prefixed with `/api/{provider}/messages` (Gmail/IMAP) or `/api/outlook/` (Outlook's special routing). For IMAP, `{uid}` may be the list's `id` (`imap:<uid>`) as is; see section 2 for `folder`, which may be omitted for INBOX.
|
||||
> All paths are prefixed with `/api/{provider}/messages` (Gmail/IMAP) or `/api/outlook/` (Outlook's special routing). For IMAP, pass the list's `id` back as `{id}` unchanged; do not build it yourself or strip its prefix. A bare numeric UID is also accepted and refers to a message in INBOX when no `folder` is given. INBOX `imap:<uid>` ids and bare UIDs do not cross-check `folder`: passing another folder redirects the call to the message with the same UID in that folder, and if that message happens to be in the local cache, a mutating operation acts on it. So for INBOX messages, do not pass `folder`, or pass only `INBOX`.
|
||||
|
||||
**Locating IMAP messages and rejections**: an `id` with a folder key is located by the `imapFolder` recorded in the local cache; `folder` may be omitted and, when passed, is only a cross-check (pass the entry's `imapFolder`). In the following cases the requested operation is not performed; do not retry it unchanged:
|
||||
- Mark as read/unread, delete, mark as junk / not junk, and reply only accept messages that are in the local cache; otherwise they return 404 `imap_message_not_cached`. First fetch the folder with `messages/fetch` or get the message detail, then use the `id` from that result.
|
||||
- Get detail and attachment download are not restricted this way, and getting the detail records the message in the local cache; but for an `id` with a folder key that is not cached locally, pass the entry's `imapFolder` as `folder`, otherwise they also return 404 `imap_message_not_cached`.
|
||||
- The `folder` passed does not match the folder of an `id` with a folder key: 409 `imap_folder_mismatch`. Omit `folder`, or pass the entry's `imapFolder` (the `folder` field of a list item cannot be used for the cross-check).
|
||||
- The server rebuilt the folder (UIDVALIDITY changed), so this `id` no longer refers to the original message: 409 `imap_uidvalidity_changed`. Run `messages/fetch` on that folder again and use the new `id`.
|
||||
|
||||
**Mark as junk / Not junk**: moves the message into the junk folder, or out of it back to the inbox. The server and the local cache change together, and the response is `result: {id, folder}`.
|
||||
- Gmail swaps the `SPAM` / `INBOX` labels and keeps the `id`; Outlook and IMAP assign a new `id` after the move, so use the returned `id` for any later operation on this message. When the IMAP server lacks UIDPLUS the `id` is `null`; run `messages/fetch` on the destination folder before using the message again.
|
||||
- If the IMAP account has no junk folder on the server, the call returns 409 `imap_spam_folder_not_found`. Tell the user as is; do not retry and do not substitute another folder.
|
||||
- A message already in the destination folder returns success without moving. A message moved back to the inbox does not trigger mail rules or a new-mail notification.
|
||||
- Not junk handles one message at a time; do not move a batch back to the inbox together. Mark as junk may be called once per message.
|
||||
- Requires client 10.0.178 or later; older clients return 404, in which case ask the user to upgrade the client.
|
||||
|
||||
**Extra fields in message detail**: `body: {content, contentType}`, `ccRecipients`, `attachments: [{id, filename, contentType, size}]`. For IMAP, an attachment's `id` is its index within the message as a string (`"0"`, `"1"`, ...).
|
||||
**Extra fields in message detail**: `body: {content, contentType}`, `ccRecipients`, `attachments: [{id, filename, contentType, size}]`. For IMAP, use an attachment's `id` as is: entries written by `messages/fetch` and by get detail generally use `part:<IMAP part number>` (e.g. `part:2`); new mail pulled by automatic polling or `POST /sync`, and entries cached earlier, may use an index string (`"0"`, `"1"`, ...). Both work for attachment download, and any other form returns 400.
|
||||
|
||||
### 4. Send and Reply
|
||||
|
||||
@@ -266,7 +272,7 @@ Each `attachments` item is `{filename, content (base64), contentType}`. Gmail re
|
||||
|----------|------|------|
|
||||
| Gmail | POST `/gmail/reply` | `{email, messageId, body, contentType}` |
|
||||
| Outlook | POST `/outlook/message/reply?id={id}&email=` | `{body, contentType}` |
|
||||
| IMAP | POST `/imap/reply` | `{email, uid, folder, body, contentType}` (`uid` may be `imap:<uid>`; `folder` defaults to `INBOX`) |
|
||||
| IMAP | POST `/imap/reply` | `{email, uid, body, contentType}` (`uid` is the list's `id` as is; `folder` may be omitted and is a cross-check only for an `id` with a folder key; the original message must be in the local cache, see section 3) |
|
||||
|
||||
### 5. Search (All Three Providers)
|
||||
|
||||
@@ -286,7 +292,7 @@ Search reads only the **local cache** and never contacts the mail server; if not
|
||||
|
||||
Parameter names must match exactly; unknown parameters (e.g. `query`, `hasAttachments`) return 400. Returns `{messages, total, offset, limit}`.
|
||||
|
||||
To run a full-text search on the Gmail server by body or sender, use the `query` parameter of `POST /gmail/messages/fetch?email=` instead: it is passed straight to the Gmail API, supports Gmail search syntax (such as `from:` and `has:attachment`), and the results are also written to the local cache. Outlook and IMAP have no equivalent remote search parameter. If an older client returns 404 for `/outlook/search` or `/imap/search`, page through `GET /{p}/messages` and filter the results yourself.
|
||||
To run a full-text search on the Gmail server by body or sender, use the `query` parameter of `POST /gmail/messages/fetch?email=` instead: it is passed straight to the Gmail API, supports Gmail search syntax (such as `from:` and `has:attachment`), and the results are also written to the local cache. Outlook and IMAP have no equivalent remote search parameter.
|
||||
|
||||
### 6. Attachment Download
|
||||
|
||||
@@ -297,7 +303,7 @@ To run a full-text search on the Gmail server by body or sender, use the `query`
|
||||
| IMAP | POST | `/imap/attachment` | `{email, messageId, attachmentId, folder?}` |
|
||||
|
||||
- `attachmentId` comes from `attachments[].id` in the message detail; call the detail endpoint first to get the attachment list.
|
||||
- IMAP: use the list's `id` (e.g. `imap:12345`) as `messageId`; `attachmentId` is the attachment index as a string (the first attachment is `"0"`); `folder` is the real folder path on the server and may be omitted for INBOX.
|
||||
- IMAP: use the list's `id` as is (e.g. `imap:12345`) as `messageId`; use `attachments[].id` as is as `attachmentId` (e.g. `part:2`, or an index such as `"0"`, see section 3); `folder` may be omitted; when an `id` with a folder key is not cached locally, pass the entry's `imapFolder` (see section 3).
|
||||
- **Always pass `save_to` to `MailOperations` when downloading an attachment** (the target file path): the tool decodes the base64 in process and writes the file, returning only the absolute path, byte count, and SHA-256; without `save_to` the tool refuses to return the attachment response. The target path must be inside a writable working directory.
|
||||
- The endpoint's raw response is `result: {data: <base64>, size}`; the tool refuses to parse responses larger than about 32 MB — in that case follow the streaming-to-disk method given in the tool's error message, or ask the user to export the attachment manually from the Emails page.
|
||||
|
||||
@@ -307,7 +313,7 @@ Example (IMAP):
|
||||
{
|
||||
"path": "/api/imap/attachment",
|
||||
"method": "POST",
|
||||
"body": {"email": "me@example.com", "messageId": "imap:12345", "attachmentId": "0"},
|
||||
"body": {"email": "me@example.com", "messageId": "imap:12345", "attachmentId": "part:2"},
|
||||
"save_to": "./attachments/report.pdf"
|
||||
}
|
||||
```
|
||||
@@ -443,7 +449,7 @@ The regex operator is `matches_regex` (`regex` is treated as an unknown operator
|
||||
|
||||
| Operation | Method | Endpoint |
|
||||
|------|------|------|
|
||||
| IMAP folder list | GET | `/imap/folders?email=` — returns `[{name, path, specialUse, flags}]`; use `path` as the `folder` of IMAP single-message operations |
|
||||
| IMAP folder list | GET | `/imap/folders?email=` — returns `[{name, path, specialUse, flags}]`; `path` can be passed directly as the `folder` of `messages/fetch` |
|
||||
| Outlook folder list | GET | `/outlook/folders?email=` |
|
||||
|
||||
> Gmail folders are fixed: inbox, sent, drafts, trash, spam, archive.
|
||||
@@ -455,8 +461,8 @@ The regex operator is `matches_regex` (`regex` is treated as an unknown operator
|
||||
The email system uses **local cache + periodic polling**:
|
||||
|
||||
- **Write operations** (send, mark, delete, Gmail native labels, Outlook categories): the provider endpoints update local and remote simultaneously, no delay; the unified label interface (section 8) and the mark, delete, and label actions of auto-rules change local data only
|
||||
- **Read operations** (query, search): return the local cache; may be delayed (default 30-second polling)
|
||||
- **Remote changes** (the user operates from the official web UI): Gmail / Outlook wait for the next polling cycle to sync; IMAP polling only pulls new INBOX mail, other folders require an explicit `messages/fetch`, and read or delete changes made on the server to already-cached messages are not written back locally
|
||||
- **Read operations** (query, search): return the local cache and may be delayed. The automatic sync interval is the account setting `syncInterval`, in minutes (5 for new accounts; `0` turns automatic sync off, other valid values are 1–1440, and any other value returns 400 when updating the settings); call `POST /sync` to sync right away
|
||||
- **Remote changes** (the user operates from the official web UI): Gmail / Outlook wait for the next polling cycle or a `POST /sync`; for IMAP, both polling and `POST /sync` only pull new INBOX mail, other folders require an explicit `messages/fetch`, and read or delete changes made on the server to already-cached messages are not written back locally
|
||||
|
||||
**Storage path**: `${DESIRECORE_ROOT}/mail/{provider}/{email}/` (meta.json, index.json, messages/)
|
||||
|
||||
@@ -469,7 +475,26 @@ The email system uses **local cache + periodic polling**:
|
||||
| 400 | parameter error (including a parameter in the wrong place, e.g. a query-string parameter put in the body) | check parameter names and locations against `msg` |
|
||||
| 401 | Gmail/Outlook authorization expired, IMAP account not configured, or missing Mail Service capability | **handle per Rule 1**; do not try other channels |
|
||||
| 404 | resource not found | sync first and retry (Rule 3) |
|
||||
| 404 | IMAP message not in the local cache (`error: imap_message_not_cached`) | fetch the folder with `messages/fetch` or get the detail first, then use the `id` from that result (see section 3) |
|
||||
| 409 | IMAP account SMTP not verified (`error: smtp_unverified`) | guide the user to re-verify SMTP (`POST /imap/accounts/verify-smtp`) |
|
||||
| 409 | the `folder` passed does not match the folder of an IMAP `id` with a folder key (`error: imap_folder_mismatch`), or the server rebuilt the folder (`error: imap_uidvalidity_changed`) | the operation was not performed; do not retry it unchanged; per section 3, omit `folder`, or fetch again and use the new `id` |
|
||||
| 500 | internal error (common IMAP cause: `folder` is not a folder that exists on the server) | check `folder` first; if it still fails, tell the user to retry later |
|
||||
|
||||
**IMAP note**: domestic Chinese mailboxes (QQ, 163) require an "app password" instead of the login password. Use `/imap/test` to validate the configuration in advance and check `result.imap.success` and `result.smtp.success` in the response.
|
||||
|
||||
### When No Complete Response Arrives
|
||||
|
||||
`MailOperations` waits up to 20 minutes for the Mail Service to respond. When no complete response arrives, the tool's message depends on how far the request got: failures while waiting for the response start with `Mail Service 请求失败:`, and failures while reading the body after a status code arrived start with `HTTP <status code>`. The messages are in Chinese; match them by these key phrases:
|
||||
|
||||
| Key phrase in the message | Meaning | Handling |
|
||||
|----------------|------|------|
|
||||
| `等待 Mail Service 响应超过 20 分钟` | timed out waiting; the mail service may still be processing the request | do not retry right away with the same parameters; reduce the batch (e.g. the `limit` of `messages/fetch`) and request again; for write requests, verify the result first |
|
||||
| `请求已被取消(运行中止)` | the run was aborted; the request may already have been delivered | for write requests, verify the result first (scope below) |
|
||||
| `请求未发出:运行已中止` | the run was aborted and the request was not sent | nothing to verify |
|
||||
| `无法连接 Mail Service` | the request was not delivered; the mail service may not have started yet or may be restarting | retry later |
|
||||
| `与 Mail Service 的连接在请求途中断开` | the server may already have processed the request | for write requests, verify the result first (scope below); read-only requests can be retried directly |
|
||||
| `Mail Service 已返回成功响应,但正文没有读完` | the request has already been processed | do not redo write requests; the result of `messages/fetch` is already in the local cache, so page through it with `GET /{p}/messages` instead of fetching again; other read-only requests can be sent again |
|
||||
| `Mail Service 返回了失败状态码,正文没有读完` | go by the status code; the request did not succeed | handle it by the status code |
|
||||
| `请求未能发出(不是网络问题)`, `GET 请求不能带 body` | the request parameters do not match | check `path`, `method`, and `body`; a request with a `body` also needs `method: "POST"` or similar |
|
||||
|
||||
The Mail Service does not stop processing because the client disconnected: after a timeout or abort, the server may still complete the request (`messages/fetch` still writes the local cache when it finishes). Therefore, when the request may have been delivered (wait timeout, run aborted, connection broken mid-request, body not fully read), **verify the result of any request other than GET, `messages/fetch`, and attachment download before deciding whether to retry** (for example, check the sent folder, fetch the folder again, get the detail, or list the drafts, rules, or labels). Requests whose replay can repeat a side effect include: send, reply, delete, and move (including mark as junk / not junk); creating a draft and sending a draft (saving an IMAP draft is not idempotent, so a replay leaves an extra draft; sending a draft sends another message); `/rules/execute` (`auto_reply` sends another reply and `agent_handle` triggers the Agent again); and creating a rule, label, or category (a replay creates another one). GET, `messages/fetch`, and attachment download can be retried (except after a wait timeout: reduce the batch first as described in the table).
|
||||
Reference in new issue
Block a user