@zhin.js/core 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (416) hide show
  1. package/README.md +7 -7
  2. package/lib/adapter.d.ts +22 -2
  3. package/lib/adapter.js +72 -2
  4. package/lib/agent-prompt.d.ts +0 -1
  5. package/lib/agent-prompt.js +0 -1
  6. package/lib/built/adapter-process.d.ts +0 -1
  7. package/lib/built/adapter-process.js +0 -1
  8. package/lib/built/agent-preset.d.ts +0 -1
  9. package/lib/built/agent-preset.js +0 -1
  10. package/lib/built/ai-access.d.ts +36 -0
  11. package/lib/built/ai-access.js +46 -0
  12. package/lib/built/ai-outbound/adapter-access.d.ts +3 -0
  13. package/lib/built/ai-outbound/adapter-access.js +9 -0
  14. package/lib/built/ai-outbound/extensions/onebot-keyboard.d.ts +2 -0
  15. package/lib/built/ai-outbound/extensions/onebot-keyboard.js +67 -0
  16. package/lib/built/ai-outbound/extensions/qq-message.d.ts +3 -0
  17. package/lib/built/ai-outbound/extensions/qq-message.js +23 -0
  18. package/lib/built/ai-outbound/index.d.ts +9 -0
  19. package/lib/built/ai-outbound/index.js +9 -0
  20. package/lib/built/ai-outbound/parse.d.ts +13 -0
  21. package/lib/built/ai-outbound/parse.js +108 -0
  22. package/lib/built/ai-outbound/plain-mention-rewrite.d.ts +6 -0
  23. package/lib/built/ai-outbound/plain-mention-rewrite.js +37 -0
  24. package/lib/built/ai-outbound/prompt.d.ts +11 -0
  25. package/lib/built/ai-outbound/prompt.js +44 -0
  26. package/lib/built/ai-outbound/resolve.d.ts +4 -0
  27. package/lib/built/ai-outbound/resolve.js +64 -0
  28. package/lib/built/ai-outbound/structured-detect.d.ts +3 -0
  29. package/lib/built/ai-outbound/structured-detect.js +7 -0
  30. package/lib/built/ai-outbound/types.d.ts +60 -0
  31. package/lib/built/ai-outbound/types.js +5 -0
  32. package/lib/built/ai-trigger.d.ts +5 -1
  33. package/lib/built/ai-trigger.js +3 -7
  34. package/lib/built/authorization.d.ts +0 -1
  35. package/lib/built/authorization.js +0 -1
  36. package/lib/built/command.d.ts +0 -1
  37. package/lib/built/command.js +1 -3
  38. package/lib/built/common-adapter-tools.d.ts +25 -26
  39. package/lib/built/common-adapter-tools.js +48 -49
  40. package/lib/built/component.d.ts +1 -3
  41. package/lib/built/component.js +2 -4
  42. package/lib/built/config.d.ts +4 -1
  43. package/lib/built/config.js +26 -5
  44. package/lib/built/connect-endpoint-instance.d.ts +0 -1
  45. package/lib/built/connect-endpoint-instance.js +3 -2
  46. package/lib/built/database.d.ts +1 -3
  47. package/lib/built/database.js +2 -4
  48. package/lib/built/dispatcher.d.ts +7 -7
  49. package/lib/built/dispatcher.js +20 -8
  50. package/lib/built/endpoint-commands.d.ts +0 -1
  51. package/lib/built/endpoint-commands.js +6 -9
  52. package/lib/built/endpoint-lifecycle-service.d.ts +2 -1
  53. package/lib/built/endpoint-lifecycle-service.js +26 -3
  54. package/lib/built/endpoint-lifecycle.d.ts +0 -1
  55. package/lib/built/endpoint-lifecycle.js +4 -4
  56. package/lib/built/endpoint-manager.d.ts +0 -1
  57. package/lib/built/endpoint-manager.js +0 -1
  58. package/lib/built/generated-qrcode.d.ts +0 -1
  59. package/lib/built/generated-qrcode.js +0 -1
  60. package/lib/built/generic-segment-mapper.d.ts +6 -0
  61. package/lib/built/generic-segment-mapper.js +232 -0
  62. package/lib/built/html-renderer-loader.d.ts +2 -1
  63. package/lib/built/html-renderer-loader.js +6 -2
  64. package/lib/built/html-segment-fallback.d.ts +0 -1
  65. package/lib/built/html-segment-fallback.js +0 -1
  66. package/lib/built/html-to-text.d.ts +0 -1
  67. package/lib/built/html-to-text.js +15 -15
  68. package/lib/built/inbound-pipeline.d.ts +1 -2
  69. package/lib/built/inbound-pipeline.js +1 -2
  70. package/lib/built/inbound-runner.d.ts +0 -1
  71. package/lib/built/inbound-runner.js +0 -1
  72. package/lib/built/interactive-segment-contract.d.ts +6 -0
  73. package/lib/built/interactive-segment-contract.js +9 -0
  74. package/lib/built/interactive-segments/action.d.ts +17 -0
  75. package/lib/built/interactive-segments/action.js +69 -0
  76. package/lib/built/interactive-segments/button-spec.d.ts +10 -0
  77. package/lib/built/interactive-segments/button-spec.js +21 -0
  78. package/lib/built/interactive-segments/handlers.d.ts +9 -0
  79. package/lib/built/interactive-segments/handlers.js +58 -0
  80. package/lib/built/interactive-segments/index.d.ts +7 -0
  81. package/lib/built/interactive-segments/index.js +7 -0
  82. package/lib/built/interactive-segments/keyboard-segment.d.ts +12 -0
  83. package/lib/built/interactive-segments/keyboard-segment.js +13 -0
  84. package/lib/built/interactive-segments/onebot-keyboard.d.ts +10 -0
  85. package/lib/built/interactive-segments/onebot-keyboard.js +53 -0
  86. package/lib/built/interactive-segments/resolve.d.ts +9 -0
  87. package/lib/built/interactive-segments/resolve.js +84 -0
  88. package/lib/built/interactive-segments/types.d.ts +62 -0
  89. package/lib/built/interactive-segments/types.js +13 -0
  90. package/lib/built/introspection-format.d.ts +0 -1
  91. package/lib/built/introspection-format.js +1 -1
  92. package/lib/built/login-assist.d.ts +0 -1
  93. package/lib/built/login-assist.js +0 -1
  94. package/lib/built/management-command-guard.d.ts +5 -1
  95. package/lib/built/management-command-guard.js +5 -1
  96. package/lib/built/message-enrich.d.ts +1 -2
  97. package/lib/built/message-enrich.js +0 -1
  98. package/lib/built/message-filter.d.ts +0 -1
  99. package/lib/built/message-filter.js +1 -3
  100. package/lib/built/optional-peer-import.d.ts +3 -0
  101. package/lib/built/optional-peer-import.js +33 -0
  102. package/lib/built/outbound-media-contract.d.ts +0 -1
  103. package/lib/built/outbound-media-contract.js +0 -1
  104. package/lib/built/outbound-media-utils.d.ts +0 -1
  105. package/lib/built/outbound-media-utils.js +0 -1
  106. package/lib/built/permission.d.ts +0 -1
  107. package/lib/built/permission.js +1 -3
  108. package/lib/built/permit-check.d.ts +1 -2
  109. package/lib/built/permit-check.js +0 -1
  110. package/lib/built/permit-parse.d.ts +0 -1
  111. package/lib/built/permit-parse.js +0 -1
  112. package/lib/built/platform-permit.d.ts +5 -6
  113. package/lib/built/platform-permit.js +11 -12
  114. package/lib/built/prepend-quote-context.d.ts +0 -1
  115. package/lib/built/prepend-quote-context.js +0 -1
  116. package/lib/built/qrcode-segment.d.ts +0 -1
  117. package/lib/built/qrcode-segment.js +0 -1
  118. package/lib/built/queue-im-field-contract.d.ts +6 -1
  119. package/lib/built/queue-im-field-contract.js +10 -1
  120. package/lib/built/rich-segments/adapter-policies.d.ts +1 -2
  121. package/lib/built/rich-segments/adapter-policies.js +0 -1
  122. package/lib/built/rich-segments/base.d.ts +0 -1
  123. package/lib/built/rich-segments/base.js +0 -1
  124. package/lib/built/rich-segments/builtins.d.ts +0 -1
  125. package/lib/built/rich-segments/builtins.js +0 -1
  126. package/lib/built/rich-segments/capabilities.d.ts +0 -1
  127. package/lib/built/rich-segments/capabilities.js +0 -1
  128. package/lib/built/rich-segments/html-segment.d.ts +1 -2
  129. package/lib/built/rich-segments/html-segment.js +0 -1
  130. package/lib/built/rich-segments/index.d.ts +0 -1
  131. package/lib/built/rich-segments/index.js +0 -1
  132. package/lib/built/rich-segments/markdown-segment.d.ts +1 -2
  133. package/lib/built/rich-segments/markdown-segment.js +0 -1
  134. package/lib/built/rich-segments/markdown-to-text.d.ts +0 -1
  135. package/lib/built/rich-segments/markdown-to-text.js +0 -1
  136. package/lib/built/rich-segments/qrcode-segment.d.ts +1 -2
  137. package/lib/built/rich-segments/qrcode-segment.js +0 -1
  138. package/lib/built/rich-segments/registry.d.ts +0 -1
  139. package/lib/built/rich-segments/registry.js +0 -1
  140. package/lib/built/rich-segments/resolve.d.ts +1 -2
  141. package/lib/built/rich-segments/resolve.js +0 -1
  142. package/lib/built/rich-segments/tts-segment.d.ts +1 -2
  143. package/lib/built/rich-segments/tts-segment.js +0 -1
  144. package/lib/built/rich-segments/types.d.ts +0 -1
  145. package/lib/built/rich-segments/types.js +0 -1
  146. package/lib/built/roles.d.ts +0 -1
  147. package/lib/built/roles.js +0 -1
  148. package/lib/built/runtime-io.d.ts +0 -1
  149. package/lib/built/runtime-io.js +0 -1
  150. package/lib/built/schedule.d.ts +54 -0
  151. package/lib/built/schedule.js +112 -0
  152. package/lib/built/schema-endpoint-manager.d.ts +0 -1
  153. package/lib/built/schema-endpoint-manager.js +0 -1
  154. package/lib/built/schema-feature.d.ts +0 -1
  155. package/lib/built/schema-feature.js +1 -3
  156. package/lib/built/segment-contract/assert.d.ts +4 -0
  157. package/lib/built/segment-contract/assert.js +30 -0
  158. package/lib/built/segment-contract/delivery.d.ts +5 -0
  159. package/lib/built/segment-contract/delivery.js +40 -0
  160. package/lib/built/segment-contract/image.d.ts +5 -0
  161. package/lib/built/segment-contract/image.js +10 -0
  162. package/lib/built/segment-contract/index.d.ts +8 -0
  163. package/lib/built/segment-contract/index.js +7 -0
  164. package/lib/built/segment-contract/media.d.ts +8 -0
  165. package/lib/built/segment-contract/media.js +39 -0
  166. package/lib/built/segment-contract/mention.d.ts +10 -0
  167. package/lib/built/segment-contract/mention.js +26 -0
  168. package/lib/built/segment-contract/preview.d.ts +3 -0
  169. package/lib/built/segment-contract/preview.js +159 -0
  170. package/lib/built/segment-contract/types.d.ts +70 -0
  171. package/lib/built/segment-contract/types.js +5 -0
  172. package/lib/built/segment-contract/validate.d.ts +138 -0
  173. package/lib/built/segment-contract/validate.js +124 -0
  174. package/lib/built/skill.d.ts +0 -1
  175. package/lib/built/skill.js +0 -1
  176. package/lib/built/speech-loader.d.ts +2 -1
  177. package/lib/built/speech-loader.js +6 -2
  178. package/lib/built/tool.d.ts +0 -1
  179. package/lib/built/tool.js +1 -3
  180. package/lib/command.d.ts +12 -7
  181. package/lib/command.js +38 -16
  182. package/lib/component.d.ts +0 -1
  183. package/lib/component.js +28 -12
  184. package/lib/endpoint-capabilities.d.ts +3 -1
  185. package/lib/endpoint-capabilities.js +0 -1
  186. package/lib/endpoint.d.ts +0 -1
  187. package/lib/endpoint.js +0 -1
  188. package/lib/errors.d.ts +0 -1
  189. package/lib/errors.js +0 -1
  190. package/lib/host-plugin-registry.d.ts +0 -1
  191. package/lib/host-plugin-registry.js +0 -1
  192. package/lib/im-scene.d.ts +29 -0
  193. package/lib/im-scene.js +77 -0
  194. package/lib/im-session-id.d.ts +25 -12
  195. package/lib/im-session-id.js +35 -17
  196. package/lib/index.d.ts +14 -7
  197. package/lib/index.js +12 -6
  198. package/lib/jsx-dev-runtime.d.ts +0 -1
  199. package/lib/jsx-dev-runtime.js +0 -1
  200. package/lib/jsx-runtime.d.ts +0 -1
  201. package/lib/jsx-runtime.js +0 -1
  202. package/lib/jsx.d.ts +0 -1
  203. package/lib/jsx.js +0 -1
  204. package/lib/message-quote.d.ts +1 -2
  205. package/lib/message-quote.js +2 -3
  206. package/lib/message.d.ts +7 -5
  207. package/lib/message.js +16 -1
  208. package/lib/models/system-log.d.ts +0 -1
  209. package/lib/models/system-log.js +0 -1
  210. package/lib/models/user.d.ts +0 -1
  211. package/lib/models/user.js +0 -1
  212. package/lib/notice.d.ts +15 -59
  213. package/lib/notice.js +1 -4
  214. package/lib/plugin-context.d.ts +0 -1
  215. package/lib/plugin-context.js +0 -1
  216. package/lib/plugin.d.ts +13 -6
  217. package/lib/plugin.js +31 -15
  218. package/lib/prompt.d.ts +0 -1
  219. package/lib/prompt.js +0 -1
  220. package/lib/request.d.ts +16 -60
  221. package/lib/request.js +0 -4
  222. package/lib/side-event/base.d.ts +45 -0
  223. package/lib/side-event/base.js +30 -0
  224. package/lib/side-event/index.d.ts +3 -0
  225. package/lib/side-event/index.js +3 -0
  226. package/lib/side-event/normalize.d.ts +40 -0
  227. package/lib/side-event/normalize.js +117 -0
  228. package/lib/side-event/types.d.ts +25 -0
  229. package/lib/side-event/types.js +55 -0
  230. package/lib/tool-zod.d.ts +0 -1
  231. package/lib/tool-zod.js +0 -1
  232. package/lib/types-generator.d.ts +0 -1
  233. package/lib/types-generator.js +0 -1
  234. package/lib/types.d.ts +30 -11
  235. package/lib/types.js +0 -1
  236. package/lib/utils.d.ts +36 -1
  237. package/lib/utils.js +33 -25
  238. package/package.json +15 -8
  239. package/lib/adapter.d.ts.map +0 -1
  240. package/lib/adapter.js.map +0 -1
  241. package/lib/agent-prompt.d.ts.map +0 -1
  242. package/lib/agent-prompt.js.map +0 -1
  243. package/lib/built/adapter-process.d.ts.map +0 -1
  244. package/lib/built/adapter-process.js.map +0 -1
  245. package/lib/built/agent-preset.d.ts.map +0 -1
  246. package/lib/built/agent-preset.js.map +0 -1
  247. package/lib/built/ai-trigger.d.ts.map +0 -1
  248. package/lib/built/ai-trigger.js.map +0 -1
  249. package/lib/built/authorization.d.ts.map +0 -1
  250. package/lib/built/authorization.js.map +0 -1
  251. package/lib/built/command.d.ts.map +0 -1
  252. package/lib/built/command.js.map +0 -1
  253. package/lib/built/common-adapter-tools.d.ts.map +0 -1
  254. package/lib/built/common-adapter-tools.js.map +0 -1
  255. package/lib/built/component.d.ts.map +0 -1
  256. package/lib/built/component.js.map +0 -1
  257. package/lib/built/config.d.ts.map +0 -1
  258. package/lib/built/config.js.map +0 -1
  259. package/lib/built/connect-endpoint-instance.d.ts.map +0 -1
  260. package/lib/built/connect-endpoint-instance.js.map +0 -1
  261. package/lib/built/cron.d.ts +0 -75
  262. package/lib/built/cron.d.ts.map +0 -1
  263. package/lib/built/cron.js +0 -122
  264. package/lib/built/cron.js.map +0 -1
  265. package/lib/built/database.d.ts.map +0 -1
  266. package/lib/built/database.js.map +0 -1
  267. package/lib/built/dispatcher.d.ts.map +0 -1
  268. package/lib/built/dispatcher.js.map +0 -1
  269. package/lib/built/endpoint-commands.d.ts.map +0 -1
  270. package/lib/built/endpoint-commands.js.map +0 -1
  271. package/lib/built/endpoint-lifecycle-service.d.ts.map +0 -1
  272. package/lib/built/endpoint-lifecycle-service.js.map +0 -1
  273. package/lib/built/endpoint-lifecycle.d.ts.map +0 -1
  274. package/lib/built/endpoint-lifecycle.js.map +0 -1
  275. package/lib/built/endpoint-manager.d.ts.map +0 -1
  276. package/lib/built/endpoint-manager.js.map +0 -1
  277. package/lib/built/generated-qrcode.d.ts.map +0 -1
  278. package/lib/built/generated-qrcode.js.map +0 -1
  279. package/lib/built/html-renderer-loader.d.ts.map +0 -1
  280. package/lib/built/html-renderer-loader.js.map +0 -1
  281. package/lib/built/html-segment-fallback.d.ts.map +0 -1
  282. package/lib/built/html-segment-fallback.js.map +0 -1
  283. package/lib/built/html-to-text.d.ts.map +0 -1
  284. package/lib/built/html-to-text.js.map +0 -1
  285. package/lib/built/inbound-pipeline.d.ts.map +0 -1
  286. package/lib/built/inbound-pipeline.js.map +0 -1
  287. package/lib/built/inbound-runner.d.ts.map +0 -1
  288. package/lib/built/inbound-runner.js.map +0 -1
  289. package/lib/built/introspection-format.d.ts.map +0 -1
  290. package/lib/built/introspection-format.js.map +0 -1
  291. package/lib/built/login-assist.d.ts.map +0 -1
  292. package/lib/built/login-assist.js.map +0 -1
  293. package/lib/built/management-command-guard.d.ts.map +0 -1
  294. package/lib/built/management-command-guard.js.map +0 -1
  295. package/lib/built/mcp-mesh-registrar.d.ts +0 -9
  296. package/lib/built/mcp-mesh-registrar.d.ts.map +0 -1
  297. package/lib/built/mcp-mesh-registrar.js +0 -17
  298. package/lib/built/mcp-mesh-registrar.js.map +0 -1
  299. package/lib/built/message-enrich.d.ts.map +0 -1
  300. package/lib/built/message-enrich.js.map +0 -1
  301. package/lib/built/message-filter.d.ts.map +0 -1
  302. package/lib/built/message-filter.js.map +0 -1
  303. package/lib/built/outbound-media-contract.d.ts.map +0 -1
  304. package/lib/built/outbound-media-contract.js.map +0 -1
  305. package/lib/built/outbound-media-utils.d.ts.map +0 -1
  306. package/lib/built/outbound-media-utils.js.map +0 -1
  307. package/lib/built/permission.d.ts.map +0 -1
  308. package/lib/built/permission.js.map +0 -1
  309. package/lib/built/permit-check.d.ts.map +0 -1
  310. package/lib/built/permit-check.js.map +0 -1
  311. package/lib/built/permit-parse.d.ts.map +0 -1
  312. package/lib/built/permit-parse.js.map +0 -1
  313. package/lib/built/platform-permit.d.ts.map +0 -1
  314. package/lib/built/platform-permit.js.map +0 -1
  315. package/lib/built/prepend-quote-context.d.ts.map +0 -1
  316. package/lib/built/prepend-quote-context.js.map +0 -1
  317. package/lib/built/qrcode-segment.d.ts.map +0 -1
  318. package/lib/built/qrcode-segment.js.map +0 -1
  319. package/lib/built/queue-im-field-contract.d.ts.map +0 -1
  320. package/lib/built/queue-im-field-contract.js.map +0 -1
  321. package/lib/built/rich-segments/adapter-policies.d.ts.map +0 -1
  322. package/lib/built/rich-segments/adapter-policies.js.map +0 -1
  323. package/lib/built/rich-segments/base.d.ts.map +0 -1
  324. package/lib/built/rich-segments/base.js.map +0 -1
  325. package/lib/built/rich-segments/builtins.d.ts.map +0 -1
  326. package/lib/built/rich-segments/builtins.js.map +0 -1
  327. package/lib/built/rich-segments/capabilities.d.ts.map +0 -1
  328. package/lib/built/rich-segments/capabilities.js.map +0 -1
  329. package/lib/built/rich-segments/html-segment.d.ts.map +0 -1
  330. package/lib/built/rich-segments/html-segment.js.map +0 -1
  331. package/lib/built/rich-segments/index.d.ts.map +0 -1
  332. package/lib/built/rich-segments/index.js.map +0 -1
  333. package/lib/built/rich-segments/markdown-segment.d.ts.map +0 -1
  334. package/lib/built/rich-segments/markdown-segment.js.map +0 -1
  335. package/lib/built/rich-segments/markdown-to-text.d.ts.map +0 -1
  336. package/lib/built/rich-segments/markdown-to-text.js.map +0 -1
  337. package/lib/built/rich-segments/qrcode-segment.d.ts.map +0 -1
  338. package/lib/built/rich-segments/qrcode-segment.js.map +0 -1
  339. package/lib/built/rich-segments/registry.d.ts.map +0 -1
  340. package/lib/built/rich-segments/registry.js.map +0 -1
  341. package/lib/built/rich-segments/resolve.d.ts.map +0 -1
  342. package/lib/built/rich-segments/resolve.js.map +0 -1
  343. package/lib/built/rich-segments/tts-segment.d.ts.map +0 -1
  344. package/lib/built/rich-segments/tts-segment.js.map +0 -1
  345. package/lib/built/rich-segments/types.d.ts.map +0 -1
  346. package/lib/built/rich-segments/types.js.map +0 -1
  347. package/lib/built/roles.d.ts.map +0 -1
  348. package/lib/built/roles.js.map +0 -1
  349. package/lib/built/runtime-io.d.ts.map +0 -1
  350. package/lib/built/runtime-io.js.map +0 -1
  351. package/lib/built/schema-endpoint-manager.d.ts.map +0 -1
  352. package/lib/built/schema-endpoint-manager.js.map +0 -1
  353. package/lib/built/schema-feature.d.ts.map +0 -1
  354. package/lib/built/schema-feature.js.map +0 -1
  355. package/lib/built/skill.d.ts.map +0 -1
  356. package/lib/built/skill.js.map +0 -1
  357. package/lib/built/speech-loader.d.ts.map +0 -1
  358. package/lib/built/speech-loader.js.map +0 -1
  359. package/lib/built/tool.d.ts.map +0 -1
  360. package/lib/built/tool.js.map +0 -1
  361. package/lib/command.d.ts.map +0 -1
  362. package/lib/command.js.map +0 -1
  363. package/lib/component.d.ts.map +0 -1
  364. package/lib/component.js.map +0 -1
  365. package/lib/endpoint-capabilities.d.ts.map +0 -1
  366. package/lib/endpoint-capabilities.js.map +0 -1
  367. package/lib/endpoint.d.ts.map +0 -1
  368. package/lib/endpoint.js.map +0 -1
  369. package/lib/errors.d.ts.map +0 -1
  370. package/lib/errors.js.map +0 -1
  371. package/lib/host-plugin-registry.d.ts.map +0 -1
  372. package/lib/host-plugin-registry.js.map +0 -1
  373. package/lib/im-session-id.d.ts.map +0 -1
  374. package/lib/im-session-id.js.map +0 -1
  375. package/lib/index.d.ts.map +0 -1
  376. package/lib/index.js.map +0 -1
  377. package/lib/jsx-dev-runtime.d.ts.map +0 -1
  378. package/lib/jsx-dev-runtime.js.map +0 -1
  379. package/lib/jsx-runtime.d.ts.map +0 -1
  380. package/lib/jsx-runtime.js.map +0 -1
  381. package/lib/jsx.d.ts.map +0 -1
  382. package/lib/jsx.js.map +0 -1
  383. package/lib/message-quote.d.ts.map +0 -1
  384. package/lib/message-quote.js.map +0 -1
  385. package/lib/message.d.ts.map +0 -1
  386. package/lib/message.js.map +0 -1
  387. package/lib/models/system-log.d.ts.map +0 -1
  388. package/lib/models/system-log.js.map +0 -1
  389. package/lib/models/user.d.ts.map +0 -1
  390. package/lib/models/user.js.map +0 -1
  391. package/lib/notice.d.ts.map +0 -1
  392. package/lib/notice.js.map +0 -1
  393. package/lib/plugin-context.d.ts.map +0 -1
  394. package/lib/plugin-context.js.map +0 -1
  395. package/lib/plugin.d.ts.map +0 -1
  396. package/lib/plugin.js.map +0 -1
  397. package/lib/prompt.d.ts.map +0 -1
  398. package/lib/prompt.js.map +0 -1
  399. package/lib/request.d.ts.map +0 -1
  400. package/lib/request.js.map +0 -1
  401. package/lib/scheduler/scheduler.d.ts +0 -49
  402. package/lib/scheduler/scheduler.d.ts.map +0 -1
  403. package/lib/scheduler/scheduler.js +0 -352
  404. package/lib/scheduler/scheduler.js.map +0 -1
  405. package/lib/scheduler/types.d.ts +0 -71
  406. package/lib/scheduler/types.d.ts.map +0 -1
  407. package/lib/scheduler/types.js +0 -8
  408. package/lib/scheduler/types.js.map +0 -1
  409. package/lib/tool-zod.d.ts.map +0 -1
  410. package/lib/tool-zod.js.map +0 -1
  411. package/lib/types-generator.d.ts.map +0 -1
  412. package/lib/types-generator.js.map +0 -1
  413. package/lib/types.d.ts.map +0 -1
  414. package/lib/types.js.map +0 -1
  415. package/lib/utils.d.ts.map +0 -1
  416. package/lib/utils.js.map +0 -1
