@zhin.js/core 1.5.16 → 1.7.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.
Files changed (334) hide show
  1. package/README.md +78 -195
  2. package/lib/ai-completion-contract.d.ts +135 -0
  3. package/lib/ai-completion-contract.js +69 -0
  4. package/lib/built/ai-access.d.ts +2 -21
  5. package/lib/built/ai-access.js +1 -46
  6. package/lib/built/ai-outbound/index.d.ts +0 -2
  7. package/lib/built/ai-outbound/index.js +0 -2
  8. package/lib/built/ai-outbound/prompt.d.ts +2 -0
  9. package/lib/built/ai-outbound/prompt.js +2 -0
  10. package/lib/built/ai-outbound/types.d.ts +1 -10
  11. package/lib/built/ai-trigger.d.ts +39 -78
  12. package/lib/built/ai-trigger.js +3 -254
  13. package/lib/built/common-adapter-tools.d.ts +21 -6
  14. package/lib/built/common-adapter-tools.js +28 -17
  15. package/lib/built/generic-segment-mapper.js +4 -1
  16. package/lib/built/html-segment-fallback.d.ts +6 -7
  17. package/lib/built/html-segment-fallback.js +1 -16
  18. package/lib/built/html-to-text.d.ts +0 -3
  19. package/lib/built/html-to-text.js +131 -40
  20. package/lib/built/interaction-messages.d.ts +1 -0
  21. package/lib/built/interaction-messages.js +30 -0
  22. package/lib/built/interactive-segments/action.d.ts +3 -4
  23. package/lib/built/interactive-segments/action.js +2 -5
  24. package/lib/built/interactive-segments/index.d.ts +0 -2
  25. package/lib/built/interactive-segments/index.js +0 -2
  26. package/lib/built/interactive-segments/keyboard-segment.d.ts +0 -1
  27. package/lib/built/interactive-segments/keyboard-segment.js +0 -1
  28. package/lib/built/interactive-segments/onebot-keyboard.d.ts +0 -1
  29. package/lib/built/interactive-segments/onebot-keyboard.js +0 -2
  30. package/lib/built/interactive-segments/resolve.d.ts +2 -3
  31. package/lib/built/interactive-segments/resolve.js +21 -14
  32. package/lib/built/interactive-segments/types.d.ts +2 -7
  33. package/lib/built/interactive-segments/types.js +22 -2
  34. package/lib/built/login-assist.d.ts +330 -25
  35. package/lib/built/login-assist.js +1156 -75
  36. package/lib/built/login-captcha.d.ts +62 -0
  37. package/lib/built/login-captcha.js +107 -0
  38. package/lib/built/message-enrich.d.ts +24 -27
  39. package/lib/built/message-enrich.js +53 -49
  40. package/lib/built/outbound-content-arrays.d.ts +4 -0
  41. package/lib/built/outbound-content-arrays.js +32 -0
  42. package/lib/built/outbound-media-trust.d.ts +46 -0
  43. package/lib/built/outbound-media-trust.js +245 -0
  44. package/lib/built/outbound-media-utils.d.ts +5 -3
  45. package/lib/built/outbound-media-utils.js +5 -3
  46. package/lib/built/readable-link.d.ts +4 -0
  47. package/lib/built/readable-link.js +32 -0
  48. package/lib/built/rich-segments/markdown-to-text.d.ts +1 -2
  49. package/lib/built/rich-segments/markdown-to-text.js +141 -17
  50. package/lib/built/roles.d.ts +141 -12
  51. package/lib/built/roles.js +253 -52
  52. package/lib/built/segment-contract/assert.js +8 -2
  53. package/lib/built/segment-contract/delivery.js +1 -0
  54. package/lib/built/segment-contract/index.d.ts +3 -3
  55. package/lib/built/segment-contract/index.js +2 -2
  56. package/lib/built/segment-contract/json-schema.d.ts +39 -5
  57. package/lib/built/segment-contract/json-schema.js +207 -24
  58. package/lib/built/segment-contract/preview.js +8 -1
  59. package/lib/built/segment-contract/text.js +1 -1
  60. package/lib/built/segment-contract/types.d.ts +2 -2
  61. package/lib/built/segment-contract/validate.d.ts +1553 -224
  62. package/lib/built/segment-contract/validate.js +39 -3
  63. package/lib/built/tool-access.d.ts +5 -0
  64. package/lib/built/tool-access.js +17 -0
  65. package/lib/built/user-interaction.d.ts +5 -4
  66. package/lib/built/user-interaction.js +64 -52
  67. package/lib/errors.d.ts +1 -18
  68. package/lib/errors.js +1 -26
  69. package/lib/feature/command-public-api.d.ts +5 -0
  70. package/lib/feature/command-public-api.js +5 -0
  71. package/lib/feature/command.d.ts +2 -0
  72. package/lib/feature/command.js +1 -0
  73. package/lib/feature/component.d.ts +1 -0
  74. package/lib/feature/component.js +1 -0
  75. package/lib/feature/handler.d.ts +13 -7
  76. package/lib/feature/handler.js +2 -1
  77. package/lib/feature/middleware-public-api.d.ts +6 -0
  78. package/lib/feature/middleware-public-api.js +6 -0
  79. package/lib/feature/middleware.d.ts +22 -2
  80. package/lib/feature/middleware.js +7 -2
  81. package/lib/im-scene.d.ts +4 -3
  82. package/lib/im-scene.js +9 -9
  83. package/lib/im-session-id.d.ts +20 -12
  84. package/lib/im-session-id.js +8 -8
  85. package/lib/index.d.ts +20 -48
  86. package/lib/index.js +15 -41
  87. package/lib/jsx/intrinsic-elements.d.ts +83 -0
  88. package/lib/jsx/message-renderer.d.ts +13 -0
  89. package/lib/jsx/message-renderer.js +128 -0
  90. package/lib/jsx/message-tags.d.ts +133 -0
  91. package/lib/jsx/message-tags.js +50 -0
  92. package/lib/jsx-dev-runtime.d.ts +2 -2
  93. package/lib/jsx-dev-runtime.js +1 -2
  94. package/lib/jsx-runtime.d.ts +2 -12
  95. package/lib/jsx-runtime.js +1 -10
  96. package/lib/jsx.d.ts +6 -30
  97. package/lib/jsx.js +3 -93
  98. package/lib/message.d.ts +0 -40
  99. package/lib/message.js +1 -27
  100. package/lib/models/system-log.d.ts +0 -2
  101. package/lib/models/system-log.js +1 -8
  102. package/lib/models/user.d.ts +0 -2
  103. package/lib/models/user.js +1 -7
  104. package/lib/notice.d.ts +38 -33
  105. package/lib/notice.js +23 -7
  106. package/lib/plugin-runtime/im/command-feedback.d.ts +59 -0
  107. package/lib/plugin-runtime/im/command-feedback.js +148 -0
  108. package/lib/plugin-runtime/im/contracts.d.ts +217 -32
  109. package/lib/plugin-runtime/im/contracts.js +141 -23
  110. package/lib/plugin-runtime/im/conversation-runtime.d.ts +42 -0
  111. package/lib/plugin-runtime/im/conversation-runtime.js +451 -0
  112. package/lib/plugin-runtime/im/endpoint-runtime.d.ts +112 -0
  113. package/lib/plugin-runtime/im/endpoint-runtime.js +434 -0
  114. package/lib/plugin-runtime/im/feature-gate.d.ts +21 -0
  115. package/lib/plugin-runtime/im/feature-gate.js +88 -0
  116. package/lib/plugin-runtime/im/host/component-host-installer.d.ts +2 -0
  117. package/lib/plugin-runtime/im/host/component-host-installer.js +14 -0
  118. package/lib/plugin-runtime/im/host/conversation-migration.d.ts +5 -0
  119. package/lib/plugin-runtime/im/host/conversation-migration.js +75 -0
  120. package/lib/plugin-runtime/im/host/database-config.d.ts +10 -0
  121. package/lib/plugin-runtime/im/host/database-config.js +152 -0
  122. package/lib/plugin-runtime/im/host/database-console-schema.d.ts +79 -0
  123. package/lib/plugin-runtime/im/host/database-console-schema.js +477 -0
  124. package/lib/plugin-runtime/im/host/database-console-sql.d.ts +66 -0
  125. package/lib/plugin-runtime/im/host/database-console-sql.js +459 -0
  126. package/lib/plugin-runtime/im/host/database-host-installer.d.ts +60 -0
  127. package/lib/plugin-runtime/im/host/database-host-installer.js +1166 -0
  128. package/lib/plugin-runtime/im/host/database-state.d.ts +9 -0
  129. package/lib/plugin-runtime/im/host/database-state.js +91 -0
  130. package/lib/plugin-runtime/im/host/index.d.ts +8 -0
  131. package/lib/plugin-runtime/im/host/index.js +8 -0
  132. package/lib/plugin-runtime/im/host/locale-host-installer.d.ts +3 -0
  133. package/lib/plugin-runtime/im/host/locale-host-installer.js +60 -0
  134. package/lib/plugin-runtime/im/host/outbound-host-installer.d.ts +8 -0
  135. package/lib/plugin-runtime/im/host/outbound-host-installer.js +153 -0
  136. package/lib/plugin-runtime/im/host/sender-enrichment.d.ts +34 -0
  137. package/lib/plugin-runtime/im/host/sender-enrichment.js +82 -0
  138. package/lib/plugin-runtime/im/im-runtime.d.ts +40 -111
  139. package/lib/plugin-runtime/im/im-runtime.js +235 -1059
  140. package/lib/plugin-runtime/im/inbound-dedup.d.ts +84 -0
  141. package/lib/plugin-runtime/im/inbound-dedup.js +322 -0
  142. package/lib/plugin-runtime/im/inbound-origin.d.ts +150 -0
  143. package/lib/plugin-runtime/im/inbound-origin.js +183 -0
  144. package/lib/plugin-runtime/im/inbound-runtime.d.ts +59 -0
  145. package/lib/plugin-runtime/im/inbound-runtime.js +478 -0
  146. package/lib/plugin-runtime/im/inbound-spine.d.ts +196 -0
  147. package/lib/plugin-runtime/im/inbound-spine.js +335 -0
  148. package/lib/plugin-runtime/im/index.d.ts +15 -4
  149. package/lib/plugin-runtime/im/index.js +11 -4
  150. package/lib/plugin-runtime/im/interaction-runtime.d.ts +50 -0
  151. package/lib/plugin-runtime/im/interaction-runtime.js +390 -0
  152. package/lib/plugin-runtime/im/interactive-router.d.ts +81 -0
  153. package/lib/plugin-runtime/im/interactive-router.js +382 -0
  154. package/lib/plugin-runtime/im/message-diagnostics.d.ts +70 -0
  155. package/lib/plugin-runtime/im/message-diagnostics.js +182 -0
  156. package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -4
  157. package/lib/plugin-runtime/im/message-dispatcher.js +138 -20
  158. package/lib/plugin-runtime/im/message-events.d.ts +85 -0
  159. package/lib/plugin-runtime/im/message-events.js +113 -0
  160. package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +39 -0
  161. package/lib/plugin-runtime/im/outbound-delivery-runtime.js +450 -0
  162. package/lib/plugin-runtime/im/outbound-renderer.d.ts +52 -3
  163. package/lib/plugin-runtime/im/outbound-renderer.js +188 -8
  164. package/lib/plugin-runtime/im/outbound-segments.d.ts +29 -5
  165. package/lib/plugin-runtime/im/outbound-segments.js +130 -36
  166. package/lib/plugin-runtime/im/progressive-reply.d.ts +58 -0
  167. package/lib/plugin-runtime/im/progressive-reply.js +501 -0
  168. package/lib/plugin-runtime/im/public-api.d.ts +1 -1
  169. package/lib/request.d.ts +27 -36
  170. package/lib/request.js +14 -6
  171. package/lib/side-event/base.d.ts +64 -44
  172. package/lib/side-event/base.js +72 -19
  173. package/lib/side-event/index.d.ts +1 -1
  174. package/lib/side-event/index.js +1 -1
  175. package/lib/side-event/normalize.d.ts +7 -38
  176. package/lib/side-event/normalize.js +4 -109
  177. package/lib/side-event/scene-events.d.ts +40 -0
  178. package/lib/side-event/scene-events.js +147 -0
  179. package/lib/side-event/types.d.ts +4 -13
  180. package/lib/side-event/types.js +1 -55
  181. package/lib/system-event.d.ts +17 -12
  182. package/lib/system-event.js +8 -6
  183. package/lib/types.d.ts +23 -167
  184. package/lib/utils.d.ts +50 -33
  185. package/lib/utils.js +12 -185
  186. package/lib/venue/contracts.d.ts +21 -0
  187. package/lib/venue/contracts.js +3 -0
  188. package/lib/venue/floor-controller.d.ts +11 -0
  189. package/lib/venue/floor-controller.js +63 -0
  190. package/lib/venue/index.d.ts +13 -0
  191. package/lib/venue/index.js +11 -0
  192. package/lib/venue/membership-port.d.ts +23 -0
  193. package/lib/venue/membership-port.js +141 -0
  194. package/lib/venue/projector.d.ts +38 -0
  195. package/lib/venue/projector.js +45 -0
  196. package/lib/venue/registry.d.ts +16 -0
  197. package/lib/venue/registry.js +63 -0
  198. package/lib/venue/router.d.ts +19 -0
  199. package/lib/venue/router.js +101 -0
  200. package/lib/venue/send-limiter.d.ts +17 -0
  201. package/lib/venue/send-limiter.js +73 -0
  202. package/lib/venue/validator.d.ts +6 -0
  203. package/lib/venue/validator.js +160 -0
  204. package/package.json +24 -50
  205. package/lib/adapter.d.ts +0 -145
  206. package/lib/adapter.js +0 -377
  207. package/lib/built/adapter-process.d.ts +0 -58
  208. package/lib/built/adapter-process.js +0 -128
  209. package/lib/built/agent-preset.d.ts +0 -64
  210. package/lib/built/agent-preset.js +0 -79
  211. package/lib/built/ai-outbound/adapter-access.d.ts +0 -3
  212. package/lib/built/ai-outbound/adapter-access.js +0 -9
  213. package/lib/built/ai-outbound/extensions/qq-message.d.ts +0 -3
  214. package/lib/built/ai-outbound/extensions/qq-message.js +0 -23
  215. package/lib/built/authorization.d.ts +0 -10
  216. package/lib/built/authorization.js +0 -76
  217. package/lib/built/command.d.ts +0 -72
  218. package/lib/built/command.js +0 -105
  219. package/lib/built/component.d.ts +0 -67
  220. package/lib/built/component.js +0 -97
  221. package/lib/built/config.d.ts +0 -98
  222. package/lib/built/config.js +0 -372
  223. package/lib/built/connect-endpoint-instance.d.ts +0 -17
  224. package/lib/built/connect-endpoint-instance.js +0 -42
  225. package/lib/built/database.d.ts +0 -68
  226. package/lib/built/database.js +0 -106
  227. package/lib/built/dispatcher.d.ts +0 -141
  228. package/lib/built/dispatcher.js +0 -383
  229. package/lib/built/endpoint-commands.d.ts +0 -3
  230. package/lib/built/endpoint-commands.js +0 -99
  231. package/lib/built/endpoint-lifecycle-service.d.ts +0 -28
  232. package/lib/built/endpoint-lifecycle-service.js +0 -242
  233. package/lib/built/endpoint-lifecycle.d.ts +0 -27
  234. package/lib/built/endpoint-lifecycle.js +0 -36
  235. package/lib/built/endpoint-manager.d.ts +0 -34
  236. package/lib/built/html-renderer-loader.d.ts +0 -13
  237. package/lib/built/html-renderer-loader.js +0 -33
  238. package/lib/built/inbound-pipeline.d.ts +0 -37
  239. package/lib/built/inbound-pipeline.js +0 -63
  240. package/lib/built/inbound-runner.d.ts +0 -22
  241. package/lib/built/inbound-runner.js +0 -34
  242. package/lib/built/interactive-segment-contract.d.ts +0 -6
  243. package/lib/built/interactive-segment-contract.js +0 -9
  244. package/lib/built/interactive-segments/fallback-store.d.ts +0 -29
  245. package/lib/built/interactive-segments/fallback-store.js +0 -63
  246. package/lib/built/interactive-segments/handlers.d.ts +0 -16
  247. package/lib/built/interactive-segments/handlers.js +0 -74
  248. package/lib/built/introspection-format.d.ts +0 -10
  249. package/lib/built/introspection-format.js +0 -28
  250. package/lib/built/management-command-guard.d.ts +0 -15
  251. package/lib/built/management-command-guard.js +0 -25
  252. package/lib/built/message-filter.d.ts +0 -176
  253. package/lib/built/message-filter.js +0 -239
  254. package/lib/built/optional-peer-import.d.ts +0 -3
  255. package/lib/built/optional-peer-import.js +0 -33
  256. package/lib/built/outbound-media-contract.d.ts +0 -22
  257. package/lib/built/outbound-media-contract.js +0 -10
  258. package/lib/built/permission.d.ts +0 -51
  259. package/lib/built/permission.js +0 -99
  260. package/lib/built/permit-check.d.ts +0 -7
  261. package/lib/built/permit-check.js +0 -35
  262. package/lib/built/permit-parse.d.ts +0 -16
  263. package/lib/built/permit-parse.js +0 -32
  264. package/lib/built/platform-permit.d.ts +0 -20
  265. package/lib/built/platform-permit.js +0 -91
  266. package/lib/built/queue-im-field-contract.d.ts +0 -32
  267. package/lib/built/queue-im-field-contract.js +0 -67
  268. package/lib/built/rich-segments/adapter-policies.d.ts +0 -9
  269. package/lib/built/rich-segments/adapter-policies.js +0 -27
  270. package/lib/built/rich-segments/base.d.ts +0 -11
  271. package/lib/built/rich-segments/base.js +0 -24
  272. package/lib/built/rich-segments/builtins.d.ts +0 -4
  273. package/lib/built/rich-segments/builtins.js +0 -40
  274. package/lib/built/rich-segments/capabilities.d.ts +0 -6
  275. package/lib/built/rich-segments/capabilities.js +0 -38
  276. package/lib/built/rich-segments/html-segment.d.ts +0 -15
  277. package/lib/built/rich-segments/html-segment.js +0 -62
  278. package/lib/built/rich-segments/index.d.ts +0 -13
  279. package/lib/built/rich-segments/index.js +0 -13
  280. package/lib/built/rich-segments/markdown-segment.d.ts +0 -14
  281. package/lib/built/rich-segments/markdown-segment.js +0 -58
  282. package/lib/built/rich-segments/qrcode-segment.d.ts +0 -18
  283. package/lib/built/rich-segments/qrcode-segment.js +0 -73
  284. package/lib/built/rich-segments/registry.d.ts +0 -16
  285. package/lib/built/rich-segments/registry.js +0 -52
  286. package/lib/built/rich-segments/resolve.d.ts +0 -5
  287. package/lib/built/rich-segments/resolve.js +0 -87
  288. package/lib/built/rich-segments/tts-segment.d.ts +0 -13
  289. package/lib/built/rich-segments/tts-segment.js +0 -51
  290. package/lib/built/rich-segments/types.d.ts +0 -79
  291. package/lib/built/rich-segments/types.js +0 -17
  292. package/lib/built/runtime-io.d.ts +0 -9
  293. package/lib/built/runtime-io.js +0 -67
  294. package/lib/built/schedule.d.ts +0 -54
  295. package/lib/built/schedule.js +0 -112
  296. package/lib/built/schema-endpoint-manager.d.ts +0 -17
  297. package/lib/built/schema-endpoint-manager.js +0 -73
  298. package/lib/built/schema-feature.d.ts +0 -77
  299. package/lib/built/schema-feature.js +0 -130
  300. package/lib/built/skill.d.ts +0 -120
  301. package/lib/built/skill.js +0 -151
  302. package/lib/built/speech-loader.d.ts +0 -14
  303. package/lib/built/speech-loader.js +0 -32
  304. package/lib/built/tool.d.ts +0 -151
  305. package/lib/built/tool.js +0 -388
  306. package/lib/command.d.ts +0 -50
  307. package/lib/command.js +0 -106
  308. package/lib/component.d.ts +0 -26
  309. package/lib/component.js +0 -583
  310. package/lib/endpoint-capabilities.d.ts +0 -46
  311. package/lib/endpoint-capabilities.js +0 -55
  312. package/lib/endpoint.d.ts +0 -19
  313. package/lib/endpoint.js +0 -3
  314. package/lib/host-plugin-registry.d.ts +0 -8
  315. package/lib/host-plugin-registry.js +0 -12
  316. package/lib/plugin-context.d.ts +0 -27
  317. package/lib/plugin-context.js +0 -64
  318. package/lib/plugin-runtime/im/interactive.d.ts +0 -26
  319. package/lib/plugin-runtime/im/interactive.js +0 -46
  320. package/lib/plugin-runtime/im/login-assist-host.d.ts +0 -6
  321. package/lib/plugin-runtime/im/login-assist-host.js +0 -6
  322. package/lib/plugin-runtime/im/message-bus.d.ts +0 -38
  323. package/lib/plugin-runtime/im/message-bus.js +0 -40
  324. package/lib/plugin-runtime/im/service-tokens.d.ts +0 -18
  325. package/lib/plugin-runtime/im/service-tokens.js +0 -13
  326. package/lib/plugin.d.ts +0 -268
  327. package/lib/plugin.js +0 -583
  328. package/lib/schema-interaction.d.ts +0 -117
  329. package/lib/schema-interaction.js +0 -247
  330. package/lib/side-event/dispatch.d.ts +0 -15
  331. package/lib/side-event/dispatch.js +0 -140
  332. package/lib/tool-zod.d.ts +0 -43
  333. package/lib/tool-zod.js +0 -184
  334. /package/lib/{built/endpoint-manager.js → jsx/intrinsic-elements.js} +0 -0
