@zhin.js/core 1.3.2 → 1.3.4

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 (416) hide show
  1. package/README.md +7 -7
  2. package/lib/adapter.d.ts +22 -2
  3. package/lib/adapter.js +72 -2
  4. package/lib/agent-prompt.d.ts +0 -1
  5. package/lib/agent-prompt.js +0 -1
  6. package/lib/built/adapter-process.d.ts +0 -1
  7. package/lib/built/adapter-process.js +0 -1
  8. package/lib/built/agent-preset.d.ts +0 -1
  9. package/lib/built/agent-preset.js +0 -1
  10. package/lib/built/ai-access.d.ts +36 -0
  11. package/lib/built/ai-access.js +46 -0
  12. package/lib/built/ai-outbound/adapter-access.d.ts +3 -0
  13. package/lib/built/ai-outbound/adapter-access.js +9 -0
  14. package/lib/built/ai-outbound/extensions/onebot-keyboard.d.ts +2 -0
  15. package/lib/built/ai-outbound/extensions/onebot-keyboard.js +67 -0
  16. package/lib/built/ai-outbound/extensions/qq-message.d.ts +3 -0
  17. package/lib/built/ai-outbound/extensions/qq-message.js +23 -0
  18. package/lib/built/ai-outbound/index.d.ts +9 -0
  19. package/lib/built/ai-outbound/index.js +9 -0
  20. package/lib/built/ai-outbound/parse.d.ts +13 -0
  21. package/lib/built/ai-outbound/parse.js +108 -0
  22. package/lib/built/ai-outbound/plain-mention-rewrite.d.ts +6 -0
  23. package/lib/built/ai-outbound/plain-mention-rewrite.js +37 -0
  24. package/lib/built/ai-outbound/prompt.d.ts +11 -0
  25. package/lib/built/ai-outbound/prompt.js +44 -0
  26. package/lib/built/ai-outbound/resolve.d.ts +4 -0
  27. package/lib/built/ai-outbound/resolve.js +64 -0
  28. package/lib/built/ai-outbound/structured-detect.d.ts +3 -0
  29. package/lib/built/ai-outbound/structured-detect.js +7 -0
  30. package/lib/built/ai-outbound/types.d.ts +60 -0
  31. package/lib/built/ai-outbound/types.js +5 -0
  32. package/lib/built/ai-trigger.d.ts +5 -1
  33. package/lib/built/ai-trigger.js +3 -7
  34. package/lib/built/authorization.d.ts +0 -1
  35. package/lib/built/authorization.js +0 -1
  36. package/lib/built/command.d.ts +0 -1
  37. package/lib/built/command.js +1 -3
  38. package/lib/built/common-adapter-tools.d.ts +25 -26
  39. package/lib/built/common-adapter-tools.js +48 -49
  40. package/lib/built/component.d.ts +1 -3
  41. package/lib/built/component.js +2 -4
  42. package/lib/built/config.d.ts +4 -1
  43. package/lib/built/config.js +26 -5
  44. package/lib/built/connect-endpoint-instance.d.ts +0 -1
  45. package/lib/built/connect-endpoint-instance.js +3 -2
  46. package/lib/built/database.d.ts +1 -3
  47. package/lib/built/database.js +2 -4
  48. package/lib/built/dispatcher.d.ts +7 -7
  49. package/lib/built/dispatcher.js +20 -8
  50. package/lib/built/endpoint-commands.d.ts +0 -1
  51. package/lib/built/endpoint-commands.js +6 -9
  52. package/lib/built/endpoint-lifecycle-service.d.ts +2 -1
  53. package/lib/built/endpoint-lifecycle-service.js +26 -3
  54. package/lib/built/endpoint-lifecycle.d.ts +0 -1
  55. package/lib/built/endpoint-lifecycle.js +4 -4
  56. package/lib/built/endpoint-manager.d.ts +0 -1
  57. package/lib/built/endpoint-manager.js +0 -1
  58. package/lib/built/generated-qrcode.d.ts +0 -1
  59. package/lib/built/generated-qrcode.js +0 -1
  60. package/lib/built/generic-segment-mapper.d.ts +6 -0
  61. package/lib/built/generic-segment-mapper.js +232 -0
  62. package/lib/built/html-renderer-loader.d.ts +2 -1
  63. package/lib/built/html-renderer-loader.js +6 -2
  64. package/lib/built/html-segment-fallback.d.ts +0 -1
  65. package/lib/built/html-segment-fallback.js +0 -1
  66. package/lib/built/html-to-text.d.ts +0 -1
  67. package/lib/built/html-to-text.js +15 -15
  68. package/lib/built/inbound-pipeline.d.ts +1 -2
  69. package/lib/built/inbound-pipeline.js +1 -2
  70. package/lib/built/inbound-runner.d.ts +0 -1
  71. package/lib/built/inbound-runner.js +0 -1
  72. package/lib/built/interactive-segment-contract.d.ts +6 -0
  73. package/lib/built/interactive-segment-contract.js +9 -0
  74. package/lib/built/interactive-segments/action.d.ts +17 -0
  75. package/lib/built/interactive-segments/action.js +69 -0
  76. package/lib/built/interactive-segments/button-spec.d.ts +10 -0
  77. package/lib/built/interactive-segments/button-spec.js +21 -0
  78. package/lib/built/interactive-segments/handlers.d.ts +9 -0
  79. package/lib/built/interactive-segments/handlers.js +58 -0
  80. package/lib/built/interactive-segments/index.d.ts +7 -0
  81. package/lib/built/interactive-segments/index.js +7 -0
  82. package/lib/built/interactive-segments/keyboard-segment.d.ts +12 -0
  83. package/lib/built/interactive-segments/keyboard-segment.js +13 -0
  84. package/lib/built/interactive-segments/onebot-keyboard.d.ts +10 -0
  85. package/lib/built/interactive-segments/onebot-keyboard.js +53 -0
  86. package/lib/built/interactive-segments/resolve.d.ts +9 -0
  87. package/lib/built/interactive-segments/resolve.js +84 -0
  88. package/lib/built/interactive-segments/types.d.ts +62 -0
  89. package/lib/built/interactive-segments/types.js +13 -0
  90. package/lib/built/introspection-format.d.ts +0 -1
  91. package/lib/built/introspection-format.js +1 -1
  92. package/lib/built/login-assist.d.ts +0 -1
  93. package/lib/built/login-assist.js +0 -1
  94. package/lib/built/management-command-guard.d.ts +5 -1
  95. package/lib/built/management-command-guard.js +5 -1
  96. package/lib/built/message-enrich.d.ts +1 -2
  97. package/lib/built/message-enrich.js +0 -1
  98. package/lib/built/message-filter.d.ts +0 -1
  99. package/lib/built/message-filter.js +1 -3
  100. package/lib/built/optional-peer-import.d.ts +3 -0
  101. package/lib/built/optional-peer-import.js +33 -0
  102. package/lib/built/outbound-media-contract.d.ts +0 -1
  103. package/lib/built/outbound-media-contract.js +0 -1
  104. package/lib/built/outbound-media-utils.d.ts +0 -1
  105. package/lib/built/outbound-media-utils.js +0 -1
  106. package/lib/built/permission.d.ts +0 -1
  107. package/lib/built/permission.js +1 -3
  108. package/lib/built/permit-check.d.ts +1 -2
  109. package/lib/built/permit-check.js +0 -1
  110. package/lib/built/permit-parse.d.ts +0 -1
  111. package/lib/built/permit-parse.js +0 -1
  112. package/lib/built/platform-permit.d.ts +5 -6
  113. package/lib/built/platform-permit.js +11 -12
  114. package/lib/built/prepend-quote-context.d.ts +0 -1
  115. package/lib/built/prepend-quote-context.js +0 -1
  116. package/lib/built/qrcode-segment.d.ts +0 -1
  117. package/lib/built/qrcode-segment.js +0 -1
  118. package/lib/built/queue-im-field-contract.d.ts +6 -1
  119. package/lib/built/queue-im-field-contract.js +10 -1
  120. package/lib/built/rich-segments/adapter-policies.d.ts +1 -2
  121. package/lib/built/rich-segments/adapter-policies.js +0 -1
  122. package/lib/built/rich-segments/base.d.ts +0 -1
  123. package/lib/built/rich-segments/base.js +0 -1
  124. package/lib/built/rich-segments/builtins.d.ts +0 -1
  125. package/lib/built/rich-segments/builtins.js +0 -1
  126. package/lib/built/rich-segments/capabilities.d.ts +0 -1
  127. package/lib/built/rich-segments/capabilities.js +0 -1
  128. package/lib/built/rich-segments/html-segment.d.ts +1 -2
  129. package/lib/built/rich-segments/html-segment.js +0 -1
  130. package/lib/built/rich-segments/index.d.ts +0 -1
  131. package/lib/built/rich-segments/index.js +0 -1
  132. package/lib/built/rich-segments/markdown-segment.d.ts +1 -2
  133. package/lib/built/rich-segments/markdown-segment.js +0 -1
  134. package/lib/built/rich-segments/markdown-to-text.d.ts +0 -1
  135. package/lib/built/rich-segments/markdown-to-text.js +0 -1
  136. package/lib/built/rich-segments/qrcode-segment.d.ts +1 -2
  137. package/lib/built/rich-segments/qrcode-segment.js +0 -1
  138. package/lib/built/rich-segments/registry.d.ts +0 -1
  139. package/lib/built/rich-segments/registry.js +0 -1
  140. package/lib/built/rich-segments/resolve.d.ts +1 -2
  141. package/lib/built/rich-segments/resolve.js +0 -1
  142. package/lib/built/rich-segments/tts-segment.d.ts +1 -2
  143. package/lib/built/rich-segments/tts-segment.js +0 -1
  144. package/lib/built/rich-segments/types.d.ts +0 -1
  145. package/lib/built/rich-segments/types.js +0 -1
  146. package/lib/built/roles.d.ts +0 -1
  147. package/lib/built/roles.js +0 -1
  148. package/lib/built/runtime-io.d.ts +0 -1
  149. package/lib/built/runtime-io.js +0 -1
  150. package/lib/built/schedule.d.ts +54 -0
  151. package/lib/built/schedule.js +112 -0
  152. package/lib/built/schema-endpoint-manager.d.ts +0 -1
  153. package/lib/built/schema-endpoint-manager.js +0 -1
  154. package/lib/built/schema-feature.d.ts +0 -1
  155. package/lib/built/schema-feature.js +1 -3
  156. package/lib/built/segment-contract/assert.d.ts +4 -0
  157. package/lib/built/segment-contract/assert.js +30 -0
  158. package/lib/built/segment-contract/delivery.d.ts +5 -0
  159. package/lib/built/segment-contract/delivery.js +40 -0
  160. package/lib/built/segment-contract/image.d.ts +5 -0
  161. package/lib/built/segment-contract/image.js +10 -0
  162. package/lib/built/segment-contract/index.d.ts +8 -0
  163. package/lib/built/segment-contract/index.js +7 -0
  164. package/lib/built/segment-contract/media.d.ts +8 -0
  165. package/lib/built/segment-contract/media.js +39 -0
  166. package/lib/built/segment-contract/mention.d.ts +10 -0
  167. package/lib/built/segment-contract/mention.js +26 -0
  168. package/lib/built/segment-contract/preview.d.ts +3 -0
  169. package/lib/built/segment-contract/preview.js +159 -0
  170. package/lib/built/segment-contract/types.d.ts +70 -0
  171. package/lib/built/segment-contract/types.js +5 -0
  172. package/lib/built/segment-contract/validate.d.ts +138 -0
  173. package/lib/built/segment-contract/validate.js +124 -0
  174. package/lib/built/skill.d.ts +0 -1
  175. package/lib/built/skill.js +0 -1
  176. package/lib/built/speech-loader.d.ts +2 -1
  177. package/lib/built/speech-loader.js +6 -2
  178. package/lib/built/tool.d.ts +0 -1
  179. package/lib/built/tool.js +1 -3
  180. package/lib/command.d.ts +12 -7
  181. package/lib/command.js +38 -16
  182. package/lib/component.d.ts +0 -1
  183. package/lib/component.js +28 -12
  184. package/lib/endpoint-capabilities.d.ts +3 -1
  185. package/lib/endpoint-capabilities.js +0 -1
  186. package/lib/endpoint.d.ts +0 -1
  187. package/lib/endpoint.js +0 -1
  188. package/lib/errors.d.ts +0 -1
  189. package/lib/errors.js +0 -1
  190. package/lib/host-plugin-registry.d.ts +0 -1
  191. package/lib/host-plugin-registry.js +0 -1
  192. package/lib/im-scene.d.ts +29 -0
  193. package/lib/im-scene.js +77 -0
  194. package/lib/im-session-id.d.ts +25 -12
  195. package/lib/im-session-id.js +35 -17
  196. package/lib/index.d.ts +14 -7
  197. package/lib/index.js +12 -6
  198. package/lib/jsx-dev-runtime.d.ts +0 -1
  199. package/lib/jsx-dev-runtime.js +0 -1
  200. package/lib/jsx-runtime.d.ts +0 -1
  201. package/lib/jsx-runtime.js +0 -1
  202. package/lib/jsx.d.ts +0 -1
  203. package/lib/jsx.js +0 -1
  204. package/lib/message-quote.d.ts +1 -2
  205. package/lib/message-quote.js +2 -3
  206. package/lib/message.d.ts +7 -5
  207. package/lib/message.js +16 -1
  208. package/lib/models/system-log.d.ts +0 -1
  209. package/lib/models/system-log.js +0 -1
  210. package/lib/models/user.d.ts +0 -1
  211. package/lib/models/user.js +0 -1
  212. package/lib/notice.d.ts +15 -59
  213. package/lib/notice.js +1 -4
  214. package/lib/plugin-context.d.ts +0 -1
  215. package/lib/plugin-context.js +0 -1
  216. package/lib/plugin.d.ts +13 -6
  217. package/lib/plugin.js +31 -15
  218. package/lib/prompt.d.ts +0 -1
  219. package/lib/prompt.js +0 -1
  220. package/lib/request.d.ts +16 -60
  221. package/lib/request.js +0 -4
  222. package/lib/side-event/base.d.ts +45 -0
  223. package/lib/side-event/base.js +30 -0
  224. package/lib/side-event/index.d.ts +3 -0
  225. package/lib/side-event/index.js +3 -0
  226. package/lib/side-event/normalize.d.ts +40 -0
  227. package/lib/side-event/normalize.js +117 -0
  228. package/lib/side-event/types.d.ts +25 -0
  229. package/lib/side-event/types.js +55 -0
  230. package/lib/tool-zod.d.ts +0 -1
  231. package/lib/tool-zod.js +0 -1
  232. package/lib/types-generator.d.ts +0 -1
  233. package/lib/types-generator.js +0 -1
  234. package/lib/types.d.ts +30 -11
  235. package/lib/types.js +0 -1
  236. package/lib/utils.d.ts +36 -1
  237. package/lib/utils.js +33 -25
  238. package/package.json +15 -8
  239. package/lib/adapter.d.ts.map +0 -1
  240. package/lib/adapter.js.map +0 -1
  241. package/lib/agent-prompt.d.ts.map +0 -1
  242. package/lib/agent-prompt.js.map +0 -1
  243. package/lib/built/adapter-process.d.ts.map +0 -1
  244. package/lib/built/adapter-process.js.map +0 -1
  245. package/lib/built/agent-preset.d.ts.map +0 -1
  246. package/lib/built/agent-preset.js.map +0 -1
  247. package/lib/built/ai-trigger.d.ts.map +0 -1
  248. package/lib/built/ai-trigger.js.map +0 -1
  249. package/lib/built/authorization.d.ts.map +0 -1
  250. package/lib/built/authorization.js.map +0 -1
  251. package/lib/built/command.d.ts.map +0 -1
  252. package/lib/built/command.js.map +0 -1
  253. package/lib/built/common-adapter-tools.d.ts.map +0 -1
  254. package/lib/built/common-adapter-tools.js.map +0 -1
  255. package/lib/built/component.d.ts.map +0 -1
  256. package/lib/built/component.js.map +0 -1
  257. package/lib/built/config.d.ts.map +0 -1
  258. package/lib/built/config.js.map +0 -1
  259. package/lib/built/connect-endpoint-instance.d.ts.map +0 -1
  260. package/lib/built/connect-endpoint-instance.js.map +0 -1
  261. package/lib/built/cron.d.ts +0 -75
  262. package/lib/built/cron.d.ts.map +0 -1
  263. package/lib/built/cron.js +0 -122
  264. package/lib/built/cron.js.map +0 -1
  265. package/lib/built/database.d.ts.map +0 -1
  266. package/lib/built/database.js.map +0 -1
  267. package/lib/built/dispatcher.d.ts.map +0 -1
  268. package/lib/built/dispatcher.js.map +0 -1
  269. package/lib/built/endpoint-commands.d.ts.map +0 -1
  270. package/lib/built/endpoint-commands.js.map +0 -1
  271. package/lib/built/endpoint-lifecycle-service.d.ts.map +0 -1
  272. package/lib/built/endpoint-lifecycle-service.js.map +0 -1
  273. package/lib/built/endpoint-lifecycle.d.ts.map +0 -1
  274. package/lib/built/endpoint-lifecycle.js.map +0 -1
  275. package/lib/built/endpoint-manager.d.ts.map +0 -1
  276. package/lib/built/endpoint-manager.js.map +0 -1
  277. package/lib/built/generated-qrcode.d.ts.map +0 -1
  278. package/lib/built/generated-qrcode.js.map +0 -1
  279. package/lib/built/html-renderer-loader.d.ts.map +0 -1
  280. package/lib/built/html-renderer-loader.js.map +0 -1
  281. package/lib/built/html-segment-fallback.d.ts.map +0 -1
  282. package/lib/built/html-segment-fallback.js.map +0 -1
  283. package/lib/built/html-to-text.d.ts.map +0 -1
  284. package/lib/built/html-to-text.js.map +0 -1
  285. package/lib/built/inbound-pipeline.d.ts.map +0 -1
  286. package/lib/built/inbound-pipeline.js.map +0 -1
  287. package/lib/built/inbound-runner.d.ts.map +0 -1
  288. package/lib/built/inbound-runner.js.map +0 -1
  289. package/lib/built/introspection-format.d.ts.map +0 -1
  290. package/lib/built/introspection-format.js.map +0 -1
  291. package/lib/built/login-assist.d.ts.map +0 -1
  292. package/lib/built/login-assist.js.map +0 -1
  293. package/lib/built/management-command-guard.d.ts.map +0 -1
  294. package/lib/built/management-command-guard.js.map +0 -1
  295. package/lib/built/mcp-mesh-registrar.d.ts +0 -9
  296. package/lib/built/mcp-mesh-registrar.d.ts.map +0 -1
  297. package/lib/built/mcp-mesh-registrar.js +0 -17
  298. package/lib/built/mcp-mesh-registrar.js.map +0 -1
  299. package/lib/built/message-enrich.d.ts.map +0 -1
  300. package/lib/built/message-enrich.js.map +0 -1
  301. package/lib/built/message-filter.d.ts.map +0 -1
  302. package/lib/built/message-filter.js.map +0 -1
  303. package/lib/built/outbound-media-contract.d.ts.map +0 -1
  304. package/lib/built/outbound-media-contract.js.map +0 -1
  305. package/lib/built/outbound-media-utils.d.ts.map +0 -1
  306. package/lib/built/outbound-media-utils.js.map +0 -1
  307. package/lib/built/permission.d.ts.map +0 -1
  308. package/lib/built/permission.js.map +0 -1
  309. package/lib/built/permit-check.d.ts.map +0 -1
  310. package/lib/built/permit-check.js.map +0 -1
  311. package/lib/built/permit-parse.d.ts.map +0 -1
  312. package/lib/built/permit-parse.js.map +0 -1
  313. package/lib/built/platform-permit.d.ts.map +0 -1
  314. package/lib/built/platform-permit.js.map +0 -1
  315. package/lib/built/prepend-quote-context.d.ts.map +0 -1
  316. package/lib/built/prepend-quote-context.js.map +0 -1
  317. package/lib/built/qrcode-segment.d.ts.map +0 -1
  318. package/lib/built/qrcode-segment.js.map +0 -1
  319. package/lib/built/queue-im-field-contract.d.ts.map +0 -1
  320. package/lib/built/queue-im-field-contract.js.map +0 -1
  321. package/lib/built/rich-segments/adapter-policies.d.ts.map +0 -1
  322. package/lib/built/rich-segments/adapter-policies.js.map +0 -1
  323. package/lib/built/rich-segments/base.d.ts.map +0 -1
  324. package/lib/built/rich-segments/base.js.map +0 -1
  325. package/lib/built/rich-segments/builtins.d.ts.map +0 -1
  326. package/lib/built/rich-segments/builtins.js.map +0 -1
  327. package/lib/built/rich-segments/capabilities.d.ts.map +0 -1
  328. package/lib/built/rich-segments/capabilities.js.map +0 -1
  329. package/lib/built/rich-segments/html-segment.d.ts.map +0 -1
  330. package/lib/built/rich-segments/html-segment.js.map +0 -1
  331. package/lib/built/rich-segments/index.d.ts.map +0 -1
  332. package/lib/built/rich-segments/index.js.map +0 -1
  333. package/lib/built/rich-segments/markdown-segment.d.ts.map +0 -1
  334. package/lib/built/rich-segments/markdown-segment.js.map +0 -1
  335. package/lib/built/rich-segments/markdown-to-text.d.ts.map +0 -1
  336. package/lib/built/rich-segments/markdown-to-text.js.map +0 -1
  337. package/lib/built/rich-segments/qrcode-segment.d.ts.map +0 -1
  338. package/lib/built/rich-segments/qrcode-segment.js.map +0 -1
  339. package/lib/built/rich-segments/registry.d.ts.map +0 -1
  340. package/lib/built/rich-segments/registry.js.map +0 -1
  341. package/lib/built/rich-segments/resolve.d.ts.map +0 -1
  342. package/lib/built/rich-segments/resolve.js.map +0 -1
  343. package/lib/built/rich-segments/tts-segment.d.ts.map +0 -1
  344. package/lib/built/rich-segments/tts-segment.js.map +0 -1
  345. package/lib/built/rich-segments/types.d.ts.map +0 -1
  346. package/lib/built/rich-segments/types.js.map +0 -1
  347. package/lib/built/roles.d.ts.map +0 -1
  348. package/lib/built/roles.js.map +0 -1
  349. package/lib/built/runtime-io.d.ts.map +0 -1
  350. package/lib/built/runtime-io.js.map +0 -1
  351. package/lib/built/schema-endpoint-manager.d.ts.map +0 -1
  352. package/lib/built/schema-endpoint-manager.js.map +0 -1
  353. package/lib/built/schema-feature.d.ts.map +0 -1
  354. package/lib/built/schema-feature.js.map +0 -1
  355. package/lib/built/skill.d.ts.map +0 -1
  356. package/lib/built/skill.js.map +0 -1
  357. package/lib/built/speech-loader.d.ts.map +0 -1
  358. package/lib/built/speech-loader.js.map +0 -1
  359. package/lib/built/tool.d.ts.map +0 -1
  360. package/lib/built/tool.js.map +0 -1
  361. package/lib/command.d.ts.map +0 -1
  362. package/lib/command.js.map +0 -1
  363. package/lib/component.d.ts.map +0 -1
  364. package/lib/component.js.map +0 -1
  365. package/lib/endpoint-capabilities.d.ts.map +0 -1
  366. package/lib/endpoint-capabilities.js.map +0 -1
  367. package/lib/endpoint.d.ts.map +0 -1
  368. package/lib/endpoint.js.map +0 -1
  369. package/lib/errors.d.ts.map +0 -1
  370. package/lib/errors.js.map +0 -1
  371. package/lib/host-plugin-registry.d.ts.map +0 -1
  372. package/lib/host-plugin-registry.js.map +0 -1
  373. package/lib/im-session-id.d.ts.map +0 -1
  374. package/lib/im-session-id.js.map +0 -1
  375. package/lib/index.d.ts.map +0 -1
  376. package/lib/index.js.map +0 -1
  377. package/lib/jsx-dev-runtime.d.ts.map +0 -1
  378. package/lib/jsx-dev-runtime.js.map +0 -1
  379. package/lib/jsx-runtime.d.ts.map +0 -1
  380. package/lib/jsx-runtime.js.map +0 -1
  381. package/lib/jsx.d.ts.map +0 -1
  382. package/lib/jsx.js.map +0 -1
  383. package/lib/message-quote.d.ts.map +0 -1
  384. package/lib/message-quote.js.map +0 -1
  385. package/lib/message.d.ts.map +0 -1
  386. package/lib/message.js.map +0 -1
  387. package/lib/models/system-log.d.ts.map +0 -1
  388. package/lib/models/system-log.js.map +0 -1
  389. package/lib/models/user.d.ts.map +0 -1
  390. package/lib/models/user.js.map +0 -1
  391. package/lib/notice.d.ts.map +0 -1
  392. package/lib/notice.js.map +0 -1
  393. package/lib/plugin-context.d.ts.map +0 -1
  394. package/lib/plugin-context.js.map +0 -1
  395. package/lib/plugin.d.ts.map +0 -1
  396. package/lib/plugin.js.map +0 -1
  397. package/lib/prompt.d.ts.map +0 -1
  398. package/lib/prompt.js.map +0 -1
  399. package/lib/request.d.ts.map +0 -1
  400. package/lib/request.js.map +0 -1
  401. package/lib/scheduler/scheduler.d.ts +0 -49
  402. package/lib/scheduler/scheduler.d.ts.map +0 -1
  403. package/lib/scheduler/scheduler.js +0 -352
  404. package/lib/scheduler/scheduler.js.map +0 -1
  405. package/lib/scheduler/types.d.ts +0 -71
  406. package/lib/scheduler/types.d.ts.map +0 -1
  407. package/lib/scheduler/types.js +0 -8
  408. package/lib/scheduler/types.js.map +0 -1
  409. package/lib/tool-zod.d.ts.map +0 -1
  410. package/lib/tool-zod.js.map +0 -1
  411. package/lib/types-generator.d.ts.map +0 -1
  412. package/lib/types-generator.js.map +0 -1
  413. package/lib/types.d.ts.map +0 -1
  414. package/lib/types.js.map +0 -1
  415. package/lib/utils.d.ts.map +0 -1
  416. package/lib/utils.js.map +0 -1