@@ -4,4 +4,3 @@ export declare function registerRichSegmentCapabilityLoader(id: string, loader:
4
4
  /** 测试隔离 */
5
5
  export declare function resetRichSegmentCapabilityLoadersForTests(): void;
6
6
  export declare function createRichSegmentRenderContext(options?: RichSegmentCapabilityLoaderOptions): RichSegmentRenderContext;
7
- //# sourceMappingURL=capabilities.d.ts.map
@@ -37,4 +37,3 @@ export function createRichSegmentRenderContext(options = {}) {
37
37
  logContentChain: options.logContentChain,
38
38
  };
39
39
  }
40
- //# sourceMappingURL=capabilities.js.map
@@ -1,5 +1,5 @@
1
1
  import { RichSegment } from './base.js';
2
- import type { RichSegmentRenderContext, RichSegmentRenderResult } from './types.js';
2
+ import { type RichSegmentRenderContext, type RichSegmentRenderResult } from './types.js';
3
3
  export interface HtmlSegmentData {
4
4
  html: string;
5
5
  text?: string;
@@ -13,4 +13,3 @@ export declare class HtmlSegment extends RichSegment<HtmlSegmentData> {
13
13
  render(mode: string, ctx?: RichSegmentRenderContext): Promise<RichSegmentRenderResult>;
14
14
  }
15
15
  export declare function wrapHtmlSegment(data: Record<string, unknown>): HtmlSegment;
16
- //# sourceMappingURL=html-segment.d.ts.map
@@ -63,4 +63,3 @@ export function wrapHtmlSegment(data) {
63
63
  fileName: typeof data.fileName === 'string' ? data.fileName : undefined,
64
64
  });
