@zhin.js/core 1.1.33 → 1.1.35

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 (380) hide show
  1. package/README.md +140 -61
  2. package/lib/adapter.d.ts +72 -23
  3. package/lib/adapter.js +222 -58
  4. package/lib/built/adapter-process.d.ts +20 -5
  5. package/lib/built/adapter-process.js +54 -7
  6. package/lib/built/agent-preset.d.ts +1 -2
  7. package/lib/built/agent-preset.js +1 -2
  8. package/lib/built/ai-access.d.ts +36 -0
  9. package/lib/built/ai-access.js +46 -0
  10. package/lib/built/ai-outbound/adapter-access.d.ts +3 -0
  11. package/lib/built/ai-outbound/adapter-access.js +9 -0
  12. package/lib/built/ai-outbound/extensions/onebot-keyboard.d.ts +2 -0
  13. package/lib/built/ai-outbound/extensions/onebot-keyboard.js +67 -0
  14. package/lib/built/ai-outbound/extensions/qq-message.d.ts +3 -0
  15. package/lib/built/ai-outbound/extensions/qq-message.js +23 -0
  16. package/lib/built/ai-outbound/index.d.ts +9 -0
  17. package/lib/built/ai-outbound/index.js +9 -0
  18. package/lib/built/ai-outbound/parse.d.ts +13 -0
  19. package/lib/built/ai-outbound/parse.js +104 -0
  20. package/lib/built/ai-outbound/plain-mention-rewrite.d.ts +6 -0
  21. package/lib/built/ai-outbound/plain-mention-rewrite.js +37 -0
  22. package/lib/built/ai-outbound/prompt.d.ts +11 -0
  23. package/lib/built/ai-outbound/prompt.js +44 -0
  24. package/lib/built/ai-outbound/resolve.d.ts +4 -0
  25. package/lib/built/ai-outbound/resolve.js +64 -0
  26. package/lib/built/ai-outbound/structured-detect.d.ts +3 -0
  27. package/lib/built/ai-outbound/structured-detect.js +6 -0
  28. package/lib/built/ai-outbound/types.d.ts +58 -0
  29. package/lib/built/ai-outbound/types.js +5 -0
  30. package/lib/built/ai-trigger.d.ts +17 -17
  31. package/lib/built/ai-trigger.js +65 -70
  32. package/lib/built/authorization.d.ts +10 -0
  33. package/lib/built/authorization.js +76 -0
  34. package/lib/built/command.d.ts +9 -5
  35. package/lib/built/command.js +20 -7
  36. package/lib/built/common-adapter-tools.d.ts +35 -29
  37. package/lib/built/common-adapter-tools.js +83 -67
  38. package/lib/built/component.d.ts +1 -3
  39. package/lib/built/component.js +2 -4
  40. package/lib/built/config.d.ts +4 -5
  41. package/lib/built/config.js +26 -9
  42. package/lib/built/connect-endpoint-instance.d.ts +17 -0
  43. package/lib/built/connect-endpoint-instance.js +42 -0
  44. package/lib/built/database.d.ts +5 -3
  45. package/lib/built/database.js +10 -4
  46. package/lib/built/dispatcher.d.ts +10 -8
  47. package/lib/built/dispatcher.js +31 -9
  48. package/lib/built/endpoint-commands.d.ts +3 -0
  49. package/lib/built/endpoint-commands.js +99 -0
  50. package/lib/built/endpoint-lifecycle-service.d.ts +28 -0
  51. package/lib/built/endpoint-lifecycle-service.js +242 -0
  52. package/lib/built/endpoint-lifecycle.d.ts +27 -0
  53. package/lib/built/endpoint-lifecycle.js +36 -0
  54. package/lib/built/endpoint-manager.d.ts +34 -0
  55. package/lib/built/endpoint-manager.js +1 -0
  56. package/lib/built/generated-qrcode.d.ts +24 -0
  57. package/lib/built/generated-qrcode.js +45 -0
  58. package/lib/built/generic-segment-mapper.d.ts +4 -0
  59. package/lib/built/generic-segment-mapper.js +190 -0
  60. package/lib/built/html-renderer-loader.d.ts +13 -0
  61. package/lib/built/html-renderer-loader.js +33 -0
  62. package/lib/built/html-segment-fallback.d.ts +9 -0
  63. package/lib/built/html-segment-fallback.js +49 -0
  64. package/lib/built/html-to-text.d.ts +4 -1
  65. package/lib/built/html-to-text.js +47 -16
  66. package/lib/built/inbound-pipeline.d.ts +37 -0
  67. package/lib/built/inbound-pipeline.js +63 -0
  68. package/lib/built/inbound-runner.d.ts +0 -1
  69. package/lib/built/inbound-runner.js +0 -3
  70. package/lib/built/interactive-segment-contract.d.ts +6 -0
  71. package/lib/built/interactive-segment-contract.js +9 -0
  72. package/lib/built/interactive-segments/action.d.ts +17 -0
  73. package/lib/built/interactive-segments/action.js +69 -0
  74. package/lib/built/interactive-segments/button-spec.d.ts +10 -0
  75. package/lib/built/interactive-segments/button-spec.js +21 -0
  76. package/lib/built/interactive-segments/fallback-store.d.ts +29 -0
  77. package/lib/built/interactive-segments/fallback-store.js +63 -0
  78. package/lib/built/interactive-segments/handlers.d.ts +16 -0
  79. package/lib/built/interactive-segments/handlers.js +74 -0
  80. package/lib/built/interactive-segments/index.d.ts +8 -0
  81. package/lib/built/interactive-segments/index.js +8 -0
  82. package/lib/built/interactive-segments/keyboard-segment.d.ts +11 -0
  83. package/lib/built/interactive-segments/keyboard-segment.js +12 -0
  84. package/lib/built/interactive-segments/onebot-keyboard.d.ts +7 -0
  85. package/lib/built/interactive-segments/onebot-keyboard.js +51 -0
  86. package/lib/built/interactive-segments/resolve.d.ts +15 -0
  87. package/lib/built/interactive-segments/resolve.js +110 -0
  88. package/lib/built/interactive-segments/types.d.ts +50 -0
  89. package/lib/built/interactive-segments/types.js +9 -0
  90. package/lib/built/introspection-format.d.ts +10 -0
  91. package/lib/built/introspection-format.js +28 -0
  92. package/lib/built/login-assist.d.ts +43 -9
  93. package/lib/built/login-assist.js +113 -11
  94. package/lib/built/management-command-guard.d.ts +15 -0
  95. package/lib/built/management-command-guard.js +25 -0
  96. package/lib/built/message-enrich.d.ts +38 -0
  97. package/lib/built/message-enrich.js +75 -0
  98. package/lib/built/message-filter.d.ts +4 -5
  99. package/lib/built/message-filter.js +5 -7
  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 +22 -0
  103. package/lib/built/outbound-media-contract.js +10 -0
  104. package/lib/built/outbound-media-utils.d.ts +9 -0
  105. package/lib/built/outbound-media-utils.js +62 -0
  106. package/lib/built/permission.d.ts +3 -7
  107. package/lib/built/permission.js +39 -52
  108. package/lib/built/permit-check.d.ts +7 -0
  109. package/lib/built/permit-check.js +35 -0
  110. package/lib/built/permit-parse.d.ts +16 -0
  111. package/lib/built/permit-parse.js +32 -0
  112. package/lib/built/platform-permit.d.ts +20 -0
  113. package/lib/built/platform-permit.js +91 -0
  114. package/lib/built/queue-im-field-contract.d.ts +7 -2
  115. package/lib/built/queue-im-field-contract.js +13 -4
  116. package/lib/built/rich-segments/adapter-policies.d.ts +9 -0
  117. package/lib/built/rich-segments/adapter-policies.js +27 -0
  118. package/lib/built/rich-segments/base.d.ts +11 -0
  119. package/lib/built/rich-segments/base.js +24 -0
  120. package/lib/built/rich-segments/builtins.d.ts +4 -0
  121. package/lib/built/rich-segments/builtins.js +40 -0
  122. package/lib/built/rich-segments/capabilities.d.ts +6 -0
  123. package/lib/built/rich-segments/capabilities.js +38 -0
  124. package/lib/built/rich-segments/html-segment.d.ts +15 -0
  125. package/lib/built/rich-segments/html-segment.js +62 -0
  126. package/lib/built/rich-segments/index.d.ts +13 -0
  127. package/lib/built/rich-segments/index.js +13 -0
  128. package/lib/built/rich-segments/markdown-segment.d.ts +14 -0
  129. package/lib/built/rich-segments/markdown-segment.js +58 -0
  130. package/lib/built/rich-segments/markdown-to-text.d.ts +3 -0
  131. package/lib/built/rich-segments/markdown-to-text.js +27 -0
  132. package/lib/built/rich-segments/qrcode-segment.d.ts +18 -0
  133. package/lib/built/rich-segments/qrcode-segment.js +73 -0
  134. package/lib/built/rich-segments/registry.d.ts +16 -0
  135. package/lib/built/rich-segments/registry.js +52 -0
  136. package/lib/built/rich-segments/resolve.d.ts +5 -0
  137. package/lib/built/rich-segments/resolve.js +87 -0
  138. package/lib/built/rich-segments/tts-segment.d.ts +13 -0
  139. package/lib/built/rich-segments/tts-segment.js +51 -0
  140. package/lib/built/rich-segments/types.d.ts +79 -0
  141. package/lib/built/rich-segments/types.js +17 -0
  142. package/lib/built/roles.d.ts +4 -5
  143. package/lib/built/roles.js +4 -5
  144. package/lib/built/runtime-io.d.ts +0 -1
  145. package/lib/built/runtime-io.js +0 -1
  146. package/lib/built/schedule.d.ts +54 -0
  147. package/lib/built/schedule.js +112 -0
  148. package/lib/built/schema-endpoint-manager.d.ts +17 -0
  149. package/lib/built/schema-endpoint-manager.js +73 -0
  150. package/lib/built/schema-feature.d.ts +0 -1
  151. package/lib/built/schema-feature.js +1 -3
  152. package/lib/built/segment-contract/assert.d.ts +7 -0
  153. package/lib/built/segment-contract/assert.js +39 -0
  154. package/lib/built/segment-contract/delivery.d.ts +5 -0
  155. package/lib/built/segment-contract/delivery.js +40 -0
  156. package/lib/built/segment-contract/image.d.ts +5 -0
  157. package/lib/built/segment-contract/image.js +10 -0
  158. package/lib/built/segment-contract/index.d.ts +10 -0
  159. package/lib/built/segment-contract/index.js +9 -0
  160. package/lib/built/segment-contract/json-schema.d.ts +28 -0
  161. package/lib/built/segment-contract/json-schema.js +128 -0
  162. package/lib/built/segment-contract/media.d.ts +12 -0
  163. package/lib/built/segment-contract/media.js +22 -0
  164. package/lib/built/segment-contract/mention.d.ts +10 -0
  165. package/lib/built/segment-contract/mention.js +26 -0
  166. package/lib/built/segment-contract/preview.d.ts +3 -0
  167. package/lib/built/segment-contract/preview.js +159 -0
  168. package/lib/built/segment-contract/text.d.ts +7 -0
  169. package/lib/built/segment-contract/text.js +34 -0
  170. package/lib/built/segment-contract/types.d.ts +58 -0
  171. package/lib/built/segment-contract/types.js +1 -0
  172. package/lib/built/segment-contract/validate.d.ts +229 -0
  173. package/lib/built/segment-contract/validate.js +174 -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 +14 -0
  177. package/lib/built/speech-loader.js +32 -0
  178. package/lib/built/tool.d.ts +14 -13
  179. package/lib/built/tool.js +30 -25
  180. package/lib/built/user-interaction.d.ts +30 -0
  181. package/lib/built/user-interaction.js +248 -0
  182. package/lib/command.d.ts +19 -11
  183. package/lib/command.js +42 -11
  184. package/lib/component.d.ts +0 -1
  185. package/lib/component.js +67 -14
  186. package/lib/endpoint-capabilities.d.ts +46 -0
  187. package/lib/endpoint-capabilities.js +55 -0
  188. package/lib/endpoint.d.ts +19 -0
  189. package/lib/endpoint.js +3 -0
  190. package/lib/errors.d.ts +2 -3
  191. package/lib/errors.js +4 -5
  192. package/lib/feature/adapter.d.ts +2 -0
  193. package/lib/feature/adapter.js +2 -0
  194. package/lib/feature/command.d.ts +2 -0
  195. package/lib/feature/command.js +2 -0
  196. package/lib/feature/component.d.ts +2 -0
  197. package/lib/feature/component.js +2 -0
  198. package/lib/feature/handler.d.ts +52 -0
  199. package/lib/feature/handler.js +26 -0
  200. package/lib/feature/middleware.d.ts +2 -0
  201. package/lib/feature/middleware.js +2 -0
  202. package/lib/host-plugin-registry.d.ts +8 -0
  203. package/lib/host-plugin-registry.js +12 -0
  204. package/lib/im-scene.d.ts +29 -0
  205. package/lib/im-scene.js +75 -0
  206. package/lib/im-session-id.d.ts +39 -0
  207. package/lib/im-session-id.js +47 -0
  208. package/lib/index.d.ts +59 -21
  209. package/lib/index.js +53 -28
  210. package/lib/jsx-dev-runtime.d.ts +0 -1
  211. package/lib/jsx-dev-runtime.js +0 -1
  212. package/lib/jsx-runtime.d.ts +1 -1
  213. package/lib/jsx-runtime.js +0 -1
  214. package/lib/jsx.d.ts +19 -22
  215. package/lib/jsx.js +0 -1
  216. package/lib/message.d.ts +16 -10
  217. package/lib/message.js +16 -13
  218. package/lib/models/system-log.d.ts +0 -1
  219. package/lib/models/system-log.js +0 -1
  220. package/lib/models/user.d.ts +0 -1
  221. package/lib/models/user.js +0 -1
  222. package/lib/notice.d.ts +16 -59
  223. package/lib/notice.js +1 -4
  224. package/lib/plugin-context.d.ts +27 -0
  225. package/lib/plugin-context.js +64 -0
  226. package/lib/plugin-runtime/im/contracts.d.ts +191 -0
  227. package/lib/plugin-runtime/im/contracts.js +169 -0
  228. package/lib/plugin-runtime/im/im-runtime.d.ts +177 -0
  229. package/lib/plugin-runtime/im/im-runtime.js +1204 -0
  230. package/lib/plugin-runtime/im/index.d.ts +9 -0
  231. package/lib/plugin-runtime/im/index.js +9 -0
  232. package/lib/plugin-runtime/im/interactive.d.ts +26 -0
  233. package/lib/plugin-runtime/im/interactive.js +46 -0
  234. package/lib/plugin-runtime/im/login-assist-host.d.ts +6 -0
  235. package/lib/plugin-runtime/im/login-assist-host.js +6 -0
  236. package/lib/plugin-runtime/im/message-bus.d.ts +38 -0
  237. package/lib/plugin-runtime/im/message-bus.js +40 -0
  238. package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -0
  239. package/lib/plugin-runtime/im/message-dispatcher.js +107 -0
  240. package/lib/plugin-runtime/im/outbound-renderer.d.ts +7 -0
  241. package/lib/plugin-runtime/im/outbound-renderer.js +70 -0
  242. package/lib/plugin-runtime/im/outbound-segments.d.ts +72 -0
  243. package/lib/plugin-runtime/im/outbound-segments.js +220 -0
  244. package/lib/plugin-runtime/im/public-api.d.ts +6 -0
  245. package/lib/plugin-runtime/im/public-api.js +6 -0
  246. package/lib/plugin-runtime/im/service-tokens.d.ts +18 -0
  247. package/lib/plugin-runtime/im/service-tokens.js +13 -0
  248. package/lib/plugin.d.ts +34 -24
  249. package/lib/plugin.js +119 -224
  250. package/lib/request.d.ts +17 -61
  251. package/lib/request.js +0 -4
  252. package/lib/{prompt.d.ts → schema-interaction.d.ts} +6 -7
  253. package/lib/{prompt.js → schema-interaction.js} +20 -17
  254. package/lib/side-event/base.d.ts +52 -0
  255. package/lib/side-event/base.js +30 -0
  256. package/lib/side-event/dispatch.d.ts +15 -0
  257. package/lib/side-event/dispatch.js +140 -0
  258. package/lib/side-event/index.d.ts +4 -0
  259. package/lib/side-event/index.js +4 -0
  260. package/lib/side-event/normalize.d.ts +42 -0
  261. package/lib/side-event/normalize.js +121 -0
  262. package/lib/side-event/types.d.ts +23 -0
  263. package/lib/side-event/types.js +55 -0
  264. package/lib/system-event.d.ts +15 -0
  265. package/lib/system-event.js +7 -0
  266. package/lib/tool-zod.d.ts +18 -3
  267. package/lib/tool-zod.js +140 -54
  268. package/lib/types.d.ts +44 -85
  269. package/lib/types.js +0 -1
  270. package/lib/utils.d.ts +68 -1
  271. package/lib/utils.js +73 -11
  272. package/package.json +98 -10
  273. package/lib/adapter.d.ts.map +0 -1
  274. package/lib/adapter.js.map +0 -1
  275. package/lib/agent-prompt.d.ts +0 -37
  276. package/lib/agent-prompt.d.ts.map +0 -1
  277. package/lib/agent-prompt.js +0 -2
  278. package/lib/agent-prompt.js.map +0 -1
  279. package/lib/bot.d.ts +0 -38
  280. package/lib/bot.d.ts.map +0 -1
  281. package/lib/bot.js +0 -2
  282. package/lib/bot.js.map +0 -1
  283. package/lib/built/adapter-process.d.ts.map +0 -1
  284. package/lib/built/adapter-process.js.map +0 -1
  285. package/lib/built/agent-preset.d.ts.map +0 -1
  286. package/lib/built/agent-preset.js.map +0 -1
  287. package/lib/built/ai-trigger.d.ts.map +0 -1
  288. package/lib/built/ai-trigger.js.map +0 -1
  289. package/lib/built/command.d.ts.map +0 -1
  290. package/lib/built/command.js.map +0 -1
  291. package/lib/built/common-adapter-tools.d.ts.map +0 -1
  292. package/lib/built/common-adapter-tools.js.map +0 -1
  293. package/lib/built/component.d.ts.map +0 -1
  294. package/lib/built/component.js.map +0 -1
  295. package/lib/built/config.d.ts.map +0 -1
  296. package/lib/built/config.js.map +0 -1
  297. package/lib/built/cron.d.ts +0 -75
  298. package/lib/built/cron.d.ts.map +0 -1
  299. package/lib/built/cron.js +0 -122
  300. package/lib/built/cron.js.map +0 -1
  301. package/lib/built/database.d.ts.map +0 -1
  302. package/lib/built/database.js.map +0 -1
  303. package/lib/built/dispatcher.d.ts.map +0 -1
  304. package/lib/built/dispatcher.js.map +0 -1
  305. package/lib/built/html-to-text.d.ts.map +0 -1
  306. package/lib/built/html-to-text.js.map +0 -1
  307. package/lib/built/inbound-runner.d.ts.map +0 -1
  308. package/lib/built/inbound-runner.js.map +0 -1
  309. package/lib/built/login-assist.d.ts.map +0 -1
  310. package/lib/built/login-assist.js.map +0 -1
  311. package/lib/built/message-filter.d.ts.map +0 -1
  312. package/lib/built/message-filter.js.map +0 -1
  313. package/lib/built/permission.d.ts.map +0 -1
  314. package/lib/built/permission.js.map +0 -1
  315. package/lib/built/prepend-quote-context.d.ts +0 -33
  316. package/lib/built/prepend-quote-context.d.ts.map +0 -1
  317. package/lib/built/prepend-quote-context.js +0 -129
  318. package/lib/built/prepend-quote-context.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/roles.d.ts.map +0 -1
  322. package/lib/built/roles.js.map +0 -1
  323. package/lib/built/runtime-io.d.ts.map +0 -1
  324. package/lib/built/runtime-io.js.map +0 -1
  325. package/lib/built/schema-feature.d.ts.map +0 -1
  326. package/lib/built/schema-feature.js.map +0 -1
  327. package/lib/built/skill.d.ts.map +0 -1
  328. package/lib/built/skill.js.map +0 -1
  329. package/lib/built/tool.d.ts.map +0 -1
  330. package/lib/built/tool.js.map +0 -1
  331. package/lib/command.d.ts.map +0 -1
  332. package/lib/command.js.map +0 -1
  333. package/lib/component.d.ts.map +0 -1
  334. package/lib/component.js.map +0 -1
  335. package/lib/errors.d.ts.map +0 -1
  336. package/lib/errors.js.map +0 -1
  337. package/lib/index.d.ts.map +0 -1
  338. package/lib/index.js.map +0 -1
  339. package/lib/jsx-dev-runtime.d.ts.map +0 -1
  340. package/lib/jsx-dev-runtime.js.map +0 -1
  341. package/lib/jsx-runtime.d.ts.map +0 -1
  342. package/lib/jsx-runtime.js.map +0 -1
  343. package/lib/jsx.d.ts.map +0 -1
  344. package/lib/jsx.js.map +0 -1
  345. package/lib/message-quote.d.ts +0 -11
  346. package/lib/message-quote.d.ts.map +0 -1
  347. package/lib/message-quote.js +0 -91
  348. package/lib/message-quote.js.map +0 -1
  349. package/lib/message.d.ts.map +0 -1
  350. package/lib/message.js.map +0 -1
  351. package/lib/models/system-log.d.ts.map +0 -1
  352. package/lib/models/system-log.js.map +0 -1
  353. package/lib/models/user.d.ts.map +0 -1
  354. package/lib/models/user.js.map +0 -1
  355. package/lib/notice.d.ts.map +0 -1
  356. package/lib/notice.js.map +0 -1
  357. package/lib/plugin.d.ts.map +0 -1
  358. package/lib/plugin.js.map +0 -1
  359. package/lib/prompt.d.ts.map +0 -1
  360. package/lib/prompt.js.map +0 -1
  361. package/lib/request.d.ts.map +0 -1
  362. package/lib/request.js.map +0 -1
  363. package/lib/scheduler/scheduler.d.ts +0 -49
  364. package/lib/scheduler/scheduler.d.ts.map +0 -1
  365. package/lib/scheduler/scheduler.js +0 -352
  366. package/lib/scheduler/scheduler.js.map +0 -1
  367. package/lib/scheduler/types.d.ts +0 -71
  368. package/lib/scheduler/types.d.ts.map +0 -1
  369. package/lib/scheduler/types.js +0 -8
  370. package/lib/scheduler/types.js.map +0 -1
  371. package/lib/tool-zod.d.ts.map +0 -1
  372. package/lib/tool-zod.js.map +0 -1
  373. package/lib/types-generator.d.ts +0 -6
  374. package/lib/types-generator.d.ts.map +0 -1
  375. package/lib/types-generator.js +0 -72
  376. package/lib/types-generator.js.map +0 -1
  377. package/lib/types.d.ts.map +0 -1
  378. package/lib/types.js.map +0 -1
  379. package/lib/utils.d.ts.map +0 -1
  380. package/lib/utils.js.map +0 -1
