@zhin.js/core 1.1.34 → 1.1.37

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 (326) hide show
  1. package/README.md +84 -142
  2. package/lib/built/ai-access.d.ts +36 -0
  3. package/lib/built/ai-access.js +46 -0
  4. package/lib/built/ai-outbound/extensions/onebot-keyboard.d.ts +2 -0
  5. package/lib/built/ai-outbound/extensions/onebot-keyboard.js +67 -0
  6. package/lib/built/ai-outbound/extensions/qq-message.d.ts +3 -0
  7. package/lib/built/ai-outbound/extensions/qq-message.js +23 -0
  8. package/lib/built/ai-outbound/index.d.ts +8 -0
  9. package/lib/built/ai-outbound/index.js +8 -0
  10. package/lib/built/ai-outbound/parse.d.ts +13 -0
  11. package/lib/built/ai-outbound/parse.js +104 -0
  12. package/lib/built/ai-outbound/plain-mention-rewrite.d.ts +6 -0
  13. package/lib/built/ai-outbound/plain-mention-rewrite.js +37 -0
  14. package/lib/built/ai-outbound/prompt.d.ts +11 -0
  15. package/lib/built/ai-outbound/prompt.js +44 -0
  16. package/lib/built/ai-outbound/resolve.d.ts +4 -0
  17. package/lib/built/ai-outbound/resolve.js +64 -0
  18. package/lib/built/ai-outbound/structured-detect.d.ts +3 -0
  19. package/lib/built/ai-outbound/structured-detect.js +6 -0
  20. package/lib/built/ai-outbound/types.d.ts +49 -0
  21. package/lib/built/ai-outbound/types.js +5 -0
  22. package/lib/built/ai-trigger.d.ts +12 -17
  23. package/lib/built/ai-trigger.js +39 -70
  24. package/lib/built/common-adapter-tools.d.ts +33 -29
  25. package/lib/built/common-adapter-tools.js +79 -67
  26. package/lib/built/generated-qrcode.d.ts +24 -0
  27. package/lib/built/generated-qrcode.js +45 -0
  28. package/lib/built/generic-segment-mapper.d.ts +4 -0
  29. package/lib/built/generic-segment-mapper.js +190 -0
  30. package/lib/built/html-segment-fallback.d.ts +2 -5
  31. package/lib/built/html-segment-fallback.js +0 -16
  32. package/lib/built/html-to-text.d.ts +0 -1
  33. package/lib/built/html-to-text.js +15 -15
  34. package/lib/built/interactive-segments/action.d.ts +17 -0
  35. package/lib/built/interactive-segments/action.js +69 -0
  36. package/lib/built/interactive-segments/button-spec.d.ts +10 -0
  37. package/lib/built/interactive-segments/button-spec.js +21 -0
  38. package/lib/built/interactive-segments/index.d.ts +6 -0
  39. package/lib/built/interactive-segments/index.js +6 -0
  40. package/lib/built/interactive-segments/keyboard-segment.d.ts +10 -0
  41. package/lib/built/interactive-segments/keyboard-segment.js +11 -0
  42. package/lib/built/interactive-segments/onebot-keyboard.d.ts +6 -0
  43. package/lib/built/interactive-segments/onebot-keyboard.js +49 -0
  44. package/lib/built/interactive-segments/resolve.d.ts +14 -0
  45. package/lib/built/interactive-segments/resolve.js +109 -0
  46. package/lib/built/interactive-segments/types.d.ts +45 -0
  47. package/lib/built/interactive-segments/types.js +9 -0
  48. package/lib/built/login-assist.d.ts +43 -16
  49. package/lib/built/login-assist.js +113 -11
  50. package/lib/built/message-enrich.d.ts +32 -0
  51. package/lib/built/message-enrich.js +67 -0
  52. package/lib/built/outbound-media-utils.d.ts +9 -0
  53. package/lib/built/outbound-media-utils.js +62 -0
  54. package/lib/built/queue-im-field-contract.d.ts +7 -2
  55. package/lib/built/queue-im-field-contract.js +13 -4
  56. package/lib/built/rich-segments/markdown-to-text.d.ts +3 -0
  57. package/lib/built/rich-segments/markdown-to-text.js +27 -0
  58. package/lib/built/roles.d.ts +4 -5
  59. package/lib/built/roles.js +4 -5
  60. package/lib/built/segment-contract/assert.d.ts +7 -0
  61. package/lib/built/segment-contract/assert.js +39 -0
  62. package/lib/built/segment-contract/delivery.d.ts +5 -0
  63. package/lib/built/segment-contract/delivery.js +40 -0
  64. package/lib/built/segment-contract/image.d.ts +5 -0
  65. package/lib/built/segment-contract/image.js +10 -0
  66. package/lib/built/segment-contract/index.d.ts +10 -0
  67. package/lib/built/segment-contract/index.js +9 -0
  68. package/lib/built/segment-contract/json-schema.d.ts +28 -0
  69. package/lib/built/segment-contract/json-schema.js +128 -0
  70. package/lib/built/segment-contract/media.d.ts +12 -0
  71. package/lib/built/segment-contract/media.js +22 -0
  72. package/lib/built/segment-contract/mention.d.ts +10 -0
  73. package/lib/built/segment-contract/mention.js +26 -0
  74. package/lib/built/segment-contract/preview.d.ts +3 -0
  75. package/lib/built/segment-contract/preview.js +159 -0
  76. package/lib/built/segment-contract/text.d.ts +7 -0
  77. package/lib/built/segment-contract/text.js +34 -0
  78. package/lib/built/segment-contract/types.d.ts +58 -0
  79. package/lib/built/segment-contract/types.js +1 -0
  80. package/lib/built/segment-contract/validate.d.ts +229 -0
  81. package/lib/built/segment-contract/validate.js +172 -0
  82. package/lib/built/tool-access.d.ts +5 -0
  83. package/lib/built/tool-access.js +17 -0
  84. package/lib/built/user-interaction.d.ts +30 -0
  85. package/lib/built/user-interaction.js +244 -0
  86. package/lib/component.d.ts +0 -1
  87. package/lib/component.js +30 -14
  88. package/lib/errors.d.ts +2 -3
  89. package/lib/errors.js +4 -5
  90. package/lib/feature/adapter.d.ts +2 -0
  91. package/lib/feature/adapter.js +2 -0
  92. package/lib/feature/command.d.ts +2 -0
  93. package/lib/feature/command.js +2 -0
  94. package/lib/feature/component.d.ts +2 -0
  95. package/lib/feature/component.js +2 -0
  96. package/lib/feature/handler.d.ts +48 -0
  97. package/lib/feature/handler.js +26 -0
  98. package/lib/feature/middleware.d.ts +2 -0
  99. package/lib/feature/middleware.js +2 -0
  100. package/lib/im-scene.d.ts +29 -0
  101. package/lib/im-scene.js +75 -0
  102. package/lib/im-session-id.d.ts +39 -0
  103. package/lib/im-session-id.js +47 -0
  104. package/lib/index.d.ts +29 -36
  105. package/lib/index.js +27 -41
  106. package/lib/jsx-dev-runtime.d.ts +0 -1
  107. package/lib/jsx-dev-runtime.js +0 -1
  108. package/lib/jsx-runtime.d.ts +1 -1
  109. package/lib/jsx-runtime.js +0 -1
  110. package/lib/jsx.d.ts +19 -22
  111. package/lib/jsx.js +0 -1
  112. package/lib/message.d.ts +17 -12
  113. package/lib/message.js +16 -13
  114. package/lib/models/system-log.d.ts +0 -3
  115. package/lib/models/system-log.js +1 -9
  116. package/lib/models/user.d.ts +0 -3
  117. package/lib/models/user.js +1 -8
  118. package/lib/notice.d.ts +16 -60
  119. package/lib/notice.js +1 -4
  120. package/lib/plugin-runtime/im/contracts.d.ts +191 -0
  121. package/lib/plugin-runtime/im/contracts.js +169 -0
  122. package/lib/plugin-runtime/im/conversation-runtime.d.ts +19 -0
  123. package/lib/plugin-runtime/im/conversation-runtime.js +312 -0
  124. package/lib/plugin-runtime/im/endpoint-runtime.d.ts +79 -0
  125. package/lib/plugin-runtime/im/endpoint-runtime.js +162 -0
  126. package/lib/plugin-runtime/im/im-runtime.d.ts +84 -0
  127. package/lib/plugin-runtime/im/im-runtime.js +201 -0
  128. package/lib/plugin-runtime/im/inbound-runtime.d.ts +31 -0
  129. package/lib/plugin-runtime/im/inbound-runtime.js +252 -0
  130. package/lib/plugin-runtime/im/index.d.ts +11 -0
  131. package/lib/plugin-runtime/im/index.js +9 -0
  132. package/lib/plugin-runtime/im/ingress-route.d.ts +10 -0
  133. package/lib/plugin-runtime/im/ingress-route.js +10 -0
  134. package/lib/plugin-runtime/im/interaction-runtime.d.ts +23 -0
  135. package/lib/plugin-runtime/im/interaction-runtime.js +181 -0
  136. package/lib/plugin-runtime/im/interactive-router.d.ts +17 -0
  137. package/lib/plugin-runtime/im/interactive-router.js +98 -0
  138. package/lib/plugin-runtime/im/login-assist-host.d.ts +6 -0
  139. package/lib/plugin-runtime/im/login-assist-host.js +6 -0
  140. package/lib/plugin-runtime/im/message-bus.d.ts +38 -0
  141. package/lib/plugin-runtime/im/message-bus.js +40 -0
  142. package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -0
  143. package/lib/plugin-runtime/im/message-dispatcher.js +107 -0
  144. package/lib/plugin-runtime/im/message-events.d.ts +26 -0
  145. package/lib/plugin-runtime/im/message-events.js +61 -0
  146. package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +19 -0
  147. package/lib/plugin-runtime/im/outbound-delivery-runtime.js +165 -0
  148. package/lib/plugin-runtime/im/outbound-renderer.d.ts +7 -0
  149. package/lib/plugin-runtime/im/outbound-renderer.js +70 -0
  150. package/lib/plugin-runtime/im/outbound-segments.d.ts +71 -0
  151. package/lib/plugin-runtime/im/outbound-segments.js +219 -0
  152. package/lib/plugin-runtime/im/public-api.d.ts +6 -0
  153. package/lib/plugin-runtime/im/public-api.js +6 -0
  154. package/lib/plugin-runtime/im/runtime-middleware.d.ts +3 -0
  155. package/lib/plugin-runtime/im/runtime-middleware.js +13 -0
  156. package/lib/request.d.ts +17 -62
  157. package/lib/request.js +0 -4
  158. package/lib/side-event/base.d.ts +51 -0
  159. package/lib/side-event/base.js +30 -0
  160. package/lib/side-event/dispatch.d.ts +15 -0
  161. package/lib/side-event/dispatch.js +140 -0
  162. package/lib/side-event/index.d.ts +4 -0
  163. package/lib/side-event/index.js +4 -0
  164. package/lib/side-event/normalize.d.ts +38 -0
  165. package/lib/side-event/normalize.js +111 -0
  166. package/lib/side-event/types.d.ts +23 -0
  167. package/lib/side-event/types.js +55 -0
  168. package/lib/system-event.d.ts +14 -0
  169. package/lib/system-event.js +7 -0
  170. package/lib/types.d.ts +35 -193
  171. package/lib/types.js +0 -1
  172. package/lib/utils.d.ts +81 -6
  173. package/lib/utils.js +54 -25
  174. package/package.json +94 -16
  175. package/lib/adapter.d.ts +0 -96
  176. package/lib/adapter.d.ts.map +0 -1
  177. package/lib/adapter.js +0 -217
  178. package/lib/adapter.js.map +0 -1
  179. package/lib/agent-prompt.d.ts +0 -37
  180. package/lib/agent-prompt.d.ts.map +0 -1
  181. package/lib/agent-prompt.js +0 -2
  182. package/lib/agent-prompt.js.map +0 -1
  183. package/lib/bot.d.ts +0 -38
  184. package/lib/bot.d.ts.map +0 -1
  185. package/lib/bot.js +0 -2
  186. package/lib/bot.js.map +0 -1
  187. package/lib/built/adapter-process.d.ts +0 -43
  188. package/lib/built/adapter-process.d.ts.map +0 -1
  189. package/lib/built/adapter-process.js +0 -81
  190. package/lib/built/adapter-process.js.map +0 -1
  191. package/lib/built/agent-preset.d.ts +0 -65
  192. package/lib/built/agent-preset.d.ts.map +0 -1
  193. package/lib/built/agent-preset.js +0 -80
  194. package/lib/built/agent-preset.js.map +0 -1
  195. package/lib/built/ai-trigger.d.ts.map +0 -1
  196. package/lib/built/ai-trigger.js.map +0 -1
  197. package/lib/built/command.d.ts +0 -68
  198. package/lib/built/command.d.ts.map +0 -1
  199. package/lib/built/command.js +0 -92
  200. package/lib/built/command.js.map +0 -1
  201. package/lib/built/common-adapter-tools.d.ts.map +0 -1
  202. package/lib/built/common-adapter-tools.js.map +0 -1
  203. package/lib/built/component.d.ts +0 -69
  204. package/lib/built/component.d.ts.map +0 -1
  205. package/lib/built/component.js +0 -99
  206. package/lib/built/component.js.map +0 -1
  207. package/lib/built/config.d.ts +0 -99
  208. package/lib/built/config.d.ts.map +0 -1
  209. package/lib/built/config.js +0 -355
  210. package/lib/built/config.js.map +0 -1
  211. package/lib/built/cron.d.ts +0 -75
  212. package/lib/built/cron.d.ts.map +0 -1
  213. package/lib/built/cron.js +0 -122
  214. package/lib/built/cron.js.map +0 -1
  215. package/lib/built/database.d.ts +0 -66
  216. package/lib/built/database.d.ts.map +0 -1
  217. package/lib/built/database.js +0 -100
  218. package/lib/built/database.js.map +0 -1
  219. package/lib/built/dispatcher.d.ts +0 -139
  220. package/lib/built/dispatcher.d.ts.map +0 -1
  221. package/lib/built/dispatcher.js +0 -361
  222. package/lib/built/dispatcher.js.map +0 -1
  223. package/lib/built/html-segment-fallback.d.ts.map +0 -1
  224. package/lib/built/html-segment-fallback.js.map +0 -1
  225. package/lib/built/html-to-text.d.ts.map +0 -1
  226. package/lib/built/html-to-text.js.map +0 -1
  227. package/lib/built/inbound-runner.d.ts +0 -23
  228. package/lib/built/inbound-runner.d.ts.map +0 -1
  229. package/lib/built/inbound-runner.js +0 -37
  230. package/lib/built/inbound-runner.js.map +0 -1
  231. package/lib/built/login-assist.d.ts.map +0 -1
  232. package/lib/built/login-assist.js.map +0 -1
  233. package/lib/built/mcp-mesh-registrar.d.ts +0 -9
  234. package/lib/built/mcp-mesh-registrar.d.ts.map +0 -1
  235. package/lib/built/mcp-mesh-registrar.js +0 -17
  236. package/lib/built/mcp-mesh-registrar.js.map +0 -1
  237. package/lib/built/message-filter.d.ts +0 -177
  238. package/lib/built/message-filter.d.ts.map +0 -1
  239. package/lib/built/message-filter.js +0 -241
  240. package/lib/built/message-filter.js.map +0 -1
  241. package/lib/built/permission.d.ts +0 -55
  242. package/lib/built/permission.d.ts.map +0 -1
  243. package/lib/built/permission.js +0 -112
  244. package/lib/built/permission.js.map +0 -1
  245. package/lib/built/prepend-quote-context.d.ts +0 -35
  246. package/lib/built/prepend-quote-context.d.ts.map +0 -1
  247. package/lib/built/prepend-quote-context.js +0 -131
  248. package/lib/built/prepend-quote-context.js.map +0 -1
  249. package/lib/built/queue-im-field-contract.d.ts.map +0 -1
  250. package/lib/built/queue-im-field-contract.js.map +0 -1
  251. package/lib/built/roles.d.ts.map +0 -1
  252. package/lib/built/roles.js.map +0 -1
  253. package/lib/built/runtime-io.d.ts +0 -10
  254. package/lib/built/runtime-io.d.ts.map +0 -1
  255. package/lib/built/runtime-io.js +0 -68
  256. package/lib/built/runtime-io.js.map +0 -1
  257. package/lib/built/schema-feature.d.ts +0 -78
  258. package/lib/built/schema-feature.d.ts.map +0 -1
  259. package/lib/built/schema-feature.js +0 -132
  260. package/lib/built/schema-feature.js.map +0 -1
  261. package/lib/built/skill.d.ts +0 -121
  262. package/lib/built/skill.d.ts.map +0 -1
  263. package/lib/built/skill.js +0 -152
  264. package/lib/built/skill.js.map +0 -1
  265. package/lib/built/tool.d.ts +0 -150
  266. package/lib/built/tool.d.ts.map +0 -1
  267. package/lib/built/tool.js +0 -383
  268. package/lib/built/tool.js.map +0 -1
  269. package/lib/command.d.ts +0 -42
  270. package/lib/command.d.ts.map +0 -1
  271. package/lib/command.js +0 -75
  272. package/lib/command.js.map +0 -1
  273. package/lib/component.d.ts.map +0 -1
  274. package/lib/component.js.map +0 -1
  275. package/lib/errors.d.ts.map +0 -1
  276. package/lib/errors.js.map +0 -1
  277. package/lib/index.d.ts.map +0 -1
  278. package/lib/index.js.map +0 -1
  279. package/lib/jsx-dev-runtime.d.ts.map +0 -1
  280. package/lib/jsx-dev-runtime.js.map +0 -1
  281. package/lib/jsx-runtime.d.ts.map +0 -1
  282. package/lib/jsx-runtime.js.map +0 -1
  283. package/lib/jsx.d.ts.map +0 -1
  284. package/lib/jsx.js.map +0 -1
  285. package/lib/message-quote.d.ts +0 -11
  286. package/lib/message-quote.d.ts.map +0 -1
  287. package/lib/message-quote.js +0 -91
  288. package/lib/message-quote.js.map +0 -1
  289. package/lib/message.d.ts.map +0 -1
  290. package/lib/message.js.map +0 -1
  291. package/lib/models/system-log.d.ts.map +0 -1
  292. package/lib/models/system-log.js.map +0 -1
  293. package/lib/models/user.d.ts.map +0 -1
  294. package/lib/models/user.js.map +0 -1
  295. package/lib/notice.d.ts.map +0 -1
  296. package/lib/notice.js.map +0 -1
  297. package/lib/plugin.d.ts +0 -258
  298. package/lib/plugin.d.ts.map +0 -1
  299. package/lib/plugin.js +0 -688
  300. package/lib/plugin.js.map +0 -1
  301. package/lib/prompt.d.ts +0 -118
  302. package/lib/prompt.d.ts.map +0 -1
  303. package/lib/prompt.js +0 -244
  304. package/lib/prompt.js.map +0 -1
  305. package/lib/request.d.ts.map +0 -1
  306. package/lib/request.js.map +0 -1
  307. package/lib/scheduler/scheduler.d.ts +0 -49
  308. package/lib/scheduler/scheduler.d.ts.map +0 -1
  309. package/lib/scheduler/scheduler.js +0 -352
  310. package/lib/scheduler/scheduler.js.map +0 -1
  311. package/lib/scheduler/types.d.ts +0 -71
  312. package/lib/scheduler/types.d.ts.map +0 -1
  313. package/lib/scheduler/types.js +0 -8
  314. package/lib/scheduler/types.js.map +0 -1
  315. package/lib/tool-zod.d.ts +0 -28
  316. package/lib/tool-zod.d.ts.map +0 -1
  317. package/lib/tool-zod.js +0 -98
  318. package/lib/tool-zod.js.map +0 -1
  319. package/lib/types-generator.d.ts +0 -6
  320. package/lib/types-generator.d.ts.map +0 -1
  321. package/lib/types-generator.js +0 -72
  322. package/lib/types-generator.js.map +0 -1
  323. package/lib/types.d.ts.map +0 -1
  324. package/lib/types.js.map +0 -1
  325. package/lib/utils.d.ts.map +0 -1
  326. package/lib/utils.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ import type { AiOutboundCapabilities, AiOutboundExtensionDefinition } from './types.js';