@@ -1,55 +1 @@
1
- /**
2
- * Side Event 标准类型。
3
- * 运行时 `$type` 仅存命名空间(`notice` / `request` / `system`);
4
- * 完整名由 `${$type}.${$scene_type}.${$sub_type}` 组合。
5
- */
6
- /** OneBot / icqq 等平台 notice_type 原始值 → 标准 scene_type + sub_type */
7
- export const ONEBOT_NOTICE_PARTS_MAP = {
8
- group_increase: { scene_type: 'group', sub_type: 'member_increase' },
9
- group_decrease: { scene_type: 'group', sub_type: 'member_decrease' },
10
- group_admin: { scene_type: 'group', sub_type: 'admin_change' },
11
- group_ban: { scene_type: 'group', sub_type: 'ban' },
12
- group_recall: { scene_type: 'group', sub_type: 'recall' },
13
- friend_recall: { scene_type: 'friend', sub_type: 'recall' },
14
- friend_add: { scene_type: 'friend', sub_type: 'increase' },
15
- group_upload: { scene_type: 'group', sub_type: 'upload' },
16
- group_transfer: { scene_type: 'group', sub_type: 'transfer' },
17
- group_card: { scene_type: 'group', sub_type: 'card_change' },
18
- group_msg_emoji_like: { scene_type: 'group', sub_type: 'emoji_reaction' },
19
- 'group.increase': { scene_type: 'group', sub_type: 'member_increase' },
20
- 'group.decrease': { scene_type: 'group', sub_type: 'member_decrease' },
21
- 'group.admin': { scene_type: 'group', sub_type: 'admin_change' },
22
- 'group.ban': { scene_type: 'group', sub_type: 'ban' },
23
- 'group.recall': { scene_type: 'group', sub_type: 'recall' },
24
- 'friend.increase': { scene_type: 'friend', sub_type: 'increase' },
25
- 'friend.decrease': { scene_type: 'friend', sub_type: 'recall' },
26
- 'friend.recall': { scene_type: 'friend', sub_type: 'recall' },
27
- };
28
- /** KOOK extra.type 原始值 → 标准 scene_type + sub_type */
29
- export const KOOK_NOTICE_PARTS_MAP = {
30
- joined_guild: { scene_type: 'group', sub_type: 'member_increase' },
31
- exited_guild: { scene_type: 'group', sub_type: 'member_decrease' },
32
- deleted_message: { scene_type: 'group', sub_type: 'recall' },
33
- deleted_private_message: { scene_type: 'friend', sub_type: 'recall' },
34
- added_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
35
- deleted_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
36
- private_added_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
37
- private_deleted_reaction: { scene_type: 'group', sub_type: 'emoji_reaction' },
38
- };
39
- /** Slack event type 原始值 → 标准 scene_type + sub_type */
40
- export const SLACK_NOTICE_PARTS_MAP = {
41
- member_joined_channel: { scene_type: 'group', sub_type: 'member_increase' },
42
- member_left_channel: { scene_type: 'group', sub_type: 'member_decrease' },
43
- reaction_added: { scene_type: 'group', sub_type: 'emoji_reaction' },
44
- reaction_removed: { scene_type: 'group', sub_type: 'emoji_reaction' },
45
- message_deleted: { scene_type: 'group', sub_type: 'recall' },
46
- channel_archive: { scene_type: 'slack', sub_type: 'channel_archive' },
47
- channel_unarchive: { scene_type: 'slack', sub_type: 'channel_unarchive' },
48
- channel_rename: { scene_type: 'slack', sub_type: 'channel_rename' },
49
- channel_created: { scene_type: 'slack', sub_type: 'channel_created' },
50
- channel_deleted: { scene_type: 'slack', sub_type: 'channel_deleted' },
51
- pin_added: { scene_type: 'slack', sub_type: 'pin_added' },
52
- pin_removed: { scene_type: 'slack', sub_type: 'pin_removed' },
53
- app_home_opened: { scene_type: 'slack', sub_type: 'app_home_opened' },
54
- team_join: { scene_type: 'friend', sub_type: 'increase' },
55
- };
1
+ export {};
@@ -1,15 +1,20 @@
1
- import type { Adapters } from './adapter.js';
2
- import type { SideEventBase } from './side-event/base.js';
3
- /**
4
- * 系统/登录侧事件(扫码、滑块、掉线等)。
5
- * `$scene_type`:`login` / `offline` / `online` 等;
6
- * `$sub_type`:`qrcode` / `slider` / `device` / `kickoff` / `network` 等。
7
- */
8
- export interface SystemEventBase extends SideEventBase {
9
- $adapter: keyof Adapters;
10
- $type: 'system';
1
+ import type { ComposedSystemName } from './side-event/types.js';
2
+ import { RuntimeEndpointEvent, type IncomingEndpointEvent, type EndpointEventBase, type EndpointEventContext } from './side-event/base.js';
3
+ export type { ComposedSystemName, SystemKind } from './side-event/types.js';
4
+ export type { IncomingEndpointEvent, EndpointEventBase } from './side-event/base.js';
5
+ export interface IncomingSystemEvent extends IncomingEndpointEvent {
6
+ readonly type: 'system';
7
+ readonly name: ComposedSystemName;
8
+ }
9
+ export interface SystemEventBase extends EndpointEventBase {
10
+ readonly type: 'system';
11
+ readonly name: ComposedSystemName;
11
12
  }
12
13
  export type SystemEvent<T extends object = {}> = SystemEventBase & T;
13
- export declare namespace SystemEvent {
14
- function from<T extends object>(input: T, format: SystemEventBase): SystemEvent<T>;
14
+ /** @internal Endpoint lifecycle signals do not imply a conversation. */
15
+ export declare class RuntimeSystemEvent extends RuntimeEndpointEvent implements SystemEventBase {
16
+ readonly type: 'system';
17
+ readonly name: ComposedSystemName;
18
+ constructor(input: IncomingSystemEvent, context: EndpointEventContext);
15
19
  }
20
+ export declare const SystemEvent: typeof RuntimeSystemEvent;
@@ -1,7 +1,9 @@
1
- export var SystemEvent;
2
- (function (SystemEvent) {
3
- function from(input, format) {
4
- return Object.assign(input, format);
1
+ import { RuntimeEndpointEvent } from './side-event/base.js';
2
+ /** @internal Endpoint lifecycle signals do not imply a conversation. */
3
+ export class RuntimeSystemEvent extends RuntimeEndpointEvent {
4
+ constructor(input, context) {
5
+ super(input, context);
6
+ Object.freeze(this);
5
7
  }
6
- SystemEvent.from = from;
7
- })(SystemEvent || (SystemEvent = {}));
8
+ }
9
+ export const SystemEvent = RuntimeSystemEvent;
package/lib/types.d.ts CHANGED
@@ -1,95 +1,22 @@
1
- import type { MessageChannel, Message, MessageComponent } from './message.js';
2
- import { Adapter, Adapters } from './adapter.js';
3
- import { Endpoint } from './endpoint.js';
1
+ import type { MessageChannel } from './message.js';
2
+ import type { Message } from './plugin-runtime/im/contracts.js';
4
3
  import { SystemLog } from './models/system-log.js';
5
4
  import { User } from './models/user.js';
6
- import { Databases, Registry } from '@zhin.js/database';
7
- import { ProcessAdapter } from './built/adapter-process.js';
8
- export type { SenderRole } from "./built/roles.js";
9
- export type ArrayItem<T> = T extends Array<infer R> ? R : unknown;
10
5
  export interface Models extends Record<string, object> {
11
6
  SystemLog: SystemLog;
12
7
  User: User;
13
8
  }
14
9
  export type MaybePromise<T> = [T] extends [Promise<infer U>] ? T | U : T | Promise<T>;
15
- export interface RegisteredAdapters extends Adapters {
16
- process: ProcessAdapter;
17
- }
18
- /**
19
- * 数据库配置类型,支持多种数据库驱动
20
- */
21
- export type DatabaseConfig<T extends keyof Databases = keyof Databases> = {
22
- dialect: T;
23
- } & Registry.Config[T];
24
- /**
25
- * 获取对象所有value类型
26
- */
27
- export type ObjectItem<T extends object> = T[keyof T];
28
- /**
29
- * 已注册适配器名类型
30
- */
31
- export type RegisteredAdapter = Extract<keyof RegisteredAdapters, string>;
32
- /**
33
- * 指定适配器的消息类型
34
- */
35
- export type AdapterMessage<T extends keyof RegisteredAdapters = keyof RegisteredAdapters> = RegisteredAdapters[T] extends Adapter<infer R> ? EndpointMessage<R> : {};
36
- /**
37
- * 指定适配器的配置类型
38
- */
39
- export type AdapterConfig<T extends keyof RegisteredAdapters = keyof RegisteredAdapters> = RegisteredAdapters[T] extends Adapter<infer R> ? PlatformConfig<R> : Endpoint.Config;
40
- /**
41
- * Bot实例的配置类型
42
- */
43
- export type PlatformConfig<T> = T extends Endpoint<infer L, infer R> ? R : Endpoint.Config;
44
- /**
45
- * Bot实例的消息类型
46
- */
47
- export type EndpointMessage<T extends Endpoint> = T extends Endpoint<infer R> ? R : {};
48
10
  /**
49
11
  * 消息段结构,支持 text/image/at/face 等类型
50
12
  */
51
- export interface MessageSegment {
52
- type: string;
53
- data: Record<string, any>;
54
- }
55
- export type MessageElement = MessageSegment | MessageComponent<any>;
56
- /**
57
- * 单个或数组类型
58
- */
59
- export type MaybeArray<T> = T | T[];
13
+ export type { Segment as MessageSegment } from './built/segment-contract/types.js';
14
+ export type MessageElement = import('./built/segment-contract/types.js').Segment;
60
15
  /**
61
16
  * 消息发送内容类型
62
17
  */
63
- export type SendContent = MaybeArray<string | MessageElement>;
64
- /** 可选:编辑已发送消息(交互式棋盘更新) */
65
- export interface EditMessageOptions {
66
- messageId: string;
67
- context: string;
68
- endpoint: string;
69
- id: string;
70
- type: 'private' | 'group' | 'channel';
71
- content: SendContent;
72
- }
73
- /** 出站回复来源(指令 / AI / proactive),仅当经 MessageDispatcher.replyWithPolish 或 runWithOutboundPolish 发出时由框架填入异步上下文 */
74
- export type OutboundReplySource = 'command' | 'ai' | 'proactive';
75
- export type OutboundReplyTrigger = 'inbound' | 'proactive';
76
- export interface OutboundReplyStore {
77
- message: Message;
78
- source: OutboundReplySource;
79
- trigger: OutboundReplyTrigger;
80
- proactiveSource?: string;
81
- }
82
- /**
83
- * 出站润色上下文(`dispatcher.addOutboundPolish` 的 handler 签名的同构类型)。
84
- * 与 {@link Adapter.sendMessage} → `before.sendMessage` 同一管道;需 `message`/`source` 时见 `getOutboundReplyStore`(dispatcher 导出)。
85
- */
86
- export interface OutboundPolishContext {
87
- message: Message;
88
- content: SendContent;
89
- source: OutboundReplySource;
90
- }
91
- /** 返回 `SendContent` 则替换后续 `before.sendMessage` 与发送中的 content */
92
- export type OutboundPolishMiddleware = (ctx: OutboundPolishContext) => MaybePromise<SendContent | void>;
18
+ export type { SendContent } from './plugin-runtime/im/contracts.js';
19
+ import type { SendContent } from './plugin-runtime/im/contracts.js';
93
20
  /**
94
21
  * 消息发送者信息
95
22
  */
@@ -108,15 +35,6 @@ export interface MessageSender {
108
35
  * 通用字典类型
109
36
  */
110
37
  export type { Dict } from '@zhin.js/kernel';
111
- /**
112
- * 用户信息结构
113
- */
114
- export interface UserInfo {
115
- user_id: string;
116
- nickname: string;
117
- card?: string;
118
- role?: string;
119
- }
120
38
  /**
121
39
  * 群组信息结构
122
40
  */
@@ -125,39 +43,14 @@ export interface Group {
125
43
  group_name: string;
126
44
  member_count: number;
127
45
  }
128
- /** 消息中间件函数 */
129
- export type MessageMiddleware<P extends RegisteredAdapter = RegisteredAdapter> = (message: Message<AdapterMessage<P>>, next: () => Promise<void>) => MaybePromise<void>;
130
- /**
131
- * defineConfig辅助类型,支持函数式/对象式配置
132
- */
133
- export type DefineConfig<T> = T | ((env: Record<string, string>) => MaybePromise<T>);
134
46
  export interface SendOptions extends MessageChannel {
47
+ locale?: import('@zhin.js/plugin-runtime').Locale;
135
48
  context: string;
136
49
  endpoint: string;
137
50
  content: SendContent;
138
51
  quoteId?: string;
139
52
  threadId?: string;
140
53
  }
141
- /** `Adapter.sendMessage` 成功发出后由 core 分发的载荷 */
142
- export interface MessageSendPayload {
143
- adapter: string;
144
- options: SendOptions;
145
- messageId: string;
146
- /** 经 `replyWithPolish` 发出时由 dispatcher 填入 */
147
- replySource?: OutboundReplySource;
148
- /** 触发回复的入站消息(replyWithPolish 时可用) */
149
- replyMessage?: Message;
150
- }
151
- export interface ProcessMessage {
152
- type: string;
153
- pid?: number;
154
- body: any;
155
- }
156
- export type QueueItem = {
157
- action: string;
158
- payload: any;
159
- };
160
- export type BeforeSendHandler = (options: SendOptions) => MaybePromise<SendOptions | void>;
161
54
  /**
162
55
  * JSON Schema 定义,用于描述工具参数
163
56
  */
@@ -222,13 +115,11 @@ export interface ToolParametersSchema<TArgs extends Record<string, any> = Record
222
115
  * 统一的 Tool 定义
223
116
  * 可同时用于:
224
117
  * - AI Agent 工具调用
225
- * - 自动生成 Command
226
118
  * - MCP 工具暴露
227
119
  *
228
120
  * @example
229
121
  * ```typescript
230
- * // 使用 defineTool 获得类型安全
231
- * const weatherTool = defineTool<{ city: string }>({
122
+ * const weatherTool: Tool<{ city: string }> = {
232
123
  * name: 'weather',
233
124
  * description: '查询天气',
234
125
  * parameters: {
@@ -241,9 +132,8 @@ export interface ToolParametersSchema<TArgs extends Record<string, any> = Record
241
132
  * execute: async (args) => {
242
133
  * return `${args.city} 的天气是晴天`; // args.city 有类型提示
243
134
  * },
244
- * });
135
+ * };
245
136
  *
246
- * plugin.addTool(weatherTool); // 无需类型断言
247
137
  * ```
248
138
  */
249
139
  /**
@@ -272,13 +162,6 @@ export type ToolResult = string | void | null | undefined | {
272
162
  data: unknown;
273
163
  format?: string;
274
164
  } | Record<string, unknown> | unknown[];
275
- /** 工具关联的聊天命令配置(可选;需自行 addCommand 注册) */
276
- export interface ToolCommandConfig {
277
- pattern: string;
278
- alias?: string[];
279
- usage?: string | string[];
280
- examples?: string | string[];
281
- }
282
165
  /**
283
166
  * 统一的 Tool 定义(支持泛型参数类型推断)。
284
167
  *
@@ -286,15 +169,15 @@ export interface ToolCommandConfig {
286
169
  *
287
170
  * @example
288
171
  * ```typescript
289
- * // 无泛型 — 兼容旧代码
172
+ * // 无泛型
290
173
  * const tool: Tool = { name: 'ping', ... };
291
174
  *
292
- * // 有泛型 — 通过 defineTool 获得类型安全
293
- * const tool = defineTool<{ city: string }>({
175
+ * // 有泛型
176
+ * const tool: Tool<{ city: string }> = {
294
177
  * name: 'weather',
295
178
  * parameters: { type: 'object', properties: { city: { type: 'string', description: '城市' } }, required: ['city'] },
296
179
  * execute: async (args) => args.city, // args.city 有类型提示
297
- * });
180
+ * };
298
181
  * ```
299
182
  */
300
183
  export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
@@ -310,20 +193,24 @@ export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
310
193
  * @param message 通讯上下文(入站 Message 或合成 Message)
311
194
  * @returns 执行结果
312
195
  */
313
- execute: (args: TArgs, message?: Message<any>) => MaybePromise<ToolResult>;
196
+ execute: (args: TArgs, message?: Message) => MaybePromise<ToolResult>;
314
197
  /** 工具来源标识(自动填充:adapter:xxx / plugin:xxx) */
315
198
  source?: string;
316
199
  /** 工具标签(用于分类和过滤) */
317
200
  tags?: string[];
318
201
  /** 触发关键词(用户消息包含这些词时优先选择此工具) */
319
202
  keywords?: string[];
320
- /**
321
- * 权限要求(旧版,保留兼容)
322
- * 执行此工具需要的权限列表
323
- */
203
+ /** 执行此工具需要满足的权限列表。 */
324
204
  permissions?: string[];
325
205
  /** Per-tool approval policy; `on-risk` remains fail-closed at Agent boundaries. */
326
- approval?: 'always' | 'once' | 'never' | 'on-risk';
206
+ requiresApproval?: 'always' | 'once' | 'never' | 'on-risk' | 'human';
207
+ /**
208
+ * Hard-gate risk (ADR 0036): `dangerous` tools never run without a fresh human approval,
209
+ * independent of `requiresApproval` and `execApprovalMode`. The Host may only raise it.
210
+ */
211
+ risk?: 'dangerous' | 'safe';
212
+ /** Dangerous category: member / publish / funds (disabled by default) / identity. */
213
+ riskCategory?: 'member' | 'publish' | 'funds' | 'identity';
327
214
  /**
328
215
  * 支持的平台列表
329
216
  * 例如:['qq', 'telegram', 'discord']
@@ -350,35 +237,4 @@ export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
350
237
  preExecutable?: boolean;
351
238
  /** 工具分类(如 file / shell / web),用于展示与 TOOLS.md 协同 */
352
239
  kind?: string;
353
- /**
354
- * 可选:关联的 IM 命令模式(历史字段;需自行 addCommand 注册聊天命令)。
355
- * `false` 表示明确不暴露为命令。
356
- */
357
- command?: ToolCommandConfig | false;
358
- }
359
- export declare namespace Tool {
360
- /**
361
- * 参数信息
362
- */
363
- interface ParamInfo {
364
- name: string;
365
- type: string;
366
- required: boolean;
367
- description?: string;
368
- default?: any;
369
- enum?: any[];
370
- }
371
- }
372
- /**
373
- * 插件清单元数据(从 plugin.yml 解析)
374
- */
375
- export interface PluginManifest {
376
- /** 插件名称 */
377
- name: string;
378
- /** 插件描述 */
379
- description?: string;
380
- /** 插件版本 */
381
- version?: string;
382
240
  }
383
- /** @deprecated 使用 Tool 替代 */
384
- export type AITool = Tool;
package/lib/utils.d.ts CHANGED
@@ -2,26 +2,14 @@
2
2
  * @zhin.js/core utilities.
3
3
  *
4
4
  * Generic utilities are re-exported from @zhin.js/kernel.
5
- * IM-specific utilities (compose, segment) remain here.
5
+ * IM-specific utilities (segment) remain here.
6
6
  */
7
- export { evaluate, execute, clearEvalCache, getEvalCacheStats, getValueWithRuntime, compiler, remove, isEmpty, Time, supportedPluginExtensions, resolveEntry, sleep, } from '@zhin.js/kernel';
8
- import { AdapterMessage, MessageMiddleware, RegisteredAdapter, SendContent } from "./types.js";
9
- import { Message } from "./message.js";
10
- import { HtmlSegment } from "./built/rich-segments/html-segment.js";
11
- import { MarkdownSegment } from "./built/rich-segments/markdown-segment.js";
12
- import { QrcodeSegment } from "./built/rich-segments/qrcode-segment.js";
13
- import { TtsSegment } from "./built/rich-segments/tts-segment.js";
7
+ export { Time, sleep } from '@zhin.js/kernel';
8
+ import type { MessageElement } from "./types.js";
14
9
  import { KeyboardSegment } from "./built/interactive-segments/keyboard-segment.js";
15
10
  import { ButtonSpec, type KeyboardRowInput } from "./built/interactive-segments/button-spec.js";
16
- import type { ButtonData, KeyboardFallback, KeyboardSegmentData } from "./built/interactive-segments/types.js";
11
+ import type { ButtonData, KeyboardFallback } from "./built/interactive-segments/types.js";
17
12
  import type { MediaRef } from "./built/segment-contract/types.js";
18
- /**
19
- * 组合中间件,洋葱模型
20
- *
21
- * 空中间件列表时必须仍调用 `next`——入站管线把 MessageDispatcher
22
- * 作为 terminal next 传入;吞掉 next 会导致命令/AI 永远不跑。
23
- */
24
- export declare function compose<P extends RegisteredAdapter = RegisteredAdapter>(middlewares: MessageMiddleware<P>[]): (message: Message<AdapterMessage<P>>, next?: () => Promise<void>) => Promise<void>;
25
13
  export declare function segment<T extends object>(type: string, data: T): {
26
14
  type: string;
27
15
  data: T;
@@ -62,44 +50,73 @@ export declare namespace segment {
62
50
  text: string | undefined;
63
51
  };
64
52
  };
65
- /** 出站 HTML 卡片段(Adapter policy 决定 image/text/origin) */
53
+ /** 出站 HTML 卡片段(统一出站链路决定渲染或文本降级)。 */
66
54
  function htmlCard(options: {
67
55
  html: string;
68
56
  text?: string;
69
57
  width?: number;
70
58
  backgroundColor?: string;
71
59
  fileName?: string;
72
- }): HtmlSegment;
60
+ }): {
61
+ type: string;
62
+ data: {
63
+ html: string;
64
+ text?: string;
65
+ width?: number;
66
+ backgroundColor?: string;
67
+ fileName?: string;
68
+ };
69
+ };
73
70
  /** Short alias for {@link htmlCard}. */
74
71
  const html: typeof htmlCard;
75
- /** 出站 Markdown 段(Adapter policy 决定 image/text/origin) */
76
- function markdown(content: string, options?: Omit<MarkdownSegment['data'], 'content'>): MarkdownSegment;
77
- /** 二维码出站段(Adapter policy 决定 image/text/origin) */
72
+ /** 出站 Markdown 段。 */
73
+ function markdown(content: string, options?: {
74
+ width?: number;
75
+ backgroundColor?: string;
76
+ fileName?: string;
77
+ }): {
78
+ type: string;
79
+ data: {
80
+ width?: number;
81
+ backgroundColor?: string;
82
+ fileName?: string;
83
+ content: string;
84
+ };
85
+ };
86
+ /** 二维码出站段。 */
78
87
  function qrcode(text: string, options?: {
79
88
  width?: number;
80
89
  margin?: number;
81
90
  errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
82
91
  small?: boolean;
83
- }): QrcodeSegment;
84
- /** TTS 出站段(Adapter policy 决定 audio/text/origin) */
92
+ }): {
93
+ type: string;
94
+ data: {
95
+ width?: number;
96
+ margin?: number;
97
+ errorCorrectionLevel?: "L" | "M" | "Q" | "H";
98
+ small?: boolean;
99
+ text: string;
100
+ };
101
+ };
102
+ /** TTS 出站段。 */
85
103
  function tts(options: {
86
104
  text: string;
87
105
  voice?: string;
88
106
  provider?: string;
89
- }): TtsSegment;
107
+ }): {
108
+ type: string;
109
+ data: {
110
+ text: string;
111
+ voice?: string;
112
+ provider?: string;
113
+ };
114
+ };
90
115
  /** 键盘按钮单元(与 {@link keyboard} 组合布局) */
91
116
  function button(data: ButtonData): ButtonSpec;
92
117
  /** 键盘布局出站段(Adapter interactivePolicy 决定 native/text) */
93
118
  function keyboard(rows: KeyboardRowInput[], options?: {
94
119
  fallback?: KeyboardFallback;
95
120
  }): KeyboardSegment;
96
- /**
97
- * @deprecated 使用 {@link keyboard} + {@link button};文本请用 `segment.text` 单独发送
98
- */
99
- function interactive(data: KeyboardSegmentData & {
100
- text?: SendContent;
101
- }): KeyboardSegment;
102
- function from(content: SendContent): SendContent;
103
- function raw(content: SendContent): string;
104
- function toString(content: SendContent): string;
121
+ function raw(content: string | MessageElement | readonly (string | MessageElement)[]): string;
105
122
  }