package/lib/index.d.ts CHANGED
@@ -1,24 +1,37 @@
1
- export * from './bot.js';
1
+ /**
2
+ * Canonical IM messages, Endpoints, rendering, and plugin-facing core types.
3
+ * @module @zhin.js/core
4
+ */
5
+ export * from './endpoint.js';
6
+ export * from './endpoint-capabilities.js';
2
7
  export * from './plugin.js';
3
8
  export * from './command.js';
4
9
  export * from './component.js';
5
10
  export * from './adapter.js';
6
11
  export * from './message.js';
7
- export { quoteIdFromContent, quoteIdFromRaw, syncQuoteId, alignReplySegments } from './message-quote.js';
8
- export { htmlToPlainText, htmlToPlainTextWithBlockBreaks } from './built/html-to-text.js';
9
- export { prependQuoteContext, resolveQuotedMessagePayload, resolveQuoteContextBlock, buildUserTurnWithQuoteContext, formatQuoteContextBlock, QUOTED_MESSAGE_CONTEXT_MARKER, CURRENT_USER_MESSAGE_MARKER, QUOTE_CONTEXT_SYSTEM_HINT, QUOTE_CONTEXT_SYSTEM_EXTRA_KEY, QUOTED_CONTENT_UNTRUSTED_NOTE, sanitizeQuotedBodyForPrompt, } from './built/prepend-quote-context.js';
12
+ export * from './im-scene.js';
10
13
  export * from './notice.js';
