@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
@@ -0,0 +1,232 @@
1
+ import { createImageSegment, isMediaRef, mediaRefFromLegacyData, mediaRefToLegacyFields, readMentionTarget, } from './segment-contract/index.js';
2
+ function isRecord(value) {
3
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
4
+ }
5
+ function readPlatform(seg) {
6
+ const platform = seg.platform;
7
+ return platform && typeof platform === 'object' ? platform : undefined;
8
+ }
9
+ function normalizeMention(seg) {
10
+ const data = seg.data;
11
+ const target = readMentionTarget(data);
12
+ const name = typeof data.name === 'string' && data.name ? data.name : undefined;
13
+ const platform = readPlatform(seg);
14
+ return {
15
+ type: 'mention',
16
+ data: name ? { target, name } : { target },
17
+ ...(platform ? { platform } : {}),
18
+ };
19
+ }
20
+ function normalizeImage(seg) {
21
+ const data = seg.data;
22
+ const platform = readPlatform(seg);
23
+ if (isMediaRef(data.media)) {
24
+ return {
25
+ type: 'image',
26
+ data: {
27
+ media: data.media,
28
+ ...(typeof data.alt === 'string' ? { alt: data.alt } : {}),
29
+ },
30
+ ...(platform ? { platform } : {}),
31
+ };
32
+ }
33
+ const media = mediaRefFromLegacyData(data);
34
+ if (media) {
35
+ const mergedPlatform = { ...(platform ?? {}) };
36
+ for (const key of ['url', 'file', 'src', 'file_id']) {
37
+ if (typeof data[key] === 'string' && data[key])
38
+ mergedPlatform[key] = data[key];
39
+ }
40
+ const platformKeys = Object.keys(mergedPlatform);
41
+ const legacyPlatform = platformKeys.length === 0
42
+ ? undefined
43
+ : platformKeys.length === 1 && mergedPlatform[platformKeys[0]] === media.value
44
+ ? undefined
45
+ : mergedPlatform;
46
+ return createImageSegment(media, {
47
+ alt: typeof data.alt === 'string' ? data.alt : undefined,
48
+ platform: legacyPlatform,
49
+ });
50
+ }
51
+ return seg;
52
+ }
53
+ function normalizeReply(seg) {
54
+ const data = seg.data;
55
+ const messageId = String(data.message_id ?? data.id ?? '').trim();
56
+ if (!messageId)
57
+ return seg;
58
+ return { type: 'reply', data: { message_id: messageId } };
59
+ }
60
+ function normalizeLink(seg) {
61
+ const data = seg.data;
62
+ const url = String(data.url ?? data.href ?? '').trim();
63
+ if (!url)
64
+ return seg;
65
+ const text = typeof data.text === 'string' && data.text ? data.text : undefined;
66
+ const platform = readPlatform(seg);
67
+ return {
68
+ type: 'link',
69
+ data: text ? { url, text } : { url },
70
+ ...(platform ? { platform } : {}),
71
+ };
72
+ }
73
+ function normalizeForward(seg) {
74
+ const data = seg.data;
75
+ const forwardId = String(data.forward_id ?? data.id ?? data.resid ?? '').trim();
76
+ if (!forwardId)
77
+ return seg;
78
+ const title = typeof data.title === 'string' ? data.title : undefined;
79
+ const messages = Array.isArray(data.messages) ? data.messages : undefined;
80
+ const platform = { ...(readPlatform(seg) ?? {}) };
81
+ if (data.resid != null)
82
+ platform.resid = String(data.resid);
83
+ return {
84
+ type: 'forward',
85
+ data: {
86
+ forward_id: forwardId,
87
+ ...(title ? { title } : {}),
88
+ ...(messages ? { messages: messages } : {}),
89
+ },
90
+ ...(Object.keys(platform).length ? { platform } : {}),
91
+ };
92
+ }
93
+ function isPlatformSticker(seg) {
94
+ if (seg.type !== 'sticker')
95
+ return false;
96
+ const data = seg.data;
97
+ return data.package_id != null
98
+ || data.sticker_id != null
99
+ || data.packageId != null
100
+ || data.stickerId != null;
101
+ }
102
+ function normalizeFace(seg) {
103
+ if (isPlatformSticker(seg))
104
+ return seg;
105
+ const data = seg.data;
106
+ const rawId = data.id ?? data.face_id;
107
+ const name = typeof data.name === 'string'
108
+ ? data.name
109
+ : typeof data.text === 'string'
110
+ ? data.text
111
+ : undefined;
112
+ const platform = readPlatform(seg);
113
+ return {
114
+ type: 'face',
115
+ data: {
116
+ ...(rawId != null ? { id: rawId } : {}),
117
+ ...(name ? { name } : {}),
118
+ },
119
+ ...(platform ? { platform } : {}),
120
+ };
121
+ }
122
+ function normalizeMarkdown(seg) {
123
+ const data = seg.data;
124
+ const content = typeof data.content === 'string'
125
+ ? data.content
126
+ : typeof data.text === 'string'
127
+ ? data.text
128
+ : '';
129
+ return { type: 'markdown', data: { content } };
130
+ }
131
+ function normalizeSegment(seg) {
132
+ if (seg.type === 'at' || seg.type === 'mention')
133
+ return normalizeMention(seg);
134
+ if (seg.type === 'image')
135
+ return normalizeImage(seg);
136
+ if (seg.type === 'reply')
137
+ return normalizeReply(seg);
138
+ if (seg.type === 'forward')
139
+ return normalizeForward(seg);
140
+ if (seg.type === 'sticker' && isPlatformSticker(seg))
141
+ return seg;
142
+ if (seg.type === 'face' || seg.type === 'sticker' || seg.type === 'emoji')
143
+ return normalizeFace(seg);
144
+ if (seg.type === 'link')
145
+ return normalizeLink(seg);
146
+ if (seg.type === 'markdown')
147
+ return normalizeMarkdown(seg);
148
+ return seg;
149
+ }
150
+ function asMessageSegments(content) {
151
+ return content.map((item) => {
152
+ if (typeof item === 'string')
153
+ return { type: 'text', data: { text: item } };
154
+ return item;
155
+ });
156
+ }
157
+ function asCanonicalSegments(content) {
158
+ if (typeof content === 'string') {
159
+ return [{ type: 'text', data: { text: content } }];
160
+ }
161
+ const items = Array.isArray(content) ? content : [content];
162
+ return items.map((item) => {
163
+ if (typeof item === 'string')
164
+ return { type: 'text', data: { text: item } };
165
+ return item;
166
+ });
167
+ }
168
+ /** 通用 IM adapter:legacy wire → canonical Segment[] */
169
+ export function toCanonicalSegments(content) {
170
+ return asMessageSegments(content).map((seg) => normalizeSegment(seg));
171
+ }
172
+ function mapCanonicalToWire(seg) {
173
+ if (seg.type === 'image' && isRecord(seg.data) && seg.data.media) {
174
+ const media = seg.data.media;
175
+ const legacy = mediaRefToLegacyFields(media);
176
+ return {
177
+ type: 'image',
178
+ data: {
179
+ ...legacy,
180
+ media,
181
+ ...(typeof seg.data.alt === 'string' ? { alt: seg.data.alt } : {}),
182
+ },
183
+ ...(seg.platform ? { platform: seg.platform } : {}),
184
+ };
185
+ }
186
+ if (seg.type === 'mention') {
187
+ const data = seg.data;
188
+ return {
189
+ type: 'at',
190
+ data: {
191
+ id: data.target,
192
+ ...(data.name ? { name: data.name } : {}),
193
+ },
194
+ ...(seg.platform ? { platform: seg.platform } : {}),
195
+ };
196
+ }
197
+ if (seg.type === 'reply') {
198
+ const messageId = String(seg.data.message_id);
199
+ return {
200
+ type: 'reply',
201
+ data: { id: messageId, message_id: messageId },
202
+ ...(seg.platform ? { platform: seg.platform } : {}),
203
+ };
204
+ }
205
+ if (seg.type === 'forward') {
206
+ const data = seg.data;
207
+ const resid = seg.platform?.resid ?? data.forward_id;
208
+ return {
209
+ type: 'forward',
210
+ data: {
211
+ id: data.forward_id,
212
+ resid,
213
+ ...(data.title ? { title: data.title } : {}),
214
+ ...(data.messages ? { messages: data.messages } : {}),
215
+ },
216
+ ...(seg.platform ? { platform: seg.platform } : {}),
217
+ };
218
+ }
219
+ if (seg.type === 'link') {
220
+ const data = seg.data;
221
+ return {
222
+ type: 'link',
223
+ data: { url: data.url, ...(data.text ? { text: data.text } : {}) },
224
+ ...(seg.platform ? { platform: seg.platform } : {}),
225
+ };
226
+ }
227
+ return seg;
228
+ }
229
+ /** canonical → wire(mention→at;image MediaRef→legacy 字段) */
230
+ export function fromCanonicalSegments(content) {
231
+ return asCanonicalSegments(content).map((seg) => mapCanonicalToWire(seg));
232
+ }
@@ -5,8 +5,9 @@ export interface LoadHtmlRendererOptions {
5
5
  getConfig?: () => Record<string, unknown> | undefined;
6
6
  warn?: (message: string) => void;
7
7
  }