2
+ export declare const AI_OUTBOUND_JSON_EXAMPLE = "{\"mentions\":[\"researcher\",\"210723495\"],\"text\":\"\u6B63\u6587\"}";
3
+ export declare function buildCoreAiOutboundPromptHint(capabilities?: AiOutboundCapabilities): string;
4
+ export declare function buildAiOutboundPromptHint(input: {
5
+ capabilities?: AiOutboundCapabilities;
6
+ extensions?: readonly AiOutboundExtensionDefinition[];
7
+ rosterLines?: string[];
8
+ forceJsonOnly?: boolean;
9
+ }): string;
10
+ /** Detect whether inbound text explicitly requests a structured handoff. */
11
+ export declare function detectInboundHandoffIntent(content: string): boolean;
@@ -0,0 +1,44 @@
1
+ export const AI_OUTBOUND_JSON_EXAMPLE = '{"mentions":["researcher","210723495"],"text":"正文"}';
2
+ export function buildCoreAiOutboundPromptHint(capabilities) {
3
+ const lines = [
4
+ 'When your reply must @ peers, send rich media, buttons, or delegate — output JSON only (no Markdown wrapper):',
5
+ AI_OUTBOUND_JSON_EXAMPLE,
6
+ 'mentions: peer endpoint ID or pipelineRole; text: message body.',
7
+ 'Do NOT write "@researcher" in plain text — the framework converts JSON mentions to real platform @ segments.',
8
+ ];
9
+ if (capabilities?.richSegments?.length) {
10
+ lines.push(`Rich segments (optional "segments" array): ${capabilities.richSegments.join(', ')}.`);
11
+ }
12
+ if (capabilities?.interactive === 'native') {
13
+ lines.push('Interactive buttons: use extensions field per adapter schema.');
14
+ }
15
+ return lines.join('\n');
16
+ }
17
+ export function buildAiOutboundPromptHint(input) {
18
+ const lines = [];
19
+ if (input.rosterLines?.length) {
20
+ lines.push(...input.rosterLines);
21
+ }
22
+ lines.push(buildCoreAiOutboundPromptHint(input.capabilities));
23
+ if (input.extensions?.length) {
24
+ lines.push('Adapter extensions (optional "extensions" object):');
25
+ for (const ext of input.extensions) {
26
+ lines.push(`- ${ext.key}: see platform schema`);
27
+ if (ext.examples[0])
28
+ lines.push(` example: ${ext.examples[0]}`);
29
+ }
30
+ }
31
+ if (input.forceJsonOnly) {
32
+ lines.push('MUST reply with JSON only when @ peers or handoff — no Markdown body with plain "@role" text.');
33
+ }
34
+ return lines.join('\n');
35
+ }
36
+ /** Detect whether inbound text explicitly requests a structured handoff. */
37
+ export function detectInboundHandoffIntent(content) {
38
+ const t = content.trim();
39
+ if (!t)
40
+ return false;
41
+ if (t.includes('@'))
42
+ return true;
43
+ return /依次|自我介绍|叫大家|请各位|handoff|delegate/i.test(t);
44
+ }
@@ -0,0 +1,4 @@
1
+ import type { MessageElement } from '../../types.js';
2
+ import type { AiOutboundParseContext, ZhinAiOutboundPayload } from './types.js';
3
+ /** 将 ZhinAiOutboundPayload 转为 MessageElement[](canonical segments + extensions)。 */
4
+ export declare function resolveAiOutboundToMessageElements(payload: ZhinAiOutboundPayload, ctx: AiOutboundParseContext): Promise<MessageElement[] | null>;
@@ -0,0 +1,64 @@
1
+ import { segmentsForImDelivery } from '../segment-contract/delivery.js';
2
+ function buildMentionSegments(endpointKeys, text, ctx) {
3
+ const segments = [];
4
+ for (const endpointKey of endpointKeys) {
5
+ const target = ctx.atIdResolver?.(endpointKey) ?? endpointKey;
6
+ segments.push({ type: 'mention', data: { target } });
7
+ }
8
+ const body = text.trim();
9
+ segments.push({
10
+ type: 'text',
11
+ data: { text: body.startsWith(' ') ? body : ` ${body}` },
12
+ });
13
+ return segments;
14
+ }
15
+ function resolveMentionEndpointIds(mentions, ctx) {
16
+ if (!mentions?.length) {
17
+ return { ok: false, error: 'mentions 不能为空' };
18
+ }
19
+ if (!ctx.mentionResolver) {
20
+ return { ok: false, error: 'mentionResolver 未配置' };
21
+ }
22
+ const endpointKeys = [];
23
+ for (const ref of mentions) {
24
+ const resolved = ctx.mentionResolver(ref);
25
+ if (!resolved) {
26
+ return { ok: false, error: `未知 peer "${ref}"` };
27
+ }
28
+ if (!endpointKeys.includes(resolved))
29
+ endpointKeys.push(resolved);
30
+ }
31
+ return { ok: true, endpointKeys };
32
+ }
33
+ /** 将 ZhinAiOutboundPayload 转为 MessageElement[](canonical segments + extensions)。 */
34
+ export async function resolveAiOutboundToMessageElements(payload, ctx) {
35
+ const segments = [];
36
+ if (payload.mentions?.length) {
37
+ const resolved = resolveMentionEndpointIds(payload.mentions, ctx);
38
+ if (!resolved.ok)
39
+ return null;
40
+ const text = payload.text?.trim() ?? '';
41
+ if (!text)
42
+ return null;
43
+ segments.push(...buildMentionSegments(resolved.endpointKeys, text, ctx));
44
+ }
45
+ else if (payload.text?.trim()) {
46
+ segments.push({ type: 'text', data: { text: payload.text.trim() } });
47
+ }
48
+ if (payload.segments?.length) {
49
+ segments.push(...payload.segments);
50
+ }
51
+ const parts = segments.length
52
+ ? segmentsForImDelivery(segments)
53
+ : [];
54
+ if (payload.extensions && ctx.extensions?.length) {
55
+ for (const def of ctx.extensions) {
56
+ const ext = payload.extensions[def.key];
57
+ if (ext == null || !def.toMessageElements)
58
+ continue;
59
+ const extSegments = await def.toMessageElements(ext, ctx);
60
+ parts.push(...(Array.isArray(extSegments) ? extSegments : [extSegments]));
61
+ }
62
+ }
63
+ return parts.length ? parts : null;
64
+ }
@@ -0,0 +1,3 @@
1
+ import type { StructuredOutboundDetectInput } from './types.js';
2
+ /** structured_only:满足任一即进入结构化出站模式。 */
3
+ export declare function isStructuredOutboundRequired(input: StructuredOutboundDetectInput): boolean;
@@ -0,0 +1,6 @@
1
+ /** structured_only:满足任一即进入结构化出站模式。 */
2
+ export function isStructuredOutboundRequired(input) {
3
+ return Boolean(input.toolRequiresStructured
4
+ || input.inboundHandoffIntent
5
+ || input.adapterHasExtensions);
6
+ }
@@ -0,0 +1,49 @@
1
+ import type { Message } from '../../message.js';
2
+ import type { MessageElement } from '../../types.js';
3
+ import type { InteractivePolicy } from '../interactive-segments/types.js';
4
+ import type { Segment } from '../segment-contract/types.js';
5
+ /** AI 结构化出站 payload — 平台无关 DSL(Adapter extensions 承载平台特有段)。 */
6
+ export interface ZhinAiOutboundPayload {
7
+ text?: string;
8
+ mentions?: string[];
9
+ segments?: Segment[];
10
+ extensions?: Record<string, unknown>;
11
+ }
12
+ export interface AiOutboundCapabilities {
13
+ mentions?: boolean;
14
+ richSegments?: readonly string[];
15
+ interactive?: InteractivePolicy;
16
+ }
17
+ export interface AiOutboundExtensionDefinition {
18
+ /** 平台扩展字段名,如 qq.ark / onebot.keyboard */
19
+ key: string;
20
+ /** JSON Schema 子集,对齐平台 SDK 文档 */
21
+ schema: Record<string, unknown>;
22
+ examples: readonly string[];
23
+ toMessageElements?: (ext: unknown, ctx: AiOutboundParseContext) => MessageElement[] | Promise<MessageElement[]>;
24
+ }
25
+ export interface AiOutboundMentionResolver {
26
+ (ref: string): string | undefined;
27
+ }
28
+ export interface AiOutboundAtIdResolver {
29
+ (endpointKey: string): string;
30
+ }
31
+ /** 解析 AI 出站 JSON 时的上下文。 */
32
+ export interface AiOutboundParseContext {
33
+ message: Message;
34
+ /** 将 peer ref(role/endpoint/primary)解析为 endpointKey */
35
+ mentionResolver?: AiOutboundMentionResolver;
36
+ /** 将 endpointKey 解析为 platform @ id */
37
+ atIdResolver?: AiOutboundAtIdResolver;
38
+ /** Adapter 声明的 extensions(运行时从 Adapter 静态属性注入) */
39
+ extensions?: readonly AiOutboundExtensionDefinition[];
40
+ }
41
+ export interface StructuredOutboundDetectInput {
42
+ /** 工具链要求结构化出站。 */
43
+ toolRequiresStructured?: boolean;
44
+ /** 用户入站含 handoff / @ 意图 */
45
+ inboundHandoffIntent?: boolean;
46
+ /** Adapter 声明 extensions 且非空 */
47
+ adapterHasExtensions?: boolean;
48
+ }
49
+ export declare const DEFAULT_AI_OUTBOUND_CAPABILITIES: AiOutboundCapabilities;
@@ -0,0 +1,5 @@
1
+ export const DEFAULT_AI_OUTBOUND_CAPABILITIES = {
2
+ mentions: true,
3
+ richSegments: ['qrcode', 'html', 'markdown', 'tts'],
4
+ interactive: 'text',
5
+ };
@@ -37,8 +37,6 @@ export interface AITriggerConfig {
37
37
  masters?: string[];
38
38
  /** 全局 trusted(trigger 级) */
39
39
  trusted?: string[];
40
- /** 是否在 AI 入参前拉取 $quote_id 对应消息正文(默认 true) */
41
- resolveQuotedMessages?: boolean;
42
40
  }