11
14
  export * from './request.js';
12
- export * from './prompt.js';
13
- export * from './models/system-log.js';
14
- export * from './models/user.js';
15
+ export * from './system-event.js';
16
+ export * from './side-event/index.js';
17
+ export * from './schema-interaction.js';
18
+ export type * from '@zhin.js/interaction';
19
+ export * from './types.js';
20
+ export * from './utils.js';
21
+ export * from './errors.js';
15
22
  export * from './built/config.js';
16
23
  export * from './built/command.js';
17
- export * from './built/cron.js';
18
- export * from './built/permission.js';
19
- export * from './built/adapter-process.js';
20
- export { isDenoDeploy, isInteractiveStdin, shouldBindProcessStdin, runtimePid, runtimeUser, } from './built/runtime-io.js';
21
- export * from './built/component.js';
24
+ export * from './built/schedule.js';
25
+ export type { ScheduleDescriptor, ScheduleHandle, ScheduleContextExtensions } from './built/schedule.js';
26
+ export * from './models/system-log.js';
27
+ export * from './models/user.js';
28
+ export * from './built/permit-parse.js';
29
+ export * from './built/permit-check.js';
30
+ export * from './built/platform-permit.js';
31
+ export * from './built/authorization.js';
32
+ export * from './built/message-enrich.js';
33
+ export type { AgentTurnMessage, SyntheticMessageInput } from './built/message-enrich.js';
34
+ export * from './built/runtime-io.js';
22
35
  export * from './built/database.js';