65
65
  }
66
- //# sourceMappingURL=html-segment.js.map
@@ -11,4 +11,3 @@ export * from './tts-segment.js';
11
11
  export * from './markdown-to-text.js';
12
12
  export * from './resolve.js';
13
13
  export * from './adapter-policies.js';
14
- //# sourceMappingURL=index.d.ts.map
@@ -11,4 +11,3 @@ export * from './tts-segment.js';
11
11
  export * from './markdown-to-text.js';
12
12
  export * from './resolve.js';
13
13
  export * from './adapter-policies.js';
14
- //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { RichSegment } from './base.js';
2
- import type { RichSegmentRenderContext, RichSegmentRenderResult } from './types.js';
2
+ import { type RichSegmentRenderContext, type RichSegmentRenderResult } from './types.js';
3
3
  export interface MarkdownSegmentData {
4
4
  content: string;
5
5
  width?: number;
@@ -12,4 +12,3 @@ export declare class MarkdownSegment extends RichSegment<MarkdownSegmentData> {
12
12
  render(mode: string, ctx?: RichSegmentRenderContext): Promise<RichSegmentRenderResult>;
13
13
  }
14
14
  export declare function wrapMarkdownSegment(data: Record<string, unknown>): MarkdownSegment;
15
- //# sourceMappingURL=markdown-segment.d.ts.map
@@ -59,4 +59,3 @@ export function wrapMarkdownSegment(data) {
59
59
  fileName: typeof data.fileName === 'string' ? data.fileName : undefined,
60
60
  });
