@zhin.js/adapter-email 1.0.1 → 1.1.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/CHANGELOG.md +374 -0
- package/README.md +50 -102
- package/adapters/email.js +25 -0
- package/adapters/email.ts +35 -0
- package/lib/client.d.ts +23 -0
- package/lib/client.js +29 -0
- package/lib/endpoint.d.ts +27 -32
- package/lib/endpoint.js +284 -317
- package/lib/index.d.ts +4 -10
- package/lib/index.js +4 -23
- package/lib/protocol.d.ts +138 -0
- package/lib/protocol.js +245 -0
- package/lib/transport.d.ts +32 -0
- package/lib/transport.js +27 -0
- package/package.json +45 -12
- package/plugin.js +8 -0
- package/schema.json +169 -0
- package/src/client.ts +40 -0
- package/src/endpoint.ts +334 -390
- package/src/index.ts +35 -28
- package/src/protocol.ts +384 -0
- package/src/transport.ts +65 -0
- package/lib/adapter.d.ts +0 -12
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -15
- package/lib/adapter.js.map +0 -1
- package/lib/endpoint.d.ts.map +0 -1
- package/lib/endpoint.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types.d.ts +0 -49
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/src/adapter.ts +0 -18
- package/src/types.ts +0 -52
- /package/{skills/email/SKILL.md → agent/skills/email.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,379 @@
|
|
|
1
1
|
# @zhin.js/adapter-email
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1fc6270: Reset all 88 published official packages onto the owner-governed 1.1.x stable line. Packages whose historical 1.1.0 version is still available publish as 1.1.0; packages where npm permanently reserves that version use the next available 1.1.x patch. Historical higher version lines remain installable but are superseded, and routine releases after this reset are patch-only.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a34bf91: Publish internal peer dependencies as compatible caret ranges instead of exact versions, preventing compatible internal minor releases from forcing unrelated major bumps.
|
|
12
|
+
- Updated dependencies [1fc6270]
|
|
13
|
+
- @zhin.js/adapter@1.1.12
|
|
14
|
+
- @zhin.js/core@1.1.35
|
|
15
|
+
- @zhin.js/feature-kit@1.1.0
|
|
16
|
+
- @zhin.js/im-contract@1.1.0
|
|
17
|
+
- @zhin.js/logger@1.1.0
|
|
18
|
+
|
|
19
|
+
## 7.0.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [f7ee28d]
|
|
24
|
+
- @zhin.js/adapter@1.2.2
|
|
25
|
+
- @zhin.js/core@1.5.16
|
|
26
|
+
- zhin.js@7.0.1
|
|
27
|
+
|
|
28
|
+
## 7.0.0
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- zhin.js@7.0.0
|
|
33
|
+
|
|
34
|
+
## 6.0.2
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [ba7e17a]
|
|
39
|
+
- Updated dependencies [7108d0b]
|
|
40
|
+
- @zhin.js/core@1.5.15
|
|
41
|
+
- zhin.js@6.0.15
|
|
42
|
+
|
|
43
|
+
## 6.0.1
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- e9c6a73: Ignore late disconnect events from replaced IMAP transports so reconnect does not leak duplicate connections.
|
|
48
|
+
- 1fc78bc: Unify native platform Client access behind the literal `adapter` discriminant. Handlers infer both native events and Clients, while command, inbound/outbound middleware, and both Agent tool authoring surfaces expose the exact operation-scoped Client through a lazy `$client` getter. Definitions without `adapter` keep `$client` typed as `unknown`, and runtime dispatch rejects adapter mismatches before resolving the Client. Bundled platform tools now use this single path instead of model-provided endpoint ids and adapter-specific dependency wrappers. Every adapter registers one Client/EventMap contract, and protocol adapters including NapCat, Milky, OneBot and Satori now produce transport-independent Client objects rather than letting Endpoint instances impersonate Clients.
|
|
49
|
+
- Updated dependencies [4e8117c]
|
|
50
|
+
- Updated dependencies [54bfd6b]
|
|
51
|
+
- Updated dependencies [12025ee]
|
|
52
|
+
- Updated dependencies [09b14d6]
|
|
53
|
+
- Updated dependencies [1fc78bc]
|
|
54
|
+
- @zhin.js/adapter@1.2.1
|
|
55
|
+
- @zhin.js/core@1.5.14
|
|
56
|
+
- @zhin.js/logger@1.0.77
|
|
57
|
+
- zhin.js@6.0.14
|
|
58
|
+
- @zhin.js/feature-kit@1.0.13
|
|
59
|
+
|
|
60
|
+
## 6.0.0
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [f2c532f]
|
|
65
|
+
- @zhin.js/adapter@1.2.0
|
|
66
|
+
- @zhin.js/core@1.5.13
|
|
67
|
+
- zhin.js@6.0.13
|
|
68
|
+
|
|
69
|
+
## 5.0.12
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- 5969c5b: Add SideEventGateway so adapters forward notice/request/system into HandlerIndex. HandlerContext now exposes only generation-safe capabilities and prompt ports; live Endpoint escape hatches are removed.
|
|
74
|
+
- Updated dependencies [5969c5b]
|
|
75
|
+
- Updated dependencies [5969c5b]
|
|
76
|
+
- Updated dependencies [5969c5b]
|
|
77
|
+
- Updated dependencies [974772e]
|
|
78
|
+
- Updated dependencies [5969c5b]
|
|
79
|
+
- Updated dependencies [2f786bd]
|
|
80
|
+
- Updated dependencies [1312ca0]
|
|
81
|
+
- @zhin.js/im-contract@1.0.4
|
|
82
|
+
- @zhin.js/core@1.5.12
|
|
83
|
+
- @zhin.js/adapter@1.1.11
|
|
84
|
+
- zhin.js@6.0.12
|
|
85
|
+
|
|
86
|
+
## 5.0.11
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- @zhin.js/core@1.5.11
|
|
91
|
+
- zhin.js@6.0.11
|
|
92
|
+
|
|
93
|
+
## 5.0.10
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- eb84b77: fix: 更新文档,建立正确的依赖关系
|
|
98
|
+
- Updated dependencies [d3920e9]
|
|
99
|
+
- @zhin.js/core@1.5.10
|
|
100
|
+
- zhin.js@6.0.10
|
|
101
|
+
- @zhin.js/adapter@1.1.10
|
|
102
|
+
|
|
103
|
+
## 5.0.9
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- Updated dependencies [e4757a8]
|
|
108
|
+
- Updated dependencies [c3c0ebf]
|
|
109
|
+
- @zhin.js/core@1.5.9
|
|
110
|
+
- @zhin.js/adapter@1.1.9
|
|
111
|
+
- zhin.js@6.0.9
|
|
112
|
+
|
|
113
|
+
## 5.0.8
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [63253bb]
|
|
118
|
+
- Updated dependencies [8e973dc]
|
|
119
|
+
- Updated dependencies [953cfe1]
|
|
120
|
+
- Updated dependencies [0e73866]
|
|
121
|
+
- @zhin.js/plugin-runtime@1.1.6
|
|
122
|
+
- @zhin.js/core@1.5.8
|
|
123
|
+
- @zhin.js/adapter@1.1.8
|
|
124
|
+
- zhin.js@6.0.8
|
|
125
|
+
|
|
126
|
+
## 5.0.7
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [36cb1ca]
|
|
131
|
+
- @zhin.js/core@1.5.7
|
|
132
|
+
- zhin.js@6.0.7
|
|
133
|
+
|
|
134
|
+
## 5.0.6
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- @zhin.js/adapter@1.1.7
|
|
139
|
+
- @zhin.js/core@1.5.6
|
|
140
|
+
- zhin.js@6.0.6
|
|
141
|
+
|
|
142
|
+
## 5.0.5
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- @zhin.js/adapter@1.1.7
|
|
147
|
+
- @zhin.js/core@1.5.5
|
|
148
|
+
- zhin.js@6.0.5
|
|
149
|
+
|
|
150
|
+
## 5.0.4
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- Updated dependencies [c106ecc]
|
|
155
|
+
- Updated dependencies [b0f37ae]
|
|
156
|
+
- Updated dependencies [ba08a2f]
|
|
157
|
+
- Updated dependencies [daffd4c]
|
|
158
|
+
- Updated dependencies [36c7400]
|
|
159
|
+
- Updated dependencies [162fa34]
|
|
160
|
+
- Updated dependencies [e40b048]
|
|
161
|
+
- Updated dependencies [f1708c3]
|
|
162
|
+
- Updated dependencies [e53444f]
|
|
163
|
+
- Updated dependencies [92b0dd7]
|
|
164
|
+
- Updated dependencies [a7df753]
|
|
165
|
+
- @zhin.js/im-contract@1.0.3
|
|
166
|
+
- @zhin.js/adapter@1.1.7
|
|
167
|
+
- @zhin.js/plugin-runtime@1.1.5
|
|
168
|
+
- @zhin.js/core@1.5.4
|
|
169
|
+
- zhin.js@6.0.4
|
|
170
|
+
|
|
171
|
+
## 5.0.3
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- f8c7a54: fix: im
|
|
176
|
+
- Updated dependencies [f8c7a54]
|
|
177
|
+
- @zhin.js/logger@1.0.76
|
|
178
|
+
- @zhin.js/adapter@1.1.6
|
|
179
|
+
- @zhin.js/core@1.5.3
|
|
180
|
+
- @zhin.js/im-contract@1.0.2
|
|
181
|
+
- @zhin.js/plugin-runtime@1.1.4
|
|
182
|
+
- zhin.js@6.0.3
|
|
183
|
+
|
|
184
|
+
## 5.0.2
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- Updated dependencies [afc0e66]
|
|
189
|
+
- Updated dependencies [2e41ad5]
|
|
190
|
+
- Updated dependencies [9f57124]
|
|
191
|
+
- @zhin.js/core@1.5.2
|
|
192
|
+
- @zhin.js/adapter@1.1.5
|
|
193
|
+
- @zhin.js/im-contract@1.0.1
|
|
194
|
+
- @zhin.js/plugin-runtime@1.1.3
|
|
195
|
+
- zhin.js@6.0.2
|
|
196
|
+
|
|
197
|
+
## 5.0.1
|
|
198
|
+
|
|
199
|
+
### Patch Changes
|
|
200
|
+
|
|
201
|
+
- Updated dependencies [c8f4d45]
|
|
202
|
+
- @zhin.js/plugin-runtime@1.1.2
|
|
203
|
+
- @zhin.js/adapter@1.1.4
|
|
204
|
+
- @zhin.js/core@1.5.1
|
|
205
|
+
- zhin.js@6.0.1
|
|
206
|
+
|
|
207
|
+
## 5.0.0
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- 4fbff5d: feat!: 多模态双向 Segment 一贯制(BREAKING,无兼容层)
|
|
212
|
+
|
|
213
|
+
全框架唯一媒体表达统一为 canonical `Segment` + `MediaRef{kind: url|path|base64|file, value, mime_type?, file_name?, size?}`,新增 audio/video/file 段类型;所有第二形状(legacy `data.url/file/base64` 字段、`mediaRefFromLegacyData`/`mediaRefToLegacyFields` 桥、双写)全部删除。
|
|
214
|
+
|
|
215
|
+
- **core**:`SendContent` 一等支持 `Segment[]`;endpoint 出站载荷只含 canonical 段;`resolveOutboundMediaPolicy` 改为纯声明驱动(adapter definition `segments.outboundMedia`),内置策略表删除,未声明回退 `url-or-text`;`ImageContent` 旧桥删除。
|
|
216
|
+
- **ai**:新增 `MediaContentBlock`/`MediaBlockRef`(Segment 同构)与 `UserMessage.media`(当前 turn 媒体,**不持久化**——存储层自动剥离);`createUserMessage(text, media?)` 签名变更(`ImageContent` 删除);provider 边界序列化器 `filterMediaBlocksForProvider` + 能力表(缺省 image-only,不支持类型降级占位文本);ai-sdk 桥媒体块 → SDK image/file parts。
|
|
217
|
+
- **agent**:入站 turn 注入(`turn/inbound-media.ts`)——commMessage 媒体段 → 当前 turn `UserMessage.media`;图片 path 物化、音频默认 STT(`@zhin.js/speech` 可选,失败降级占位)、视频/文件占位;`publishOutboundElements` 产出 canonical Segment;`transcribeAudioPayload` 导出。
|
|
218
|
+
- **cli**:`bridgeRuntimeMessage` 回复链路媒体段透传,不再压平为文本(`$reply` 直达 normalize → adapter)。
|
|
219
|
+
- **全部 20 个平台适配器**:出站媒体只消费 `data.media`(url 直发 / base64 直发 / 平台上传 / 读盘),入站媒体产出 canonical `data.media`;`segments.outboundMedia` 声明与实际消费逐一核对修正;QQ 入站新增 canonical segments(image/audio/video/file/mention/face/reply),图片/语音/视频不再丢失。
|
|
220
|
+
|
|
221
|
+
迁移:适配器/插件产媒体一律用 `{ type, data: { media: MediaRef } }`;发送 legacy `data.url/file/base64` 形状的段会被 warn 丢弃。
|
|
222
|
+
|
|
223
|
+
- Updated dependencies [7c1e63a]
|
|
224
|
+
- Updated dependencies [4fbff5d]
|
|
225
|
+
- Updated dependencies [5b94d9c]
|
|
226
|
+
- @zhin.js/adapter@1.1.3
|
|
227
|
+
- @zhin.js/core@1.5.0
|
|
228
|
+
- zhin.js@6.0.0
|
|
229
|
+
|
|
230
|
+
## 4.0.3
|
|
231
|
+
|
|
232
|
+
### Patch Changes
|
|
233
|
+
|
|
234
|
+
- Updated dependencies [45b3256]
|
|
235
|
+
- @zhin.js/core@1.4.3
|
|
236
|
+
- zhin.js@5.0.3
|
|
237
|
+
|
|
238
|
+
## 4.0.2
|
|
239
|
+
|
|
240
|
+
### Patch Changes
|
|
241
|
+
|
|
242
|
+
- d5cd4aa: Publish Plugin Runtime entry points and convention modules as JavaScript so
|
|
243
|
+
installed npm plugins load on Node without TypeScript stripping. Workspace
|
|
244
|
+
development continues to prefer TypeScript sources for local HMR.
|
|
245
|
+
|
|
246
|
+
Remove the unconsumed legacy game hub APIs from game-kit; game navigation and
|
|
247
|
+
records now use ordinary convention commands owned by the game hub plugin.
|
|
248
|
+
|
|
249
|
+
- zhin.js@5.0.2
|
|
250
|
+
- @zhin.js/adapter@1.1.2
|
|
251
|
+
- @zhin.js/core@1.4.2
|
|
252
|
+
|
|
253
|
+
## 4.0.1
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- 5691aba: 第二轮全量审计修复批(8 面 ~60 bug):
|
|
258
|
+
|
|
259
|
+
- **安全**:email 附件路径穿越修复(basename + downloadPath 约束);lark/telegram/satori webhook 鉴权(缺密钥告警、timingSafeEqual、±5min 时效窗、chat_type 修正);onebot wss/webhook 缺 token 告警;qq webhook 改原始字节验签;renderJsx/JSX 转义注入修复;console runtime token 401 死循环。
|
|
260
|
+
- **P0 功能**:sandbox 多 endpoint 解析 + WS 路径隔离;short-url expand(undici opaqueredirect)改 follow;AI 压缩摘要失败不再静默丢历史(熔断恢复生效);console-ui 实时推送事件名归一化 + IndexedDB schema 对齐;process-monitor 热重载不再误判崩溃。
|
|
261
|
+
- **生命周期**:email IMAP 断线重连 + 在飞锁;onebot11/12 start 失败清理;line replyToken TTL + push 兜底;wechat-mp token 过期重试 + MsgId 去重;weixin-ilink buf 推进/防抖写盘/媒体 TTL/QR abort;satori PONG 看门狗;退避自毁修复。
|
|
262
|
+
- **游戏**:text-adventure 终局 restart 复活 + requires 服务端校验;tic-tac-toe PvP 占用/restart/队列清理/TTL;idiom-chain/word-riddle 闲聊不扣失误;别名中间件不劫持普通聊天。
|
|
263
|
+
- **共享库**:schema falsy 默认值/date/tuple/union 修复;database parseCondition Date/未知操作符、sqlite TEXT 往返、query 分派、belongsToMany 方言、migration dry-run;schedule DST 回拨死循环、重复 id 去重、flush 串行化;game-kit fallback 编号/onboarding 提示/尾缀边界/活引用拷贝。
|
|
264
|
+
- **渲染语音**:fetch 全部超时 + 渲染并发闸;sanitizeHtml form 保文本;STT 扩展名映射 + 删临时文件;TTS 未知 provider 报错;emojiCache LRU 负缓存/fontCache style/clearFonts 恢复;register 错误分类收窄。
|
|
265
|
+
|
|
266
|
+
- Updated dependencies [cdf64e7]
|
|
267
|
+
- Updated dependencies [5691aba]
|
|
268
|
+
- Updated dependencies [078e3f7]
|
|
269
|
+
- Updated dependencies [9c997b2]
|
|
270
|
+
- Updated dependencies [09d4f25]
|
|
271
|
+
- Updated dependencies [43485a9]
|
|
272
|
+
- Updated dependencies [f0ec5ab]
|
|
273
|
+
- Updated dependencies [3e925d0]
|
|
274
|
+
- Updated dependencies [fa66c4c]
|
|
275
|
+
- Updated dependencies [fa66c4c]
|
|
276
|
+
- Updated dependencies [6cb6152]
|
|
277
|
+
- @zhin.js/plugin-runtime@1.1.1
|
|
278
|
+
- zhin.js@5.0.1
|
|
279
|
+
- @zhin.js/adapter@1.1.1
|
|
280
|
+
- @zhin.js/core@1.4.1
|
|
281
|
+
|
|
282
|
+
## 4.0.0
|
|
283
|
+
|
|
284
|
+
### Patch Changes
|
|
285
|
+
|
|
286
|
+
- 7db69c1: 命令前缀改为适配器配置项:`MessageDispatcher` 不再硬编码 `/`,默认按消息所属适配器实例 config 的 `commandPrefix` 解析(默认 `''` 无前缀,任意文本按命令匹配),`endpoints[i].commandPrefix` 逐项覆盖;`ImRuntime({ commandPrefix })` 仍可设全局静态前缀。全部 20 个平台适配器 schema 新增 `commandPrefix` 属性。
|
|
287
|
+
|
|
288
|
+
BREAKING(行为变化):未配置时命令不再需要 `/` 前缀——原 `/zt` 写法不再命中,直接发 `zt` 即可;需要斜杠风格的适配器请在配置里显式设 `commandPrefix: '/'`。
|
|
289
|
+
|
|
290
|
+
- 713445c: 适配器配置格式定稿(不兼容旧格式):`plugins.<adapter>` 顶层仅共享字段 + `commandPrefix`,`endpoints[i]` 携带 endpoint 级字段(`name` + 凭据,各 schema 已类型化),`endpoints` 为必填(icqq 另需顶层 `master`);icqq 新增 `trusted` 列表(顶层/逐项均可)。scaffold-wizard 全部字段式与自定义 configure() 产出改为新格式,examples(full-bot / qq-games-bot)与 20 个适配器 README 同步迁移。
|
|
291
|
+
- Updated dependencies [7db69c1]
|
|
292
|
+
- Updated dependencies [e5c84ed]
|
|
293
|
+
- Updated dependencies [3ea84a0]
|
|
294
|
+
- Updated dependencies [1ddcd70]
|
|
295
|
+
- Updated dependencies [ac9da66]
|
|
296
|
+
- @zhin.js/core@1.4.0
|
|
297
|
+
- @zhin.js/adapter@1.1.0
|
|
298
|
+
- @zhin.js/plugin-runtime@1.1.0
|
|
299
|
+
- zhin.js@5.0.0
|
|
300
|
+
|
|
301
|
+
## 3.0.3
|
|
302
|
+
|
|
303
|
+
### Patch Changes
|
|
304
|
+
|
|
305
|
+
- cc5c94d: 约定式插件运行时迁移(breaking):插件与适配器由 `usePlugin()` / `extends Adapter` 迁移为 `definePlugin` / `defineAdapter` + `plugin.ts` + 约定目录(`adapters/`、`commands/`、`components/`、`tools/` 等)。
|
|
306
|
+
|
|
307
|
+
- 新增约定式运行时包:`@zhin.js/plugin-runtime`、`@zhin.js/adapter`、`@zhin.js/runtime`、`@zhin.js/host-http`(首版 1.0.0 走 init-publish,不在本 changeset 内 bump)。
|
|
308
|
+
- 全部 20 个平台适配器改为约定式 `defineAdapter`,旧 `usePlugin` / `extends Adapter` / `segment-mapper` 生产入口已删除;onebot11 反向 WSS、onebot12 webhook/wss、milky sse/webhook/wss、satori webhook、kook webhook、qq webhook/middleware 等 slice 1 推迟的连接模式已补齐。
|
|
309
|
+
- 游戏 / 工具 / 服务插件同步迁移到约定目录结构。
|
|
310
|
+
- CLI 增加 plugin-runtime host installer(http/database/outbound/schedule/console 等)。
|
|
311
|
+
|
|
312
|
+
后续加固(同批):
|
|
313
|
+
|
|
314
|
+
- CLI:`zhin runtime start --daemon`(pidfile/崩溃拉起/风暴保护),orphan watchdog 防僵尸进程;legacy `zhin dev` / `zhin start` 已移除(含 `zhin restart`),`zhin stop` 兼容新 daemon。
|
|
315
|
+
- 安全:builtin 工具统一走 `security/policy-facade.ts` 的 `runToolPolicies`(声明式策略表,deny 优先);审计日志 close flush + 背压队列;`splitCompoundCommand` 引号感知、`extractCommandName` 去引号堵绕过。
|
|
316
|
+
- 日志:Logger 双堆栈修复、本地时区、`getLogger` 挂树(`setLevel` 递归生效)、第三方库(log4js/discord)桥接、启动人读总结。
|
|
317
|
+
- 结构:`plugins/games/shared` 迁为 `packages/game-kit`(`@zhin.js/game-kit`);死目录 `plugins/adapters/common` 删除。
|
|
318
|
+
- 脚手架:`create-zhin-app` / `zhin new` / scaffold-wizard 生成物改为 Plugin Runtime 形态(minimal-bot 同构,新配置格式)。
|
|
319
|
+
- Console:endpoint.list 真实名称与 phase、schema:get-all 按 instanceKey 映射、db:\* 接 DatabaseHost。
|
|
320
|
+
|
|
321
|
+
注:按仓库发布惯例(见 1bb345dd2),本次 breaking 迁移统一使用 patch,避免 zhin.js 5.0 级联。
|
|
322
|
+
|
|
323
|
+
- Updated dependencies [16ec4e8]
|
|
324
|
+
- Updated dependencies [cc5c94d]
|
|
325
|
+
- Updated dependencies [447f3e2]
|
|
326
|
+
- @zhin.js/core@1.3.5
|
|
327
|
+
- zhin.js@4.1.3
|
|
328
|
+
- @zhin.js/logger@1.0.75
|
|
329
|
+
- @zhin.js/plugin-runtime@1.0.1
|
|
330
|
+
- @zhin.js/adapter@1.0.1
|
|
331
|
+
|
|
332
|
+
## 3.0.2
|
|
333
|
+
|
|
334
|
+
### Patch Changes
|
|
335
|
+
|
|
336
|
+
- 872c583: Slack 适配器 Phase 1/2:mrkdwn 出站、长消息切分、斜杠/按钮 ephemeral 反馈、入站 mrkdwn→Markdown、editMessage 对齐 core。
|
|
337
|
+
|
|
338
|
+
Logger 表格日志与 string-width 列宽;Agent AI Handler 框线表格与 introspection/MCP 导出;Core side-event 归一化;Schedule 时区规划;多适配器 side-event 与 API surface 更新。
|
|
339
|
+
|
|
340
|
+
- 872c583: fix: 代码格式优化
|
|
341
|
+
- Updated dependencies [872c583]
|
|
342
|
+
- Updated dependencies [872c583]
|
|
343
|
+
- zhin.js@4.1.2
|
|
344
|
+
|
|
345
|
+
## 3.0.1
|
|
346
|
+
|
|
347
|
+
### Patch Changes
|
|
348
|
+
|
|
349
|
+
- 5cc9c03: fix: ai 优化
|
|
350
|
+
- b9b3881: fix: 增加游戏引擎以及部分游戏
|
|
351
|
+
- Updated dependencies [5cc9c03]
|
|
352
|
+
- Updated dependencies [7700903]
|
|
353
|
+
- zhin.js@4.1.1
|
|
354
|
+
|
|
355
|
+
## 3.0.0
|
|
356
|
+
|
|
357
|
+
### Patch Changes
|
|
358
|
+
|
|
359
|
+
- c4575c9: fix: 输入输出优化,文档优化
|
|
360
|
+
- Updated dependencies [c4575c9]
|
|
361
|
+
- Updated dependencies [c4575c9]
|
|
362
|
+
- zhin.js@4.1.0
|
|
363
|
+
|
|
364
|
+
## 2.0.1
|
|
365
|
+
|
|
366
|
+
### Patch Changes
|
|
367
|
+
|
|
368
|
+
- Updated dependencies [ae5239c]
|
|
369
|
+
- zhin.js@4.0.1
|
|
370
|
+
|
|
371
|
+
## 2.0.0
|
|
372
|
+
|
|
373
|
+
### Patch Changes
|
|
374
|
+
|
|
375
|
+
- zhin.js@3.0.0
|
|
376
|
+
|
|
3
377
|
## 1.0.1
|
|
4
378
|
|
|
5
379
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @zhin.js/adapter-email
|
|
2
2
|
|
|
3
|
-
Zhin.js
|
|
3
|
+
Zhin.js 邮件适配器(Plugin Runtime),通过 SMTP 发送和 IMAP 接收邮件,将邮箱作为聊天通道接入。
|
|
4
4
|
|
|
5
5
|
## 功能特性
|
|
6
6
|
|
|
7
7
|
- SMTP 邮件发送(基于 nodemailer)
|
|
8
8
|
- IMAP 邮件接收(基于 imap + mailparser)
|
|
9
|
-
-
|
|
10
|
-
- 定时轮询新邮件
|
|
9
|
+
- 定时轮询未读邮件
|
|
11
10
|
- TLS/SSL 加密连接
|
|
11
|
+
- 约定式 `defineAdapter` / `definePlugin`(无需 `usePlugin`)
|
|
12
12
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
@@ -16,131 +16,79 @@ Zhin.js 邮件适配器,通过 SMTP 发送和 IMAP 接收邮件,将邮箱作
|
|
|
16
16
|
pnpm add @zhin.js/adapter-email
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
## Plugin Runtime
|
|
20
|
+
|
|
21
|
+
- `@zhin.js/adapter` — 约定式 `adapters/email.ts`(`defineAdapter`)
|
|
22
|
+
- `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
|
|
23
|
+
- `zhin.js` — `plugin.ts`(`definePlugin`)
|
|
24
|
+
- 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`(`smtp` / `imap`)
|
|
25
|
+
|
|
26
|
+
入站:`gateway.receive({ conversation, message, content: text, sender, metadata })`(`conversation` 为 kind=private、id=发件人地址的 ConversationRef)
|
|
27
|
+
出站:`send({ conversation, payload })` → nodemailer(收件人取 `conversation.id`;payload 已由 gateway/core 渲染;无 segment-mapper)
|
|
28
|
+
|
|
19
29
|
## 前置条件
|
|
20
30
|
|
|
21
31
|
| 要求 | 说明 |
|
|
22
32
|
|------|------|
|
|
23
|
-
| **邮箱账号** | 可用的 SMTP 发信与 IMAP
|
|
24
|
-
| **应用专用密码** | Gmail、Outlook
|
|
33
|
+
| **邮箱账号** | 可用的 SMTP 发信与 IMAP 收信账号 |
|
|
34
|
+
| **应用专用密码** | Gmail、Outlook 等常需应用密码 |
|
|
25
35
|
| **网络** | 出站可连 SMTP/IMAP 端口(465/587/993 等) |
|
|
26
|
-
| **host-
|
|
27
|
-
|
|
28
|
-
必填字段见 `EmailEndpointConfig`:`context`、`name`、`smtp`、`imap`(含 `auth.user` / `auth.pass` 与 `user` / `password`)。
|
|
36
|
+
| **host-http** | 不需要;IMAP 轮询在适配器内完成 |
|
|
29
37
|
|
|
30
38
|
## 最小配置
|
|
31
39
|
|
|
32
40
|
```yaml
|
|
41
|
+
# zhin.config.yml(Plugin Runtime)
|
|
33
42
|
plugins:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
user: bot@example.com
|
|
51
|
-
password: "${EMAIL_PASSWORD}"
|
|
43
|
+
email:
|
|
44
|
+
endpoints:
|
|
45
|
+
- name: my-email-bot
|
|
46
|
+
smtp:
|
|
47
|
+
host: smtp.example.com
|
|
48
|
+
port: 465
|
|
49
|
+
secure: true
|
|
50
|
+
auth:
|
|
51
|
+
user: bot@example.com
|
|
52
|
+
pass: "${EMAIL_PASSWORD}"
|
|
53
|
+
imap:
|
|
54
|
+
host: imap.example.com
|
|
55
|
+
port: 993
|
|
56
|
+
tls: true
|
|
57
|
+
user: bot@example.com
|
|
58
|
+
password: "${EMAIL_PASSWORD}"
|
|
52
59
|
```
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
根插件 `zhin.plugins`(或项目图)需引用 `@zhin.js/adapter-email`(`instanceKey: email`)。
|
|
55
62
|
|
|
56
63
|
### 可选 IMAP 字段
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
port: 993
|
|
62
|
-
tls: true
|
|
63
|
-
user: bot@example.com
|
|
64
|
-
password: "${EMAIL_PASSWORD}"
|
|
65
|
-
# checkInterval: 30000 # 轮询间隔(毫秒),默认 30 秒
|
|
66
|
-
# mailbox: INBOX # 监听的邮箱文件夹
|
|
67
|
-
# markSeen: true # 已读标记
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### TypeScript 配置
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import { defineConfig } from 'zhin.js'
|
|
74
|
-
|
|
75
|
-
export default defineConfig({
|
|
76
|
-
endpoints: [
|
|
77
|
-
{
|
|
78
|
-
context: 'email',
|
|
79
|
-
name: 'my-email-bot',
|
|
80
|
-
smtp: {
|
|
81
|
-
host: 'smtp.example.com',
|
|
82
|
-
port: 465,
|
|
83
|
-
secure: true,
|
|
84
|
-
auth: {
|
|
85
|
-
user: 'bot@example.com',
|
|
86
|
-
pass: process.env.EMAIL_PASSWORD!,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
imap: {
|
|
90
|
-
host: 'imap.example.com',
|
|
91
|
-
port: 993,
|
|
92
|
-
tls: true,
|
|
93
|
-
user: 'bot@example.com',
|
|
94
|
-
password: process.env.EMAIL_PASSWORD!,
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
plugins: ['@zhin.js/adapter-email']
|
|
99
|
-
})
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## 使用示例
|
|
65
|
+
- `checkInterval`:轮询间隔(毫秒),默认 `60000`
|
|
66
|
+
- `mailbox`:默认 `INBOX`
|
|
67
|
+
- `markSeen`:默认 `true`
|
|
103
68
|
|
|
104
|
-
###
|
|
69
|
+
### 附件下载
|
|
105
70
|
|
|
106
|
-
|
|
107
|
-
import { usePlugin, MessageCommand } from 'zhin.js'
|
|
71
|
+
`attachments.enabled: true` 时,入站邮件附件会落盘并把保存信息写入消息 metadata(`attachments: [{ filename, path, contentType, size }]`):
|
|
108
72
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
new MessageCommand('status')
|
|
113
|
-
.desc('查询状态')
|
|
114
|
-
.action(() => 'Agent 运行中')
|
|
115
|
-
)
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### 消息处理
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
import { usePlugin } from 'zhin.js'
|
|
122
|
-
|
|
123
|
-
const { addMiddleware } = usePlugin()
|
|
124
|
-
|
|
125
|
-
addMiddleware(async (message, next) => {
|
|
126
|
-
if (message.$adapter === 'email') {
|
|
127
|
-
console.log('收到邮件:', message.$sender.name, message.$content)
|
|
128
|
-
}
|
|
129
|
-
await next()
|
|
130
|
-
})
|
|
131
|
-
```
|
|
73
|
+
- `downloadPath`:保存目录,默认 `./downloads/email`
|
|
74
|
+
- `maxFileSize`:单附件上限(字节),默认 10MB,超限跳过
|
|
75
|
+
- `allowedTypes`:允许的 MIME 类型白名单,不在列表内跳过
|
|
132
76
|
|
|
133
77
|
## 故障排查
|
|
134
78
|
|
|
135
79
|
| 现象 | 排查 |
|
|
136
80
|
|------|------|
|
|
137
|
-
| IMAP 连接失败 | 主机/端口/TLS
|
|
138
|
-
| 收不到新邮件 |
|
|
139
|
-
| SMTP 发送失败 | `secure`
|
|
140
|
-
| 重复处理邮件 |
|
|
81
|
+
| IMAP 连接失败 | 主机/端口/TLS;是否需应用专用密码 |
|
|
82
|
+
| 收不到新邮件 | `checkInterval` / `mailbox`;确认 `open()` 后才准入入站 |
|
|
83
|
+
| SMTP 发送失败 | `secure` 与端口匹配;发信地址与 `auth.user` 一致 |
|
|
84
|
+
| 重复处理邮件 | `markSeen: true`;避免多实例轮询同一邮箱 |
|
|
141
85
|
|
|
142
86
|
建议使用环境变量存储邮箱密码,勿提交到版本库。
|
|
143
87
|
|
|
88
|
+
## AI 工具
|
|
89
|
+
|
|
90
|
+
技能说明见 `agent/skills/email.md`。
|
|
91
|
+
|
|
144
92
|
## 文档链接
|
|
145
93
|
|
|
146
94
|
- [Email 适配器文档](https://zhin.js.org/adapters/email)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Convention entry: discover `adapters/email.ts` → defineAdapter.
|
|
4
|
+
*/
|
|
5
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
|
+
import { EmailEndpoint } from "../lib/endpoint.js";
|
|
7
|
+
import { resolveEmailConfig, } from "../lib/protocol.js";
|
|
8
|
+
export { EmailEndpoint } from "../lib/endpoint.js";
|
|
9
|
+
export default defineAdapter({
|
|
10
|
+
capabilities: ['inbound', 'outbound'],
|
|
11
|
+
// image/audio/video/file 段映射为邮件附件:canonical MediaRef kind=url/path
|
|
12
|
+
// 作 nodemailer attachment.path(URL 由 nodemailer 拉流、path 读盘),
|
|
13
|
+
// kind=base64 直发(content + encoding);kind=file 无邮件对应概念,丢弃留痕。
|
|
14
|
+
// 邮件无交互面,交互段降级纯文本。
|
|
15
|
+
segments: {
|
|
16
|
+
outboundMedia: ['url', 'path', 'base64'],
|
|
17
|
+
interactive: 'text',
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
return new EmailEndpoint({
|
|
21
|
+
id: context.id,
|
|
22
|
+
config: resolveEmailConfig(context.config),
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convention entry: discover `adapters/email.ts` → defineAdapter.
|
|
3
|
+
*/
|
|
4
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
|
+
import { EmailEndpoint } from '../src/endpoint.js';
|
|
6
|
+
import {
|
|
7
|
+
resolveEmailConfig,
|
|
8
|
+
type EmailAdapterConfig,
|
|
9
|
+
} from '../src/protocol.js';
|
|
10
|
+
|
|
11
|
+
export { EmailEndpoint } from '../src/endpoint.js';
|
|
12
|
+
export type { EmailEndpointOptions } from '../src/endpoint.js';
|
|
13
|
+
export type {
|
|
14
|
+
EmailImapFetchMessage,
|
|
15
|
+
EmailImapTransport,
|
|
16
|
+
EmailSmtpTransport,
|
|
17
|
+
} from '../src/transport.js';
|
|
18
|
+
|
|
19
|
+
export default defineAdapter<EmailAdapterConfig>({
|
|
20
|
+
capabilities: ['inbound', 'outbound'],
|
|
21
|
+
// image/audio/video/file 段映射为邮件附件:canonical MediaRef kind=url/path
|
|
22
|
+
// 作 nodemailer attachment.path(URL 由 nodemailer 拉流、path 读盘),
|
|
23
|
+
// kind=base64 直发(content + encoding);kind=file 无邮件对应概念,丢弃留痕。
|
|
24
|
+
// 邮件无交互面,交互段降级纯文本。
|
|
25
|
+
segments: {
|
|
26
|
+
outboundMedia: ['url', 'path', 'base64'],
|
|
27
|
+
interactive: 'text',
|
|
28
|
+
},
|
|
29
|
+
create(context) {
|
|
30
|
+
return new EmailEndpoint({
|
|
31
|
+
id: context.id,
|
|
32
|
+
config: resolveEmailConfig(context.config),
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
});
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EmailImapTransport, EmailSmtpTransport } from './transport.js';
|
|
2
|
+
/** Live SMTP + IMAP client pair exposed to event handlers and plugins. */
|
|
3
|
+
export declare class EmailClient {
|
|
4
|
+
private readonly resolveSmtp;
|
|
5
|
+
private readonly resolveImap;
|
|
6
|
+
constructor(resolveSmtp: () => EmailSmtpTransport | null, resolveImap: () => EmailImapTransport | null);
|
|
7
|
+
get smtp(): EmailSmtpTransport;
|
|
8
|
+
get imap(): EmailImapTransport;
|
|
9
|
+
verify(): Promise<void>;
|
|
10
|
+
sendMail(options: unknown): Promise<{
|
|
11
|
+
messageId?: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export type EmailClientEventMap = Record<string, unknown>;
|
|
15
|
+
declare module '@zhin.js/feature-kit' {
|
|
16
|
+
interface AdapterClientRegistry {
|
|
17
|
+
readonly email: {
|
|
18
|
+
readonly client: EmailClient;
|
|
19
|
+
readonly events: EmailClientEventMap;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare const emailClient: import("@zhin.js/adapter").EndpointClientToken<EmailClient, EmailClientEventMap>;
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineEndpointClient } from 'zhin.js/adapter';
|
|
2
|
+
/** Live SMTP + IMAP client pair exposed to event handlers and plugins. */
|
|
3
|
+
export class EmailClient {
|
|
4
|
+
resolveSmtp;
|
|
5
|
+
resolveImap;
|
|
6
|
+
constructor(resolveSmtp, resolveImap) {
|
|
7
|
+
this.resolveSmtp = resolveSmtp;
|
|
8
|
+
this.resolveImap = resolveImap;
|
|
9
|
+
}
|
|
10
|
+
get smtp() {
|
|
11
|
+
const transport = this.resolveSmtp();
|
|
12
|
+
if (!transport)
|
|
13
|
+
throw new Error('SMTP transporter not connected');
|
|
14
|
+
return transport;
|
|
15
|
+
}
|
|
16
|
+
get imap() {
|
|
17
|
+
const transport = this.resolveImap();
|
|
18
|
+
if (!transport)
|
|
19
|
+
throw new Error('IMAP client not connected');
|
|
20
|
+
return transport;
|
|
21
|
+
}
|
|
22
|
+
verify() {
|
|
23
|
+
return this.smtp.verify();
|
|
24
|
+
}
|
|
25
|
+
sendMail(options) {
|
|
26
|
+
return this.smtp.sendMail(options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const emailClient = defineEndpointClient('email');
|