23
36
  export * from './built/message-filter.js';
24
37
  export * from './built/tool.js';
@@ -26,20 +39,45 @@ export * from './built/skill.js';
26
39
  export * from './built/agent-preset.js';
27
40
  export * from './built/common-adapter-tools.js';
28
41
  export * from './built/roles.js';
42
+ export * from './im-session-id.js';
29
43
  export * from './built/ai-trigger.js';
44
+ export * from './built/ai-access.js';
30
45
  export * from './built/dispatcher.js';
31
46
  export * from './built/schema-feature.js';
32
47
  export * from './built/login-assist.js';
33
- export { BaseProvider, OpenAIProvider, DeepSeekProvider, MoonshotProvider, ZhipuProvider, AnthropicProvider, OllamaProvider, CloudflareProvider, GoogleProvider, Agent, createAgent, formatToolTitle, filterTools, tokenize, SessionManager, MemorySessionManager, DatabaseSessionManager, createSessionManager, createMemorySessionManager, createDatabaseSessionManager, AI_SESSION_MODEL, resolveIMSessionId, resolveIMSceneIdForSession, resolveIMSessionIdFromToolContext, ContextManager, createContextManager, CHAT_MESSAGE_MODEL, CONTEXT_SUMMARY_MODEL, ConversationMemory, AI_MESSAGE_MODEL, AI_SUMMARY_MODEL, estimateTokens, estimateMessagesTokens, DEFAULT_CONTEXT_TOKENS, microCompactMessages, CostTracker, CachedToolFilter, computeToolSetHash, FileStateCache, RateLimiter, detectTone, parseOutput, renderToPlainText, renderToSatori, MemoryStorageBackend, DatabaseStorageBackend, createSwappableBackend, ModelRegistry, extractModelRoot, computeTierScore, } from '@zhin.js/ai';
34
- export type { AIConfig, AIProvider, ProviderConfig, ProviderCapabilities, ChatMessage, ChatCompletionRequest, ChatCompletionResponse, ChatCompletionChunk, ContentPart, ToolCall, MessageRole, AgentTool, AgentConfig, AgentResult, ToolFilterOptions, Usage, SessionConfig, Session, JsonSchema, AgentState, AgentEvents, ContextConfig, MessageRecord as AIMessageRecord, ConversationMemoryConfig, ContextWindowSource, ContextWindowInfo, ContextWindowGuardResult, PruneResult, MicroCompactOptions, MicroCompactResult, ModelUsage, ModelPricing, CostSnapshot, RateLimitConfig, RateLimitResult, Tone, OutputElement, TextElement, ImageElement, AudioElement, VideoElement, CardElement, FileElement, StorageBackend, DbModel as AIDbModel, AIModelInfo, ModelTask, } from '@zhin.js/ai';
35
- export * from './types.js';
36
- export * from './agent-prompt.js';
37
- export * from './utils.js';
38
- export * from './errors.js';
48
+ export * from './built/generated-qrcode.js';
49
+ export * from './built/rich-segments/index.js';
50
+ export * from './built/interactive-segments/index.js';
51
+ export * from './built/user-interaction.js';
52
+ export * from './built/ai-outbound/index.js';
53
+ export { loadHtmlRenderer, seedHtmlRenderer, HTML_RENDERER_PACKAGE } from './built/html-renderer-loader.js';
54
+ export { loadSpeechPipeline, seedSpeechPipeline, SPEECH_PACKAGE } from './built/speech-loader.js';
55
+ export * from './built/outbound-media-utils.js';
56
+ export * from './built/outbound-media-contract.js';
57
+ export * from './built/interactive-segment-contract.js';
58
+ export * from './built/segment-contract/index.js';
59
+ export type { SegmentMediaRef } from './built/segment-contract/media.js';
60
+ export * from './built/generic-segment-mapper.js';
61
+ export * from './built/adapter-process.js';
62
+ export * from './built/component.js';
63
+ export * from './built/inbound-runner.js';
64
+ export type { RunInboundMessageOptions, InboundRunResult } from './built/inbound-runner.js';
65
+ export * from './built/connect-endpoint-instance.js';
66
+ export type { ConnectEndpointInstanceOptions } from './built/connect-endpoint-instance.js';
67
+ export * from './built/endpoint-lifecycle.js';
68
+ export type { EndpointLifecycleKind, EndpointLifecyclePayload } from './built/endpoint-lifecycle.js';
69
+ export * from './built/endpoint-manager.js';
70
+ export type { EndpointConfigRecord, EndpointManager, ProvisionContext } from './built/endpoint-manager.js';
71
+ export * from './built/endpoint-lifecycle-service.js';
72
+ export * from './built/schema-endpoint-manager.js';
73
+ export * from './built/endpoint-commands.js';
74
+ export * from './built/introspection-format.js';
75
+ export * from './built/management-command-guard.js';
76
+ export * from './built/html-to-text.js';
77
+ export * from './built/html-segment-fallback.js';
39
78
  export * from '@zhin.js/database';