43
41
  /**
44
42
  * AI 触发检查结果
@@ -49,8 +47,8 @@ export interface AITriggerResult {
49
47
  }
50
48
  /** shouldTriggerAI 可选参数(如适配器提供的平台 @ ID) */
51
49
  export interface AITriggerOptions {
52
- /** 用于 @ 匹配的 bot 标识符(默认仅 message.$bot) */
53
- botAtIds?: string[];
50
+ /** 用于 @ 匹配的 Endpoint 标识符(默认仅 message.$endpoint) */
51
+ endpointAtIds?: string[];
54
52
  }
55
53
  /** 发送者角色解析结果 */
56
54
  export interface SenderRolesResult {
@@ -59,13 +57,13 @@ export interface SenderRolesResult {
59
57
  }
60
58
  export declare const DEFAULT_AI_TRIGGER_CONFIG: Required<AITriggerConfig>;
61
59
  /**
62
- * 收集用于 @ 匹配的 bot 标识符
60
+ * 收集用于 @ 匹配的 Endpoint 标识符
63
61
  */
64
- export declare function collectBotAtIds<T extends object>(message: Message<T>, extraIds?: string[]): string[];
62
+ export declare function collectEndpointAtIds<T extends object>(message: Message<T>, extraIds?: string[]): string[];
65
63
  /**
66
- * 检查消息是否 @ 了机器人
64
+ * 检查消息是否 @ 了 Endpoint
67
65
  */
68
- export declare function isAtBot<T extends object>(message: Message<T>, botAtIds?: string[]): boolean;
66
+ export declare function isAtEndpoint<T extends object>(message: Message<T>, endpointAtIds?: string[]): boolean;
69
67
  /**
70
68
  * 提取消息文本内容(保留富媒体信息)
71
69
  * 使用 segment.toString 将 MessageElement 转为 XML 格式
@@ -77,20 +75,18 @@ export declare function extractTextContent<T extends object>(message: Message<T>
77
75
  */
78
76
  export declare function parseRichMediaContent(content: string): MessageElement[];
79
77
  /**
80
- * 移除 @ 机器人的部分
78
+ * 移除 @ Endpoint 的部分
81
79
  */
82
- export declare function removeAtBot<T extends object>(message: Message<T>, botAtIds?: string[]): MessageElement[];
83
- /** Bot 配置(adapter bots[].$config) */
84
- export interface BotConfigRoles {
80
+ export declare function removeAtEndpoint<T extends object>(message: Message<T>, endpointAtIds?: string[]): MessageElement[];
81
+ /** Endpoint 配置(adapter endpoints[].$config) */
82
+ export interface EndpointConfigRoles {
85
83
  master?: unknown;
86
84
  trusted?: unknown;
87
85
  }
88
86
  /**
89
- * 解析发送者角色集合(IM 群角色 + trigger + bots[].$config)
87
+ * 解析发送者角色集合(IM 群角色 + trigger + endpoints[].$config)
90
88
  */
91
- export declare function resolveSenderRoles<T extends object>(message: Message<T>, config: AITriggerConfig, botConfig?: BotConfigRoles | Record<string, unknown> | null): SenderRolesResult;
92
- /** 从 IM 消息生成 sessionId(platform:botId:type:sceneId) */
93
- export declare function resolveIMSessionIdFromMessage<T extends object>(message: Message<T>): string;
89
+ export declare function resolveSenderRoles<T extends object>(message: Message<T>, config: AITriggerConfig, endpointConfig?: EndpointConfigRoles | Record<string, unknown> | null): SenderRolesResult;
94
90
  /**
95
91
  * 检查消息是否应该触发 AI
96
92
  */
@@ -99,4 +95,3 @@ export declare function shouldTriggerAI<T extends object>(message: Message<T>, c
99
95
  * 合并配置
100
96
  */
101
97
  export declare function mergeAITriggerConfig(config: AITriggerConfig): Required<AITriggerConfig>;
102
- //# sourceMappingURL=ai-trigger.d.ts.map
@@ -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
  }
@@ -118,23 +112,23 @@ export function parseRichMediaContent(content) {
118
112
  }
119
113
  }
120
114
  /**
121
- * 移除 @ 机器人的部分
115
+ * 移除 @ Endpoint 的部分
122
116
  */
123
- export function removeAtBot(message, botAtIds) {
124
- const botIds = normalizeAtIds(botAtIds?.length ? botAtIds : collectBotAtIds(message));
117
+ export function removeAtEndpoint(message, endpointAtIds) {
118
+ const endpointKeys = normalizeAtIds(endpointAtIds?.length ? endpointAtIds : collectEndpointAtIds(message));
125
119
  return message.$content
126
- .filter((seg) => !isAtSegmentForBot(seg, botIds))
120
+ .filter((seg) => !isAtSegmentForEndpoint(seg, endpointKeys))
127
121
  .map((seg) => {
128
122
  if (seg.type !== 'text' || !seg.data?.text)
129
123
  return seg;
130
- const stripped = stripTextAtBot(seg.data.text, botIds).trim();
124
+ const stripped = stripTextAtEndpoint(seg.data.text, endpointKeys).trim();
131
125
  if (!stripped)
132
126
  return null;
133
127
  return { ...seg, data: { ...seg.data, text: stripped } };
134
128
  })
135
129
  .filter((seg) => seg != null);
136
130
  }
137
- function normalizeBotIdList(input) {
131
+ function normalizeEndpointIdList(input) {
138
132
  if (Array.isArray(input))
139
133
  return input.map((v) => String(v)).filter(Boolean);
140
134
  if (typeof input === 'string') {
@@ -142,15 +136,15 @@ function normalizeBotIdList(input) {
142
136
  }
143
137
  return [];
144
138
  }
145
- function collectBotTrustedIds(botConfig) {
146
- if (!botConfig)
139
+ function collectEndpointTrustedIds(endpointConfig) {
140
+ if (!endpointConfig)
147
141
  return [];
148
- return normalizeBotIdList(botConfig.trusted);
142
+ return normalizeEndpointIdList(endpointConfig.trusted);
149
143
  }
150
144
  /**
151
- * 解析发送者角色集合(IM 群角色 + trigger + bots[].$config)
145
+ * 解析发送者角色集合(IM 群角色 + trigger + endpoints[].$config)
152
146
  */
153
- export function resolveSenderRoles(message, config, botConfig) {
147
+ export function resolveSenderRoles(message, config, endpointConfig) {
154
148
  const scope = message.$channel?.type || 'private';
155
149
  // process 适配器(stdin/本机 CLI):操作者即宿主用户,恒为 master
156
150
  if (message.$adapter === 'process') {
@@ -160,54 +154,29 @@ export function resolveSenderRoles(message, config, botConfig) {
160
154
  };
161
155
  }
162
156
  const senderId = String(message.$sender.id);
163
- const senderPermissions = message.$sender.permissions || [];
164
157
  const roles = [];
165
158
  const masters = config.masters || [];
166
159
  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)) {
160
+ const cfg = endpointConfig;
161
+ const endpointMaster = cfg?.master != null ? String(cfg.master) : undefined;
162
+ const endpointTrustedIds = collectEndpointTrustedIds(cfg);
163
+ if (masters.includes(senderId) || (endpointMaster != null && senderId === endpointMaster)) {
171
164
  roles.push('master');
172
165
  }
173
- else if (globalTrusted.includes(senderId) || botTrustedIds.includes(senderId)) {
166
+ else if (globalTrusted.includes(senderId) || endpointTrustedIds.includes(senderId)) {
174
167
  roles.push('trusted');
175
168
  }
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
169
  return {
188
170
  scope,
189
171
  roles: normalizeSenderRoles(roles),
190
172
  };
191
173
  }
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
174
  /**
206
175
  * 检查消息是否应该触发 AI
207
176
  */
208
177
  export function shouldTriggerAI(message, config, options) {
209
178
  const fullConfig = { ...DEFAULT_AI_TRIGGER_CONFIG, ...config };
210
- const botAtIds = collectBotAtIds(message, options?.botAtIds);
179
+ const endpointAtIds = collectEndpointAtIds(message, options?.endpointAtIds);
211
180
  if (!fullConfig.enabled) {
212
181
  return { triggered: false, content: '' };
213
182
  }
@@ -229,11 +198,12 @@ export function shouldTriggerAI(message, config, options) {
229
198
  }
230
199
  }
231
200
  // 2. 检查 @ 触发(群/频道主路径;仅 @ 无正文时也触发,由 Agent 处理空输入)
232
- if (fullConfig.respondToAt && isAtBot(message, botAtIds)) {
233
- const content = removeAtBot(message, botAtIds);
201
+ if (fullConfig.respondToAt && isAtEndpoint(message, endpointAtIds)) {
202
+ const content = removeAtEndpoint(message, endpointAtIds);
203
+ const body = content.length ? segment.toString(content).trim() : '';
234
204
  return {
235
205
  triggered: true,
236
- content: content.length ? segment.toString(content).trim() : '',
206
+ content: body,
237
207
  };
238
208
  }
239
209
  // 3. 检查私聊触发
@@ -259,4 +229,3 @@ export function shouldTriggerAI(message, config, options) {
259
229
  export function mergeAITriggerConfig(config) {
260
230
  return { ...DEFAULT_AI_TRIGGER_CONFIG, ...config };
261
231
  }
262
- //# sourceMappingURL=ai-trigger.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,17 @@ 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
+ }
57
+ export declare function createSceneManagementTools(adapter: ISceneManagement, prefix: string, options?: CreateSceneManagementToolsOptions): Tool[];
58
+ export declare function createSceneManagementToolsRaw<T>(adapter: ISceneManagement, prefix: string, factory: SceneManagementToolFactory<T>): T[];
59
+ export declare function buildSceneMethodArgs(method: keyof ISceneManagement, endpointKey: string, sceneId: string, rest: Record<string, any>): any[];