@eduwork/dsh-mail 0.1.0-alpha.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.
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ [简体中文](CHANGELOG.md) | **English**
4
+
5
+ ## Unreleased
6
+
7
+ ## 0.1.0-alpha.5 - 2026-09-05
8
+
9
+ - Move the npm identity to `@eduwork/dsh-mail`; update installation/module paths and Client registration together.
10
+ - Keep the Host export name, row id, settings namespace and security scope using `dsh-mail-assistant`, as well as `DSH_MAIL_ASSISTANT_PASSWORD` and `.dsh-mail-assistant/attachments`. The Client ModuleLoader uses the new package name.
11
+ - Keep the previous unscoped version installable and document Profile migration.
12
+
13
+ - Removed build-time transitive packages that were mistakenly listed as production dependencies; the Host runtime remains fully embedded in the published artifact.
14
+ - Limited Dependabot automation to minor and patch updates for development dependencies; major updates, the DSH compatibility baseline, and `tsdown` minor updates now require manual review.
15
+ - Added a publish-manifest assertion to the Host bundle check so external runtime dependencies cannot be reintroduced silently.
16
+
17
+ ## 0.1.0-alpha.4 - 2026-09-01
18
+
19
+ - First public npm preview.
20
+ - Replaced repository placeholders and unpublished-install text with the public repository and exact npm installation path.
21
+ - Added GitHub CI, CodeQL, Dependabot, issue/PR templates, governance, and a public-release checklist.
22
+ - Added dependency-license, bilingual-documentation, link, secret, and npm-package-content checks.
23
+ - Kept IMAP/SMTP runtime libraries inside the Host bundle so consumers do not install a duplicate runtime dependency tree.
24
+ - Revalidated real filesystem paths before local attachment writes to reject symlink or junction workspace escapes.
25
+
26
+ ## 0.1.0-alpha.3 - 2026-08-31
27
+
28
+ - Updated the reviewed baseline to DeepSeek Harness `0.1.2-alpha.2` and `@deepseek-ai/cordis` `4.0.2`.
29
+ - Routed `mail_send` through DSH permission presets: ordinary sessions ask per call; Full Access skips prompts only after sending is independently enabled.
30
+ - Added read-only `mail_list_folders` for archive and provider-specific folder discovery.
31
+ - Added stable cursor pagination, newest/oldest ordering, and `matched`, `returned`, `hasMore`, and `nextCursor` fields to `mail_find`.
32
+ - Added bounded IMAP error normalization without exposing remote diagnostics.
33
+
34
+ ## 0.1.0-alpha.2 - 2026-08-30
35
+
36
+ - Reworked settings around mailbox account, servers, advanced options, and Agent access.
37
+ - Preserved the alpha.1 settings schema and credential reference.
38
+
39
+ ## 0.1.0-alpha.1 - 2026-08-29
40
+
41
+ - Initial internal preview.
42
+ - Added `mail_find`, `mail_read`, `mail_get_attachment`, and `mail_send`.
43
+ - Established read-only IMAP, DSH Credential storage, independent read/send controls, workspace attachment boundaries, and untrusted-mail fencing.
package/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # 变更日志
2
+
3
+ **简体中文** | [English](CHANGELOG.en.md)
4
+
5
+ ## 未发布
6
+
7
+ ## 0.1.0-alpha.5 - 2026-09-05
8
+
9
+ - npm 包身份改为 `@eduwork/dsh-mail`,同步安装路径、组合模块路径与客户端注册。
10
+ - 保留 Host 导出名、插件行 id、settings namespace 和安全作用域中的 `dsh-mail-assistant`,保留 `DSH_MAIL_ASSISTANT_PASSWORD` 与 `.dsh-mail-assistant/attachments`;客户端 ModuleLoader 使用新包名。
11
+ - 旧无作用域版本保留可安装,并提供 Profile 迁移说明。
12
+
13
+ - 移除误列为生产依赖的打包时传递依赖;Host 运行库继续完整内嵌在发布产物中。
14
+ - Dependabot 只自动提交开发依赖的 minor/patch 更新;major、DSH 兼容基线和 `tsdown` minor 更新改为人工评估。
15
+ - Host bundle 检查新增发布清单约束,防止重新引入外部运行时依赖。
16
+
17
+ ## 0.1.0-alpha.4 - 2026-09-01
18
+
19
+ - 首个公开 npm 预览版。
20
+ - 仓库元数据、安装入口、默认中文与英文镜像文档更新为公开地址。
21
+ - 增加 GitHub CI、CodeQL、Dependabot、Issue/PR 模板、治理规则和公开发布检查表。
22
+ - 新增依赖许可证、文档镜像、链接、敏感信息和 npm 包内容检查。
23
+ - Host bundle 内嵌 IMAP/SMTP 运行库,发布包不再要求终端用户重复安装这些依赖。
24
+ - 下载附件在本地写入前重新验证真实路径,拒绝由符号链接或目录联接造成的工作区逃逸。
25
+
26
+ ## 0.1.0-alpha.3 - 2026-08-31
27
+
28
+ - 兼容基线更新到 DeepSeek Harness `0.1.2-alpha.2` 和 `@deepseek-ai/cordis` `4.0.2`。
29
+ - `mail_send` 接入 DSH 原生权限预设:普通权限逐次确认,Full Access 在发信能力已单独开启时免确认。
30
+ - 增加只读 `mail_list_folders`,允许发现归档目录和服务商自定义目录。
31
+ - 增加稳定的 `mail_find` 游标分页、正序/倒序以及 `matched`、`returned`、`hasMore`、`nextCursor`。
32
+ - 增加有限且不泄露服务端诊断的 IMAP 错误归一化。
33
+
34
+ ## 0.1.0-alpha.2 - 2026-08-30
35
+
36
+ - 设置流程调整为邮箱账号、服务器、高级选项和 Agent 权限四部分。
37
+ - 保持 alpha.1 的设置 Schema 和 Credential Ref 兼容。
38
+
39
+ ## 0.1.0-alpha.1 - 2026-08-29
40
+
41
+ - 首个内部预览版。
42
+ - 提供 `mail_find`、`mail_read`、`mail_get_attachment` 和 `mail_send`。
43
+ - 默认只读 IMAP、DSH Credential 存储、独立读/发开关、工作区附件限制和邮件不可信数据标记。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-mail-assistant contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,95 @@
1
+ # dsh-mail-assistant
2
+
3
+ > npm package: `@eduwork/dsh-mail@0.1.0-alpha.5`. The previous unscoped package remains available during migration. See [migration and data compatibility](docs/EDUWORK-MIGRATION.en.md).
4
+
5
+ [简体中文](README.md) | **English**
6
+
7
+ A security-focused mail assistant plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness). It reads through standard IMAP and sends through standard SMTP, while deliberately refusing to become another full mail client.
8
+
9
+ Current version: `0.1.0-alpha.5`. This is a public alpha preview for isolated environments and dedicated test mailboxes. Complete your own security and compliance review before connecting a critical mailbox.
10
+
11
+ ## Scope
12
+
13
+ The plugin exposes exactly five agent tools:
14
+
15
+ | Tool | Capability | Hard boundary |
16
+ | --- | --- | --- |
17
+ | `mail_list_folders` | List server mailbox folders | Read-only; returns exact paths for archive/history searches |
18
+ | `mail_find` | Page through mail by metadata and date | At most 50 rows per page; opaque continuation cursor; no body search |
19
+ | `mail_read` | Read one plain-text message and attachment metadata | Read-only IMAP; never marks mail as read |
20
+ | `mail_get_attachment` | Save one attachment into the session workspace | Size cap, random name, no overwrite, workspace only |
21
+ | `mail_send` | Send or reply with plain text and workspace attachments | Ordinary permissions ask each time; Full Access skips prompts; sending must still be enabled separately |
22
+
23
+ It does not delete, move, archive, label, change flags, manage contacts or rules, poll in the background, wake agents, auto-reply, compose HTML, or provide a mailbox UI.
24
+
25
+ ## Secure defaults
26
+
27
+ - Reading and sending are both disabled after installation. Startup performs no mail network access.
28
+ - Passwords and app passwords live only behind the DSH credential reference `DSH_MAIL_ASSISTANT_PASSWORD`; they never enter `settings.yaml` or a browser read response.
29
+ - IMAP always uses a read-only mailbox lock and never calls `STORE`, `COPY`, `MOVE`, or `EXPUNGE`.
30
+ - Subjects, bodies, addresses, and filenames are untrusted external data. They cannot authorize a send, request a secret, or change system policy.
31
+ - Historical searches expose `hasMore` and `nextCursor`; complete-coverage tasks must continue until `hasMore=false` instead of treating the first page as the entire mailbox.
32
+ - Sending is plain-text only. Recipient headers reject newline injection, and attachments must be regular files inside the current session workspace.
33
+ - Only implicit TLS and STARTTLS are supported; certificate validation cannot be disabled.
34
+ - A connection loss during SMTP DATA returns `unknown` and tells the agent not to retry automatically.
35
+
36
+ See the complete [security model](docs/security-model.en.md).
37
+
38
+ ## Install
39
+
40
+ Prerequisites: Node.js 22+, DSH `0.1.2-alpha.2`, and a Profile with the official Settings, Credentials, Tools, Filesystem, Permission Presets, Approval, and Web Client capabilities.
41
+
42
+ For normal use, pin the reviewed exact npm version:
43
+
44
+ ```bash
45
+ dsh plugin --profile web add @eduwork/dsh-mail@0.1.0-alpha.5
46
+ ```
47
+
48
+ Use a source checkout for auditing, development, or unpublished changes:
49
+
50
+ ```bash
51
+ git clone https://github.com/freedomkk-qfeng/dsh-mail-assistant.git
52
+ cd dsh-mail-assistant
53
+ npm ci
54
+ npm run check
55
+ dsh plugin --profile web add .
56
+ ```
57
+
58
+ From the parent directory:
59
+
60
+ ```bash
61
+ dsh plugin --profile web add ./dsh-mail-assistant
62
+ ```
63
+
64
+ DSH links the checkout; it does not scan the invoking directory. Keep a source checkout in place. Use `@eduwork/dsh-mail@alpha` only when intentionally following prerelease updates.
65
+
66
+ ## Configure and verify
67
+
68
+ Open **Settings → Mail assistant**. Enter the email address, app password, and optional sender display name first; choose a common provider or manually configure IMAP/SMTP; use Advanced settings only when needed; then enable agent reading and sending independently. After saving, ask the agent to find recent mail. The plugin intentionally does not log in during startup or save.
69
+
70
+ The v0.1 authentication profile is username plus password/app password over standard IMAP/SMTP. Providers that require OAuth2 are outside the current scope.
71
+
72
+ ## DSH composition
73
+
74
+ The plugin uses official DSH seams: `ctx.credentials`, `ctx.settings`, `settings.section`, `ctx.tools`, `ctx.permissionPresets`, `tools/pre-execute`, `ctx.fs`, and the Client Loader. Ordinary permissions route sends through the composed Approval service; Full Access proceeds without a prompt. It does not fork the upstream Web client.
75
+
76
+ DSH `0.1.2-alpha.2` has bounded binary reads but no binary-write filesystem seam. `mail_get_attachment` therefore uses `ctx.fs` to resolve and fence the local destination before an exclusive local write. A remote/non-local FS Provider may not support that one tool. See [compatibility](docs/compatibility.en.md).
77
+
78
+ ## Documentation
79
+
80
+ - [Getting started](docs/getting-started.en.md)
81
+ - [Architecture](docs/architecture.en.md)
82
+ - [Tool contract](docs/tool-contract.en.md)
83
+ - [Security model](docs/security-model.en.md)
84
+ - [Compatibility](docs/compatibility.en.md)
85
+ - [Public release checklist](docs/release-checklist.en.md)
86
+ - [Contributing](CONTRIBUTING.en.md)
87
+ - [Governance](GOVERNANCE.en.md)
88
+ - [Support](SUPPORT.en.md)
89
+ - [Security reporting](SECURITY.en.md)
90
+
91
+ The integration approach was informed by the MIT-licensed community project [`STARDUSTLC666/dsh-email`](https://github.com/STARDUSTLC666/dsh-email), with a redesigned permission, credential, read-only, workspace, untrusted-content, and approval boundary. See [third-party notices](THIRD_PARTY_NOTICES.en.md).
92
+
93
+ ## License
94
+
95
+ [MIT](LICENSE)
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # dsh-mail-assistant
2
+
3
+ > npm 包:`@eduwork/dsh-mail@0.1.0-alpha.5`。旧无作用域包保留供迁移;安装切换与数据兼容见 [迁移说明](docs/EDUWORK-MIGRATION.md)。
4
+
5
+ **简体中文** | [English](README.en.md)
6
+
7
+ 面向 [DeepSeek Harness(DSH)](https://github.com/deepseek-ai/deepseek-harness) 的安全型邮件助手插件。它通过标准 IMAP 读取邮件、通过标准 SMTP 发送纯文本邮件,但刻意不成为另一个邮箱客户端。
8
+
9
+ 当前版本:`0.1.0-alpha.5`。这是公开 alpha 预览版,适合隔离环境和专用测试邮箱;连接重要邮箱前仍应完成组织自己的安全与合规审查。
10
+
11
+ ## 定位与边界
12
+
13
+ 插件只提供五个 Agent 工具:
14
+
15
+ | 工具 | 能力 | 关键约束 |
16
+ | --- | --- | --- |
17
+ | `mail_list_folders` | 列出服务器上的邮箱目录 | 只读;返回精确路径,便于查找归档和历史邮件 |
18
+ | `mail_find` | 按主题、发件人、收件人与日期分页查找邮件 | 每页最多 50 条;用不透明游标持续拉取,不搜索或执行正文指令 |
19
+ | `mail_read` | 读取一封邮件的纯文本正文和附件元数据 | IMAP `EXAMINE`/只读锁;不修改已读状态 |
20
+ | `mail_get_attachment` | 把一个附件保存到会话工作区 | 大小上限、随机文件名、不覆盖、仅工作区内 |
21
+ | `mail_send` | 发送或回复纯文本邮件,可附加工作区文件 | 普通权限逐次确认;Full Access 免确认;仍需单独开启发信能力 |
22
+
23
+ 明确不做:删除、移动、归档、标签、已读/未读修改、联系人、规则、后台轮询、自动唤醒、自动回复、HTML 邮件创作和完整邮箱 UI。
24
+
25
+ ## 安全默认值
26
+
27
+ - 安装后读信和发信权限都为关闭;启动时不连接邮箱。
28
+ - 密码或客户端授权码只通过 DSH Credential Provider 保存,固定引用为 `DSH_MAIL_ASSISTANT_PASSWORD`;不会进入 `settings.yaml` 或浏览器回读。
29
+ - IMAP 始终使用只读 mailbox lock,不调用 `STORE`、`COPY`、`MOVE`、`EXPUNGE`。
30
+ - 邮件正文、标题、地址和附件名全部标记为不可信外部数据;它们不能授权发信、请求密钥或改变系统规则。
31
+ - 历史检索显式返回 `hasMore` 和 `nextCursor`;需要完整覆盖时,Agent 必须持续翻页至 `hasMore=false`,不能把首屏结果误当成整个邮箱。
32
+ - 发信只接受纯文本。收件地址拒绝换行注入,附件必须是当前会话工作区内的普通文件。
33
+ - 只支持隐式 TLS 或 STARTTLS,证书校验不可关闭。
34
+ - SMTP 在 DATA 阶段断线或超时时返回 `unknown`,并明确禁止 Agent 自动重试,避免重复发信。
35
+
36
+ 完整威胁模型见[安全模型](docs/security-model.md)。
37
+
38
+ ## 安装
39
+
40
+ 要求:Node.js 22+、DSH `0.1.2-alpha.2`,且所用 Profile 已包含 Settings、Credentials、Tools、Filesystem、Permission Presets、Approval 和 Web Client 官方能力。
41
+
42
+ 普通使用请固定经过复核的 npm 精确版本:
43
+
44
+ ```bash
45
+ dsh plugin --profile web add @eduwork/dsh-mail@0.1.0-alpha.5
46
+ ```
47
+
48
+ 需要审计、开发或验证尚未发布的改动时,再从源码安装:
49
+
50
+ ```bash
51
+ git clone https://github.com/freedomkk-qfeng/dsh-mail-assistant.git
52
+ cd dsh-mail-assistant
53
+ npm ci
54
+ npm run check
55
+ dsh plugin --profile web add .
56
+ ```
57
+
58
+ 从父目录也可以显式传入路径:
59
+
60
+ ```bash
61
+ dsh plugin --profile web add ./dsh-mail-assistant
62
+ ```
63
+
64
+ DSH 会链接本地 checkout,不会扫描当前目录;源码安装后请保留这个目录。明确希望持续跟随预发布更新时可以使用:
65
+
66
+ ```bash
67
+ dsh plugin --profile web add @eduwork/dsh-mail@alpha
68
+ ```
69
+
70
+ ## 配置与首次验证
71
+
72
+ 1. 打开 DSH 的“设置 → 邮件助手”。
73
+ 2. 填写邮箱地址、客户端授权码和可选的发件人显示名称。
74
+ 3. 选择邮箱服务商自动填写服务器;单位邮箱或自建邮箱使用“手动配置”。
75
+ 4. 登录用户名、收件箱目录和安全上限收纳在“高级设置”中,通常无需修改。
76
+ 5. 配置完成后,分别决定是否开放“允许 Agent 读信”和“允许 Agent 发信”。
77
+ 6. 保存后,在对话中让 Agent“查一下最近的邮件”。插件不会在保存时主动登录邮箱。
78
+
79
+ 无 UI 的部署可在 `cordis.patch.yml` 中覆盖非敏感配置,并把密码放入 DSH 凭据引用 `DSH_MAIL_ASSISTANT_PASSWORD`(本地 Credential Provider 也会按引用名读取同名环境变量)。不要把密码写进 Bundle 或 patch。
80
+
81
+ 不同服务商对普通密码、应用密码和 OAuth2 的支持不同。此插件的 v0.1 只实现用户名 + 密码/授权码的标准 IMAP/SMTP 登录;强制 OAuth2 的邮箱不在当前支持范围内。
82
+
83
+ ## 与 DSH 的组合关系
84
+
85
+ 插件复用 DSH 原生能力,而不是 fork 客户端:
86
+
87
+ - `ctx.credentials`:保存和逐次解析授权码;
88
+ - `ctx.settings` 与 `settings.section`:配置存储和设置页;
89
+ - `ctx.tools`:工具注册、单调拒绝 guard 和统一执行管线;
90
+ - `ctx.permissionPresets` 与原生 `tools/pre-execute`:普通权限逐次确认,Full Access 免确认;
91
+ - `ctx.fs`:发送附件的工作区解析、包含性检查和有界读取;
92
+ - DSH Client Loader:动态加载设置页,不修改官方 Web 应用。
93
+
94
+ 二进制写入尚未出现在 DSH `ctx.fs` seam 中,因此 `mail_get_attachment` 在本地 Host 文件系统上通过 `ctx.fs` 完成路径解析与包含性校验后,以独占写方式落盘。远程/非本地 FS Provider 可能不支持该工具;其他读信和发信能力不受影响。详见[兼容性](docs/compatibility.md)。
95
+
96
+ ## 文档
97
+
98
+ - [快速接入](docs/getting-started.md)
99
+ - [架构与扩展边界](docs/architecture.md)
100
+ - [工具契约](docs/tool-contract.md)
101
+ - [安全模型](docs/security-model.md)
102
+ - [兼容性与限制](docs/compatibility.md)
103
+ - [公开发布检查表](docs/release-checklist.md)
104
+ - [贡献指南](CONTRIBUTING.md)
105
+ - [治理规则](GOVERNANCE.md)
106
+ - [支持](SUPPORT.md)
107
+ - [安全问题报告](SECURITY.md)
108
+
109
+ ## 致谢与来源
110
+
111
+ 本项目参考了社区插件 [`STARDUSTLC666/dsh-email`](https://github.com/STARDUSTLC666/dsh-email) 对 ImapFlow、Nodemailer、MailParser 与 DSH 的组合经验,但重新划定了能力边界,并改用 DSH Credentials、默认关闭权限、只读 IMAP、工作区附件边界、邮件不可信标记和 DSH 原生权限预设。第三方依赖与许可证见[第三方组件声明](THIRD_PARTY_NOTICES.md)。
112
+
113
+ ## License
114
+
115
+ [MIT](LICENSE)
package/SECURITY.en.md ADDED
@@ -0,0 +1,9 @@
1
+ # Security policy
2
+
3
+ [简体中文](SECURITY.md) | **English**
4
+
5
+ `0.1.0-alpha.x` is a prerelease for local testing and should not be connected to a critical mailbox.
6
+
7
+ Do not open a public issue for authorization bypass, credential disclosure, workspace escape, unexpected message mutation, approval bypass, duplicate sending, or remote-code-execution risk. Use GitHub [Private Vulnerability Reporting](https://github.com/freedomkk-qfeng/dsh-mail-assistant/security/advisories/new).
8
+
9
+ Include only minimal reproduction steps, affected versions, and sanitized protocol facts. Never attach real app passwords, cookies, full messages, personal addresses, or unsanitized diagnostics. High-impact outbound, credential, and workspace-boundary issues receive priority, although no fixed prerelease SLA is promised.
package/SECURITY.md ADDED
@@ -0,0 +1,11 @@
1
+ # 安全政策
2
+
3
+ **简体中文** | [English](SECURITY.en.md)
4
+
5
+ 当前 `0.1.0-alpha.x` 为预发布版本,只接受本地测试,不建议直接接入重要邮箱。
6
+
7
+ 如发现授权绕过、凭据泄露、工作区逃逸、邮件状态意外修改、审批绕过、重复发信或远程代码执行风险,请不要公开 issue。请通过 GitHub [Private Vulnerability Reporting](https://github.com/freedomkk-qfeng/dsh-mail-assistant/security/advisories/new) 私密报告。
8
+
9
+ 报告请只包含最小复现步骤、受影响版本和脱敏后的协议事实。不要附上真实授权码、Cookie、完整邮件、个人地址或未清理的诊断包。
10
+
11
+ 我们会确认收到、评估影响、准备修复和回归测试,再协商披露时间。预发布阶段不承诺固定 SLA,但会优先处理可导致外发、凭据或工作区越界的问题。
@@ -0,0 +1,15 @@
1
+ # Third-party notices
2
+
3
+ [简体中文](THIRD_PARTY_NOTICES.md) | **English**
4
+
5
+ `dsh-mail-assistant` is distributed under the MIT License. Its build uses or embeds:
6
+
7
+ - [ImapFlow](https://github.com/postalsys/imapflow) — MIT License — IMAP client;
8
+ - [Nodemailer](https://github.com/nodemailer/nodemailer) — MIT-0 License — SMTP message submission;
9
+ - [MailParser](https://github.com/nodemailer/mailparser) — MIT License — MIME parsing;
10
+ - [Schemastery](https://github.com/shigma/schemastery) — MIT License — DSH-compatible settings schema;
11
+ - [React](https://github.com/facebook/react) — MIT License — DSH Client settings surface (peer dependency).
12
+
13
+ The project was informed by the MIT-licensed integration approach in [`STARDUSTLC666/dsh-email`](https://github.com/STARDUSTLC666/dsh-email), but redesigns the permission, credential, read-only IMAP, workspace, untrusted-content, and approval boundaries. No third-party project endorses this plugin.
14
+
15
+ Exact direct and transitive versions are recorded in `package-lock.json`. Review the lockfile, license-check output, and final npm tarball before every public release.
@@ -0,0 +1,15 @@
1
+ # 第三方组件声明
2
+
3
+ **简体中文** | [English](THIRD_PARTY_NOTICES.en.md)
4
+
5
+ `dsh-mail-assistant` 自身使用 MIT 许可证。构建产物包含或使用以下直接依赖:
6
+
7
+ - [ImapFlow](https://github.com/postalsys/imapflow) — MIT License — IMAP 客户端;
8
+ - [Nodemailer](https://github.com/nodemailer/nodemailer) — MIT-0 License — SMTP 邮件提交;
9
+ - [MailParser](https://github.com/nodemailer/mailparser) — MIT License — MIME 解析;
10
+ - [Schemastery](https://github.com/shigma/schemastery) — MIT License — DSH 兼容的设置 Schema;
11
+ - [React](https://github.com/facebook/react) — MIT License — DSH Client 设置界面(peer dependency)。
12
+
13
+ 项目参考了 MIT 许可的社区项目 [`STARDUSTLC666/dsh-email`](https://github.com/STARDUSTLC666/dsh-email) 在 ImapFlow、Nodemailer、MailParser 与 DSH 之间的组合思路,但重新设计了权限、凭据、只读 IMAP、工作区、邮件不可信内容和审批边界。没有任何第三方项目为本插件背书。
14
+
15
+ 直接和间接依赖的精确版本记录在 `package-lock.json`。每次公开发布前必须重新审查锁文件、许可证检查结果和最终 npm tarball。
@@ -0,0 +1,8 @@
1
+ # dsh-mail-assistant installs disabled and performs no network access at boot.
2
+ # Configure it in Settings -> Mail assistant, or override this row for headless
3
+ # deployments. Store the password/app password through the DSH credential ref
4
+ # DSH_MAIL_ASSISTANT_PASSWORD; never put it in this file.
5
+ - insert:
6
+ - id: dsh-mail-assistant
7
+ name: '@eduwork/dsh-mail'
8
+ config: {}
@@ -0,0 +1,23 @@
1
+ # eduwork npm scope migration
2
+
3
+ [简体中文](EDUWORK-MIGRATION.md) | **English**
4
+
5
+ Starting with this version, the npm package is `@eduwork/dsh-mail@0.1.0-alpha.5`, replacing `dsh-mail-assistant`. The npm `eduwork` organization exists. The GitHub repository and checkout directory remain `dsh-mail-assistant`. Consult the npm registry for current publication status.
6
+
7
+ ## Installation and migration
8
+
9
+ ```sh
10
+ dsh plugin --profile web add @eduwork/dsh-mail@0.1.0-alpha.5
11
+ ```
12
+
13
+ Back up an existing Profile's package.json and cordis.patch.yml, then update its dependency and dsh.profile.bundles entries. Update module name paths in custom patches too. Do not enable both package identities together; restart the Host after switching. These are separate npm packages, so updating the old package cannot migrate an installation automatically.
14
+
15
+ ## Data compatibility
16
+
17
+ Keep the Host export name, row id, settings namespace and security scope using `dsh-mail-assistant`, as well as `DSH_MAIL_ASSISTANT_PASSWORD` and `.dsh-mail-assistant/attachments`. The Client ModuleLoader uses the new package name.
18
+
19
+ Storage directories and user configuration content do not change. Product-managed Profiles migrate their owned dependencies through the product upgrader; community plugins remain unchanged.
20
+
21
+ ## Release scope
22
+
23
+ This is an alpha package-identity migration retaining the declared DSH peer baseline. Build, tests, documentation, license and tarball checks cover this change. It adds no claims of real institutional sign-in, real email delivery or production acceptance. Stable releases still require the complete deployment checks. Keep previous versions installable and add a migration notice only after the new package passes installation validation.
@@ -0,0 +1,23 @@
1
+ # eduwork npm 作用域迁移
2
+
3
+ **简体中文** | [English](EDUWORK-MIGRATION.en.md)
4
+
5
+ 从本版本起,npm 包使用 `@eduwork/dsh-mail@0.1.0-alpha.5`,替代旧的 `dsh-mail-assistant`。npm `eduwork` 组织已创建;GitHub 仓库和本地 checkout 目录继续使用 `dsh-mail-assistant`。包的当前发布状态以 npm registry 为准。
6
+
7
+ ## 安装与迁移
8
+
9
+ ```sh
10
+ dsh plugin --profile web add @eduwork/dsh-mail@0.1.0-alpha.5
11
+ ```
12
+
13
+ 已有 Profile 先备份 package.json 与 cordis.patch.yml,再更新依赖和 dsh.profile.bundles;手写 patch 的模块路径 name 也需切换。不要同时启用新旧两份插件,切换后重启 Host。旧版本和新作用域版本是不同 npm 包,旧包的更新不会自动迁移安装。
14
+
15
+ ## 数据兼容
16
+
17
+ 保留 Host 导出名、插件行 id、settings namespace 和安全作用域中的 `dsh-mail-assistant`,保留 `DSH_MAIL_ASSISTANT_PASSWORD` 与 `.dsh-mail-assistant/attachments`;客户端 ModuleLoader 使用新包名。
18
+
19
+ 本次迁移不修改存储目录或用户配置内容。产品管理的 Profile 由产品升级逻辑迁移其受管依赖;社区插件保持原状。
20
+
21
+ ## 发布范围
22
+
23
+ 此版本为 alpha 包身份迁移,沿用声明的 DSH peer 基线。构建、测试、文档、开源和 tarball 检查针对本次变更执行;不新增真实学校登录、真实邮件发送或生产部署验收结论。稳定发布仍须完成公开发布检查表中的完整部署验收。旧包保持可安装,新包安装验证通过后添加迁移提示,不撤回旧版本。
@@ -0,0 +1,68 @@
1
+ # Architecture and extension boundary
2
+
3
+ [简体中文](architecture.md) | **English**
4
+
5
+ ## Composition
6
+
7
+ `dsh-mail-assistant` is one Host + Client Bundle:
8
+
9
+ ```text
10
+ DSH Web Client
11
+ └─ settings.section: Mail assistant
12
+ ├─ remote.settings non-secret account/server settings
13
+ └─ remote.credentials write-only app password
14
+
15
+ DSH Host
16
+ ├─ ctx.settings live configuration
17
+ ├─ ctx.credentials resolve app password per operation
18
+ ├─ ctx.tools five tools, capability guard, execution pipeline
19
+ ├─ ctx.permissionPresets
20
+ │ ├─ ordinary preset one approval for mail_send
21
+ │ └─ Full Access no per-call prompt
22
+ ├─ ctx.fs workspace resolution and bounded binary reads
23
+ ├─ ImapFlow read-only IMAP
24
+ └─ Nodemailer controlled SMTP submission
25
+ ```
26
+
27
+ The plugin does not provide a Credential, Settings, Filesystem, Permission Preset, Approval, or Web Shell provider. The DSH Profile owns those services, allowing ordinary Web, local desktop, and other product compositions to reuse the same package.
28
+
29
+ ## Configuration and credentials
30
+
31
+ Non-secret fields live in the `dsh-mail-assistant` settings namespace. The app password uses the fixed credential reference `DSH_MAIL_ASSISTANT_PASSWORD`. The Host resolves it at the beginning of every tool call and never caches it across operations, so rotation applies to the next call.
32
+
33
+ The settings page only invokes `credentials.describe/set/unset`. It can observe configured/writable state, but it cannot read the credential value back into the browser.
34
+
35
+ ## Message identity and pagination
36
+
37
+ The model never constructs an IMAP UID directly. `mail_find` returns an opaque handle that binds folder, UIDVALIDITY, and UID. A later read reopens the same folder and revalidates UIDVALIDITY. If a mailbox is rebuilt or its UID namespace changes, the old handle fails and instructs the caller to search again. Attachment handles additionally bind the message and MIME part and are compared with the current body structure before download.
38
+
39
+ Handles prevent stale or accidental addressing; they are not bearer authorization and contain no password. Capability settings, the current credential, session workspace, and DSH permission preset remain authoritative.
40
+
41
+ A `mail_find` continuation cursor binds the complete filter, direction, UIDVALIDITY, and preceding-page UID boundary. Newest-first continuation only moves toward lower UIDs, so messages arriving during pagination do not duplicate earlier pages; oldest-first moves in the opposite direction. Every page reruns server-side search and checks UIDVALIDITY. `mail_list_folders` discovers exact paths; `mail_find` opens one explicit folder. No mailbox synchronization or local mail database exists.
42
+
43
+ ## Connection lifecycle
44
+
45
+ Each tool call creates one short-lived connection and closes it after the operation:
46
+
47
+ - no background IDLE or polling;
48
+ - no startup or save-time probe;
49
+ - no connection pool across calls;
50
+ - cancellation closes the protocol connection;
51
+ - protocol logging is disabled.
52
+
53
+ This trades a small amount of latency for simpler credential rotation, cleanup, and failure isolation. Any future pool must still re-resolve credentials per operation and invalidate immediately on settings or credential changes.
54
+
55
+ ## Binary boundary
56
+
57
+ Outbound attachments use `ctx.fs`: resolve from the session `cwd`, verify containment, require a regular file, enforce an aggregate size bound, then use bounded `readBytes`.
58
+
59
+ The Host artifact embeds the IMAP/SMTP implementation libraries in `lib/index.js`. Users do not install a second protocol runtime after npm, source-package, or offline-product installation, and plugin dependencies cannot collide with a product's private Node runtime during updates.
60
+
61
+ DSH `0.1.2-alpha.2` does not expose `writeBytes`. Attachment download therefore requires a local Host filesystem. The plugin resolves the logical destination with `ctx.fs`, creates the directory, resolves real workspace and directory paths, rechecks containment to reject pre-existing symlinks or junctions, and finally performs a random-name `wx` exclusive write. Replace this local adapter when DSH provides an official binary-write seam.
62
+
63
+ ## Extension rules
64
+
65
+ - OAuth2 requires a separate authentication adapter; tokens never belong in settings.
66
+ - Multiple accounts require independent Credential Keys/Refs and an explicit account parameter; YAML must not carry passwords.
67
+ - Polling, auto-reply, move, delete, and flag mutation are separate high-risk product boundaries.
68
+ - Background or scheduled sending requires an explicit deployment mode and recipient allowlist. Interactive Full Access cannot silently become background authorization.
@@ -0,0 +1,76 @@
1
+ # 架构与扩展边界
2
+
3
+ **简体中文** | [English](architecture.en.md)
4
+
5
+ ## 组合结构
6
+
7
+ `dsh-mail-assistant` 是一个 Host + Client Bundle:
8
+
9
+ ```text
10
+ DSH Web Client
11
+ └─ settings.section: 邮件助手设置页
12
+ ├─ remote.settings 非敏感账号和服务器配置
13
+ └─ remote.credentials 授权码只写
14
+
15
+ DSH Host
16
+ ├─ ctx.settings 动态配置
17
+ ├─ ctx.credentials 每次操作重新解析授权码
18
+ ├─ ctx.tools 五个模型工具、能力 guard 与 pre-execute 权限通路
19
+ ├─ ctx.permissionPresets
20
+ │ ├─ 普通权限 mail_send 请求一次性确认
21
+ │ └─ Full Access mail_send 不弹确认
22
+ ├─ ctx.fs 工作区路径与有界二进制读取
23
+ ├─ ImapFlow 只读 IMAP
24
+ └─ Nodemailer 受控 SMTP
25
+ ```
26
+
27
+ 插件不提供 Credential Provider、Settings Provider、Permission Preset/Approval UI、Filesystem Provider 或 Web Shell;这些都由部署使用的 DSH Profile 负责。这样普通 Web、本地桌面宿主和其他组合可以复用同一插件。
28
+
29
+ ## 配置与密钥
30
+
31
+ 非敏感字段保存在 `dsh-mail-assistant` settings namespace。授权码使用固定 Credential Ref `DSH_MAIL_ASSISTANT_PASSWORD`。Host 在每个工具调用开始时重新解析引用,不跨操作缓存密码,因此轮换后的值会在下一次调用生效。
32
+
33
+ 设置页只能调用 `credentials.describe/set/unset`:它能看到“是否配置”和“是否可写”,不能读回实际值。
34
+
35
+ ## 邮件标识
36
+
37
+ 模型不会直接拼接 IMAP UID。`mail_find` 返回的不透明 message handle 同时包含:
38
+
39
+ - folder;
40
+ - UIDVALIDITY;
41
+ - UID。
42
+
43
+ 后续读取会再次打开同一 folder 并验证 UIDVALIDITY。邮箱重建或 UID 空间变化时,旧 handle 会明确失败,要求重新查找。附件 handle 绑定 message handle 和当前 MIME part;下载前再次对照实时 body structure。
44
+
45
+ handle 用于完整性检查和防误用,不是授权令牌,也不包含密码。它目前是可解码但严格校验的结构;所有能力仍由当前配置、凭据、会话工作区和权限预设共同决定。
46
+
47
+ `mail_find` 的翻页游标还绑定完整筛选条件、方向和上一页 UID 边界。默认 newest 方向只继续读取更小的 UID,因此翻页期间新收到的邮件不会造成重复;oldest 方向反向处理。每页都会重新执行服务器端搜索,并检查 UIDVALIDITY。游标不保存邮件内容,也不是跨账号授权。
48
+
49
+ 目录发现与检索分离:`mail_list_folders` 只执行 IMAP `LIST`,`mail_find` 每次只打开一个明确目录。插件不会后台同步全邮箱,也不会建立本地邮件数据库。
50
+
51
+ ## 连接生命周期
52
+
53
+ 每次工具调用创建短生命周期连接,操作完成即关闭:
54
+
55
+ - 无后台 IDLE;
56
+ - 无启动探测;
57
+ - 无跨调用邮箱连接池;
58
+ - 中止信号会关闭底层连接;
59
+ - 连接日志关闭,避免协议内容进入应用日志。
60
+
61
+ 这个选择牺牲少量延迟,换取更简单的凭据轮换、资源回收和故障边界。以后若引入连接池,必须保持按操作重新解析凭据,并在凭据或设置变化时立即失效。
62
+
63
+ ## 二进制边界
64
+
65
+ 发送附件完全走 `ctx.fs`:以会话 `cwd` 解析、验证包含关系、检查普通文件、累计大小,再通过 `readBytes` 有界读取。
66
+
67
+ Host 产物会把 IMAP/SMTP 运行依赖编入 `lib/index.js`。因此通过 npm、源码包或 ChatECNU Work 离线装配安装后,终端用户都不需要再安装 Node 依赖;这也避免了插件依赖与宿主随版本更新的私有 Node 运行时互相覆盖。
68
+
69
+ DSH `0.1.2-alpha.2` 暂无 `writeBytes`。下载附件因此只在本地 Host FS 上可用:插件先用 `ctx.fs` 解析逻辑路径,创建目录后再解析工作区与目标目录的真实路径并重新验证包含关系,最后把随机文件名以 `wx` 独占模式写入。这样会拒绝预置符号链接或目录联接造成的工作区逃逸。未来官方提供二进制写 seam 后,应删除这段本地适配,直接复用官方能力。
70
+
71
+ ## 后续扩展规则
72
+
73
+ - OAuth2 认证应增加独立认证适配层,不得把 token 放进 settings。
74
+ - 多账号需要为每个账号使用独立 Credential Key/Ref 和明确 account 参数,不得用 YAML 承载密码。
75
+ - 后台轮询、自动回复、移动和删除属于新的高风险产品边界,不应顺手加入本插件。
76
+ - 后台或计划任务发信仍属于新的高风险边界,应使用显式部署模式和收件人 allowlist;不能把交互会话里的 Full Access 自动扩张为后台授权。
@@ -0,0 +1,37 @@
1
+ # Compatibility and known limits
2
+
3
+ [简体中文](compatibility.md) | **English**
4
+
5
+ Package `@eduwork/dsh-mail@0.1.0-alpha.5` retains the alpha.4 runtime and settings contracts. See [migration](EDUWORK-MIGRATION.en.md).
6
+
7
+ ## Reviewed baseline
8
+
9
+ - DeepSeek Harness `0.1.2-alpha.2`;
10
+ - Node.js 22+;
11
+ - dynamic Web Client Bundle;
12
+ - local Host filesystem;
13
+ - IMAP4rev1/IMAP4rev2 and SMTP Submission with username plus password/app-password authentication.
14
+
15
+ The DSH Profile provides `settings`, `credentials`, `tools`, `permissionPresets`, `approval`, and `fs`. The settings page also depends on official Remotes, Renderer, and Settings Client packages. Ordinary sending requires an interactive approval path; Full Access does not prompt.
16
+
17
+ ## Protocol scope
18
+
19
+ - IMAP uses read-only mailbox semantics and UIDVALIDITY to reject stale UIDs.
20
+ - SMTP supports implicit TLS and STARTTLS, never plaintext.
21
+ - XOAUTH2/OIDC mailbox login is not implemented. Gmail, Microsoft 365, and similar providers work only when tenant policy permits app passwords and SMTP AUTH.
22
+ - The plugin does not append a copy to the IMAP Sent folder; server policy decides whether sent mail is retained.
23
+ - S/MIME, PGP, calendar invitations, and nested `message/rfc822` are treated as ordinary MIME data without specialized semantics.
24
+
25
+ ## DSH binary-write limitation
26
+
27
+ DSH `0.1.2-alpha.2` exposes `ctx.fs.readBytes` but no `writeBytes`:
28
+
29
+ - outbound local attachments use the official seam end to end;
30
+ - downloads require `ctx.fs.processPath()` and the Host Node process to share one filesystem;
31
+ - after creating the destination directory the plugin resolves real paths and rechecks workspace containment;
32
+ - E2B, remote containers, and other non-shared Filesystem Providers should disable or expect a clear `mail_get_attachment` failure;
33
+ - migrate to the official binary-write API and remove the local adapter when one becomes available.
34
+
35
+ ## Version policy
36
+
37
+ During `0.x`, a DSH alpha may change the Client Loader, settings slots, or tool schemas. For every upgrade, run the full automated suite and real IMAP/SMTP acceptance in an isolated Profile. Compilation alone is insufficient.