40
79
  export * from '@zhin.js/logger';
41
80
  export { Schema } from '@zhin.js/schema';
42
81
  export type { PluginLike } from '@zhin.js/kernel';
43
- export { Feature, Cron, Scheduler, getScheduler, setScheduler, } from '@zhin.js/kernel';
44
- export type { FeatureJSON, FeatureListener, Schedule, JobPayload, JobState, ScheduledJob, JobStore, JobCallback, AddJobOptions, IScheduler, SchedulerOptions, } from '@zhin.js/kernel';
45
- //# sourceMappingURL=index.d.ts.map
82
+ export { Feature, ScheduleEngine, getScheduleEngine, setScheduleEngine, Scheduler, getScheduler, setScheduler, } from '@zhin.js/kernel';
83
+ export type { FeatureJSON, FeatureListener, Schedule, JobPayload, JobState, ScheduledJob, JobStore, JobCallback, AddJobOptions, IScheduler, SchedulerOptions, ScheduleFireCallback, MemoryScheduleRegistration, ScheduleEngineOptions, JobContext, ResolvedJob, ScheduleKind, } from '@zhin.js/kernel';
package/lib/index.js CHANGED
@@ -1,52 +1,77 @@
1
- // Core exports
2
- export * from './bot.js';
1
+ /**
2
+ * Canonical IM messages, Endpoints, rendering, and plugin-facing core types.
3
+ * @module @zhin.js/core
4
+ */
5
+ // ── Core 类模块 ──────────────────────────────────────────────────────
6
+ export * from './endpoint.js';
7
+ export * from './endpoint-capabilities.js';
3
8
  export * from './plugin.js';
4
9
  export * from './command.js';
5
10
  export * from './component.js';
6
11
  export * from './adapter.js';
7
12
  export * from './message.js';
8
- export { quoteIdFromContent, quoteIdFromRaw, syncQuoteId, alignReplySegments } from './message-quote.js';
9
- export { htmlToPlainText, htmlToPlainTextWithBlockBreaks } from './built/html-to-text.js';
10
- export { prependQuoteContext, resolveQuotedMessagePayload, resolveQuoteContextBlock, buildUserTurnWithQuoteContext, formatQuoteContextBlock, QUOTED_MESSAGE_CONTEXT_MARKER, CURRENT_USER_MESSAGE_MARKER, QUOTE_CONTEXT_SYSTEM_HINT, QUOTE_CONTEXT_SYSTEM_EXTRA_KEY, QUOTED_CONTENT_UNTRUSTED_NOTE, sanitizeQuotedBodyForPrompt, } from './built/prepend-quote-context.js';
13
+ export * from './im-scene.js';
11
14
  export * from './notice.js';
12
15
  export * from './request.js';
13
- export * from './prompt.js';
16
+ export * from './system-event.js';
17
+ export * from './side-event/index.js';
18
+ export * from './schema-interaction.js';
19
+ export * from './types.js';
20
+ export * from './utils.js';
21
+ export * from './errors.js';
22
+ // ── Built 模块 ──────────────────────────────────────────────────────
23
+ export * from './built/config.js';
24
+ export * from './built/command.js';
25
+ export * from './built/schedule.js';
14
26
  // Models