package/lib/message.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { alignReplySegments as alignReplySegmentsImpl, quoteIdFromContent as quoteIdFromContentImpl, syncQuoteId as syncQuoteIdImpl, } from "./message-quote.js";
2
+ import { isActionMessage as isActionMessageImpl } from "./built/interactive-segments/action.js";
2
3
  export var Message;
3
4
  (function (Message) {
4
5
  /**
@@ -20,5 +21,19 @@ export var Message;
20
21
  alignReplySegmentsImpl(content, quoteId);
21
22
  }
22
23
  Message.alignReplySegments = alignReplySegments;
24
+ function actionPayload(message) {
25
+ for (const item of message.$content ?? []) {
26
+ if (typeof item === 'string')
27
+ continue;
28
+ if (item.type === 'action' && item.data?.payload) {
29
+ return String(item.data.payload);
30
+ }
31
+ }
32
+ return undefined;
33
+ }
34
+ Message.actionPayload = actionPayload;
35
+ function isAction(message) {
36
+ return isActionMessageImpl(message);
37
+ }
38
+ Message.isAction = isAction;
23
39
  })(Message || (Message = {}));
24
- //# sourceMappingURL=message.js.map
@@ -8,4 +8,3 @@ export interface SystemLog {
8
8
  timestamp: Date;
9
9
  }
10
10
  export declare const SystemLogDefinition: Definition<SystemLog>;
11
- //# sourceMappingURL=system-log.d.ts.map
@@ -6,4 +6,3 @@ export const SystemLogDefinition = {
6
6
  source: { type: 'text', nullable: false },
7
7
  timestamp: { type: 'date', nullable: false }
8
8
  };
9
- //# sourceMappingURL=system-log.js.map
@@ -7,4 +7,3 @@ export interface User {
7
7
  permissions?: string[];
8
8
  }
9
9
  export declare const UserDefinition: Definition<User>;
10
- //# sourceMappingURL=user.d.ts.map
@@ -5,4 +5,3 @@ export const UserDefinition = {
5
5
  third_part: { type: 'json', default: [] },
6
6
  permissions: { type: 'json', default: [] }
7
7
  };
8
- //# sourceMappingURL=user.js.map
package/lib/notice.d.ts CHANGED
@@ -1,82 +1,38 @@
1
- import { Adapters } from './adapter.js';
2
- import type { MessageSender } from './types.js';
1
+ import type { Adapters } from './adapter.js';
2
+ import type { NoticeKind } from './side-event/types.js';
3
+ import type { SideEventBase } from './side-event/base.js';
4
+ export type { NoticeKind, ComposedNoticeName, NoticeType } from './side-event/types.js';
5
+ export type { SideEventBase } from './side-event/base.js';
6
+ export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventSendChannel, } from './side-event/base.js';
3
7
  /**
4
- * 通知类型枚举
5
- *
6
- * 常见 IM 通知事件分类:
7
- * - group_member_increase: 群成员增加(入群)
8
- * - group_member_decrease: 群成员减少(退群/被踢)
9
- * - group_admin_change: 群管理员变动
10
- * - group_ban: 群禁言
11
- * - group_recall: 群消息撤回
12
- * - friend_recall: 好友消息撤回
13
- * - friend_add: 新增好友
14
- * - group_poke: 群戳一戳
15
- * - friend_poke: 好友戳一戳
16
- * - group_transfer: 群转让
17
- * - endpoint.lifecycle: Endpoint 连接/断开/错误($subType: connect | disconnect | error)
18
- *
19
- * 适配器可自行扩展更多子类型
20
- */
21
- export type NoticeType = 'group_member_increase' | 'group_member_decrease' | 'group_admin_change' | 'group_ban' | 'group_recall' | 'friend_recall' | 'friend_add' | 'group_poke' | 'friend_poke' | 'group_transfer' | (string & {});
22
- /**
23
- * 通知频道信息
24
- */
25
- export interface NoticeChannel {
26
- id: string;
27
- type: 'group' | 'private' | 'channel';
28
- }
29
- /**
30
- * 通知基础结构
31
- *
32
- * 与 MessageBase 同构设计,所有通知共享以下字段。
33
- * 适配器通过 `Notice.from(raw, base)` 合并平台原始数据和标准字段。
8
+ * 通知基础结构 — 继承 SideEventBase。
34
9
  *
35
10
  * @example
36
11
  * ```typescript
37
- * // 适配器中格式化通知
38
12
  * const notice = Notice.from(rawEvent, {
39
13
  * $id: rawEvent.id,
40
14
  * $adapter: 'icqq',
41
15
  * $endpoint: endpointId,
42
- * $type: 'group_member_decrease',
43
- * $subType: 'kick',
44
- * $channel: { id: groupId, type: 'group' },
45
- * $operator: { id: operatorId, name: '管理员' },
16
+ * $type: 'notice',
17
+ * $scene_id: groupId,
18
+ * $scene_type: 'group',
19
+ * $sub_type: 'member_decrease',
20
+ * $actor: { id: operatorId, name: '管理员' },
46
21
  * $target: { id: userId, name: '被踢者' },
47
22
  * $timestamp: Date.now(),
48
23
  * });
24
+ * // formatSideEventName(notice) === 'notice.group.member_decrease'
49
25
  * this.adapter.emit('notice.receive', notice);
50
26
  * ```
51
27
  */
52
- export interface NoticeBase {
53
- /** 通知唯一 ID(平台提供或自生成) */
54
- $id: string;
55
- /** 适配器名称 */
28
+ export interface NoticeBase extends SideEventBase {
56
29
  $adapter: keyof Adapters;
57
- /** Endpoint 名称 */
58
- $endpoint: string;
59
- /** 通知类型 */
60
- $type: NoticeType;
61
- /** 通知子类型(如 leave/kick、set/unset) */
62
- $subType?: string;
63
- /** 通知发生的频道/群/会话 */
64
- $channel: NoticeChannel;
65
- /** 操作者信息(如管理员) */
66
- $operator?: MessageSender;
67
- /** 被操作目标信息(如被踢的成员) */
68
- $target?: MessageSender;
69
- /** 通知时间戳 */
70
- $timestamp: number;
30
+ $type: NoticeKind;
71
31
  }
72
32
  /**
73
33
  * 完整通知类型,支持平台原始数据扩展
74
34
  */
75
35
  export type Notice<T extends object = {}> = NoticeBase & T;
76
36
  export declare namespace Notice {
77
- /**
78
- * 工具方法:合并自定义字段与基础通知结构
79
- */
80
37
  function from<T extends object>(input: T, format: NoticeBase): Notice<T>;
81
38
  }
82
- //# sourceMappingURL=notice.d.ts.map
package/lib/notice.js CHANGED
@@ -1,11 +1,8 @@
1
+ export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventSendChannel, } from './side-event/base.js';
1
2
  export var Notice;
2
3
  (function (Notice) {
3
- /**
4
- * 工具方法:合并自定义字段与基础通知结构
5
- */
6
4
  function from(input, format) {
7
5
  return Object.assign(input, format);
8
6
  }
9
7
  Notice.from = from;
10
8
  })(Notice || (Notice = {}));
11
- //# sourceMappingURL=notice.js.map
@@ -27,4 +27,3 @@ export declare function getCurrentFile(metaUrl?: string): string;
27
27
  * @see docs/guide/plugin-development.md#getplugin-与-useplugin
28
28
  */
29
29
  export declare function getPlugin(): Plugin;
30
- //# sourceMappingURL=plugin-context.d.ts.map
@@ -59,4 +59,3 @@ export function getPlugin() {
59
59
  }
60
60
  return plugin;
61
61
  }
62
- //# sourceMappingURL=plugin-context.js.map
package/lib/plugin.d.ts CHANGED
@@ -6,11 +6,10 @@
6
6
  * - 生命周期事件类型安全(Plugin.Lifecycle)
7
7
  * - 中间件系统、适配器管理、useContext 等
8
8
  */
9
- import type { PluginManifest } from "./types.js";
10
- import { MessageMiddleware, RegisteredAdapter, MaybePromise, ArrayItem, SendOptions, MessageSendPayload } from "./types.js";
9
+ import { MessageMiddleware, RegisteredAdapter, MaybePromise, ArrayItem, SendOptions, MessageSendPayload, type PluginManifest } from './types.js';
10
+ import type { InteractiveHandler } from "./built/interactive-segments/types.js";
11
11
  import { Adapter, Adapters } from "./adapter.js";
12
- import { PluginBase, PluginBaseLifecycle } from "@zhin.js/kernel";
13
- import type { PluginLike } from "@zhin.js/kernel";
12
+ import { PluginBase, PluginBaseLifecycle, type PluginLike } from '@zhin.js/kernel';
14
13
  export { getPlugin } from "./plugin-context.js";
15
14
  export { storage, getCurrentFile } from "./plugin-context.js";
16
15
  export { setHostRootPlugin, getHostRootPlugin } from "./host-plugin-registry.js";
@@ -64,6 +63,10 @@ export declare class Plugin extends PluginBase implements PluginLike {
64
63
  * 中间件用于处理消息流转
65
64
  */
66
65
  addMiddleware<T extends RegisteredAdapter>(middleware: MessageMiddleware<T>, name?: string): () => void;
66
+ /**
67
+ * 注册交互式 action 回调处理器(自动安装根中间件,优先于 Dispatcher)
68
+ */
69
+ registerInteractiveHandler(prefix: string, handler: InteractiveHandler): () => void;
67
70
  /**
68
71
  * 插件名称
69
72
  */
@@ -159,7 +162,7 @@ export declare namespace Plugin {
159
162
  interface Features {
160
163
  commands: string[];
161
164
  components: string[];
162
- crons: string[];
165
+ schedules: string[];
163
166
  middlewares: string[];
164
167
  }
165
168
  /**
@@ -193,6 +196,8 @@ export declare namespace Plugin {
193
196
  "ai.response": [Plugin.AIEventPayload];
194
197
  "ai.typing.start": [Plugin.AIEventPayload];
195
198
  "ai.typing.stop": [Plugin.AIEventPayload];
199
+ "ai.activity.queued.start": [Plugin.AIEventPayload];
200
+ "ai.activity.queued.clear": [Plugin.AIEventPayload];
196
201
  "ai.subagent.spawn": [Plugin.AIEventPayload];
197
202
  "ai.subagent.start": [Plugin.AIEventPayload];
198
203
  "ai.subagent.finish": [Plugin.AIEventPayload];
@@ -204,6 +209,9 @@ export declare namespace Plugin {
204
209
  "ai.session.new": [Plugin.AIEventPayload];
205
210
  "ai.session.compact": [Plugin.AIEventPayload];
206
211
  "ai.hook": [Plugin.AIEventPayload];
212
+ "schedule.start": [Plugin.AIEventPayload];
213
+ "schedule.finish": [Plugin.AIEventPayload];
214
+ "schedule.error": [Plugin.AIEventPayload];
207
215
  }
208
216
  interface AIEventPayload {
209
217
  sessionId: string;
@@ -257,4 +265,3 @@ export declare namespace Plugin {
257
265
  interface Extensions {
258
266
  }
259
267
  }
260
- //# sourceMappingURL=plugin.d.ts.map
package/lib/plugin.js CHANGED
@@ -11,9 +11,9 @@ import * as path from "node:path";
11
11
  import { pathToFileURL } from "node:url";
12
12
  import { formatCompact } from "@zhin.js/logger";
13
13
  import { compose, remove, resolveEntry } from "./utils.js";
14
+ import { ensureInteractiveMiddleware, registerInteractiveHandler as registerInteractiveHandlerCore, } from "./built/interactive-segments/handlers.js";
14
15
  import { Adapter } from "./adapter.js";
15
- import { Feature } from "@zhin.js/kernel";
16
- import { PluginBase, resolvePluginResolveDir as _resolvePluginResolveDir, pluginCreateRequire as _pluginCreateRequire, getFileHash, watchFile, registerExtension, unregisterExtensions, installExtensionProxy, } from "@zhin.js/kernel";
16
+ import { Feature, PluginBase, resolvePluginResolveDir as _resolvePluginResolveDir, pluginCreateRequire as _pluginCreateRequire, getFileHash, watchFile, registerExtension, unregisterExtensions, installExtensionProxy } from '@zhin.js/kernel';
17
17
  import { storage, getCurrentFile } from "./plugin-context.js";
18
18
  // Re-export getPlugin from plugin-context for backward compatibility
19
19
  export { getPlugin } from "./plugin-context.js";
@@ -36,7 +36,9 @@ function pluginCreateRequire() {
36
36
  * 同一上下文中同一文件多次调用返回同一实例
37
37
  */
38
38
  export function usePlugin() {
39
- const callerFile = getCurrentFile();
39
+ // 必须传入 plugin.ts 的 import.meta.url:getCurrentFile 默认锚定在 plugin-context.ts,
40
+ // 否则会多跳一层 usePlugin 帧,把调用方误判为 plugin.ts(plugin.name === "plugin")。
41
+ const callerFile = getCurrentFile(import.meta.url);
40
42
  // 如果当前 store 已是同一文件创建的插件,直接返回
41
43
  const current = storage.getStore();
42
44
  if (current && current.filePath.replace(/\?t=\d+$/, '') === callerFile.replace(/\?t=\d+$/, '')) {
@@ -103,21 +105,35 @@ export class Plugin extends PluginBase {
103
105
  this.onDispose(dispose);
104
106
  return dispose;
105
107
  }
108
+ /**
109
+ * 注册交互式 action 回调处理器(自动安装根中间件,优先于 Dispatcher)
110
+ */
111
+ registerInteractiveHandler(prefix, handler) {
112
+ ensureInteractiveMiddleware((mw) => this.root.addMiddleware(mw));
113
+ const dispose = registerInteractiveHandlerCore(prefix, handler);
114
+ this.onDispose(dispose);
115
+ return dispose;
116
+ }
106
117
  /**
107
118
  * 插件名称
108
119
  */
109
120
  get name() {
110
121
  if (this.#cachedName)
111
122
  return this.#cachedName;
112
- this.#cachedName = path
123
+ let name = path
113
124
  .relative(process.cwd(), this.filePath)
114
125
  .replace(/\?t=\d+$/, "")
115
126
  .replace(/\\/g, "/")
116
127
  .replace(/\/index\.(js|ts)x?$/, "")
117
- .replace(/\/(lib|src|dist)$/, "")
118
- .replace(/.*\/node_modules\//, "")
119
- .replace(/.*\//, "")
120
- .replace(/\.(js|ts)x?$/, "");
128
+ .replace(/\/(lib|src|dist)$/, "");
129
+ const nodeModulesIndex = name.indexOf("node_modules/");
130
+ if (nodeModulesIndex !== -1)
131
+ name = name.slice(nodeModulesIndex + "node_modules/".length);
132
+ const slash = name.lastIndexOf("/");
133
+ if (slash !== -1)
134
+ name = name.slice(slash + 1);
135
+ name = name.replace(/\.(js|ts)x?$/, "");
136
+ this.#cachedName = name;
121
137
  return this.#cachedName;
122
138
  }
123
139
  /**
@@ -212,7 +228,8 @@ export class Plugin extends PluginBase {
212
228
  contextReadyCallback();
213
229
  }
214
230
  inject(name) {
215
- const context = this.root.contexts.get(name);
231
+ const resolved = name === 'cron' ? 'schedule' : name;
232
+ const context = this.root.contexts.get(resolved);
216
233
  return context?.value;
217
234
  }
218
235
  injectAdapter(name) {
@@ -291,11 +308,11 @@ export class Plugin extends PluginBase {
291
308
  get features() {
292
309
  const commandService = this.inject('command');
293
310
  const componentService = this.inject('component');
294
- const cronService = this.inject('cron');
311
+ const scheduleService = this.inject('schedule');
295
312
  return {
296
313
  commands: commandService ? commandService.items.map(c => c.pattern) : [],
297
314
  components: componentService ? componentService.getAllNames() : [],
298
- crons: cronService ? cronService.items.map(c => c.cronExpression) : [],
315
+ schedules: scheduleService ? scheduleService.items.map(s => s.id) : [],
299
316
  middlewares: this.#middlewares.map((m, i) => m.name || `middleware_${i}`),
300
317
  };
301
318
  }
@@ -310,8 +327,8 @@ export class Plugin extends PluginBase {
310
327
  result.push({ name: 'command', count: f.commands.length });
311
328
  if (f.components.length > 0)
312
329
  result.push({ name: 'component', count: f.components.length });
313
- if (f.crons.length > 0)
314
- result.push({ name: 'cron', count: f.crons.length });
330
+ if (f.schedules.length > 0)
331
+ result.push({ name: 'schedule', count: f.schedules.length });
315
332
  // #middlewares includes the default command middleware, only count user-added ones
316
333
  const userMiddlewareCount = this.#middlewares.length - 1; // subtract default #messageMiddleware
317
334
  if (userMiddlewareCount > 0)
@@ -413,7 +430,7 @@ export class Plugin extends PluginBase {
413
430
  installExtensionProxy(Plugin.prototype);
414
431
  for (const [name, fn] of Object.entries(context.extensions)) {
415
432
  if (typeof fn === 'function') {
416
- registerExtension(name, fn); // eslint-disable-line @typescript-eslint/no-explicit-any
433
+ registerExtension(name, fn);
417
434
  }
418
435
  }
419
436
  }
@@ -573,4 +590,3 @@ export class Plugin extends PluginBase {
573
590
  export function defineContext(options) {
574
591
  return options;
575
592
  }
576
- //# sourceMappingURL=plugin.js.map
package/lib/prompt.d.ts CHANGED
@@ -115,4 +115,3 @@ export declare namespace Prompt {
115
115
  };
116
116
  export {};
117
117
  }
118
- //# sourceMappingURL=prompt.d.ts.map
package/lib/prompt.js CHANGED
@@ -245,4 +245,3 @@ export class Prompt {
245
245
  }
246
246
  }
247
247
  }
248
- //# sourceMappingURL=prompt.js.map
package/lib/request.d.ts CHANGED
@@ -1,85 +1,41 @@
1
- import { Adapters } from './adapter.js';
2
- import type { MessageSender, MaybePromise } from './types.js';
1
+ import type { MaybePromise } from './types.js';
2
+ import type { Adapters } from './adapter.js';
3
+ import type { RequestKind } from './side-event/types.js';
4
+ import type { SideEventBase } from './side-event/base.js';
5
+ export type { RequestKind, ComposedRequestName, RequestType } from './side-event/types.js';
3
6
  /**
4
- * 请求类型枚举
5
- *
6
- * 常见 IM 请求事件分类:
7
- * - friend_add: 好友添加请求
8
- * - group_add: 主动申请入群
9
- * - group_invite: 邀请入群请求
10
- *
11
- * 适配器可自行扩展更多子类型
12
- */
13
- export type RequestType = 'friend_add' | 'group_add' | 'group_invite' | (string & {});
14
- /**
15
- * 请求频道信息
16
- */
17
- export interface RequestChannel {
18
- id: string;
19
- type: 'group' | 'private' | 'channel';
20
- }
21
- /**
22
- * 请求基础结构
23
- *
24
- * 与 MessageBase / NoticeBase 同构设计。
25
- * 核心区别:Request 提供 `$approve()` 和 `$reject()` 方法,用于快速处理请求。
7
+ * 请求基础结构 — 继承 SideEventBase,附加审批方法。
26
8
  *
27
9
  * @example
28
10
  * ```typescript
29
- * // 适配器中格式化请求
30
11
  * const request = Request.from(rawEvent, {
31
12
  * $id: rawEvent.flag,
32
13
  * $adapter: 'icqq',
33
14
  * $endpoint: endpointId,
34
- * $type: 'group_invite',
35
- * $channel: { id: groupId, type: 'group' },
36
- * $sender: { id: userId, name: '邀请者' },
15
+ * $type: 'request',
16
+ * $scene_id: groupId,
17
+ * $scene_type: 'group',
18
+ * $sub_type: 'invite',
19
+ * $actor: { id: userId, name: '邀请者' },
37
20
  * $comment: '请求加群消息',
38
21
  * $timestamp: Date.now(),
39
22
  * $approve: async (remark?) => { await api.approve(flag, remark); },
40
23
  * $reject: async (reason?) => { await api.reject(flag, reason); },
41
24
  * });
25
+ * // formatSideEventName(request) === 'request.group.invite'
42
26
  * this.adapter.emit('request.receive', request);
43
27
  * ```
44
28
  */
45
- export interface RequestBase {
46
- /** 请求唯一 ID / flag(平台提供的请求标识,用于后续处理) */
47
- $id: string;
48
- /** 适配器名称 */
29
+ export interface RequestBase extends SideEventBase {
49
30
  $adapter: keyof Adapters;
50
- /** Endpoint 名称 */
51
- $endpoint: string;
52
- /** 请求类型 */
53
- $type: RequestType;
54
- /** 请求子类型 */
55
- $subType?: string;
56
- /** 请求发生的频道/群/会话 */
57
- $channel: RequestChannel;
58
- /** 请求发送者 */
59
- $sender: MessageSender;
60
- /** 请求附言/验证消息 */
31
+ $type: RequestKind;
32
+ /** 主参与者(必填) */
33
+ $actor: NonNullable<SideEventBase['$actor']>;
61
34
  $comment?: string;
62
- /** 请求时间戳 */
63
- $timestamp: number;
64
- /**
65
- * 同意请求
66
- * @param remark 备注信息(如好友备注)
67
- */
68
35
  $approve(remark?: string): MaybePromise<void>;
69
- /**
70
- * 拒绝请求
71
- * @param reason 拒绝原因
72
- */
73
36
  $reject(reason?: string): MaybePromise<void>;
74
37
  }
75
- /**
76
- * 完整请求类型,支持平台原始数据扩展
77
- */
78
38
  export type Request<T extends object = {}> = RequestBase & T;
79
39
  export declare namespace Request {
80
- /**
81
- * 工具方法:合并自定义字段与基础请求结构
82
- */
83
40
  function from<T extends object>(input: T, format: RequestBase): Request<T>;
84
41
  }
85
- //# sourceMappingURL=request.d.ts.map
package/lib/request.js CHANGED
@@ -1,11 +1,7 @@
1
1
  export var Request;
2
2
  (function (Request) {
3
- /**
4
- * 工具方法:合并自定义字段与基础请求结构
5
- */
6
3
  function from(input, format) {
7
4
  return Object.assign(input, format);
8
5
  }
9
6
  Request.from = from;
10
7
  })(Request || (Request = {}));
11
- //# sourceMappingURL=request.js.map
@@ -0,0 +1,45 @@
1
+ import type { Adapters } from '../adapter.js';
2
+ import type { MessageSender } from '../types.js';
3
+ /**
4
+ * Side Event 共享基础结构(Notice 与 Request 共用)。
5
+ * 字段统一为 `$foo_bar` 命名。
6
+ *
7
+ * 完整事件名:`${$type}.${$scene_type}.${$sub_type}`(见 `formatSideEventName`)。
8
+ */
9
+ export interface SideEventBase {
10
+ /** 平台侧去重键 / flag(非 DB 行 id) */
11
+ $id: string;
12
+ $adapter: keyof Adapters;
13
+ $endpoint: string;
14
+ /** 命名空间:`notice` 或 `request` */
15
+ $type: string;
16
+ /** 平台场景 ID(群号、用户号、频道 ID 等) */
17
+ $scene_id: string;
18
+ /** 场景域(如 group、friend、channel、endpoint) */
19
+ $scene_type?: string;
20
+ /** 动作子类型(如 member_increase、add、poke) */
21
+ $sub_type?: string;
22
+ /** 主参与者(原 Notice.$operator / Request.$sender) */
23
+ $actor?: MessageSender;
24
+ /** 被操作对象 */
25
+ $target?: MessageSender;
26
+ /** 毫秒时间戳 */
27
+ $timestamp: number;
28
+ }
29
+ /** 组合 Side Event 完整类型名 */
30
+ export declare function composeSideEventName(type: string, sceneType: string | undefined, subType: string | undefined): string;
31
+ /** 从 Side Event 字段生成完整类型名 */
32
+ export declare function formatSideEventName(event: Pick<SideEventBase, '$type' | '$scene_type' | '$sub_type'>): string;
33
+ /** 判断 Side Event 是否匹配完整类型名(如 `notice.group.member_increase`) */
34
+ export declare function matchesSideEventName(event: Pick<SideEventBase, '$type' | '$scene_type' | '$sub_type'>, fullName: string): boolean;
35
+ /** 解析完整类型名为三段 */
36
+ export declare function parseSideEventName(fullName: string): {
37
+ type: string;
38
+ scene_type?: string;
39
+ sub_type?: string;
40
+ };
41
+ /** 将 Side Event 场景映射为 IM 发送通道(group-suite 等消费者用) */
42
+ export declare function sideEventSendChannel(event: Pick<SideEventBase, '$scene_type' | '$scene_id'>): {
43
+ id: string;
44
+ type: 'group' | 'private' | 'channel';
45
+ };
@@ -0,0 +1,30 @@
1
+ /** 组合 Side Event 完整类型名 */
2
+ export function composeSideEventName(type, sceneType, subType) {
3
+ return [type, sceneType, subType].filter((p) => !!p).join('.');
4
+ }
5
+ /** 从 Side Event 字段生成完整类型名 */
6
+ export function formatSideEventName(event) {
7
+ return composeSideEventName(event.$type, event.$scene_type, event.$sub_type);
8
+ }
9
+ /** 判断 Side Event 是否匹配完整类型名(如 `notice.group.member_increase`) */
10
+ export function matchesSideEventName(event, fullName) {
11
+ return formatSideEventName(event) === fullName;
12
+ }
13
+ /** 解析完整类型名为三段 */
14
+ export function parseSideEventName(fullName) {
15
+ const parts = fullName.split('.');
16
+ return {
17
+ type: parts[0] ?? '',
18
+ scene_type: parts[1],
19
+ sub_type: parts.slice(2).join('.') || undefined,
20
+ };
21
+ }
22
+ /** 将 Side Event 场景映射为 IM 发送通道(group-suite 等消费者用) */
23
+ export function sideEventSendChannel(event) {
24
+ const domain = event.$scene_type ?? 'private';
25
+ if (domain === 'group')
26
+ return { id: event.$scene_id, type: 'group' };
27
+ if (domain === 'channel')
28
+ return { id: event.$scene_id, type: 'channel' };
29
+ return { id: event.$scene_id, type: 'private' };
30
+ }
@@ -0,0 +1,3 @@
1
+ export * from './base.js';
2
+ export * from './types.js';
3
+ export * from './normalize.js';
@@ -0,0 +1,3 @@
1
+ export * from './base.js';
2
+ export * from './types.js';
3
+ export * from './normalize.js';
@@ -0,0 +1,40 @@
1
+ import { Notice, type NoticeBase } from '../notice.js';
2
+ import { Request, type RequestBase } from '../request.js';
3
+ import { type ComposedNoticeName, type ComposedRequestName, type SideEventParts } from './types.js';
4
+ export type SideEventPlatform = 'onebot' | 'icqq' | 'napcat' | 'kook' | (string & {});
5
+ export interface OneBotLikeRawEvent {
6
+ notice_type?: string;
7
+ request_type?: string;
8
+ sub_type?: string;
9
+ group_id?: number | string;
10
+ user_id?: number | string;
11
+ operator_id?: number | string;
12
+ flag?: string;
13
+ time?: number;
14
+ self_id?: number | string;
15
+ [key: string]: unknown;
16
+ }
17
+ /** 去重用:notice / request 无稳定 id 时组合键 */
18
+ export declare function resolveSideEventDedupeKey(data: OneBotLikeRawEvent, kind: 'notice' | 'request'): string;
19
+ /**
20
+ * 将平台原始 notice_type 映射为标准 `$scene_type` + `$sub_type`。
21
+ */
22
+ export declare function mapNoticeParts(platform: SideEventPlatform, raw: string, options?: {
23
+ sub_type?: string;
24
+ is_group?: boolean;
25
+ notify_handler?: (subType: string | undefined, isGroup: boolean) => SideEventParts;
26
+ }): SideEventParts;
27
+ /**
28
+ * 将平台原始 request_type 映射为标准 `$scene_type` + `$sub_type`。
29
+ */
30
+ export declare function mapRequestParts(_platform: SideEventPlatform, raw: string, subType?: string): SideEventParts;
31
+ /** 组合完整 Notice 类型名(兼容旧 API) */
32
+ export declare function mapNoticeType(platform: SideEventPlatform, raw: string, options?: Parameters<typeof mapNoticeParts>[2]): ComposedNoticeName;
33
+ /** 组合完整 Request 类型名(兼容旧 API) */
34
+ export declare function mapRequestType(platform: SideEventPlatform, raw: string, subType?: string): ComposedRequestName;
35
+ export declare function senderFromId(id: unknown, name?: string): {
36
+ id: string;
37
+ name: string;
38
+ } | undefined;
39
+ export declare function buildNotice<T extends object>(input: T, format: NoticeBase): Notice<T>;
40
+ export declare function buildRequest<T extends object>(input: T, format: RequestBase): Request<T>;