61
61
  }
62
- //# sourceMappingURL=markdown-segment.js.map
@@ -1,4 +1,3 @@
1
1
  /** 将 Markdown 转为可读纯文本(出站 text 降级用) */
2
2
  export declare function markdownToPlainText(md: string): string;
3
3
  export declare function markdownToHtmlForRender(md: string): string;
4
- //# sourceMappingURL=markdown-to-text.d.ts.map
@@ -25,4 +25,3 @@ export function markdownToHtmlForRender(md) {
25
25
  .replace(/>/g, '&gt;');
26
26
  return `<pre style="white-space:pre-wrap;font-family:sans-serif;font-size:14px;line-height:1.5;padding:16px;">${escaped}</pre>`;
27
27
  }
28
- //# sourceMappingURL=markdown-to-text.js.map
@@ -1,7 +1,7 @@
1
1
  import type { MessageElement } from '../../types.js';
2
2
  import { type GenerateQrCodeOptions } from '../generated-qrcode.js';
3
3
  import { RichSegment } from './base.js';
4
- import type { RichSegmentRenderContext, RichSegmentRenderResult } from './types.js';
4
+ import { type RichSegmentRenderContext, type RichSegmentRenderResult } from './types.js';
5
5
  export interface QrcodeSegmentData extends GenerateQrCodeOptions {
6
6
  text: string;
7
7
  /** process origin 模式终端渲染时使用 */
@@ -16,4 +16,3 @@ export declare class QrcodeSegment extends RichSegment<QrcodeSegmentData> {
16
16
  export declare function wrapQrcodeSegment(data: Record<string, unknown>): QrcodeSegment;
17
17
  /** process endpoint:origin qrcode 段 → 终端 ASCII + 文本占位 */
18
18
  export declare function interpretOriginQrcodeForProcess(content: MessageElement | string | (MessageElement | string)[]): Promise<MessageElement | string | (MessageElement | string)[]>;
19
- //# sourceMappingURL=qrcode-segment.d.ts.map
@@ -71,4 +71,3 @@ export async function interpretOriginQrcodeForProcess(content) {
71
71
  return out[0];
72
72
  return out;
73
73
  }
74
- //# sourceMappingURL=qrcode-segment.js.map
@@ -14,4 +14,3 @@ export declare class RichSegmentRegistry {
14
14
  export declare const RICH_SEGMENT_FALLBACK_MODE = "origin";
15
15
  export declare const richSegmentRegistry: RichSegmentRegistry;
16
16
  export declare function registerRichSegmentKind(definition: RichSegmentKindDefinition): void;
17
- //# sourceMappingURL=registry.d.ts.map
@@ -50,4 +50,3 @@ export const richSegmentRegistry = new RichSegmentRegistry();
50
50
  export function registerRichSegmentKind(definition) {
51
51
  richSegmentRegistry.register(definition);
52
52
  }
53
- //# sourceMappingURL=registry.js.map
@@ -1,6 +1,5 @@
1
1
  import type { SendContent } from '../../types.js';
2
- import type { OutboundRichSegmentPolicy, RichSegmentRenderContext } from './types.js';
2
+ import { type OutboundRichSegmentPolicy, type RichSegmentRenderContext } from './types.js';
3
3
  export declare function hasRichSegment(content: SendContent | undefined): boolean;
4
4
  /** 按 Adapter 出站策略在 renderSendMessage 首步统一渲染富媒体段 */
5
5
  export declare function resolveRichSegments(content: SendContent, policy: OutboundRichSegmentPolicy, ctx?: RichSegmentRenderContext): Promise<SendContent>;
6
- //# sourceMappingURL=resolve.d.ts.map
@@ -85,4 +85,3 @@ export async function resolveRichSegments(content, policy, ctx) {
85
85
  }
86
86
  return packSegments(out);
87
87
  }
88
- //# sourceMappingURL=resolve.js.map
@@ -1,5 +1,5 @@
1
1
  import { RichSegment } from './base.js';
2
- import type { RichSegmentRenderContext, RichSegmentRenderResult } from './types.js';
2
+ import { type RichSegmentRenderContext, type RichSegmentRenderResult } from './types.js';
3
3
  export interface TtsSegmentData {
4
4
  text: string;
5
5
  voice?: string;
@@ -11,4 +11,3 @@ export declare class TtsSegment extends RichSegment<TtsSegmentData> {
11
11
  render(mode: string, ctx?: RichSegmentRenderContext): Promise<RichSegmentRenderResult>;
12
12
  }
13
13
  export declare function wrapTtsSegment(data: Record<string, unknown>): TtsSegment;
14
- //# sourceMappingURL=tts-segment.d.ts.map
@@ -49,4 +49,3 @@ export function wrapTtsSegment(data) {
49
49
  provider: typeof data.provider === 'string' ? data.provider : undefined,
50
50
  });
51
51
  }
52
- //# sourceMappingURL=tts-segment.js.map
@@ -82,4 +82,3 @@ export interface RichSegmentCapabilityLoaderOptions {
82
82
  logContentChain?: RichSegmentRenderContext['logContentChain'];
83
83
  }
84
84
  export type RichSegmentCapabilityLoader = (options: RichSegmentCapabilityLoaderOptions) => Promise<unknown>;
85
- //# sourceMappingURL=types.d.ts.map
@@ -15,4 +15,3 @@ export const RICH_SEGMENT_MODE = {
15
15
  AUDIO: 'audio',
16
16
  VIDEO: 'video',
17
17
  };
18
- //# sourceMappingURL=types.js.map
@@ -12,4 +12,3 @@ export declare function hasSenderRole(roles: Iterable<SenderRole>, role: SenderR
12
12
  export declare function formatSenderRolesForLabel(roles: readonly SenderRole[]): string;
13
13
  /** 剥离用户正文里自造的发送者前缀 */
14
14
  export declare function stripUserSpoofedSenderPrefix(rawContent: string): string;
15
- //# sourceMappingURL=roles.d.ts.map
@@ -60,4 +60,3 @@ export function stripUserSpoofedSenderPrefix(rawContent) {
60
60
  }
61
61
  return text;
62
62
  }
63
- //# sourceMappingURL=roles.js.map
@@ -7,4 +7,3 @@ export declare function shouldBindProcessStdin(): boolean;
7
7
  export declare function isInteractiveStdin(): boolean;
8
8
  export declare function isDenoDeploy(): boolean;
9
9
  export declare function bindStdin(onChunk: (chunk: string) => void): () => void;
10
- //# sourceMappingURL=runtime-io.d.ts.map
@@ -65,4 +65,3 @@ export function bindStdin(onChunk) {
65
65
  process.stdin.on("data", handler);
66
66
  return () => process.stdin.removeListener("data", handler);
67
67
  }
68
- //# sourceMappingURL=runtime-io.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ScheduleFeature — 管理插件注册的内存定时任务
3
+ */
4
+ import { Feature, FeatureJSON, type ScheduleKind, type HolidayInput, type ScatterInput } from '@zhin.js/kernel';
5
+ export interface ScheduleDescriptor {
6
+ kind: ScheduleKind | 'every' | 'at';
7
+ /** 6 段 cron(solar/lunar/workday/freeDay/holiday) */
8
+ cron?: string;
9
+ everyMs?: number;
10
+ atMs?: number;
11
+ scatterInput?: ScatterInput;
12
+ holidayInput?: HolidayInput;
13
+ tz?: string;
14
+ }
15
+ export interface ScheduleHandle {
16
+ id: string;
17
+ descriptor: ScheduleDescriptor;
18
+ dispose: () => void;
19
+ }
20
+ export interface ScheduleContextExtensions {
21
+ addSchedule(descriptor: ScheduleDescriptor, callback: () => void | Promise<void>, id?: string): () => void;
22
+ }
23
+ declare module '../plugin.js' {
24
+ namespace Plugin {
25
+ interface Extensions extends ScheduleContextExtensions {
26
+ }
27
+ interface Contexts {
28
+ schedule: ScheduleFeature;
29
+ }
30
+ }
31
+ }
32
+ export declare class ScheduleFeature extends Feature<ScheduleHandle> {
33
+ readonly name: "schedule";
34
+ readonly icon = "Clock";
35
+ readonly desc = "\u65E5\u5386\u8C03\u5EA6";
36
+ readonly byName: Map<string, ScheduleHandle>;
37
+ add(handle: ScheduleHandle, pluginName: string): () => void;
38
+ remove(handle: ScheduleHandle): boolean;
39
+ get(id: string): ScheduleHandle | undefined;
40
+ stopAll(): void;
41
+ getStatus(): Array<{
42
+ id: string;
43
+ kind: string;
44
+ expression?: string;
45
+ running: boolean;
46
+ nextExecution: Date | null;
47
+ plugin: string;
48
+ }>;
49
+ dispose(): void;
50
+ toJSON(pluginName?: string): FeatureJSON;
51
+ get extensions(): {
52
+ addSchedule(descriptor: ScheduleDescriptor, callback: () => void | Promise<void>, id?: string): () => void;
53
+ };
54
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * ScheduleFeature — 管理插件注册的内存定时任务
3
+ */
4
+ import { Feature, ScheduleEngine, getScheduleEngine, setScheduleEngine } from '@zhin.js/kernel';
5
+ function ensureEngine() {
6
+ let engine = getScheduleEngine();
7
+ if (!engine) {
8
+ engine = new ScheduleEngine();
9
+ setScheduleEngine(engine);
10
+ }
11
+ return engine;
12
+ }
13
+ export class ScheduleFeature extends Feature {
14
+ name = 'schedule';
15
+ icon = 'Clock';
16
+ desc = '日历调度';
17
+ byName = new Map();
18
+ add(handle, pluginName) {
19
+ this.byName.set(handle.id, handle);
20
+ return super.add(handle, pluginName);
21
+ }
22
+ remove(handle) {
23
+ if (!this.byName.has(handle.id) && !this.items.includes(handle)) {
24
+ return false;
25
+ }
26
+ this.byName.delete(handle.id);
27
+ const removed = super.remove(handle);
28
+ if (removed) {
29
+ handle.dispose();
30
+ }
31
+ return removed;
32
+ }
33
+ get(id) {
34
+ return this.byName.get(id);
35
+ }
36
+ stopAll() {
37
+ for (const handle of this.items) {
38
+ handle.dispose();
39
+ }
40
+ }
41
+ getStatus() {
42
+ const engine = getScheduleEngine();
43
+ const engineStatus = engine?.getStatus() ?? [];
44
+ const byId = new Map(engineStatus.map((s) => [s.id, s]));
45
+ return this.items.map((handle) => {
46
+ let pluginName = 'unknown';
47
+ for (const [name, items] of this.pluginItems) {
48
+ if (items.includes(handle)) {
49
+ pluginName = name;
50
+ break;
51
+ }
52
+ }
53
+ const st = byId.get(handle.id);
54
+ return {
55
+ id: handle.id,
56
+ kind: handle.descriptor.kind,
57
+ expression: handle.descriptor.cron,
58
+ running: st?.running ?? true,
59
+ nextExecution: st?.nextExecution ?? null,
60
+ plugin: pluginName,
61
+ };
62
+ });
63
+ }
64
+ dispose() {
65
+ this.stopAll();
66
+ }
67
+ toJSON(pluginName) {
68
+ const list = pluginName ? this.getByPlugin(pluginName) : this.items;
69
+ return {
70
+ name: this.name,
71
+ icon: this.icon,
72
+ desc: this.desc,
73
+ count: list.length,
74
+ items: list.map((h) => ({
75
+ id: h.id,
76
+ kind: h.descriptor.kind,
77
+ cron: h.descriptor.cron,
78
+ })),
79
+ };
80
+ }
81
+ get extensions() {
82
+ const feature = this;
83
+ return {
84
+ addSchedule(descriptor, callback, id) {
85
+ const plugin = this;
86
+ const jobId = id ?? `sched_${Math.random().toString(36).slice(2, 10)}`;
87
+ const engine = ensureEngine();
88
+ const disposeEngine = engine.register(jobId, descriptor.kind, async () => {
89
+ await callback();
90
+ }, {
91
+ cron: descriptor.cron,
92
+ everyMs: descriptor.everyMs,
93
+ atMs: descriptor.atMs,
94
+ scatterInput: descriptor.scatterInput,
95
+ holidayInput: descriptor.holidayInput,
96
+ tz: descriptor.tz,
97
+ });
98
+ const handle = {
99
+ id: jobId,
100
+ descriptor,
101
+ dispose: () => {
102
+ disposeEngine();
103
+ },
104
+ };
105
+ const dispose = feature.add(handle, plugin.name);
106
+ plugin.recordFeatureContribution(feature.name, jobId);
107
+ plugin.onDispose(dispose);
108
+ return dispose;
109
+ },
110
+ };
111
+ }
112
+ }
@@ -15,4 +15,3 @@ export declare class SchemaEndpointManager implements EndpointManager {
15
15
  }
16
16
  export declare function resolveEndpointManager(adapter: Adapter): EndpointManager | null;
17
17
  export declare function adapterSupportsProvision(adapter: Adapter): boolean;
18
- //# sourceMappingURL=schema-endpoint-manager.d.ts.map
@@ -71,4 +71,3 @@ export function adapterSupportsProvision(adapter) {
71
71
  const manager = resolveEndpointManager(adapter);
72
72
  return manager?.supportsProvision() ?? false;
73
73
  }
74
- //# sourceMappingURL=schema-endpoint-manager.js.map
@@ -75,4 +75,3 @@ export declare class SchemaFeature extends Feature<SchemaRecord> {
75
75
  }): Required<T>;
76
76
  };