15
27
  export * from './models/system-log.js';
16
28
  export * from './models/user.js';
17
- // Built-in Contexts
18
- export * from './built/config.js';
19
- export * from './built/command.js';
20
- export * from './built/cron.js';
21
- export * from './built/permission.js';
22
- export * from './built/adapter-process.js';
23
- export { isDenoDeploy, isInteractiveStdin, shouldBindProcessStdin, runtimePid, runtimeUser, } from './built/runtime-io.js';
24
- export * from './built/component.js';
29
+ export * from './built/permit-parse.js';
30
+ export * from './built/permit-check.js';
31
+ export * from './built/platform-permit.js';
32
+ export * from './built/authorization.js';
33
+ export * from './built/message-enrich.js';
34
+ export * from './built/runtime-io.js';
25
35
  export * from './built/database.js';
26
36
  export * from './built/message-filter.js';
27
- // Tool/Skill/AgentPreset Features (backward-compat; canonical source is @zhin.js/agent)
28
37
  export * from './built/tool.js';
29
38
  export * from './built/skill.js';
30
39
  export * from './built/agent-preset.js';
31
40
  export * from './built/common-adapter-tools.js';
32
- // AI Trigger Service (纯工具,无副作用)
33
41
  export * from './built/roles.js';
42
+ export * from './im-session-id.js';
34
43
  export * from './built/ai-trigger.js';
35
- // MessageDispatcher (消息调度器)
44
+ export * from './built/ai-access.js';
36
45
  export * from './built/dispatcher.js';
37
- // Schema 注册表 (插件配置声明)
38
46
  export * from './built/schema-feature.js';
39
- // Login assist (producer-consumer for QR / SMS / slider etc.)
40
47
  export * from './built/login-assist.js';
41
- // AI 模块 — selective re-export from @zhin.js/ai to avoid conflicts with core types
42
- export { BaseProvider, OpenAIProvider, DeepSeekProvider, MoonshotProvider, ZhipuProvider, AnthropicProvider, OllamaProvider, CloudflareProvider, GoogleProvider, Agent, createAgent, formatToolTitle, filterTools, tokenize, SessionManager, MemorySessionManager, DatabaseSessionManager, createSessionManager, createMemorySessionManager, createDatabaseSessionManager, AI_SESSION_MODEL, resolveIMSessionId, resolveIMSceneIdForSession, resolveIMSessionIdFromToolContext, ContextManager, createContextManager, CHAT_MESSAGE_MODEL, CONTEXT_SUMMARY_MODEL, ConversationMemory, AI_MESSAGE_MODEL, AI_SUMMARY_MODEL, estimateTokens, estimateMessagesTokens, DEFAULT_CONTEXT_TOKENS, microCompactMessages, CostTracker, CachedToolFilter, computeToolSetHash, FileStateCache, RateLimiter, detectTone, parseOutput, renderToPlainText, renderToSatori, MemoryStorageBackend, DatabaseStorageBackend, createSwappableBackend, ModelRegistry, extractModelRoot, computeTierScore, } from '@zhin.js/ai';
43
- export * from './types.js';
44
- export * from './agent-prompt.js';
45
- export * from './utils.js';
46
- export * from './errors.js'; // 导出错误处理系统
48
+ export * from './built/generated-qrcode.js';
49
+ export * from './built/rich-segments/index.js';
50
+ export * from './built/interactive-segments/index.js';
51
+ export * from './built/user-interaction.js';
52
+ export * from './built/ai-outbound/index.js';
53
+ export { loadHtmlRenderer, seedHtmlRenderer, HTML_RENDERER_PACKAGE } from './built/html-renderer-loader.js';
54
+ export { loadSpeechPipeline, seedSpeechPipeline, SPEECH_PACKAGE } from './built/speech-loader.js';
55
+ export * from './built/outbound-media-utils.js';
56
+ export * from './built/outbound-media-contract.js';
57
+ export * from './built/interactive-segment-contract.js';
58
+ export * from './built/segment-contract/index.js';
59
+ export * from './built/generic-segment-mapper.js';
60
+ export * from './built/adapter-process.js';
61
+ export * from './built/component.js';
62
+ export * from './built/inbound-runner.js';
63
+ export * from './built/connect-endpoint-instance.js';
64
+ export * from './built/endpoint-lifecycle.js';
65
+ export * from './built/endpoint-manager.js';
66
+ export * from './built/endpoint-lifecycle-service.js';
67
+ export * from './built/schema-endpoint-manager.js';
68
+ export * from './built/endpoint-commands.js';
69
+ export * from './built/introspection-format.js';
70
+ export * from './built/management-command-guard.js';
71
+ export * from './built/html-to-text.js';
72
+ export * from './built/html-segment-fallback.js';
73
+ // ── 外部库 re-export ──────────────────────────────────────────────────
47
74
  export * from '@zhin.js/database';
48
75
  export * from '@zhin.js/logger';
49
- // 只导出 Schema 类,避免与 utils.js 的 isEmpty 冲突
50
76
  export { Schema } from '@zhin.js/schema';
51
- export { Feature, Cron, Scheduler, getScheduler, setScheduler, } from '@zhin.js/kernel';
52
- //# sourceMappingURL=index.js.map
77
+ export { Feature, ScheduleEngine, getScheduleEngine, setScheduleEngine, Scheduler, getScheduler, setScheduler, } from '@zhin.js/kernel';
@@ -1,3 +1,2 @@
1
1
  export * from './jsx-runtime.js';
2
2
  export { jsx as jsxDEV } from './jsx.js';
3
- //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './jsx-runtime.js';
2
2
  export { jsx as jsxDEV } from './jsx.js';
3
- //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -1,5 +1,6 @@
1
1
  import { jsx, jsxs, Fragment, renderJSX } from './jsx.js';
2
2
  export { jsx, jsxs, Fragment, renderJSX };
3
+ export type { JSX } from './jsx.js';
3
4
  declare const _default: {
4
5
  jsx: typeof jsx;
5
6
  jsxs: typeof jsxs;
@@ -9,4 +10,3 @@ declare const _default: {
9
10
  renderJSX: typeof renderJSX;
10
11
  };
11
12
  export default _default;
12
- //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -8,4 +8,3 @@ export default {
8
8
  Fragment,
9
9
  renderJSX
10
10
  };
11
- //# sourceMappingURL=jsx-runtime.js.map
package/lib/jsx.d.ts CHANGED
@@ -1,33 +1,30 @@
1
- import { SendContent, MessageElement } from './types.js';
2
- import { MessageComponent } from './message.js';
3
- import { Component, ComponentContext } from './component.js';
1
+ import type { SendContent, MessageElement } from './types.js';
2
+ import type { MessageComponent } from './message.js';
3
+ import type { Component, ComponentContext } from './component.js';
4
4
  export type JSXChildren = MessageElement | string | number | boolean | null | undefined | JSXChildren[];