8
+ /** zhin 启动时已创建 renderer 时注入,避免 core 目录下 peer 解析失败 */
9
+ export declare function seedHtmlRenderer(renderer: HtmlRendererForRichSegment): void;
8
10
  /** 动态加载 @zhin.js/html-renderer;未安装时 warn 一次并返回 undefined */
9
11
  export declare function loadHtmlRenderer(opts?: LoadHtmlRendererOptions): Promise<HtmlRendererForRichSegment | undefined>;
10
12
  /** 测试用:重置加载缓存 */
11
13
  export declare function resetHtmlRendererLoaderForTests(): void;
12
- //# sourceMappingURL=html-renderer-loader.d.ts.map
@@ -1,14 +1,19 @@
1
+ import { importOptionalPeerPackage } from './optional-peer-import.js';
1
2
  /** 动态 import 时使用的包名(与 @zhin.js/html-renderer package.json 一致) */
2
3
  export const HTML_RENDERER_PACKAGE = '@zhin.js/html-renderer';
3
4
  let cached;
4
5
  let warned = false;
6
+ /** zhin 启动时已创建 renderer 时注入,避免 core 目录下 peer 解析失败 */
7
+ export function seedHtmlRenderer(renderer) {
8
+ cached = renderer;
9
+ }
5
10
  /** 动态加载 @zhin.js/html-renderer;未安装时 warn 一次并返回 undefined */
