@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/tool-zod.d.ts CHANGED
@@ -10,8 +10,24 @@
10
10
  * const tool = createToolFromZod('my_tool', '描述', z.object({ id: z.string() }), async (args) => { ... });
11
11
  * plugin.addTool(tool);
12
12
  */
13
- import type { Tool, ToolContext } from './types.js';
13
+ import type { Tool, ToolParametersSchema } from './types.js';
14
+ import type { Message } from './message.js';
14
15
  type MaybePromise<T> = T | Promise<T>;
16
+ export type ToolSchemaParseResult<T> = {
17
+ ok: true;
18
+ data: T;
19
+ } | {
20
+ ok: false;
21
+ error: string;
22
+ };
23
+ /**
24
+ * Normalize a JSON Schema or Zod object schema into the canonical Core tool
25
+ * parameter schema. Zod remains an optional peer: this adapter uses only its
26
+ * public instance methods and retains a structural fallback for Zod 3.
27
+ */
28
+ export declare function toolInputSchemaToParameters(schema: unknown): ToolParametersSchema;
29
+ /** Validate input with a Zod-like schema, or pass it through for JSON Schema. */
30
+ export declare function parseToolInputSchema<T>(schema: unknown, input: unknown): ToolSchemaParseResult<T>;
15
31
  export interface CreateToolFromZodOptions {
16
32
  tags?: string[];
17
33
  keywords?: string[];
@@ -23,6 +39,5 @@ export interface CreateToolFromZodOptions {
23
39
  * 从 Zod 模式创建 Tool,便于类型安全与校验。
24
40
  * 需要安装 zod:pnpm add zod。传入的 schema 应为 z.object({ ... })。
25
41
  */
26
- export declare function createToolFromZod<T extends Record<string, any>>(name: string, description: string, schema: any, execute: (args: T, context?: ToolContext) => MaybePromise<any>, options?: CreateToolFromZodOptions): Tool;
42
+ export declare function createToolFromZod<T extends Record<string, any>>(name: string, description: string, schema: any, execute: (args: T, message?: Message<any>) => MaybePromise<any>, options?: CreateToolFromZodOptions): Tool;
27
43
  export {};
28
- //# sourceMappingURL=tool-zod.d.ts.map
package/lib/tool-zod.js CHANGED
@@ -10,62 +10,151 @@
10
10
  * const tool = createToolFromZod('my_tool', '描述', z.object({ id: z.string() }), async (args) => { ... });
11
11
  * plugin.addTool(tool);
12
12
  */
13
- function zodFieldToJsonSchema(z) {
14
- if (!z || !z._def)
13
+ function isRecord(value) {
14
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
15
+ }
16
+ function getShape(schema) {
17
+ const shape = schema?.shape;
18
+ if (typeof shape === 'function') {
19
+ const value = shape();
20
+ return isRecord(value) ? value : undefined;
21
+ }
22
+ return isRecord(shape) ? shape : undefined;
23
+ }
24
+ function acceptsUndefined(schema) {
25
+ const candidate = schema;
26
+ if (typeof candidate?.safeParse === 'function') {
27
+ try {
28
+ return candidate.safeParse(undefined).success;
29
+ }
30
+ catch {
31
+ // Fall through to structural compatibility for non-Zod lookalikes.
32
+ }
33
+ }
34
+ const def = candidate?._def;
35
+ const kind = def?.typeName ?? def?.type;
36
+ return kind === 'ZodOptional'
37
+ || kind === 'ZodDefault'
38
+ || kind === 'optional'
39
+ || kind === 'default';
40
+ }
41
+ function requiredFromShape(schema, fallback) {
42
+ const shape = getShape(schema);
43
+ if (!shape)
44
+ return fallback?.length ? [...fallback] : undefined;
45
+ const required = Object.entries(shape)
46
+ .filter(([, field]) => !acceptsUndefined(field))
47
+ .map(([key]) => key);
48
+ return required.length ? required : undefined;
49
+ }
50
+ function descriptionOf(schema, def) {
51
+ const description = schema?.description ?? def.description;
52
+ return typeof description === 'string' ? description : undefined;
53
+ }
54
+ function zodFieldToJsonSchema(schema) {
55
+ const candidate = schema;
56
+ const def = candidate?._def;
57
+ if (!isRecord(def))
15
58
  return { type: 'string' };
16
- const def = z._def;
17
- const typeName = def.typeName;
18
- if (typeName === 'ZodOptional' || typeName === 'ZodDefault') {
19
- const inner = def.innerType ?? def.type;
20
- return zodFieldToJsonSchema(inner);
59
+ const kind = def.typeName ?? def.type;
60
+ if (kind === 'ZodOptional' || kind === 'ZodDefault' || kind === 'optional' || kind === 'default') {
61
+ return zodFieldToJsonSchema(def.innerType ?? def.type);
21
62
  }
22
- if (typeName === 'ZodString') {
23
- const out = { type: 'string' };
24
- if (def.description)
25
- out.description = def.description;
26
- return out;
63
+ const description = descriptionOf(schema, def);
64
+ const withDescription = (type) => description
65
+ ? { type, description }
66
+ : { type };
67
+ if (kind === 'ZodString' || kind === 'string')
68
+ return withDescription('string');
69
+ if (kind === 'ZodNumber' || kind === 'number')
70
+ return withDescription('number');
71
+ if (kind === 'ZodBoolean' || kind === 'boolean')
72
+ return withDescription('boolean');
73
+ if (kind === 'ZodEnum' || kind === 'enum') {
74
+ const values = Array.isArray(def.values)
75
+ ? def.values
76
+ : isRecord(def.entries)
77
+ ? Object.values(def.entries)
78
+ : [];
79
+ return { ...withDescription('string'), enum: values };
27
80
  }
28
- if (typeName === 'ZodNumber') {
29
- const out = { type: 'number' };
30
- if (def.description)
31
- out.description = def.description;
32
- return out;
81
+ if (kind === 'ZodArray' || kind === 'array') {
82
+ return {
83
+ ...withDescription('array'),
84
+ items: zodFieldToJsonSchema(def.element ?? def.type),
85
+ };
33
86
  }
34
- if (typeName === 'ZodBoolean') {
35
- const out = { type: 'boolean' };
36
- if (def.description)
37
- out.description = def.description;
38
- return out;
87
+ if (kind === 'ZodObject' || kind === 'object') {
88
+ return toolInputSchemaToParameters(schema);
39
89
  }
40
- if (typeName === 'ZodEnum') {
41
- return { type: 'string', enum: def.values };
90
+ return withDescription('string');
91
+ }
92
+ function isJsonObjectSchema(schema) {
93
+ if (!isRecord(schema) || schema.type !== 'object')
94
+ return false;
95
+ return typeof schema.safeParse !== 'function';
96
+ }
97
+ function fromNativeJsonSchema(schema) {
98
+ const candidate = schema;
99
+ if (typeof candidate?.toJSONSchema !== 'function')
100
+ return undefined;
101
+ try {
102
+ const converted = candidate.toJSONSchema();
103
+ if (!isRecord(converted) || converted.type !== 'object')
104
+ return undefined;
105
+ return {
106
+ ...converted,
107
+ type: 'object',
108
+ properties: isRecord(converted.properties)
109
+ ? converted.properties
110
+ : {},
111
+ required: requiredFromShape(schema, Array.isArray(converted.required)
112
+ ? converted.required.filter((key) => typeof key === 'string')
113
+ : undefined),
114
+ };
42
115
  }
43
- if (typeName === 'ZodArray') {
44
- return { type: 'array', items: zodFieldToJsonSchema(def.type ?? def.element) };
116
+ catch {
117
+ return undefined;
45
118
  }
46
- return { type: 'string' };
47
119
  }
48
- function zodToJsonSchema(schema) {
49
- const result = {
120
+ /**
121
+ * Normalize a JSON Schema or Zod object schema into the canonical Core tool
122
+ * parameter schema. Zod remains an optional peer: this adapter uses only its
123
+ * public instance methods and retains a structural fallback for Zod 3.
124
+ */
125
+ export function toolInputSchemaToParameters(schema) {
126
+ if (isJsonObjectSchema(schema))
127
+ return schema;
128
+ const native = fromNativeJsonSchema(schema);
129
+ if (native)
130
+ return native;
131
+ const shape = getShape(schema);
132
+ const properties = {};
133
+ if (shape) {
134
+ for (const [key, value] of Object.entries(shape)) {
135
+ properties[key] = zodFieldToJsonSchema(value);
136
+ }
137
+ }
138
+ return {
50
139
  type: 'object',
51
- properties: {},
52
- required: [],
140
+ properties: properties,
141
+ required: requiredFromShape(schema),
53
142
  };
54
- if (!schema || !schema.shape)
55
- return result;
56
- const shape = schema.shape;
57
- const properties = result.properties;
58
- const required = [];
59
- for (const [key, value] of Object.entries(shape)) {
60
- const zodValue = value;
61
- properties[key] = zodFieldToJsonSchema(zodValue);
62
- const typeName = zodValue?._def?.typeName;
63
- if (typeName !== 'ZodOptional' && typeName !== 'ZodDefault') {
64
- required.push(key);
65
- }
143
+ }
144
+ /** Validate input with a Zod-like schema, or pass it through for JSON Schema. */
145
+ export function parseToolInputSchema(schema, input) {
146
+ const candidate = schema;
147
+ if (typeof candidate?.safeParse !== 'function') {
148
+ return { ok: true, data: input };
66
149
  }
67
- result.required = required.length > 0 ? required : undefined;
68
- return result;
150
+ const parsed = candidate.safeParse(input);
151
+ if (parsed.success)
152
+ return { ok: true, data: parsed.data };
153
+ const issues = parsed.error?.issues ?? parsed.error?.errors ?? [];
154
+ const error = issues
155
+ .map((issue) => `${(issue.path ?? []).join('.') || 'root'}: ${issue.message ?? 'invalid'}`)
156
+ .join('; ');
157
+ return { ok: false, error: error || 'Invalid arguments' };
69
158
  }
70
159
  /**
71
160
  * 从 Zod 模式创建 Tool,便于类型安全与校验。
@@ -75,18 +164,16 @@ export function createToolFromZod(name, description, schema, execute, options) {
75
164
  if (!schema?.safeParse) {
76
165
  throw new Error('createToolFromZod: schema must be a Zod object schema (e.g. z.object({ ... })). Install zod: pnpm add zod');
77
166
  }
78
- const parameters = zodToJsonSchema(schema);
167
+ const parameters = toolInputSchemaToParameters(schema);
79
168
  return {
80
169
  name,
81
170
  description,
82
171
  parameters,
83
- execute: async (args, context) => {
84
- const parsed = schema.safeParse(args);
85
- if (!parsed.success) {
86
- const msg = parsed.error.errors?.map((e) => `${e.path?.join('.') ?? 'root'}: ${e.message}`).join('; ') ?? 'Invalid arguments';
87
- return `Error: ${msg}`;
88
- }
89
- return execute(parsed.data, context);
172
+ execute: async (args, message) => {
173
+ const parsed = parseToolInputSchema(schema, args);
174
+ if (!parsed.ok)
175
+ return `Error: ${parsed.error}`;
176
+ return execute(parsed.data, message);
90
177
  },
91
178
  tags: options?.tags,
92
179
  keywords: options?.keywords,
@@ -95,4 +182,3 @@ export function createToolFromZod(name, description, schema, execute, options) {
95
182
  kind: options?.kind,
96
183
  };
97
184
  }
98
- //# sourceMappingURL=tool-zod.js.map
package/lib/types.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { MessageChannel, Message } from "./message.js";
2
- import { Adapter, Adapters } from "./adapter.js";
3
- import { Bot } from "./bot.js";
4
- import { SystemLog } from "./models/system-log.js";
5
- import { User } from "./models/user.js";
6
- import { Databases, Registry } from "@zhin.js/database";
7
- import { MessageComponent } from "./message.js";
8
- import { ProcessAdapter } from "./built/adapter-process.js";
9
- import type { SenderRole } from "./built/roles.js";
1
+ import type { MessageChannel, Message, MessageComponent } from './message.js';
2
+ import { Adapter, Adapters } from './adapter.js';
3
+ import { Endpoint } from './endpoint.js';
4
+ import { SystemLog } from './models/system-log.js';
5
+ import { User } from './models/user.js';
6
+ import { Databases, Registry } from '@zhin.js/database';
7
+ import { ProcessAdapter } from './built/adapter-process.js';
10
8
  export type { SenderRole } from "./built/roles.js";
11
9
  export type ArrayItem<T> = T extends Array<infer R> ? R : unknown;
12
10
  export interface Models extends Record<string, object> {
@@ -34,19 +32,19 @@ export type RegisteredAdapter = Extract<keyof RegisteredAdapters, string>;
34
32
  /**
35
33
  * 指定适配器的消息类型
36
34
  */
37
- export type AdapterMessage<T extends keyof RegisteredAdapters = keyof RegisteredAdapters> = RegisteredAdapters[T] extends Adapter<infer R> ? BotMessage<R> : {};
35
+ export type AdapterMessage<T extends keyof RegisteredAdapters = keyof RegisteredAdapters> = RegisteredAdapters[T] extends Adapter<infer R> ? EndpointMessage<R> : {};
38
36
  /**
39
37
  * 指定适配器的配置类型
40
38
  */
41
- export type AdapterConfig<T extends keyof RegisteredAdapters = keyof RegisteredAdapters> = RegisteredAdapters[T] extends Adapter<infer R> ? PlatformConfig<R> : Bot.Config;
39
+ export type AdapterConfig<T extends keyof RegisteredAdapters = keyof RegisteredAdapters> = RegisteredAdapters[T] extends Adapter<infer R> ? PlatformConfig<R> : Endpoint.Config;
42
40
  /**
43
41
  * Bot实例的配置类型
44
42
  */
45
- export type PlatformConfig<T> = T extends Bot<infer L, infer R> ? R : Bot.Config;
43
+ export type PlatformConfig<T> = T extends Endpoint<infer L, infer R> ? R : Endpoint.Config;
46
44
  /**
47
45
  * Bot实例的消息类型
48
46
  */
49
- export type BotMessage<T extends Bot> = T extends Bot<infer R> ? R : {};
47
+ export type EndpointMessage<T extends Endpoint> = T extends Endpoint<infer R> ? R : {};
50
48
  /**
51
49
  * 消息段结构,支持 text/image/at/face 等类型
52
50
  */
@@ -63,23 +61,24 @@ export type MaybeArray<T> = T | T[];
63
61
  * 消息发送内容类型
64
62
  */
65
63
  export type SendContent = MaybeArray<string | MessageElement>;
66
- /** $getMsg 返回的被引用消息载荷 */
67
- export interface QuotedMessagePayload {
64
+ /** 可选:编辑已发送消息(交互式棋盘更新) */
65
+ export interface EditMessageOptions {
68
66
  messageId: string;
69
- sender?: {
70
- id?: string;
71
- name?: string;
72
- };
73
- content: MessageElement[] | string;
74
- raw?: string;
75
- time?: number;
67
+ context: string;
68
+ endpoint: string;
69
+ id: string;
70
+ type: 'private' | 'group' | 'channel';
71
+ content: SendContent;
76
72
  }
77
- /** 支持按 message_id 拉取历史消息的 Bot(可选实现) */
78
- export interface QuotableBot {
79
- $getMsg(messageId: string): Promise<QuotedMessagePayload>;
73
+ /** 出站回复来源(指令 / AI / proactive),仅当经 MessageDispatcher.replyWithPolish 或 runWithOutboundPolish 发出时由框架填入异步上下文 */
74
+ export type OutboundReplySource = 'command' | 'ai' | 'proactive';
75
+ export type OutboundReplyTrigger = 'inbound' | 'proactive';
76
+ export interface OutboundReplyStore {
77
+ message: Message;
78
+ source: OutboundReplySource;
79
+ trigger: OutboundReplyTrigger;
80
+ proactiveSource?: string;
80
81
  }
81
- /** 出站回复来源(指令 / AI),仅当经 MessageDispatcher.replyWithPolish 发出时由框架填入异步上下文 */
82
- export type OutboundReplySource = 'command' | 'ai';
83
82
  /**
84
83
  * 出站润色上下文(`dispatcher.addOutboundPolish` 的 handler 签名的同构类型)。
85
84
  * 与 {@link Adapter.sendMessage} → `before.sendMessage` 同一管道;需 `message`/`source` 时见 `getOutboundReplyStore`(dispatcher 导出)。
@@ -98,13 +97,17 @@ export interface MessageSender {
98
97
  id: string;
99
98
  name?: string;
100
99
  permissions?: string[];
101
- /** 平台侧角色标识(owner / admin / member 等) */
100
+ /** 平台群成员身份(owner / admin / member)— 仅供 platform checker */
102
101
  role?: string;
102
+ /** enrich 快照:endpoint 实例 master */
103
+ isMaster?: boolean;
104
+ /** enrich 快照:endpoint 实例 trusted */
105
+ isTrusted?: boolean;
103
106
  }
104
107
  /**
105
108
  * 通用字典类型
106
109
  */
107
- export type Dict<V = any, K extends string | symbol = string> = Record<K, V>;
110
+ export type { Dict } from '@zhin.js/kernel';
108
111
  /**
109
112
  * 用户信息结构
110
113
  */
@@ -130,8 +133,10 @@ export type MessageMiddleware<P extends RegisteredAdapter = RegisteredAdapter> =
130
133
  export type DefineConfig<T> = T | ((env: Record<string, string>) => MaybePromise<T>);
131
134
  export interface SendOptions extends MessageChannel {
132
135
  context: string;
133
- bot: string;
136
+ endpoint: string;
134
137
  content: SendContent;
138
+ quoteId?: string;
139
+ threadId?: string;
135
140
  }
136
141
  /** `Adapter.sendMessage` 成功发出后由 core 分发的载荷 */
137
142
  export interface MessageSendPayload {
@@ -156,8 +161,8 @@ export type BeforeSendHandler = (options: SendOptions) => MaybePromise<SendOptio
156
161
  /**
157
162
  * JSON Schema 定义,用于描述工具参数
158
163
  */
159
- /** ToolContext 中可自动注入的字段名 */
160
- export type ContextInjectableKey = 'platform' | 'botId' | 'sceneId' | 'senderId' | 'scope';
164
+ /** Message 通讯上下文上可经 resolveContextKey 自动注入的字段名 */
165
+ export type ContextInjectableKey = 'platform' | 'endpointKey' | 'sceneId' | 'senderId' | 'scope';
161
166
  export interface ToolJsonSchema {
162
167
  type: string;
163
168
  properties?: Record<string, ToolJsonSchema & {
@@ -170,9 +175,9 @@ export interface ToolJsonSchema {
170
175
  description?: string;
171
176
  default?: any;
172
177
  /**
173
- * 自动从 ToolContext 注入的字段名。
178
+ * 自动从 Message 通讯上下文注入的字段名(经 resolveContextKey 映射 $ 字段)。
174
179
  * 设置后该参数对 AI 隐藏,执行时自动从上下文填充。
175
- * 例如: contextKey: 'botId' → 执行时自动填入 context.botId
180
+ * 例如: contextKey: 'endpointKey' → 执行时自动填入 message.$endpoint
176
181
  */
177
182
  contextKey?: ContextInjectableKey;
178
183
  [key: string]: any;
@@ -190,7 +195,7 @@ export interface PropertySchema<T = any> extends ToolJsonSchema {
190
195
  default?: T;
191
196
  enum?: T extends string | number ? T[] : never;
192
197
  paramType?: 'text' | 'number' | 'boolean' | 'rest';
193
- /** 自动从 ToolContext 注入的字段名(继承自 ToolJsonSchema) */
198
+ /** 自动从 Message 注入的字段名(继承自 ToolJsonSchema) */
194
199
  contextKey?: ContextInjectableKey;
195
200
  }
196
201
  /**
@@ -213,38 +218,6 @@ export interface ToolParametersSchema<TArgs extends Record<string, any> = Record
213
218
  /** 描述 */
214
219
  description?: string;
215
220
  }
216
- /**
217
- * 工具执行上下文
218
- * 包含消息来源、发送者等 IM 信息。
219
- * 通用(IM 无关)版本请使用 @zhin.js/ai 的 ToolContext。
220
- */
221
- export interface ToolContext {
222
- /** 来源平台 */
223
- platform?: string;
224
- /** 来源 Bot */
225
- botId?: string;
226
- /** 消息 ID */
227
- messageId?: string;
228
- /** 场景 ID(群号/频道ID/私聊用户ID) */
229
- sceneId?: string;
230
- /** 发送者 ID */
231
- senderId?: string;
232
- /** 原始消息对象(如果从消息触发) */
233
- message?: Message<any>;
234
- /**
235
- * 消息场景类型
236
- * private: 私聊, group: 群聊, channel: 频道
237
- */
238
- scope?: ToolScope;
239
- /** 发送者角色集合(群角色 + bot master/trusted 可并存) */
240
- roles?: readonly SenderRole[];
241
- /**
242
- * 文件操作角色 — 用于文件工具的权限控制
243
- */
244
- fileRole?: FileRole;
245
- /** 额外数据 */
246
- extra?: Record<string, any>;
247
- }
248
221
  /**
249
222
  * 统一的 Tool 定义
250
223
  * 可同时用于:
@@ -334,10 +307,10 @@ export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
334
307
  /**
335
308
  * 工具执行函数
336
309
  * @param args 解析后的参数
337
- * @param context 执行上下文(包含消息、发送者等信息)
310
+ * @param message 通讯上下文(入站 Message 或合成 Message)
338
311
  * @returns 执行结果
339
312
  */
340
- execute: (args: TArgs, context?: ToolContext) => MaybePromise<ToolResult>;
313
+ execute: (args: TArgs, message?: Message<any>) => MaybePromise<ToolResult>;
341
314
  /** 工具来源标识(自动填充:adapter:xxx / plugin:xxx) */
342
315
  source?: string;
343
316
  /** 工具标签(用于分类和过滤) */
@@ -349,6 +322,8 @@ export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
349
322
  * 执行此工具需要的权限列表
350
323
  */
351
324
  permissions?: string[];
325
+ /** Per-tool approval policy; `on-risk` remains fail-closed at Agent boundaries. */
326
+ approval?: 'always' | 'once' | 'never' | 'on-risk';
352
327
  /**
353
328
  * 支持的平台列表
354
329
  * 例如:['qq', 'telegram', 'discord']
@@ -361,11 +336,6 @@ export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
361
336
  * 不填则支持所有场景
362
337
  */
363
338
  scopes?: ToolScope[];
364
- /**
365
- * 调用者需具备的角色之一(隐含升格见 roles.ts)
366
- * 省略则仅需 user
367
- */
368
- requiredAnyRole?: readonly SenderRole[];
369
339
  /**
370
340
  * 是否隐藏
371
341
  * 隐藏的工具不会出现在帮助列表中,但仍可被调用
@@ -386,10 +356,6 @@ export interface Tool<TArgs extends Record<string, any> = Record<string, any>> {
386
356
  */
387
357
  command?: ToolCommandConfig | false;
388
358
  }
389
- /**
390
- * @deprecated 使用 `Tool<TArgs>` 替代。Tool 已原生支持泛型。
391
- */
392
- export type ToolDefinition<TArgs extends Record<string, any> = Record<string, any>> = Tool<TArgs>;
393
359
  export declare namespace Tool {
394
360
  /**
395
361
  * 参数信息
@@ -416,10 +382,3 @@ export interface PluginManifest {
416
382
  }
417
383
  /** @deprecated 使用 Tool 替代 */
418
384
  export type AITool = Tool;
419
- /**
420
- * IMToolContext — ToolContext 的显式 IM 别名。
421
- * 当同时使用 @zhin.js/ai (通用 ToolContext) 和 @zhin.js/core (IM ToolContext) 时,
422
- * 用此类型消除歧义。
423
- */
424
- export type IMToolContext = ToolContext;
425
- //# sourceMappingURL=types.d.ts.map
package/lib/types.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
package/lib/utils.d.ts CHANGED
@@ -7,8 +7,19 @@
7
7
  export { evaluate, execute, clearEvalCache, getEvalCacheStats, getValueWithRuntime, compiler, remove, isEmpty, Time, supportedPluginExtensions, resolveEntry, sleep, } from '@zhin.js/kernel';
8
8
  import { AdapterMessage, MessageMiddleware, RegisteredAdapter, SendContent } from "./types.js";
9
9
  import { Message } from "./message.js";
10
+ import { HtmlSegment } from "./built/rich-segments/html-segment.js";
11
+ import { MarkdownSegment } from "./built/rich-segments/markdown-segment.js";
12
+ import { QrcodeSegment } from "./built/rich-segments/qrcode-segment.js";
13
+ import { TtsSegment } from "./built/rich-segments/tts-segment.js";
14
+ import { KeyboardSegment } from "./built/interactive-segments/keyboard-segment.js";
15
+ import { ButtonSpec, type KeyboardRowInput } from "./built/interactive-segments/button-spec.js";
16
+ import type { ButtonData, KeyboardFallback, KeyboardSegmentData } from "./built/interactive-segments/types.js";
17
+ import type { MediaRef } from "./built/segment-contract/types.js";
10
18
  /**
11
19
  * 组合中间件,洋葱模型
20
+ *
21
+ * 空中间件列表时必须仍调用 `next`——入站管线把 MessageDispatcher
22
+ * 作为 terminal next 传入;吞掉 next 会导致命令/AI 永远不跑。
12
23
  */
13
24
  export declare function compose<P extends RegisteredAdapter = RegisteredAdapter>(middlewares: MessageMiddleware<P>[]): (message: Message<AdapterMessage<P>>, next?: () => Promise<void>) => Promise<void>;
14
25
  export declare function segment<T extends object>(type: string, data: T): {
@@ -24,6 +35,26 @@ export declare namespace segment {
24
35
  text: string;
25
36
  };
26
37
  };
38
+ function mention(target: string, name?: string): {
39
+ type: string;
40
+ data: {
41
+ target: string;
42
+ name: string;
43
+ } | {
44
+ target: string;
45
+ name?: undefined;
46
+ };
47
+ };
48
+ function image(media: MediaRef, alt?: string): {
49
+ type: string;
50
+ data: {
51
+ media: MediaRef;
52
+ alt: string;
53
+ } | {
54
+ media: MediaRef;
55
+ alt?: undefined;
56
+ };
57
+ };
27
58
  function face(id: string, text?: string): {
28
59
  type: string;
29
60
  data: {
@@ -31,8 +62,44 @@ export declare namespace segment {
31
62
  text: string | undefined;
32
63
  };
33
64
  };
65
+ /** 出站 HTML 卡片段(Adapter policy 决定 image/text/origin) */
66
+ function htmlCard(options: {
67
+ html: string;
68
+ text?: string;
69
+ width?: number;
70
+ backgroundColor?: string;
71
+ fileName?: string;
72
+ }): HtmlSegment;
73
+ /** Short alias for {@link htmlCard}. */
74
+ const html: typeof htmlCard;
75
+ /** 出站 Markdown 段(Adapter policy 决定 image/text/origin) */
76
+ function markdown(content: string, options?: Omit<MarkdownSegment['data'], 'content'>): MarkdownSegment;
77
+ /** 二维码出站段(Adapter policy 决定 image/text/origin) */
78
+ function qrcode(text: string, options?: {
79
+ width?: number;
80
+ margin?: number;
81
+ errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
82
+ small?: boolean;
83
+ }): QrcodeSegment;
84
+ /** TTS 出站段(Adapter policy 决定 audio/text/origin) */
85
+ function tts(options: {
86
+ text: string;
87
+ voice?: string;
88
+ provider?: string;
89
+ }): TtsSegment;
90
+ /** 键盘按钮单元(与 {@link keyboard} 组合布局) */
91
+ function button(data: ButtonData): ButtonSpec;
92
+ /** 键盘布局出站段(Adapter interactivePolicy 决定 native/text) */
93
+ function keyboard(rows: KeyboardRowInput[], options?: {
94
+ fallback?: KeyboardFallback;
95
+ }): KeyboardSegment;
96
+ /**
97
+ * @deprecated 使用 {@link keyboard} + {@link button};文本请用 `segment.text` 单独发送
98
+ */
99
+ function interactive(data: KeyboardSegmentData & {
100
+ text?: SendContent;
101
+ }): KeyboardSegment;
34
102
  function from(content: SendContent): SendContent;
35
103
  function raw(content: SendContent): string;
36
104
  function toString(content: SendContent): string;
37
105
  }
38
- //# sourceMappingURL=utils.d.ts.map