5
5
  export type JSXElementType = string | Component<any>;
6
6
  export type JSXProps = Record<string, any> & {
7
7
  children?: JSXChildren;
8
8
  };
9
9
  export { Fragment } from './component.js';
10
- declare global {
11
- namespace JSX {
12
- type Element = SendContent | Promise<SendContent>;
13
- interface ElementClass {
14
- render(props: any, context?: ComponentContext): Element;
15
- }
16
- interface ElementAttributesProperty {
17
- data: {};
18
- }
19
- interface ElementChildrenAttribute {
20
- children: {};
21
- }
22
- interface IntrinsicElements {
23
- [elemName: string]: any;
24
- }
25
- interface IntrinsicAttributes {
26
- key?: string | number;
27
- }
10
+ export declare namespace JSX {
11
+ type Element = SendContent | Promise<SendContent>;
12
+ interface ElementClass {
13
+ render(props: any, context?: ComponentContext): Element;
14
+ }
15
+ interface ElementAttributesProperty {
16
+ data: {};
17
+ }
18
+ interface ElementChildrenAttribute {
19
+ children: {};
20
+ }
21
+ interface IntrinsicElements {
22
+ [elemName: string]: any;
23
+ }
24
+ interface IntrinsicAttributes {
25
+ key?: string | number;
28
26
  }
29
27
  }
30
28
  export declare function jsx(type: JSXElementType, data: JSXProps): MessageComponent<any>;
31
29
  export declare function jsxs(type: JSXElementType, props: JSXProps): MessageElement;
32
30
  export declare function renderJSX(element: MessageComponent<any>, context?: ComponentContext): Promise<SendContent>;
33
- //# sourceMappingURL=jsx.d.ts.map
package/lib/jsx.js CHANGED
@@ -91,4 +91,3 @@ async function renderChildren(children, context) {
91
91
  }
92
92
  return '';
93
93
  }
94
- //# sourceMappingURL=jsx.js.map
package/lib/message.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MessageElement, MessageSender, SendContent } from "./types";
1
+ import type { MessageElement, MessageSender, SendContent } from "./types.js";
2
2
  import { Component } from "./component.js";
3
3
  import { Adapters } from "./adapter.js";
4
4
  /**
@@ -16,6 +16,15 @@ export type MessageComponent<T extends object> = {
16
16
  export interface MessageChannel {
17
17
  id: string;
18
18
  type: MessageType;
19
+ /**
20
+ * 私聊/子频道消息的来源场景:
21
+ * - 群临时会话:type=private + parent.group
22
+ * - QQ 子频道:type=channel + parent.guild
23
+ */
24
+ parent?: {
25
+ type: 'group' | 'channel' | 'guild';
26
+ id: string;
27
+ };
19
28
  }
20
29
  /**
21
30
  * 消息类型枚举
@@ -27,28 +36,25 @@ export type MessageType = 'group' | 'private' | 'channel';
27
36
  export interface MessageBase {
28
37
  $id: string;
29
38
  $adapter: keyof Adapters;
30
- $bot: string;
39
+ $endpoint: string;
31
40
  $content: MessageElement[];
32
41
  $sender: MessageSender;
33
- $reply(content: SendContent, quote?: boolean | string): Promise<string>;
34
- $recall(): Promise<void>;
42
+ $reply?(content: SendContent, quote?: boolean | string): Promise<string>;
43
+ $recall?(): Promise<void>;
35
44
  $channel: MessageChannel;
36
45
  $timestamp: number;
37
46
  $raw: string;
38
- /** 本条消息引用的上游 message_id(平台原样字符串) */
39
- $quote_id?: string;
40
47
  }
41
48
  /**
42
49
  * 完整消息类型,支持扩展
43
50
  */
44
51
  export type Message<T extends object = {}> = MessageBase & T;
52
+ /** @internal Legacy static helpers; not part of Agent resource authoring. */
45
53
  export declare namespace Message {
46
54
  /**
47
55
  * 工具方法:合并自定义字段与基础消息结构
48
56
  */
49
57
  function from<T extends object>(input: T, format: MessageBase): Message<T>;
50
- function quoteIdFromContent(content: MessageElement[]): string | undefined;
51
- function syncQuoteId(message: Message<any>): void;
52
- function alignReplySegments(content: MessageElement[], quoteId?: string): void;
58
+ function actionPayload(message: Message<any>): string | undefined;
59
+ function isAction(message: Message<any>): boolean;
53
60
  }
54
- //# sourceMappingURL=message.d.ts.map
package/lib/message.js CHANGED
@@ -1,24 +1,27 @@
1
- import { alignReplySegments as alignReplySegmentsImpl, quoteIdFromContent as quoteIdFromContentImpl, syncQuoteId as syncQuoteIdImpl, } from "./message-quote.js";
1
+ import { isActionMessage as isActionMessageImpl } from "./built/interactive-segments/action.js";
2
+ /** @internal Legacy static helpers; not part of Agent resource authoring. */
2
3
  export var Message;