6
11
  export async function loadHtmlRenderer(opts) {
7
12
  if (cached !== undefined) {
8
13
  return cached ?? undefined;
9
14
  }
10
15
  try {
11
- const mod = await import(HTML_RENDERER_PACKAGE);
16
+ const mod = await importOptionalPeerPackage(HTML_RENDERER_PACKAGE);
12
17
  cached = mod.createHtmlRenderer(opts?.getConfig?.() ?? {});
13
18
  return cached;
14
19
  }
@@ -26,4 +31,3 @@ export function resetHtmlRendererLoaderForTests() {
26
31
  cached = undefined;
27
32
  warned = false;
28
33
  }
29
- //# sourceMappingURL=html-renderer-loader.js.map
@@ -7,4 +7,3 @@ import type { SendContent } from '../types.js';
7
7
  export declare function coerceHtmlSegmentsToText(content: SendContent): SendContent;
8
8
  /** 注册链尾 before.sendMessage:将未转换的 html 段降级为 text */
9
9
  export declare function registerHtmlSegmentFallback(plugin: Plugin): () => void;
10
- //# sourceMappingURL=html-segment-fallback.d.ts.map
@@ -47,4 +47,3 @@ export function registerHtmlSegmentFallback(plugin) {
47
47
  plugin.root.on('before.sendMessage', handler);
48
48
  return () => plugin.root.off('before.sendMessage', handler);
49
49
  }
50
- //# sourceMappingURL=html-segment-fallback.js.map
@@ -14,4 +14,3 @@ export declare function htmlToPlainTextWithBlockBreaks(html: string, options?: H
14
14
  * HTML 卡片出站回退:块级换行 + 语义标题轻量 markdown 前缀。
15
15
  */
16
16
  export declare function htmlToFallbackText(html: string, options?: HtmlToPlainTextOptions): string;
17
- //# sourceMappingURL=html-to-text.d.ts.map
@@ -79,20 +79,21 @@ function stripRemainingTags(html) {
79
79
  return out;
80
80
  }
81
81
  function decodeCommonEntities(text) {
82
- return text
83
- .replace(/&nbsp;/gi, ' ')
84
- .replace(/&amp;/g, '&')
85
- .replace(/&lt;/g, '<')
86
- .replace(/&gt;/g, '>')
87
- .replace(/&quot;/g, '"')
88
- .replace(/&#39;/g, "'")
89
- .replace(/&apos;/g, "'")
90
- .replace(/&#(\d+);/g, (_, code) => {
91
- const n = Number(code);
92
- return Number.isFinite(n) && n >= 0 && n <= 0x10ffff ? String.fromCodePoint(n) : '';
93
- })
94
- .replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => {
95
- const n = parseInt(hex, 16);
82
+ return text.replace(/&(#x[0-9a-fA-F]+|#\d+|nbsp|amp|lt|gt|quot|apos);/gi, (entity) => {
83
+ const key = entity.slice(1, -1).toLowerCase();
84
+ if (key === 'nbsp')
85
+ return ' ';
86
+ if (key === 'amp')
87
+ return '&';
88
+ if (key === 'lt')
89
+ return '<';
90
+ if (key === 'gt')
91
+ return '>';
92
+ if (key === 'quot')
93
+ return '"';
94
+ if (key === 'apos')
95
+ return "'";
96
+ const n = key.startsWith('#x') ? parseInt(key.slice(2), 16) : Number(key.slice(1));
96
97
  return Number.isFinite(n) && n >= 0 && n <= 0x10ffff ? String.fromCodePoint(n) : '';
97
98
  });
98
99
  }
@@ -163,4 +164,3 @@ export function htmlToFallbackText(html, options) {
163
164
  .replace(/\n{3,}/g, '\n\n')
164
165
  .trim();
165
166
  }
166
- //# sourceMappingURL=html-to-text.js.map
@@ -4,7 +4,7 @@
4
4
  * Extracted from Adapter.emit() override to improve testability and decoupling.
5
5
  * Handles: event routing, logging, backpressure, pipeline execution, observer emission.
6
6
  */
7
- import type { Logger } from '@zhin.js/logger';
7
+ import { type Logger } from '@zhin.js/logger';
8
8
  import { type Message as MessageType } from '../message.js';
9
9
  import type { Plugin } from '../plugin.js';
10
10
  export interface InboundPipelineOptions {
@@ -35,4 +35,3 @@ export declare class InboundMessagePipeline {
35
35
  bridgeNoticeOrRequest(event: string, args: unknown[], directEmit: () => boolean): boolean;
36
36
  private logIncoming;
37
37
  }
38
- //# sourceMappingURL=inbound-pipeline.d.ts.map
@@ -54,7 +54,7 @@ export class InboundMessagePipeline {
54
54
  return result;
55
55
  }
56
56
  logIncoming(message) {
57
- this.options.logger.info(formatCompact({
57
+ this.options.logger.debug(formatCompact({
58
58
  recv: `${message.$channel.type}(${message.$channel.id})`,
59
59
  endpoint: message.$endpoint,
60
60
  preview: truncatePreview(segment.raw(message.$content)),
@@ -62,4 +62,3 @@ export class InboundMessagePipeline {
62
62
  }));
63
63
  }
64
64
  }
65
- //# sourceMappingURL=inbound-pipeline.js.map
@@ -20,4 +20,3 @@ export interface InboundRunResult {
20
20
  * Agent / 业务逻辑一致。
21
21
  */
22
22
  export declare function runInboundMessage(options: RunInboundMessageOptions): Promise<InboundRunResult>;
23
- //# sourceMappingURL=inbound-runner.d.ts.map
@@ -34,4 +34,3 @@ export async function runInboundMessage(options) {
34
34
  emitAdapterObservers();
35
35
  return { dispatched: !!dispatcher };
36
36
  }
37
- //# sourceMappingURL=inbound-runner.js.map
@@ -0,0 +1,6 @@
1
+ import type { InteractivePolicy } from './interactive-segments/types.js';
2
+ /** 契约测试:adapter 须声明 interactivePolicy */
3
+ export declare function assertAdapterDeclaresInteractivePolicy(adapterClass: {
4
+ interactivePolicy?: InteractivePolicy;
5
+ }): void;
6
+ export type { InteractivePolicy };
@@ -0,0 +1,9 @@
1
+ /** 契约测试:adapter 须声明 interactivePolicy */
2
+ export function assertAdapterDeclaresInteractivePolicy(adapterClass) {
3
+ if (!adapterClass.interactivePolicy) {
4
+ throw new Error('Adapter must declare static interactivePolicy');
5
+ }
6
+ if (adapterClass.interactivePolicy !== 'native' && adapterClass.interactivePolicy !== 'text') {
7
+ throw new Error('interactivePolicy must be "native" or "text"');
8
+ }
9
+ }
@@ -0,0 +1,17 @@
1
+ import type { Message } from '../../message.js';
2
+ import type { MessageElement } from '../../types.js';
3
+ import { type ActionSegmentData } from './types.js';
4
+ export declare function actionSegment(data: ActionSegmentData): MessageElement;
5
+ export declare function getActionFromMessage(message: Message<any>): ActionSegmentData | undefined;
6
+ /** 入站互动 action(按钮点击等),不应计入用户发言/消息统计 */
7
+ export declare function isActionMessage(message: Message<any>): boolean;
8
+ /** 去掉 @bot、XML at 段、首尾空白(QQ 指令预填文本归一化) */
9
+ export declare function stripInteractiveCommandText(raw: string): string;
10
+ /** 从文本降级输入解析 payload(需在 active session 的 fallback.map 中查找) */
11
+ export declare function resolveTextFallbackPayload(raw: string, map: Record<string, string>): string | undefined;
12
+ /**
13
+ * 从用户文本入站解析 interactive payload:
14
+ * 归一化 → 直接匹配 prefix:session:id → fallback 数字映射
15
+ */
16
+ export declare function resolvePayloadFromText(raw: string, map?: Record<string, string>): string | undefined;
17
+ export declare function formatActionAsRaw(data: ActionSegmentData): string;
@@ -0,0 +1,69 @@
1
+ import { ACTION_SEGMENT_TYPE, isActionSegment, } from './types.js';
2
+ export function actionSegment(data) {
3
+ return { type: ACTION_SEGMENT_TYPE, data };
4
+ }
5
+ export function getActionFromMessage(message) {
6
+ for (const item of message.$content ?? []) {
7
+ if (typeof item === 'string')
8
+ continue;
9
+ if (isActionSegment(item))
10
+ return item.data;
11
+ }
12
+ return undefined;
13
+ }
14
+ /** 入站互动 action(按钮点击等),不应计入用户发言/消息统计 */
15
+ export function isActionMessage(message) {
16
+ return getActionFromMessage(message) != null;
17
+ }
18
+ const PAYLOAD_PATTERN = /^[a-z0-9_]+:[^:\s]+:[a-z0-9_-]+$/i;
19
+ /** 去掉 @bot、XML at 段、首尾空白(QQ 指令预填文本归一化) */
20
+ export function stripInteractiveCommandText(raw) {
21
+ let text = raw.trim();
22
+ text = stripXmlAtSegments(text);
23
+ text = text.replace(/^@\S+\s+/u, '');
24
+ text = text.replace(/\s+/g, ' ').trim();
25
+ return text;
26
+ }
27
+ function stripXmlAtSegments(text) {
28
+ let out = '';
29
+ let cursor = 0;
30
+ while (cursor < text.length) {
31
+ const start = text.toLowerCase().indexOf('<at ', cursor);
32
+ if (start < 0)
33
+ break;
34
+ const end = text.indexOf('/>', start + 4);
35
+ if (end < 0)
36
+ break;
37
+ out += text.slice(cursor, start) + ' ';
38
+ cursor = end + 2;
39
+ }
40
+ return out + text.slice(cursor);
41
+ }
42
+ /** 从文本降级输入解析 payload(需在 active session 的 fallback.map 中查找) */
43
+ export function resolveTextFallbackPayload(raw, map) {
44
+ const trimmed = raw.trim();
45
+ if (map[trimmed])
46
+ return map[trimmed];
47
+ const match = trimmed.match(/^(?:ttt\s+)?(\d)$/i);
48
+ if (match && map[match[1]])
49
+ return map[match[1]];
50
+ return undefined;
51
+ }
52
+ /**
53
+ * 从用户文本入站解析 interactive payload:
54
+ * 归一化 → 直接匹配 prefix:session:id → fallback 数字映射
55
+ */
56
+ export function resolvePayloadFromText(raw, map) {
57
+ const normalized = stripInteractiveCommandText(raw);
58
+ if (!normalized)
59
+ return undefined;
60
+ if (PAYLOAD_PATTERN.test(normalized))
61
+ return normalized;
62
+ if (map && Object.keys(map).length > 0) {
63
+ return resolveTextFallbackPayload(normalized, map);
64
+ }
65
+ return undefined;
66
+ }
67
+ export function formatActionAsRaw(data) {
68
+ return data.payload;
69
+ }
@@ -0,0 +1,10 @@
1
+ import type { ButtonData } from './types.js';
2
+ /** 键盘布局单元:`segment.button()` 产物,仅用于组装 `segment.keyboard()` */
3
+ export declare class ButtonSpec {
4
+ readonly data: ButtonData;
5
+ constructor(data: ButtonData);
6
+ }
7
+ export type KeyboardRowInput = Array<ButtonSpec | ButtonData>;
8
+ export declare function isButtonLike(value: unknown): value is ButtonSpec | ButtonData;
9
+ export declare function normalizeButton(btn: ButtonSpec | ButtonData): ButtonData;
10
+ export declare function normalizeKeyboardRows(rows: KeyboardRowInput[]): ButtonData[][];
@@ -0,0 +1,21 @@
1
+ /** 键盘布局单元:`segment.button()` 产物,仅用于组装 `segment.keyboard()` */
2
+ export class ButtonSpec {
3
+ data;
4
+ constructor(data) {
5
+ this.data = data;
6
+ }
7
+ }
8
+ export function isButtonLike(value) {
9
+ if (value == null || typeof value !== 'object')
10
+ return false;
11
+ if (value instanceof ButtonSpec)
12
+ return true;
13
+ const v = value;
14
+ return typeof v.id === 'string' && typeof v.label === 'string' && typeof v.payload === 'string';
15
+ }
16
+ export function normalizeButton(btn) {
17
+ return btn instanceof ButtonSpec ? btn.data : btn;
18
+ }
19
+ export function normalizeKeyboardRows(rows) {
20
+ return rows.map((row) => row.map(normalizeButton));
21
+ }
@@ -0,0 +1,9 @@
1
+ import type { Message } from '../../message.js';
2
+ import type { MessageMiddleware } from '../../types.js';
3
+ import type { InteractiveHandler, RegisteredInteractiveHandler } from './types.js';
4
+ export declare function registerInteractiveHandler(prefix: string, handler: InteractiveHandler): () => void;
5
+ export declare function getInteractiveHandlers(): readonly RegisteredInteractiveHandler[];
6
+ export declare function resetInteractiveHandlersForTests(): void;
7
+ /** 在根插件上安装一次性 action 路由中间件(幂等) */
8
+ export declare function ensureInteractiveMiddleware(addMiddleware: (mw: MessageMiddleware) => () => void): void;
9
+ export declare function dispatchInteractiveAction(message: Message<any>): Promise<boolean>;
@@ -0,0 +1,58 @@
1
+ import { getActionFromMessage } from './action.js';
2
+ const handlers = [];
3
+ let middlewareInstalled = false;
4
+ function findHandler(payload) {
5
+ let match;
6
+ for (const entry of handlers) {
7
+ if (payload.startsWith(entry.prefix)) {
8
+ if (!match || entry.prefix.length > match.prefix.length) {
9
+ match = entry;
10
+ }
11
+ }
12
+ }
13
+ return match?.handler;
14
+ }
15
+ export function registerInteractiveHandler(prefix, handler) {
16
+ const entry = { prefix, handler };
17
+ handlers.push(entry);
18
+ const dispose = () => {
19
+ const idx = handlers.indexOf(entry);
20
+ if (idx >= 0)
21
+ handlers.splice(idx, 1);
22
+ };
23
+ return dispose;
24
+ }
25
+ export function getInteractiveHandlers() {
26
+ return handlers;
27
+ }
28
+ export function resetInteractiveHandlersForTests() {
29
+ handlers.length = 0;
30
+ middlewareInstalled = false;
31
+ }
32
+ /** 在根插件上安装一次性 action 路由中间件(幂等) */
33
+ export function ensureInteractiveMiddleware(addMiddleware) {
34
+ if (middlewareInstalled)
35
+ return;
36
+ middlewareInstalled = true;
37
+ addMiddleware(async (message, next) => {
38
+ const action = getActionFromMessage(message);
39
+ if (!action)
40
+ return next();
41
+ const handler = findHandler(action.payload);
42
+ if (!handler)
43
+ return next();
44
+ const handled = await handler(message);
45
+ if (handled)
46
+ return;
47
+ return next();
48
+ });
49
+ }
50
+ export async function dispatchInteractiveAction(message) {
51
+ const action = getActionFromMessage(message);
52
+ if (!action)
53
+ return false;
54
+ const handler = findHandler(action.payload);
55
+ if (!handler)
56
+ return false;
57
+ return !!(await handler(message));
58
+ }
@@ -0,0 +1,7 @@
1
+ export * from './types.js';
2
+ export * from './button-spec.js';
3
+ export * from './action.js';
4
+ export * from './resolve.js';
5
+ export * from './handlers.js';
6
+ export { KeyboardSegment, InteractiveSegment } from './keyboard-segment.js';
7
+ export * from './onebot-keyboard.js';
@@ -0,0 +1,7 @@
1
+ export * from './types.js';
2
+ export * from './button-spec.js';
3
+ export * from './action.js';
4
+ export * from './resolve.js';
5
+ export * from './handlers.js';
6
+ export { KeyboardSegment, InteractiveSegment } from './keyboard-segment.js';
7
+ export * from './onebot-keyboard.js';
@@ -0,0 +1,12 @@
1
+ import { type KeyboardSegmentData } from './types.js';
2
+ export declare class KeyboardSegment {
3
+ readonly data: KeyboardSegmentData;
4
+ readonly segmentType: "keyboard";
5
+ constructor(data: KeyboardSegmentData);
6
+ toElement(): {
7
+ type: "keyboard";
8
+ data: KeyboardSegmentData;
9
+ };
10
+ }
11
+ /** @deprecated 使用 {@link KeyboardSegment} */
12
+ export declare const InteractiveSegment: typeof KeyboardSegment;
@@ -0,0 +1,13 @@
1
+ import { KEYBOARD_SEGMENT_TYPE } from './types.js';
2
+ export class KeyboardSegment {
3
+ data;
4
+ segmentType = KEYBOARD_SEGMENT_TYPE;
5
+ constructor(data) {
6
+ this.data = data;
7
+ }
8
+ toElement() {
9
+ return { type: this.segmentType, data: this.data };
10
+ }
11
+ }
12
+ /** @deprecated 使用 {@link KeyboardSegment} */
13
+ export const InteractiveSegment = KeyboardSegment;
@@ -0,0 +1,10 @@
1
+ import type { MessageSegment, SendContent } from '../../types.js';
2
+ import { type KeyboardSegmentData } from './types.js';
3
+ /** OneBot / QQ 系 keyboard 段(各 adapter 在 $sendMessage 中识别) */
4
+ export declare function keyboardToOneBotSegment(data: KeyboardSegmentData): MessageSegment;
5
+ /** @deprecated 使用 {@link keyboardToOneBotSegment} */
6
+ export declare const interactiveToKeyboardSegment: typeof keyboardToOneBotSegment;
7
+ /** 出站前将 core keyboard 段展开为 OneBot keyboard(保留前置 text 等段) */
8
+ export declare function expandKeyboardSegmentsInContent(content: SendContent): SendContent;
9
+ /** @deprecated 使用 {@link expandKeyboardSegmentsInContent} */
10
+ export declare const expandInteractiveSegmentsInContent: typeof expandKeyboardSegmentsInContent;