@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
@@ -9,7 +9,7 @@
9
9
  * 4. 关键词触发 - 非群/频道场景下匹配关键词时触发
10
10
  */
11
11
  import { segment } from "../utils.js";
12
- import { resolveIMSessionId, } from '@zhin.js/ai';
12
+ import { readMentionSegmentTarget } from './segment-contract/mention.js';
13
13
  import { normalizeSenderRoles, } from './roles.js';
14
14
  // ============================================================================
15
15
  // 默认配置
@@ -26,50 +26,44 @@ export const DEFAULT_AI_TRIGGER_CONFIG = {
26
26
  errorTemplate: '❌ AI 处理失败: {error}',
27
27
  masters: [],
28
28
  trusted: [],
29
- resolveQuotedMessages: true,
30
29
  };
31
30
  // ============================================================================
32
31
  // 工具函数
33
32
  // ============================================================================
34
- function normalizeAtIds(botAtIds) {
35
- const ids = botAtIds?.length ? botAtIds : [];
33
+ function normalizeAtIds(endpointAtIds) {
34
+ const ids = endpointAtIds?.length ? endpointAtIds : [];
36
35
  return [...new Set(ids.map((id) => String(id)).filter(Boolean))];
37
36
  }
38
37
  function segmentAtUserId(seg) {
39
- const { data } = seg;
40
- if (!data || typeof data !== 'object')
41
- return '';
42
- const record = data;
43
- const raw = record.user_id ?? record.qq ?? record.id;
44
- return raw == null ? '' : String(raw);
38
+ return readMentionSegmentTarget(seg);
45
39
  }
46
- function isAtSegmentForBot(seg, botIds) {
40
+ function isAtSegmentForEndpoint(seg, endpointKeys) {
47
41
  if (seg.type !== 'at' && seg.type !== 'mention')
48
42
  return false;
49
43
  const uid = segmentAtUserId(seg);
50
- return uid !== '' && botIds.includes(uid);
44
+ return uid !== '' && endpointKeys.includes(uid);
51
45
  }
52
- function textMentionsBot(text, botIds) {
53
- for (const id of botIds) {
46
+ function textMentionsEndpoint(text, endpointKeys) {
47
+ for (const id of endpointKeys) {
54
48
  const re = new RegExp(`@${id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\s|$|[\\u200b\\uFEFF])`);
55
49
  if (re.test(text))
56
50
  return true;
57
51
  }
58
52
  return false;
59
53
  }
60
- function stripTextAtBot(text, botIds) {
54
+ function stripTextAtEndpoint(text, endpointKeys) {
61
55
  let result = text;
62
- for (const id of botIds) {
56
+ for (const id of endpointKeys) {
63
57
  const re = new RegExp(`@${id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\s|[\\u200b\\uFEFF])?`, 'g');
64
58
  result = result.replace(re, '');
65
59
  }
66
60
  return result;
67
61
  }
68
62
  /**
69
- * 收集用于 @ 匹配的 bot 标识符
63
+ * 收集用于 @ 匹配的 Endpoint 标识符
70
64
  */
71
- export function collectBotAtIds(message, extraIds) {
72
- const ids = new Set([String(message.$bot)]);
65
+ export function collectEndpointAtIds(message, extraIds) {
66
+ const ids = new Set([String(message.$endpoint)]);
73
67
  for (const id of extraIds ?? []) {
74
68
  if (id)
75
69
  ids.add(String(id));
@@ -77,15 +71,15 @@ export function collectBotAtIds(message, extraIds) {
77
71
  return [...ids];
78
72
  }
79
73
  /**
80
- * 检查消息是否 @ 了机器人
74
+ * 检查消息是否 @ 了 Endpoint
81
75
  */
82
- export function isAtBot(message, botAtIds) {
83
- const botIds = normalizeAtIds(botAtIds?.length ? botAtIds : collectBotAtIds(message));
84
- if (message.$content.some((seg) => isAtSegmentForBot(seg, botIds))) {
76
+ export function isAtEndpoint(message, endpointAtIds) {
77
+ const endpointKeys = normalizeAtIds(endpointAtIds?.length ? endpointAtIds : collectEndpointAtIds(message));
78
+ if (message.$content.some((seg) => isAtSegmentForEndpoint(seg, endpointKeys))) {
85
79
  return true;
86
80
  }
87
81
  for (const seg of message.$content) {
88
- if (seg.type === 'text' && seg.data?.text && textMentionsBot(seg.data.text, botIds)) {
82
+ if (seg.type === 'text' && seg.data?.text && textMentionsEndpoint(seg.data.text, endpointKeys)) {
89
83
  return true;
90
84
  }
91
85
  }
@@ -98,6 +92,22 @@ export function isAtBot(message, botAtIds) {
98
92
  export function extractTextContent(message) {
99
93
  return segment.toString(message.$content);
100
94
  }
95
+ /**
96
+ * 为群/频道消息构建发送者前缀(与 sender-extra.ts buildSenderPrefix 格式对齐)
97
+ * 私聊消息返回 null
98
+ */
99
+ export function buildSenderPrefixForMessage(message, roles) {
100
+ const scope = message.$channel?.type || 'private';
101
+ if (scope !== 'group' && scope !== 'channel')
102
+ return null;
103
+ const rawId = String(message.$sender?.id ?? 'unknown');
104
+ const id = rawId.trim().replace(/[\]\s]+/g, '_').slice(0, 64) || 'unknown';
105
+ const rawName = message.$sender?.name;
106
+ const name = (rawName?.trim() || 'unknown').replace(/[\]\s]+/g, '_').slice(0, 64);
107
+ const nonUserRoles = roles.filter((r) => r !== 'user');
108
+ const roleStr = nonUserRoles.join(',') || 'user';
109
+ return `[sender:id=${id} name=${name} roles=${roleStr}]`;
110
+ }
101
111
  /**
102
112
  * 解析 AI 回复中的富媒体内容
103
113
  * 将字符串中的 XML-like 标签解析为 MessageElement
@@ -118,23 +128,23 @@ export function parseRichMediaContent(content) {
118
128
  }
119
129
  }
120
130
  /**
121
- * 移除 @ 机器人的部分
131
+ * 移除 @ Endpoint 的部分
122
132
  */
123
- export function removeAtBot(message, botAtIds) {
124
- const botIds = normalizeAtIds(botAtIds?.length ? botAtIds : collectBotAtIds(message));
133
+ export function removeAtEndpoint(message, endpointAtIds) {
134
+ const endpointKeys = normalizeAtIds(endpointAtIds?.length ? endpointAtIds : collectEndpointAtIds(message));
125
135
  return message.$content
126
- .filter((seg) => !isAtSegmentForBot(seg, botIds))
136
+ .filter((seg) => !isAtSegmentForEndpoint(seg, endpointKeys))
127
137
  .map((seg) => {
128
138
  if (seg.type !== 'text' || !seg.data?.text)
129
139
  return seg;
130
- const stripped = stripTextAtBot(seg.data.text, botIds).trim();
140
+ const stripped = stripTextAtEndpoint(seg.data.text, endpointKeys).trim();
131
141
  if (!stripped)
132
142
  return null;
133
143
  return { ...seg, data: { ...seg.data, text: stripped } };
134
144
  })
135
145
  .filter((seg) => seg != null);
136
146
  }
137
- function normalizeBotIdList(input) {
147
+ function normalizeEndpointIdList(input) {
138
148
  if (Array.isArray(input))
139
149
  return input.map((v) => String(v)).filter(Boolean);
140
150
  if (typeof input === 'string') {
@@ -142,15 +152,15 @@ function normalizeBotIdList(input) {
142
152
  }
143
153
  return [];
144
154
  }
145
- function collectBotTrustedIds(botConfig) {
146
- if (!botConfig)
155
+ function collectEndpointTrustedIds(endpointConfig) {
156
+ if (!endpointConfig)
147
157
  return [];
148
- return normalizeBotIdList(botConfig.trusted);
158
+ return normalizeEndpointIdList(endpointConfig.trusted);
149
159
  }
150
160
  /**
151
- * 解析发送者角色集合(IM 群角色 + trigger + bots[].$config)
161
+ * 解析发送者角色集合(IM 群角色 + trigger + endpoints[].$config)
152
162
  */
153
- export function resolveSenderRoles(message, config, botConfig) {
163
+ export function resolveSenderRoles(message, config, endpointConfig) {
154
164
  const scope = message.$channel?.type || 'private';
155
165
  // process 适配器(stdin/本机 CLI):操作者即宿主用户,恒为 master
156
166
  if (message.$adapter === 'process') {
@@ -160,60 +170,45 @@ export function resolveSenderRoles(message, config, botConfig) {
160
170
  };
161
171
  }
162
172
  const senderId = String(message.$sender.id);
163
- const senderPermissions = message.$sender.permissions || [];
164
173
  const roles = [];
165
174
  const masters = config.masters || [];
166
175
  const globalTrusted = config.trusted || [];
167
- const cfg = botConfig;
168
- const botMaster = cfg?.master != null ? String(cfg.master) : undefined;
169
- const botTrustedIds = collectBotTrustedIds(cfg);
170
- if (masters.includes(senderId) || (botMaster != null && senderId === botMaster)) {
176
+ const cfg = endpointConfig;
177
+ const endpointMaster = cfg?.master != null ? String(cfg.master) : undefined;
178
+ const endpointTrustedIds = collectEndpointTrustedIds(cfg);
179
+ if (masters.includes(senderId) || (endpointMaster != null && senderId === endpointMaster)) {
171
180
  roles.push('master');
172
181
  }
173
- else if (globalTrusted.includes(senderId) || botTrustedIds.includes(senderId)) {
182
+ else if (globalTrusted.includes(senderId) || endpointTrustedIds.includes(senderId)) {
174
183
  roles.push('trusted');
175
184
  }
176
- const isGroupOwner = senderPermissions.includes('owner')
177
- || senderPermissions.includes('group_owner')
178
- || message.$sender?.role === 'owner';
179
- const isGroupAdmin = isGroupOwner
180
- || senderPermissions.includes('admin')
181
- || senderPermissions.includes('group_admin')
182
- || message.$sender?.role === 'admin';
183
- if (isGroupOwner)
184
- roles.push('group_owner');
185
- else if (isGroupAdmin)
186
- roles.push('group_admin');
187
185
  return {
188
186
  scope,
189
187
  roles: normalizeSenderRoles(roles),
190
188
  };
191
189
  }
192
- /** 从 IM 消息生成 sessionId(platform:botId:type:sceneId) */
193
- export function resolveIMSessionIdFromMessage(message) {
194
- const scope = (message.$channel?.type || 'private');
195
- const sceneId = scope === 'private'
196
- ? String(message.$sender.id)
197
- : String(message.$channel?.id || message.$sender.id);
198
- return resolveIMSessionId({
199
- platform: message.$adapter,
200
- botId: message.$bot,
201
- scope,
202
- sceneId,
203
- });
204
- }
205
190
  /**
206
191
  * 检查消息是否应该触发 AI
207
192
  */
208
193
  export function shouldTriggerAI(message, config, options) {
209
194
  const fullConfig = { ...DEFAULT_AI_TRIGGER_CONFIG, ...config };
210
- const botAtIds = collectBotAtIds(message, options?.botAtIds);
195
+ const endpointAtIds = collectEndpointAtIds(message, options?.endpointAtIds);
211
196
  if (!fullConfig.enabled) {
212
197
  return { triggered: false, content: '' };
213
198
  }
214
199
  const text = extractTextContent(message);
215
200
  const scope = message.$channel?.type || 'private';
216
201
  const isSharedSession = scope === 'group' || scope === 'channel';
202
+ /** 对群/频道触发结果附加发送者前缀(与 DB 历史的 buildSenderPrefix 格式对齐) */
203
+ const withSenderPrefix = (content) => {
204
+ if (!isSharedSession)
205
+ return content;
206
+ const { roles } = resolveSenderRoles(message, config);
207
+ const prefix = buildSenderPrefixForMessage(message, roles);
208
+ if (!prefix)
209
+ return content;
210
+ return content ? `${prefix} ${content}` : prefix;
211
+ };
217
212
  // 检查忽略前缀
218
213
  for (const prefix of fullConfig.ignorePrefixes) {
219
214
  if (text.startsWith(prefix)) {
@@ -229,11 +224,12 @@ export function shouldTriggerAI(message, config, options) {
229
224
  }
230
225
  }
231
226
  // 2. 检查 @ 触发(群/频道主路径;仅 @ 无正文时也触发,由 Agent 处理空输入)
232
- if (fullConfig.respondToAt && isAtBot(message, botAtIds)) {
233
- const content = removeAtBot(message, botAtIds);
227
+ if (fullConfig.respondToAt && isAtEndpoint(message, endpointAtIds)) {
228
+ const content = removeAtEndpoint(message, endpointAtIds);
229
+ const body = content.length ? segment.toString(content).trim() : '';
234
230
  return {
235
231
  triggered: true,
236
- content: content.length ? segment.toString(content).trim() : '',
232
+ content: withSenderPrefix(body),
237
233
  };
238
234
  }
239
235
  // 3. 检查私聊触发
@@ -259,4 +255,3 @@ export function shouldTriggerAI(message, config, options) {
259
255
  export function mergeAITriggerConfig(config) {
260
256
  return { ...DEFAULT_AI_TRIGGER_CONFIG, ...config };
261
257
  }
262
- //# sourceMappingURL=ai-trigger.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 授权重算 — ConfigFeature + Message 为单一真相源($sender.isMaster/isTrusted 为 enrich 快照)
3
+ */
4
+ import type { Plugin } from '../plugin.js';
5
+ import type { Message } from '../message.js';
6
+ import { type SenderRolesResult } from './ai-trigger.js';
7
+ /**
8
+ * 从 ConfigFeature + Message 重算发送者角色(含群角色与 master/trusted)
9
+ */
10
+ export declare function resolveSubjectRoles(plugin: Plugin, message: Message<any>): SenderRolesResult;
@@ -0,0 +1,76 @@
1
+ import { mergeAITriggerConfig, resolveSenderRoles, } from './ai-trigger.js';
2
+ import { formatCompact, getLogger } from '@zhin.js/logger';
3
+ const logger = getLogger('Authorization');
4
+ function findEndpointEntryFromConfig(config, adapter, endpointKey) {
5
+ // 1) top-level endpoints[] (legacy / flat format)
6
+ const topLevel = config.endpoints;
7
+ if (Array.isArray(topLevel)) {
8
+ const found = topLevel.find((b) => b.context === adapter && String(b.id) === endpointKey);
9
+ if (found)
10
+ return found;
11
+ }
12
+ // 2) plugins.<adapter> — adapter-level master/trusted + nested endpoints[]
13
+ const adapterConfig = config.plugins?.[adapter];
14
+ if (!adapterConfig)
15
+ return undefined;
16
+ const nested = adapterConfig.endpoints;
17
+ const entry = Array.isArray(nested)
18
+ ? nested.find((b) => String(b.id) === endpointKey)
19
+ : undefined;
20
+ // Merge adapter-level master/trusted onto the matched endpoint entry
21
+ // so that resolveSenderRoles sees them in one place
22
+ const merged = {
23
+ context: adapter,
24
+ ...(entry ?? { id: endpointKey }),
25
+ };
26
+ if (adapterConfig.master != null && merged.master == null) {
27
+ merged.master = adapterConfig.master;
28
+ }
29
+ if (adapterConfig.trusted != null && merged.trusted == null) {
30
+ merged.trusted = adapterConfig.trusted;
31
+ }
32
+ return merged;
33
+ }
34
+ function readTriggerConfig(plugin) {
35
+ const root = plugin.root ?? plugin;
36
+ try {
37
+ const ai = root.inject('ai');
38
+ if (ai?.getTriggerConfig)
39
+ return ai.getTriggerConfig();
40
+ }
41
+ catch (e) {
42
+ logger.debug(formatCompact({ auth: 'trigger_config_fallback', reason: 'ai_not_ready' }));
43
+ }
44
+ try {
45
+ const configSvc = root.inject('config');
46
+ const primary = configSvc?.getPrimary?.();
47
+ return primary?.ai?.trigger ?? {};
48
+ }
49
+ catch (e) {
50
+ logger.debug(formatCompact({ auth: 'trigger_config_read_error' }));
51
+ return {};
52
+ }
53
+ }
54
+ function readEndpointConfig(plugin, message) {
55
+ const root = plugin.root ?? plugin;
56
+ try {
57
+ const configSvc = root.inject('config');
58
+ const primary = configSvc?.getPrimary?.();
59
+ if (!primary)
60
+ return undefined;
61
+ const entry = findEndpointEntryFromConfig(primary, String(message.$adapter), String(message.$endpoint));
62
+ return entry;
63
+ }
64
+ catch (e) {
65
+ logger.debug(formatCompact({ auth: 'endpoint_config_read_error' }));
66
+ return undefined;
67
+ }
68
+ }
69
+ /**
70
+ * 从 ConfigFeature + Message 重算发送者角色(含群角色与 master/trusted)
71
+ */
72
+ export function resolveSubjectRoles(plugin, message) {
73
+ const triggerConfig = mergeAITriggerConfig(readTriggerConfig(plugin));
74
+ const endpointConfig = readEndpointConfig(plugin, message);
75
+ return resolveSenderRoles(message, triggerConfig, endpointConfig);
76
+ }
@@ -5,15 +5,17 @@
5
5
  import { Feature, FeatureJSON } from "@zhin.js/kernel";
6
6
  /** 命令 pattern 的首个词(用于前缀排序) */
7
7
  export declare function commandLeadingToken(pattern: string): string;
8
+ /** 命令匹配优先级:首词越长越优先;同首词则完整 pattern 越长越优先 */
9
+ export declare function compareCommandPatterns(a: string, b: string): number;
8
10
  import { MessageCommand } from "../command.js";
9
11
  import { Message } from "../message.js";
10
- import { Plugin } from "../plugin.js";
11
12
  import type { RegisteredAdapter, AdapterMessage } from "../types.js";
13
+ import type { PermissionHost } from '@zhin.js/permission';
12
14
  /**
13
15
  * CommandContext 扩展方法类型
14
16
  */
15
17
  export interface CommandContextExtensions {
16
- /** 添加命令 */
18
+ /** @deprecated 使用 `defineCommand` + `commands/`;勿在新代码调用。 */
17
19
  addCommand<T extends RegisteredAdapter>(command: MessageCommand<T>): () => void;
18
20
  }
19
21
  declare module "../plugin.js" {
@@ -26,7 +28,10 @@ declare module "../plugin.js" {
26
28
  }
27
29
  }
28
30
  /**
29
- * 命令服务 Feature
31
+ * 命令服务 Feature(经典 MessageCommand 注册表)。
32
+ *
33
+ * @deprecated 新命令走 `@zhin.js/command` 的 `defineCommand` + 约定目录发现。
34
+ * 本 Feature 仍服务 Agent / game-kit / legacy Plugin.addCommand。
30
35
  */
31
36
  export declare class CommandFeature extends Feature<MessageCommand<RegisteredAdapter>> {
32
37
  readonly name: "command";
@@ -49,7 +54,7 @@ export declare class CommandFeature extends Feature<MessageCommand<RegisteredAda
49
54
  /**
50
55
  * 处理消息,依次尝试匹配命令(较长前缀优先,避免 `teach` 抢 `teach-list`)
51
56
  */
52
- handle(message: Message<AdapterMessage<RegisteredAdapter>>, plugin: Plugin): Promise<any>;
57
+ handle(message: Message<AdapterMessage<RegisteredAdapter>>, host: PermissionHost | null): Promise<any>;
53
58
  /**
54
59
  * 生命周期: 销毁时清理所有命令
55
60
  */
@@ -65,4 +70,3 @@ export declare class CommandFeature extends Feature<MessageCommand<RegisteredAda
65
70
  addCommand<T extends RegisteredAdapter>(command: MessageCommand<T>): () => void;
66
71
  };
67
72
  }
68
- //# sourceMappingURL=command.d.ts.map
@@ -7,9 +7,23 @@ import { Feature } from "@zhin.js/kernel";
7
7
  export function commandLeadingToken(pattern) {
8
8
  return pattern.split(/\s/)[0] ?? "";
9
9
  }
10
- import { getPlugin } from "../plugin.js";
10
+ /** 命令匹配优先级:首词越长越优先;同首词则完整 pattern 越长越优先 */
11
+ export function compareCommandPatterns(a, b) {
12
+ const leadDiff = commandLeadingToken(b).length - commandLeadingToken(a).length;
13
+ if (leadDiff !== 0)
14
+ return leadDiff;
15
+ const lenDiff = b.length - a.length;
16
+ if (lenDiff !== 0)
17
+ return lenDiff;
18
+ const tokA = a.trim().split(/\s+/).length;
19
+ const tokB = b.trim().split(/\s+/).length;
20
+ return tokB - tokA;
21
+ }
11
22
  /**
12
- * 命令服务 Feature
23
+ * 命令服务 Feature(经典 MessageCommand 注册表)。
24
+ *
25
+ * @deprecated 新命令走 `@zhin.js/command` 的 `defineCommand` + 约定目录发现。
26
+ * 本 Feature 仍服务 Agent / game-kit / legacy Plugin.addCommand。
13
27
  */
14
28
  export class CommandFeature extends Feature {
15
29
  name = 'command';
@@ -40,10 +54,10 @@ export class CommandFeature extends Feature {
40
54
  /**
41
55
  * 处理消息,依次尝试匹配命令(较长前缀优先,避免 `teach` 抢 `teach-list`)
42
56
  */
43
- async handle(message, plugin) {
44
- const commands = [...this.items].sort((a, b) => commandLeadingToken(b.pattern).length - commandLeadingToken(a.pattern).length);
57
+ async handle(message, host) {
58
+ const commands = [...this.items].sort((a, b) => compareCommandPatterns(a.pattern, b.pattern));
45
59
  for (const command of commands) {
46
- const result = await command.handle(message, plugin);
60
+ const result = await command.handle(message, host);
47
61
  if (result)
48
62
  return result;
49
63
  }
@@ -80,7 +94,7 @@ export class CommandFeature extends Feature {
80
94
  const feature = this;
81
95
  return {
82
96
  addCommand(command) {
83
- const plugin = getPlugin();
97
+ const plugin = this;
84
98
  const dispose = feature.add(command, plugin.name);
85
99
  plugin.recordFeatureContribution(feature.name, command.pattern);
86
100
  plugin.onDispose(dispose);
@@ -89,4 +103,3 @@ export class CommandFeature extends Feature {
89
103
  };
90
104
  }
91
105
  }
92
- //# sourceMappingURL=command.js.map
@@ -1,40 +1,40 @@
1
1
  /**
2
- * Group Management — 方法规范与 Tool 工厂
2
+ * Scene Management — 方法规范与 Tool 工厂
3
3
  *
4
4
  * 设计理念:
5
- * 各 IM 平台在适配器内自行实现群管方法(kickMember、muteMember 等),
5
+ * 各 IM 平台在适配器内自行实现场景治理方法(removeMember、muteMember 等),
6
6
  * 并自行注册 Tool;平台说明使用包内 `skills/<adapter>/SKILL.md`。
7
7
  *
8
8
  * 使用方式(在各适配器 start 或注册方法中):
9
9
  *
10
- * import { createGroupManagementTools, GROUP_MANAGEMENT_SKILL_KEYWORDS, GROUP_MANAGEMENT_SKILL_TAGS } from 'zhin.js';
11
- * const tools = createGroupManagementTools(this, this.name);
10
+ * import { createSceneManagementTools, SCENE_MANAGEMENT_SKILL_KEYWORDS, SCENE_MANAGEMENT_SKILL_TAGS } from 'zhin.js';
11
+ * const tools = createSceneManagementTools(this, this.name);
12
12
  * tools.forEach(t => this.addTool(t));
13
13
  * // 另:包内 skills/<name>/SKILL.md 供 Agent 发现
14
14
  */
15
- import type { Tool, SenderRole } from '../types.js';
15
+ import type { Tool } from '../types.js';
16
16
  /**
17
- * 群管理能力接口。
17
+ * 场景治理能力接口。
18
18
  * Adapter 基类通过此接口声明方法签名,子类选择性覆写。
19
19
  */
20
- export interface IGroupManagement {
21
- kickMember?(botId: string, sceneId: string, userId: string): Promise<any>;
22
- muteMember?(botId: string, sceneId: string, userId: string, duration?: number): Promise<any>;
23
- setMemberNickname?(botId: string, sceneId: string, userId: string, nickname: string): Promise<any>;
24
- setAdmin?(botId: string, sceneId: string, userId: string, enable?: boolean): Promise<any>;
25
- listMembers?(botId: string, sceneId: string): Promise<any>;
26
- banMember?(botId: string, sceneId: string, userId: string, reason?: string): Promise<any>;
27
- unbanMember?(botId: string, sceneId: string, userId: string): Promise<any>;
28
- setGroupName?(botId: string, sceneId: string, name: string): Promise<any>;
29
- muteAll?(botId: string, sceneId: string, enable?: boolean): Promise<any>;
30
- getGroupInfo?(botId: string, sceneId: string): Promise<any>;
20
+ export interface ISceneManagement {
21
+ removeMember?(endpointKey: string, sceneId: string, userId: string): Promise<any>;
22
+ muteMember?(endpointKey: string, sceneId: string, userId: string, duration?: number): Promise<any>;
23
+ setMemberNickname?(endpointKey: string, sceneId: string, userId: string, nickname: string): Promise<any>;
24
+ setModerator?(endpointKey: string, sceneId: string, userId: string, enable?: boolean): Promise<any>;
25
+ listMembers?(endpointKey: string, sceneId: string): Promise<any>;
26
+ banMember?(endpointKey: string, sceneId: string, userId: string, reason?: string): Promise<any>;
27
+ unbanMember?(endpointKey: string, sceneId: string, userId: string): Promise<any>;
28
+ renameScene?(endpointKey: string, sceneId: string, name: string): Promise<any>;
29
+ setSceneMuted?(endpointKey: string, sceneId: string, enable?: boolean): Promise<any>;
30
+ getSceneInfo?(endpointKey: string, sceneId: string): Promise<any>;
31
31
  }
32
- export interface GroupMethodSpec {
33
- method: keyof IGroupManagement;
32
+ export interface SceneManagementMethodSpec {
33
+ method: keyof ISceneManagement;
34
34
  toolSuffix: string;
35
35
  description: string;
36
36
  keywords: string[];
37
- requiredAnyRole?: SenderRole[];
37
+ permit?: string;
38
38
  extraParams: Record<string, {
39
39
  type: string;
40
40
  description: string;
@@ -43,13 +43,19 @@ export interface GroupMethodSpec {
43
43
  extraRequired?: string[];
44
44
  preExecutable?: boolean;
45
45
  }
46
- export declare const GROUP_METHOD_SPECS: GroupMethodSpec[];
47
- export declare const GROUP_MANAGEMENT_SKILL_TAGS: string[];
48
- export declare const GROUP_MANAGEMENT_SKILL_KEYWORDS: string[];
49
- export interface GroupManagementToolFactory<T> {
50
- (spec: GroupMethodSpec, prefix: string, execute: (args: Record<string, any>) => Promise<any>): T;
46
+ export declare const SCENE_MANAGEMENT_METHOD_SPECS: SceneManagementMethodSpec[];
47
+ export declare const SCENE_MANAGEMENT_SKILL_TAGS: string[];
48
+ export declare const SCENE_MANAGEMENT_SKILL_KEYWORDS: string[];
49
+ export interface SceneManagementToolFactory<T> {
50
+ (spec: SceneManagementMethodSpec, prefix: string, execute: (args: Record<string, any>) => Promise<any>): T;
51
51
  }
52
- export declare function createGroupManagementTools(adapter: IGroupManagement, prefix: string): Tool[];
53
- export declare function createGroupManagementToolsRaw<T>(adapter: IGroupManagement, prefix: string, factory: GroupManagementToolFactory<T>): T[];
54
- export declare function buildMethodArgs(method: keyof IGroupManagement, botId: string, sceneId: string, rest: Record<string, any>): any[];
55
- //# sourceMappingURL=common-adapter-tools.d.ts.map
52
+ export declare function defaultScenePermitResolver(adapterPrefix: string): (logicalPerm: string) => string;
53
+ export interface CreateSceneManagementToolsOptions {
54
+ /** SCENE_MANAGEMENT_METHOD_SPECS 逻辑 perm(scene_admin/scene_owner)映射为 platform(...) 字符串 */
55
+ permitResolver?: (logicalPerm: string) => string | undefined;
56
+ /** 是否注册默认 QQ 系 scene checker(默认 true) */
57
+ registerChecker?: boolean;
58
+ }
59
+ export declare function createSceneManagementTools(adapter: ISceneManagement, prefix: string, options?: CreateSceneManagementToolsOptions): Tool[];
60
+ export declare function createSceneManagementToolsRaw<T>(adapter: ISceneManagement, prefix: string, factory: SceneManagementToolFactory<T>): T[];
61
+ export declare function buildSceneMethodArgs(method: keyof ISceneManagement, endpointKey: string, sceneId: string, rest: Record<string, any>): any[];