3
4
  (function (Message) {
4
5
  /**
5
6
  * 工具方法:合并自定义字段与基础消息结构
6
7
  */
7
8
  function from(input, format) {
8
- return Object.assign(input, format);
9
+ return Object.assign({}, input, format);
9
10
  }
10
11
  Message.from = from;
11
- function quoteIdFromContent(content) {
12
- return quoteIdFromContentImpl(content);
12
+ function actionPayload(message) {
13
+ for (const item of message.$content ?? []) {
14
+ if (typeof item === 'string')
15
+ continue;
16
+ if (item.type === 'action' && item.data?.payload) {
17
+ return String(item.data.payload);
18
+ }
19
+ }
20
+ return undefined;
13
21
  }
14
- Message.quoteIdFromContent = quoteIdFromContent;
15
- function syncQuoteId(message) {
16
- syncQuoteIdImpl(message);
22
+ Message.actionPayload = actionPayload;
23
+ function isAction(message) {
24
+ return isActionMessageImpl(message);
17
25
  }
18
- Message.syncQuoteId = syncQuoteId;
19
- function alignReplySegments(content, quoteId) {
20
- alignReplySegmentsImpl(content, quoteId);
21
- }
22
- Message.alignReplySegments = alignReplySegments;
26
+ Message.isAction = isAction;
23
27
  })(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,81 +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 } 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
- *
18
- * 适配器可自行扩展更多子类型
19
- */
20
- 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 & {});
21
- /**
22
- * 通知频道信息
23
- */
24
- export interface NoticeChannel {
25
- id: string;
26
- type: 'group' | 'private' | 'channel';
27
- }
28
- /**
29
- * 通知基础结构
30
- *
31
- * 与 MessageBase 同构设计,所有通知共享以下字段。
32
- * 适配器通过 `Notice.from(raw, base)` 合并平台原始数据和标准字段。
8
+ * 通知基础结构 — 继承 SideEventBase。
33
9
  *
34
10
  * @example
35
11
  * ```typescript
36
- * // 适配器中格式化通知
37
12
  * const notice = Notice.from(rawEvent, {
38
13
  * $id: rawEvent.id,
39
14
  * $adapter: 'icqq',
40
- * $bot: botName,
41
- * $type: 'group_member_decrease',
42
- * $subType: 'kick',
43
- * $channel: { id: groupId, type: 'group' },
44
- * $operator: { id: operatorId, name: '管理员' },
15
+ * $endpoint: endpointKey,
16
+ * $type: 'notice',
17
+ * $scene_id: groupId,
18
+ * $scene_type: 'group',
19
+ * $sub_type: 'member_decrease',
20
+ * $actor: { id: operatorId, name: '管理员' },
45
21
  * $target: { id: userId, name: '被踢者' },
46
22
  * $timestamp: Date.now(),
47
23
  * });
24
+ * // formatSideEventName(notice) === 'notice.group.member_decrease'
48
25
  * this.adapter.emit('notice.receive', notice);
49
26
  * ```
50
27
  */
51
- export interface NoticeBase {
52
- /** 通知唯一 ID(平台提供或自生成) */
53
- $id: string;
54
- /** 适配器名称 */
28
+ export interface NoticeBase extends SideEventBase {
55
29
  $adapter: keyof Adapters;
56
- /** Bot 名称 */
57
- $bot: string;
58
- /** 通知类型 */
59
- $type: NoticeType;
60
- /** 通知子类型(如 leave/kick、set/unset) */
61
- $subType?: string;
62
- /** 通知发生的频道/群/会话 */
63
- $channel: NoticeChannel;
64
- /** 操作者信息(如管理员) */
65
- $operator?: MessageSender;
66
- /** 被操作目标信息(如被踢的成员) */
67
- $target?: MessageSender;
68
- /** 通知时间戳 */
69
- $timestamp: number;
30
+ $type: NoticeKind;
70
31
  }
71
32
  /**
72
33
  * 完整通知类型,支持平台原始数据扩展
73
34
  */
74
35
  export type Notice<T extends object = {}> = NoticeBase & T;
75
36
  export declare namespace Notice {
76
- /**
77
- * 工具方法:合并自定义字段与基础通知结构
78
- */
79
37
  function from<T extends object>(input: T, format: NoticeBase): Notice<T>;
80
38
  }
81
- //# 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
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Plugin 上下文管理 — AsyncLocalStorage + getPlugin
3
+ *
4
+ * 从 plugin.ts 提取的独立关注点,消除与 Plugin 类的循环依赖。
5
+ * usePlugin() 保留在 plugin.ts(需要 Plugin 构造函数)。
6
+ */
7
+ import { AsyncLocalStorage } from "node:async_hooks";
8
+ import type { Plugin } from "./plugin.js";
9
+ export declare const storage: AsyncLocalStorage<Plugin>;
10
+ /**
11
+ * Plugin Runtime (`zhin runtime start`) 启动时调用。
12
+ * 标记后 getPlugin()/usePlugin() 在 ALS 为空时抛出更明确的迁移提示,
13
+ * 而非通用的 "must be called within a plugin context"。
14
+ */
15
+ export declare function markPluginRuntimeActive(): void;
16
+ export declare function isPluginRuntimeActive(): boolean;
17
+ /** 测试重置 */
18
+ export declare function resetPluginRuntimeFlag(): void;
19
+ /**
20
+ * 获取当前文件路径(调用者)
21
+ */
22
+ export declare function getCurrentFile(metaUrl?: string): string;
23
+ /**
24
+ * @deprecated **已删除**。请使用 `definePlugin` + 约定目录;运行时通过 Scope+Token 访问服务。
25
+ * @throws 总是抛出——仅保留签名供编译期过渡。
26
+ */
27
+ export declare function getPlugin(): Plugin;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Plugin 上下文管理 — AsyncLocalStorage + getPlugin
3
+ *
4
+ * 从 plugin.ts 提取的独立关注点,消除与 Plugin 类的循环依赖。
5
+ * usePlugin() 保留在 plugin.ts(需要 Plugin 构造函数)。
6
+ */
7
+ import { AsyncLocalStorage } from "node:async_hooks";
8
+ import * as path from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ // ============================================================================
11
+ // AsyncLocalStorage 上下文
12
+ // ============================================================================
13
+ export const storage = new AsyncLocalStorage();
14
+ let _pluginRuntimeActive = false;
15
+ /**
16
+ * Plugin Runtime (`zhin runtime start`) 启动时调用。
17
+ * 标记后 getPlugin()/usePlugin() 在 ALS 为空时抛出更明确的迁移提示,
18
+ * 而非通用的 "must be called within a plugin context"。
19
+ */
20
+ export function markPluginRuntimeActive() {
21
+ _pluginRuntimeActive = true;
22
+ }
23
+ export function isPluginRuntimeActive() {
24
+ return _pluginRuntimeActive;
25
+ }
26
+ /** 测试重置 */
27
+ export function resetPluginRuntimeFlag() {
28
+ _pluginRuntimeActive = false;
29
+ }
30
+ /**
31
+ * 获取当前文件路径(调用者)
32
+ */
33
+ export function getCurrentFile(metaUrl = import.meta.url) {
34
+ if (typeof metaUrl !== "string" || metaUrl.length === 0) {
35
+ return path.join(process.cwd(), "__zhin_edge_bootstrap__.mjs");
36
+ }
37
+ const previousPrepareStackTrace = Error.prepareStackTrace;
38
+ Error.prepareStackTrace = function (_, stack) {
39
+ return stack;
40
+ };
41
+ const stack = new Error().stack;
42
+ Error.prepareStackTrace = previousPrepareStackTrace;
43
+ const stackFiles = Array.from(new Set(stack.map((site) => site.getFileName())));
44
+ const idx = stackFiles.findIndex((f) => (metaUrl.startsWith('file://') ? f === fileURLToPath(metaUrl) : false) || f === metaUrl);
45
+ const result = stackFiles[idx + 1];
46
+ if (!result) {
47
+ return path.join(process.cwd(), "__zhin_edge_bootstrap__.mjs");
48
+ }
49
+ try {
50
+ return fileURLToPath(result);
51
+ }
52
+ catch {
53
+ return result;
54
+ }
55
+ }
56
+ /**
57
+ * @deprecated **已删除**。请使用 `definePlugin` + 约定目录;运行时通过 Scope+Token 访问服务。
58
+ * @throws 总是抛出——仅保留签名供编译期过渡。
59
+ */
60
+ export function getPlugin() {
61
+ throw new Error('getPlugin() has been removed. Use `definePlugin` + convention directories, '
62
+ + 'and access services via Scope+Token. '
63
+ + 'See docs/contributing/public-api-surface.md');
64
+ }