77
77
  }
78
- //# sourceMappingURL=schema-feature.d.ts.map
@@ -9,7 +9,6 @@
9
9
  * - Schema.toJSON() 传给前端驱动 PluginConfigForm
10
10
  * - reloadable 标记决定保存后是否自动重载插件
11
11
  */
12
- import { getPlugin } from '../plugin.js';
13
12
  import { Feature } from '@zhin.js/kernel';
14
13
  // ============================================================================
15
14
  // SchemaFeature
@@ -91,7 +90,7 @@ export class SchemaFeature extends Feature {
91
90
  const feature = this;
92
91
  return {
93
92
  declareConfig(key, schema, options) {
94
- const plugin = getPlugin();
93
+ const plugin = this;
95
94
  const reloadable = options?.reloadable ?? true;
96
95
  // 从 Schema 提取默认值
97
96
  const defaults = extractDefaults(schema);
@@ -129,4 +128,3 @@ function extractDefaults(schema) {
129
128
  }
130
129
  return result;
131
130
  }
132
- //# sourceMappingURL=schema-feature.js.map
@@ -0,0 +1,4 @@
1
+ import type { Segment } from './types.js';
2
+ /** 宽松判断:已知 canonical type 走严格校验;未知 type 仅校验顶层形状(adapter 渐进迁移) */
3
+ export declare function isCanonicalSegment(value: unknown): value is Segment;
4
+ export declare function assertCanonicalSegments(segments: unknown): asserts segments is Segment[];
@@ -0,0 +1,30 @@
1
+ import { isStrictCanonicalSegment } from './validate.js';
2
+ const STRICT_CANONICAL_TYPES = new Set([
3
+ 'text', 'mention', 'image', 'reply', 'forward', 'face', 'dice', 'rps',
4
+ ]);
5
+ function isPlainObject(value) {
6
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
7
+ }
8
+ /** 宽松判断:已知 canonical type 走严格校验;未知 type 仅校验顶层形状(adapter 渐进迁移) */
9
+ export function isCanonicalSegment(value) {
10
+ if (!isPlainObject(value) || typeof value.type !== 'string')
11
+ return false;
12
+ if (!isPlainObject(value.data))
13
+ return false;
14
+ if (value.platform !== undefined && !isPlainObject(value.platform))
15
+ return false;
16
+ if (!STRICT_CANONICAL_TYPES.has(value.type)) {
17
+ return true;
18
+ }
19
+ return isStrictCanonicalSegment(value);
20
+ }
21
+ export function assertCanonicalSegments(segments) {
22
+ if (!Array.isArray(segments)) {
23
+ throw new Error('segments must be an array');
24
+ }
25
+ for (let i = 0; i < segments.length; i++) {
26
+ if (!isCanonicalSegment(segments[i])) {
27
+ throw new Error(`segment[${i}] is not canonical`);
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,5 @@
1
+ import type { Segment } from './types.js';
2
+ /**
3
+ * 过滤 agent / AI 出站段,仅保留可经 IM 投递的 canonical 段。
4
+ */
5
+ export declare function segmentsForImDelivery(segments: readonly unknown[]): Segment[];
@@ -0,0 +1,40 @@
1
+ import { isCanonicalSegment } from './assert.js';
2
+ /** IM 可见段白名单(thinking / tool_call 等 AI-only 段过滤) */
3
+ const IM_VISIBLE_TYPES = new Set([
4
+ 'text',
5
+ 'mention',
6
+ 'image',
7
+ 'video',
8
+ 'audio',
9
+ 'voice',
10
+ 'record',
11
+ 'file',
12
+ 'face',
13
+ 'reply',
14
+ 'forward',
15
+ 'link',
16
+ 'dice',
17
+ 'rps',
18
+ 'markdown',
19
+ 'html',
20
+ 'qrcode',
21
+ 'tts',
22
+ 'keyboard',
23
+ ]);
24
+ const AI_ONLY_TYPES = new Set(['thinking', 'tool_call']);
25
+ /**
26
+ * 过滤 agent / AI 出站段,仅保留可经 IM 投递的 canonical 段。
27
+ */
28
+ export function segmentsForImDelivery(segments) {
29
+ const out = [];
30
+ for (const item of segments) {
31
+ if (!isCanonicalSegment(item))
32
+ continue;
33
+ if (AI_ONLY_TYPES.has(item.type))
34
+ continue;
35
+ if (!IM_VISIBLE_TYPES.has(item.type))
36
+ continue;
37
+ out.push(item);
38
+ }
39
+ return out;
40
+ }
@@ -0,0 +1,5 @@
1
+ import type { MediaRef, Segment } from './types.js';
2
+ export declare function createImageSegment(media: MediaRef, options?: {
3
+ alt?: string;
4
+ platform?: Record<string, unknown>;
5
+ }): Segment;
@@ -0,0 +1,10 @@
1
+ export function createImageSegment(media, options) {
2
+ return {
3
+ type: 'image',
4
+ data: {
5
+ media,
6
+ ...(options?.alt ? { alt: options.alt } : {}),
7
+ },
8
+ ...(options?.platform ? { platform: options.platform } : {}),
9
+ };
10
+ }
@@ -0,0 +1,8 @@
1
+ export type { Segment, SegmentBase, MediaRef, TextSegment, MentionSegment, ImageSegment, ReplySegment, ForwardSegment, FaceSegment, DiceSegment, RpsSegment, } from './types.js';
2
+ export { mediaRefSchema, textSegmentSchema, mentionSegmentSchema, imageSegmentSchema, replySegmentSchema, forwardSegmentSchema, faceSegmentSchema, diceSegmentSchema, rpsSegmentSchema, canonicalSegmentSchema, segmentArraySchema, } from './validate.js';
3
+ export { assertCanonicalSegments, isCanonicalSegment } from './assert.js';
4
+ export { segmentsForImDelivery } from './delivery.js';
5
+ export { isMediaRef, mediaRefFromLegacyData, mediaRefToLegacyFields } from './media.js';
6
+ export { createImageSegment } from './image.js';
7
+ export { formatSegmentPreview } from './preview.js';
8
+ export { readMentionTarget, readMentionName, readMentionSegmentTarget } from './mention.js';
@@ -0,0 +1,7 @@
1
+ export { mediaRefSchema, textSegmentSchema, mentionSegmentSchema, imageSegmentSchema, replySegmentSchema, forwardSegmentSchema, faceSegmentSchema, diceSegmentSchema, rpsSegmentSchema, canonicalSegmentSchema, segmentArraySchema, } from './validate.js';
2
+ export { assertCanonicalSegments, isCanonicalSegment } from './assert.js';
3
+ export { segmentsForImDelivery } from './delivery.js';
4
+ export { isMediaRef, mediaRefFromLegacyData, mediaRefToLegacyFields } from './media.js';
5
+ export { createImageSegment } from './image.js';
6
+ export { formatSegmentPreview } from './preview.js';
7
+ export { readMentionTarget, readMentionName, readMentionSegmentTarget } from './mention.js';
@@ -0,0 +1,8 @@
1
+ import type { MediaRef } from './types.js';
2
+ import { isMediaRef } from './validate.js';
3
+ export { isMediaRef };
4
+ export declare function mediaRefFromLegacyData(data: Record<string, unknown>): MediaRef | undefined;
5
+ export declare function mediaRefToLegacyFields(media: MediaRef): {
6
+ url?: string;
7
+ file?: string;
8
+ };
@@ -0,0 +1,39 @@
1
+ import { isMediaRef } from './validate.js';
2
+ export { isMediaRef };
3
+ export function mediaRefFromLegacyData(data) {
4
+ if (isMediaRef(data.media)) {
5
+ return data.media;
6
+ }
7
+ const mimeType = typeof data.mime_type === 'string' ? data.mime_type : undefined;
8
+ const base64 = typeof data.base64 === 'string' && data.base64.trim()
9
+ ? data.base64.trim()
10
+ : typeof data.data === 'string' && data.data.trim() && !String(data.data).startsWith('http')
11
+ ? data.data.trim()
12
+ : undefined;
13
+ if (base64) {
14
+ return { kind: 'base64', value: base64, ...(mimeType ? { mime_type: mimeType } : {}) };
15
+ }
16
+ const raw = [data.url, data.file, data.src, data.href]
17
+ .find((v) => typeof v === 'string' && v.trim().length > 0);
18
+ if (!raw)
19
+ return undefined;
20
+ const value = raw.trim();
21
+ if (value.startsWith('base64://')) {
22
+ return { kind: 'base64', value: value.slice('base64://'.length), ...(mimeType ? { mime_type: mimeType } : {}) };
23
+ }
24
+ if (value.startsWith('http://') || value.startsWith('https://')) {
25
+ return { kind: 'url', value, ...(mimeType ? { mime_type: mimeType } : {}) };
26
+ }
27
+ if (value.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(value)) {
28
+ return { kind: 'path', value, ...(mimeType ? { mime_type: mimeType } : {}) };
29
+ }
30
+ return { kind: 'url', value, ...(mimeType ? { mime_type: mimeType } : {}) };
31
+ }
32
+ export function mediaRefToLegacyFields(media) {
33
+ if (media.kind === 'url')
34
+ return { url: media.value, file: media.value };
35
+ if (media.kind === 'path')
36
+ return { file: media.value, url: media.value };
37
+ const encoded = media.value.startsWith('base64://') ? media.value : `base64://${media.value}`;
38
+ return { file: encoded, url: encoded };
39
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Canonical mention field readers (SSOT).
3
+ */
4
+ export declare function readMentionTarget(data: Record<string, unknown> | undefined): string;
5
+ export declare function readMentionName(data: Record<string, unknown> | undefined): string | undefined;
6
+ /** Resolve @ target from at / mention segment. */
7
+ export declare function readMentionSegmentTarget(seg: {
8
+ type: unknown;
9
+ data?: unknown;
10
+ }): string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Canonical mention field readers (SSOT).
3
+ */
4
+ export function readMentionTarget(data) {
5
+ if (!data)
6
+ return '';
7
+ const raw = data.target ?? data.user_id ?? data.qq ?? data.id;
8
+ if (raw === 'all')
9
+ return 'all';
10
+ return raw != null ? String(raw) : '';
11
+ }
12
+ export function readMentionName(data) {
13
+ if (!data)
14
+ return undefined;
15
+ const name = data.name ?? data.nickname ?? data.username;
16
+ return typeof name === 'string' && name.trim() ? name.trim() : undefined;
17
+ }
18
+ function isRecord(value) {
19
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
20
+ }
21
+ /** Resolve @ target from at / mention segment. */
22
+ export function readMentionSegmentTarget(seg) {
23
+ if (seg.type !== 'at' && seg.type !== 'mention')
24
+ return '';
25
+ return readMentionTarget(isRecord(seg.data) ? seg.data : undefined);
26
+ }
@@ -0,0 +1,3 @@
1
+ import type { SegmentBase } from './types.js';
2
+ /** Single canonical segment → compact human-readable preview for logs. */
3
+ export declare function formatSegmentPreview(item: SegmentBase): string;