@zhin.js/core 1.5.15 → 1.6.0

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 (328) hide show
  1. package/README.md +78 -195
  2. package/lib/ai-completion-contract.d.ts +135 -0
  3. package/lib/ai-completion-contract.js +69 -0
  4. package/lib/built/ai-access.d.ts +2 -21
  5. package/lib/built/ai-access.js +1 -46
  6. package/lib/built/ai-outbound/index.d.ts +0 -2
  7. package/lib/built/ai-outbound/index.js +0 -2
  8. package/lib/built/ai-outbound/prompt.d.ts +2 -0
  9. package/lib/built/ai-outbound/prompt.js +2 -0
  10. package/lib/built/ai-outbound/types.d.ts +1 -10
  11. package/lib/built/ai-trigger.d.ts +39 -78
  12. package/lib/built/ai-trigger.js +3 -254
  13. package/lib/built/common-adapter-tools.d.ts +21 -6
  14. package/lib/built/common-adapter-tools.js +28 -17
  15. package/lib/built/generic-segment-mapper.js +4 -1
  16. package/lib/built/html-segment-fallback.d.ts +6 -7
  17. package/lib/built/html-segment-fallback.js +1 -16
  18. package/lib/built/html-to-text.d.ts +0 -3
  19. package/lib/built/html-to-text.js +131 -40
  20. package/lib/built/interaction-messages.d.ts +1 -0
  21. package/lib/built/interaction-messages.js +30 -0
  22. package/lib/built/interactive-segments/action.d.ts +3 -4
  23. package/lib/built/interactive-segments/action.js +2 -5
  24. package/lib/built/interactive-segments/index.d.ts +0 -2
  25. package/lib/built/interactive-segments/index.js +0 -2
  26. package/lib/built/interactive-segments/keyboard-segment.d.ts +0 -1
  27. package/lib/built/interactive-segments/keyboard-segment.js +0 -1
  28. package/lib/built/interactive-segments/onebot-keyboard.d.ts +0 -1
  29. package/lib/built/interactive-segments/onebot-keyboard.js +0 -2
  30. package/lib/built/interactive-segments/resolve.d.ts +2 -3
  31. package/lib/built/interactive-segments/resolve.js +21 -14
  32. package/lib/built/interactive-segments/types.d.ts +2 -7
  33. package/lib/built/interactive-segments/types.js +22 -2
  34. package/lib/built/login-assist.d.ts +13 -11
  35. package/lib/built/login-assist.js +32 -26
  36. package/lib/built/message-enrich.d.ts +24 -27
  37. package/lib/built/message-enrich.js +53 -49
  38. package/lib/built/outbound-content-arrays.d.ts +4 -0
  39. package/lib/built/outbound-content-arrays.js +32 -0
  40. package/lib/built/outbound-media-trust.d.ts +46 -0
  41. package/lib/built/outbound-media-trust.js +245 -0
  42. package/lib/built/outbound-media-utils.d.ts +5 -3
  43. package/lib/built/outbound-media-utils.js +5 -3
  44. package/lib/built/readable-link.d.ts +4 -0
  45. package/lib/built/readable-link.js +32 -0
  46. package/lib/built/rich-segments/markdown-to-text.d.ts +1 -2
  47. package/lib/built/rich-segments/markdown-to-text.js +141 -17
  48. package/lib/built/roles.d.ts +141 -12
  49. package/lib/built/roles.js +253 -52
  50. package/lib/built/segment-contract/assert.js +8 -2
  51. package/lib/built/segment-contract/delivery.js +1 -0
  52. package/lib/built/segment-contract/index.d.ts +3 -3
  53. package/lib/built/segment-contract/index.js +2 -2
  54. package/lib/built/segment-contract/json-schema.d.ts +39 -5
  55. package/lib/built/segment-contract/json-schema.js +207 -24
  56. package/lib/built/segment-contract/preview.js +8 -1
  57. package/lib/built/segment-contract/text.js +1 -1
  58. package/lib/built/segment-contract/types.d.ts +2 -2
  59. package/lib/built/segment-contract/validate.d.ts +1553 -224
  60. package/lib/built/segment-contract/validate.js +39 -3
  61. package/lib/built/tool-access.d.ts +5 -0
  62. package/lib/built/tool-access.js +17 -0
  63. package/lib/built/user-interaction.d.ts +5 -4
  64. package/lib/built/user-interaction.js +64 -52
  65. package/lib/errors.d.ts +1 -18
  66. package/lib/errors.js +1 -26
  67. package/lib/feature/command-public-api.d.ts +5 -0
  68. package/lib/feature/command-public-api.js +5 -0
  69. package/lib/feature/command.d.ts +2 -0
  70. package/lib/feature/command.js +1 -0
  71. package/lib/feature/component.d.ts +1 -0
  72. package/lib/feature/component.js +1 -0
  73. package/lib/feature/handler.d.ts +13 -7
  74. package/lib/feature/handler.js +2 -1
  75. package/lib/feature/middleware-public-api.d.ts +6 -0
  76. package/lib/feature/middleware-public-api.js +6 -0
  77. package/lib/feature/middleware.d.ts +22 -2
  78. package/lib/feature/middleware.js +7 -2
  79. package/lib/im-scene.d.ts +4 -3
  80. package/lib/im-scene.js +9 -9
  81. package/lib/im-session-id.d.ts +20 -12
  82. package/lib/im-session-id.js +8 -8
  83. package/lib/index.d.ts +19 -48
  84. package/lib/index.js +14 -41
  85. package/lib/jsx/intrinsic-elements.d.ts +83 -0
  86. package/lib/jsx/message-renderer.d.ts +13 -0
  87. package/lib/jsx/message-renderer.js +128 -0
  88. package/lib/jsx/message-tags.d.ts +133 -0
  89. package/lib/jsx/message-tags.js +50 -0
  90. package/lib/jsx-dev-runtime.d.ts +2 -2
  91. package/lib/jsx-dev-runtime.js +1 -2
  92. package/lib/jsx-runtime.d.ts +2 -12
  93. package/lib/jsx-runtime.js +1 -10
  94. package/lib/jsx.d.ts +6 -30
  95. package/lib/jsx.js +3 -93
  96. package/lib/message.d.ts +0 -40
  97. package/lib/message.js +1 -27
  98. package/lib/models/system-log.d.ts +0 -2
  99. package/lib/models/system-log.js +1 -8
  100. package/lib/models/user.d.ts +0 -2
  101. package/lib/models/user.js +1 -7
  102. package/lib/notice.d.ts +38 -33
  103. package/lib/notice.js +23 -7
  104. package/lib/plugin-runtime/im/command-feedback.d.ts +59 -0
  105. package/lib/plugin-runtime/im/command-feedback.js +148 -0
  106. package/lib/plugin-runtime/im/contracts.d.ts +217 -32
  107. package/lib/plugin-runtime/im/contracts.js +141 -23
  108. package/lib/plugin-runtime/im/conversation-runtime.d.ts +42 -0
  109. package/lib/plugin-runtime/im/conversation-runtime.js +451 -0
  110. package/lib/plugin-runtime/im/endpoint-runtime.d.ts +89 -0
  111. package/lib/plugin-runtime/im/endpoint-runtime.js +381 -0
  112. package/lib/plugin-runtime/im/feature-gate.d.ts +21 -0
  113. package/lib/plugin-runtime/im/feature-gate.js +88 -0
  114. package/lib/plugin-runtime/im/host/component-host-installer.d.ts +2 -0
  115. package/lib/plugin-runtime/im/host/component-host-installer.js +14 -0
  116. package/lib/plugin-runtime/im/host/conversation-migration.d.ts +5 -0
  117. package/lib/plugin-runtime/im/host/conversation-migration.js +75 -0
  118. package/lib/plugin-runtime/im/host/database-config.d.ts +10 -0
  119. package/lib/plugin-runtime/im/host/database-config.js +114 -0
  120. package/lib/plugin-runtime/im/host/database-host-installer.d.ts +29 -0
  121. package/lib/plugin-runtime/im/host/database-host-installer.js +442 -0
  122. package/lib/plugin-runtime/im/host/database-state.d.ts +9 -0
  123. package/lib/plugin-runtime/im/host/database-state.js +91 -0
  124. package/lib/plugin-runtime/im/host/index.d.ts +8 -0
  125. package/lib/plugin-runtime/im/host/index.js +8 -0
  126. package/lib/plugin-runtime/im/host/locale-host-installer.d.ts +3 -0
  127. package/lib/plugin-runtime/im/host/locale-host-installer.js +60 -0
  128. package/lib/plugin-runtime/im/host/outbound-host-installer.d.ts +8 -0
  129. package/lib/plugin-runtime/im/host/outbound-host-installer.js +153 -0
  130. package/lib/plugin-runtime/im/host/sender-enrichment.d.ts +34 -0
  131. package/lib/plugin-runtime/im/host/sender-enrichment.js +82 -0
  132. package/lib/plugin-runtime/im/im-runtime.d.ts +40 -111
  133. package/lib/plugin-runtime/im/im-runtime.js +234 -1059
  134. package/lib/plugin-runtime/im/inbound-dedup.d.ts +84 -0
  135. package/lib/plugin-runtime/im/inbound-dedup.js +322 -0
  136. package/lib/plugin-runtime/im/inbound-origin.d.ts +150 -0
  137. package/lib/plugin-runtime/im/inbound-origin.js +183 -0
  138. package/lib/plugin-runtime/im/inbound-runtime.d.ts +59 -0
  139. package/lib/plugin-runtime/im/inbound-runtime.js +478 -0
  140. package/lib/plugin-runtime/im/inbound-spine.d.ts +196 -0
  141. package/lib/plugin-runtime/im/inbound-spine.js +335 -0
  142. package/lib/plugin-runtime/im/index.d.ts +15 -4
  143. package/lib/plugin-runtime/im/index.js +11 -4
  144. package/lib/plugin-runtime/im/interaction-runtime.d.ts +50 -0
  145. package/lib/plugin-runtime/im/interaction-runtime.js +390 -0
  146. package/lib/plugin-runtime/im/interactive-router.d.ts +81 -0
  147. package/lib/plugin-runtime/im/interactive-router.js +382 -0
  148. package/lib/plugin-runtime/im/message-diagnostics.d.ts +70 -0
  149. package/lib/plugin-runtime/im/message-diagnostics.js +182 -0
  150. package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -4
  151. package/lib/plugin-runtime/im/message-dispatcher.js +138 -20
  152. package/lib/plugin-runtime/im/message-events.d.ts +85 -0
  153. package/lib/plugin-runtime/im/message-events.js +113 -0
  154. package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +39 -0
  155. package/lib/plugin-runtime/im/outbound-delivery-runtime.js +450 -0
  156. package/lib/plugin-runtime/im/outbound-renderer.d.ts +52 -3
  157. package/lib/plugin-runtime/im/outbound-renderer.js +188 -8
  158. package/lib/plugin-runtime/im/outbound-segments.d.ts +29 -5
  159. package/lib/plugin-runtime/im/outbound-segments.js +130 -36
  160. package/lib/plugin-runtime/im/progressive-reply.d.ts +58 -0
  161. package/lib/plugin-runtime/im/progressive-reply.js +501 -0
  162. package/lib/plugin-runtime/im/public-api.d.ts +1 -1
  163. package/lib/request.d.ts +27 -36
  164. package/lib/request.js +14 -6
  165. package/lib/side-event/base.d.ts +64 -44
  166. package/lib/side-event/base.js +72 -19
  167. package/lib/side-event/index.d.ts +1 -1
  168. package/lib/side-event/index.js +1 -1
  169. package/lib/side-event/normalize.d.ts +7 -38
  170. package/lib/side-event/normalize.js +4 -109
  171. package/lib/side-event/scene-events.d.ts +40 -0
  172. package/lib/side-event/scene-events.js +147 -0
  173. package/lib/side-event/types.d.ts +4 -13
  174. package/lib/side-event/types.js +1 -55
  175. package/lib/system-event.d.ts +17 -12
  176. package/lib/system-event.js +8 -6
  177. package/lib/types.d.ts +23 -167
  178. package/lib/utils.d.ts +50 -33
  179. package/lib/utils.js +12 -185
  180. package/lib/venue/contracts.d.ts +21 -0
  181. package/lib/venue/contracts.js +3 -0
  182. package/lib/venue/floor-controller.d.ts +11 -0
  183. package/lib/venue/floor-controller.js +63 -0
  184. package/lib/venue/index.d.ts +13 -0
  185. package/lib/venue/index.js +11 -0
  186. package/lib/venue/membership-port.d.ts +23 -0
  187. package/lib/venue/membership-port.js +141 -0
  188. package/lib/venue/projector.d.ts +38 -0
  189. package/lib/venue/projector.js +45 -0
  190. package/lib/venue/registry.d.ts +16 -0
  191. package/lib/venue/registry.js +63 -0
  192. package/lib/venue/router.d.ts +19 -0
  193. package/lib/venue/router.js +101 -0
  194. package/lib/venue/send-limiter.d.ts +17 -0
  195. package/lib/venue/send-limiter.js +73 -0
  196. package/lib/venue/validator.d.ts +6 -0
  197. package/lib/venue/validator.js +160 -0
  198. package/package.json +24 -50
  199. package/lib/adapter.d.ts +0 -145
  200. package/lib/adapter.js +0 -377
  201. package/lib/built/adapter-process.d.ts +0 -58
  202. package/lib/built/adapter-process.js +0 -128
  203. package/lib/built/agent-preset.d.ts +0 -64
  204. package/lib/built/agent-preset.js +0 -79
  205. package/lib/built/ai-outbound/adapter-access.d.ts +0 -3
  206. package/lib/built/ai-outbound/adapter-access.js +0 -9
  207. package/lib/built/ai-outbound/extensions/qq-message.d.ts +0 -3
  208. package/lib/built/ai-outbound/extensions/qq-message.js +0 -23
  209. package/lib/built/authorization.d.ts +0 -10
  210. package/lib/built/authorization.js +0 -76
  211. package/lib/built/command.d.ts +0 -72
  212. package/lib/built/command.js +0 -105
  213. package/lib/built/component.d.ts +0 -67
  214. package/lib/built/component.js +0 -97
  215. package/lib/built/config.d.ts +0 -98
  216. package/lib/built/config.js +0 -372
  217. package/lib/built/connect-endpoint-instance.d.ts +0 -17
  218. package/lib/built/connect-endpoint-instance.js +0 -42
  219. package/lib/built/database.d.ts +0 -68
  220. package/lib/built/database.js +0 -106
  221. package/lib/built/dispatcher.d.ts +0 -141
  222. package/lib/built/dispatcher.js +0 -383
  223. package/lib/built/endpoint-commands.d.ts +0 -3
  224. package/lib/built/endpoint-commands.js +0 -99
  225. package/lib/built/endpoint-lifecycle-service.d.ts +0 -28
  226. package/lib/built/endpoint-lifecycle-service.js +0 -242
  227. package/lib/built/endpoint-lifecycle.d.ts +0 -27
  228. package/lib/built/endpoint-lifecycle.js +0 -36
  229. package/lib/built/endpoint-manager.d.ts +0 -34
  230. package/lib/built/html-renderer-loader.d.ts +0 -13
  231. package/lib/built/html-renderer-loader.js +0 -33
  232. package/lib/built/inbound-pipeline.d.ts +0 -37
  233. package/lib/built/inbound-pipeline.js +0 -63
  234. package/lib/built/inbound-runner.d.ts +0 -22
  235. package/lib/built/inbound-runner.js +0 -34
  236. package/lib/built/interactive-segment-contract.d.ts +0 -6
  237. package/lib/built/interactive-segment-contract.js +0 -9
  238. package/lib/built/interactive-segments/fallback-store.d.ts +0 -29
  239. package/lib/built/interactive-segments/fallback-store.js +0 -63
  240. package/lib/built/interactive-segments/handlers.d.ts +0 -16
  241. package/lib/built/interactive-segments/handlers.js +0 -74
  242. package/lib/built/introspection-format.d.ts +0 -10
  243. package/lib/built/introspection-format.js +0 -28
  244. package/lib/built/management-command-guard.d.ts +0 -15
  245. package/lib/built/management-command-guard.js +0 -25
  246. package/lib/built/message-filter.d.ts +0 -176
  247. package/lib/built/message-filter.js +0 -239
  248. package/lib/built/optional-peer-import.d.ts +0 -3
  249. package/lib/built/optional-peer-import.js +0 -33
  250. package/lib/built/outbound-media-contract.d.ts +0 -22
  251. package/lib/built/outbound-media-contract.js +0 -10
  252. package/lib/built/permission.d.ts +0 -51
  253. package/lib/built/permission.js +0 -99
  254. package/lib/built/permit-check.d.ts +0 -7
  255. package/lib/built/permit-check.js +0 -35
  256. package/lib/built/permit-parse.d.ts +0 -16
  257. package/lib/built/permit-parse.js +0 -32
  258. package/lib/built/platform-permit.d.ts +0 -20
  259. package/lib/built/platform-permit.js +0 -91
  260. package/lib/built/queue-im-field-contract.d.ts +0 -32
  261. package/lib/built/queue-im-field-contract.js +0 -67
  262. package/lib/built/rich-segments/adapter-policies.d.ts +0 -9
  263. package/lib/built/rich-segments/adapter-policies.js +0 -27
  264. package/lib/built/rich-segments/base.d.ts +0 -11
  265. package/lib/built/rich-segments/base.js +0 -24
  266. package/lib/built/rich-segments/builtins.d.ts +0 -4
  267. package/lib/built/rich-segments/builtins.js +0 -40
  268. package/lib/built/rich-segments/capabilities.d.ts +0 -6
  269. package/lib/built/rich-segments/capabilities.js +0 -38
  270. package/lib/built/rich-segments/html-segment.d.ts +0 -15
  271. package/lib/built/rich-segments/html-segment.js +0 -62
  272. package/lib/built/rich-segments/index.d.ts +0 -13
  273. package/lib/built/rich-segments/index.js +0 -13
  274. package/lib/built/rich-segments/markdown-segment.d.ts +0 -14
  275. package/lib/built/rich-segments/markdown-segment.js +0 -58
  276. package/lib/built/rich-segments/qrcode-segment.d.ts +0 -18
  277. package/lib/built/rich-segments/qrcode-segment.js +0 -73
  278. package/lib/built/rich-segments/registry.d.ts +0 -16
  279. package/lib/built/rich-segments/registry.js +0 -52
  280. package/lib/built/rich-segments/resolve.d.ts +0 -5
  281. package/lib/built/rich-segments/resolve.js +0 -87
  282. package/lib/built/rich-segments/tts-segment.d.ts +0 -13
  283. package/lib/built/rich-segments/tts-segment.js +0 -51
  284. package/lib/built/rich-segments/types.d.ts +0 -79
  285. package/lib/built/rich-segments/types.js +0 -17
  286. package/lib/built/runtime-io.d.ts +0 -9
  287. package/lib/built/runtime-io.js +0 -67
  288. package/lib/built/schedule.d.ts +0 -54
  289. package/lib/built/schedule.js +0 -112
  290. package/lib/built/schema-endpoint-manager.d.ts +0 -17
  291. package/lib/built/schema-endpoint-manager.js +0 -73
  292. package/lib/built/schema-feature.d.ts +0 -77
  293. package/lib/built/schema-feature.js +0 -130
  294. package/lib/built/skill.d.ts +0 -120
  295. package/lib/built/skill.js +0 -151
  296. package/lib/built/speech-loader.d.ts +0 -14
  297. package/lib/built/speech-loader.js +0 -32
  298. package/lib/built/tool.d.ts +0 -151
  299. package/lib/built/tool.js +0 -388
  300. package/lib/command.d.ts +0 -50
  301. package/lib/command.js +0 -106
  302. package/lib/component.d.ts +0 -26
  303. package/lib/component.js +0 -583
  304. package/lib/endpoint-capabilities.d.ts +0 -46
  305. package/lib/endpoint-capabilities.js +0 -55
  306. package/lib/endpoint.d.ts +0 -19
  307. package/lib/endpoint.js +0 -3
  308. package/lib/host-plugin-registry.d.ts +0 -8
  309. package/lib/host-plugin-registry.js +0 -12
  310. package/lib/plugin-context.d.ts +0 -27
  311. package/lib/plugin-context.js +0 -64
  312. package/lib/plugin-runtime/im/interactive.d.ts +0 -26
  313. package/lib/plugin-runtime/im/interactive.js +0 -46
  314. package/lib/plugin-runtime/im/login-assist-host.d.ts +0 -6
  315. package/lib/plugin-runtime/im/login-assist-host.js +0 -6
  316. package/lib/plugin-runtime/im/message-bus.d.ts +0 -38
  317. package/lib/plugin-runtime/im/message-bus.js +0 -40
  318. package/lib/plugin-runtime/im/service-tokens.d.ts +0 -18
  319. package/lib/plugin-runtime/im/service-tokens.js +0 -13
  320. package/lib/plugin.d.ts +0 -268
  321. package/lib/plugin.js +0 -583
  322. package/lib/schema-interaction.d.ts +0 -117
  323. package/lib/schema-interaction.js +0 -247
  324. package/lib/side-event/dispatch.d.ts +0 -15
  325. package/lib/side-event/dispatch.js +0 -140
  326. package/lib/tool-zod.d.ts +0 -43
  327. package/lib/tool-zod.js +0 -184
  328. /package/lib/{built/endpoint-manager.js → jsx/intrinsic-elements.js} +0 -0
@@ -0,0 +1,50 @@
1
+ import { jsx } from '@zhin.js/jsx';
2
+ export function Text(props) {
3
+ return jsx('text', { ...props });
4
+ }
5
+ /** URLs and local paths are convenient sources; opaque platform IDs use MediaRef. */
6
+ export function Image({ src, alt }) {
7
+ let media;
8
+ if (typeof src !== 'string')
9
+ media = src;
10
+ else if (/^https?:\/\//i.test(src))
11
+ media = { kind: 'url', value: src };
12
+ else if (src.startsWith('base64://'))
13
+ media = { kind: 'base64', value: src.slice(9) };
14
+ else if (src.startsWith('data:')) {
15
+ const match = /^data:([^;,]+)(?:;[^;,]*)*;base64,([\s\S]+)$/i.exec(src);
16
+ if (!match)
17
+ throw new TypeError('Image data URI must contain base64 media');
18
+ media = { kind: 'base64', value: match[2], mime_type: match[1] };
19
+ }
20
+ else
21
+ media = { kind: 'path', value: src };
22
+ return jsx('image', { media, ...(alt === undefined ? {} : { alt }) });
23
+ }
24
+ export function Mention(props) { return jsx('mention', { ...props }); }
25
+ export function Face(props) { return jsx('face', { ...props }); }
26
+ export function Markdown(props) {
27
+ return jsx('markdown', { ...props });
28
+ }
29
+ export function Card({ data }) { return { type: 'card', data }; }
30
+ /** Event handlers are bound by the active IM operation, never serialized onto the wire. */
31
+ export function Button(props) { return jsx('button', { ...props }); }
32
+ function nativeTag(type) {
33
+ return (props) => jsx(type, { ...props });
34
+ }
35
+ export const Audio = nativeTag('audio');
36
+ export const Video = nativeTag('video');
37
+ export const File = nativeTag('file');
38
+ export const Reply = nativeTag('reply');
39
+ export const Forward = nativeTag('forward');
40
+ export const Share = nativeTag('share');
41
+ export const Dice = nativeTag('dice');
42
+ export const Rps = nativeTag('rps');
43
+ // Explicit annotations keep the emitted .d.ts on the leaf type module. Inferred, they
44
+ // print as import("../index.js"), dragging the whole core entry (and @zhin.js/ai,
45
+ // database drivers) into every packed consumer that only imports a feature subpath.
46
+ export const Keyboard = nativeTag('keyboard');
47
+ export const Action = nativeTag('action');
48
+ export const Link = nativeTag('link');
49
+ export const Qrcode = nativeTag('qrcode');
50
+ export const Tts = nativeTag('tts');
@@ -1,2 +1,2 @@
1
- export * from './jsx-runtime.js';
2
- export { jsx as jsxDEV } from './jsx.js';
1
+ export { Fragment, jsxDEV } from '@zhin.js/jsx/jsx-dev-runtime';
2
+ export type { JSX } from './jsx/intrinsic-elements.js';
@@ -1,2 +1 @@
1
- export * from './jsx-runtime.js';
2
- export { jsx as jsxDEV } from './jsx.js';
1
+ export { Fragment, jsxDEV } from '@zhin.js/jsx/jsx-dev-runtime';
@@ -1,12 +1,2 @@
1
- import { jsx, jsxs, Fragment, renderJSX } from './jsx.js';
2
- export { jsx, jsxs, Fragment, renderJSX };
3
- export type { JSX } from './jsx.js';
4
- declare const _default: {
5
- jsx: typeof jsx;
6
- jsxs: typeof jsxs;
7
- Fragment: import("./component.js").Component<{
8
- children?: import("./types.js").SendContent;
9
- }>;
10
- renderJSX: typeof renderJSX;
11
- };
12
- export default _default;
1
+ export { Fragment, jsx, jsxs } from '@zhin.js/jsx/jsx-runtime';
2
+ export type { JSX } from './jsx/intrinsic-elements.js';
@@ -1,10 +1 @@
1
- // JSX 运行时入口文件
2
- import { jsx, jsxs, Fragment, renderJSX } from './jsx.js';
3
- export { jsx, jsxs, Fragment, renderJSX };
4
- // 默认导出 JSX 运行时
5
- export default {
6
- jsx,
7
- jsxs,
8
- Fragment,
9
- renderJSX
10
- };
1
+ export { Fragment, jsx, jsxs } from '@zhin.js/jsx/jsx-runtime';
package/lib/jsx.d.ts CHANGED
@@ -1,30 +1,6 @@
1
- import type { SendContent, MessageElement } from './types.js';
2
- import type { MessageComponent } from './message.js';
3
- import type { Component, ComponentContext } from './component.js';
4
- export type JSXChildren = MessageElement | string | number | boolean | null | undefined | JSXChildren[];
5
- export type JSXElementType = string | Component<any>;
6
- export type JSXProps = Record<string, any> & {
7
- children?: JSXChildren;
8
- };
9
- export { Fragment } from './component.js';
10
- export declare namespace JSX {
11
- type Element = SendContent | Promise<SendContent>;
12
- interface ElementClass {
13
- render(props: any, context?: ComponentContext): Element;
14
- }
15
- interface ElementAttributesProperty {
16
- data: {};
17
- }
18
- interface ElementChildrenAttribute {
19
- children: {};
20
- }
21
- interface IntrinsicElements {
22
- [elemName: string]: any;
23
- }
24
- interface IntrinsicAttributes {
25
- key?: string | number;
26
- }
27
- }
28
- export declare function jsx(type: JSXElementType, data: JSXProps): MessageComponent<any>;
29
- export declare function jsxs(type: JSXElementType, props: JSXProps): MessageElement;
30
- export declare function renderJSX(element: MessageComponent<any>, context?: ComponentContext): Promise<SendContent>;
1
+ export * from '@zhin.js/jsx';
2
+ export { Image, Mention, Card, Button, Markdown, Face, Text, Audio, Video, File, Reply, Forward, Share, Dice, Rps, Keyboard, Action, Link, Qrcode, Tts } from './jsx/message-tags.js';
3
+ export type { ImageProps, MentionProps, CardProps, ButtonProps, ButtonClickHandler, ButtonClickResult, MarkdownProps, FaceProps, TextProps } from './jsx/message-tags.js';
4
+ export { renderToSegments } from './jsx/message-renderer.js';
5
+ export type { MessageRenderOptions } from './jsx/message-renderer.js';
6
+ export type { JSX, MessageTagProps } from './jsx/intrinsic-elements.js';
package/lib/jsx.js CHANGED
@@ -1,93 +1,3 @@
1
- export { Fragment } from './component.js';
2
- // JSX 运行时函数 - 支持异步组件
3
- export function jsx(type, data) {
4
- return {
5
- type,
6
- data,
7
- };
8
- }
9
- // JSX Fragment 支持
10
- export function jsxs(type, props) {
11
- return jsx(type, props);
12
- }
13
- // JSX 渲染函数
14
- export async function renderJSX(element, context) {
15
- try {
16
- if (typeof element.type === 'string') {
17
- if (element.type === 'Fragment') {
18
- return await renderChildren(element.data.children, context);
19
- }
20
- // 其他内置组件处理
21
- return await renderChildren(element.data.children, context);
22
- }
23
- else if (typeof element.type === 'function') {
24
- // 函数组件
25
- const component = element.type;
26
- const result = await component(element.data, context || {});
27
- // 如果组件返回 Promise,自动 await
28
- if (result && typeof result === 'object' && 'then' in result) {
29
- return await result;
30
- }
31
- return result;
32
- }
33
- else {
34
- // 类组件或其他类型
35
- const component = element.type;
36
- const result = await component(element.data, context || {});
37
- // 如果组件返回 Promise,自动 await
38
- if (result && typeof result === 'object' && 'then' in result) {
39
- return await result;
40
- }
41
- return result;
42
- }
43
- }
44
- catch (error) {
45
- // 渲染错误时返回错误信息
46
- const errorMessage = error instanceof Error ? error.message : String(error);
47
- return `❌ 组件渲染失败: ${errorMessage}`;
48
- }
49
- }
50
- // 渲染子元素
51
- async function renderChildren(children, context) {
52
- if (children == null)
53
- return '';
54
- if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {
55
- return String(children);
56
- }
57
- if (Array.isArray(children)) {
58
- const results = await Promise.all(children.map(async (child) => {
59
- if (typeof child === 'string' || typeof child === 'number' || typeof child === 'boolean') {
60
- return String(child);
61
- }
62
- if (child && typeof child === 'object' && 'type' in child) {
63
- return await renderJSX(child, context);
64
- }
65
- // 如果子元素是 Promise,自动 await
66
- if (child && typeof child === 'object' && 'then' in child) {
67
- try {
68
- return await child;
69
- }
70
- catch (error) {
71
- const errorMessage = error instanceof Error ? error.message : String(error);
72
- return `❌ 组件渲染失败: ${errorMessage}`;
73
- }
74
- }
75
- return '';
76
- }));
77
- return results.join('');
78
- }
79
- if (children && typeof children === 'object' && 'type' in children) {
80
- return await renderJSX(children, context);
81
- }
82
- // 如果子元素是 Promise,自动 await
83
- if (children && typeof children === 'object' && 'then' in children) {
84
- try {
85
- return await children;
86
- }
87
- catch (error) {
88
- const errorMessage = error instanceof Error ? error.message : String(error);
89
- return `❌ 组件渲染失败: ${errorMessage}`;
90
- }
91
- }
92
- return '';
93
- }
1
+ export * from '@zhin.js/jsx';
2
+ export { Image, Mention, Card, Button, Markdown, Face, Text, Audio, Video, File, Reply, Forward, Share, Dice, Rps, Keyboard, Action, Link, Qrcode, Tts } from './jsx/message-tags.js';
3
+ export { renderToSegments } from './jsx/message-renderer.js';
package/lib/message.d.ts CHANGED
@@ -1,15 +1,3 @@
1
- import type { MessageElement, MessageSender, SendContent } from "./types.js";
2
- import { Component } from "./component.js";
3
- import { Adapters } from "./adapter.js";
4
- /**
5
- * 消息组件类型:用于自定义消息结构
6
- */
7
- export type MessageComponent<T extends object> = {
8
- type: Component<T & {
9
- children?: SendContent | Promise<SendContent>;
10
- }>;
11
- data: T;
12
- };
13
1
  /**
14
2
  * 消息频道信息
15
3
  */
@@ -30,31 +18,3 @@ export interface MessageChannel {
30
18
  * 消息类型枚举
31
19
  */
32
20
  export type MessageType = 'group' | 'private' | 'channel';
33
- /**
34
- * 消息基础结构
35
- */
36
- export interface MessageBase {
37
- $id: string;
38
- $adapter: keyof Adapters;
39
- $endpoint: string;
40
- $content: MessageElement[];
41
- $sender: MessageSender;
42
- $reply?(content: SendContent, quote?: boolean | string): Promise<string>;
43
- $recall?(): Promise<void>;
44
- $channel: MessageChannel;
45
- $timestamp: number;
46
- $raw: string;
47
- }
48
- /**
49
- * 完整消息类型,支持扩展
50
- */
51
- export type Message<T extends object = {}> = MessageBase & T;
52
- /** @internal Legacy static helpers; not part of Agent resource authoring. */
53
- export declare namespace Message {
54
- /**
55
- * 工具方法:合并自定义字段与基础消息结构
56
- */
57
- function from<T extends object>(input: T, format: MessageBase): Message<T>;
58
- function actionPayload(message: Message<any>): string | undefined;
59
- function isAction(message: Message<any>): boolean;
60
- }
package/lib/message.js CHANGED
@@ -1,27 +1 @@
1
- import { isActionMessage as isActionMessageImpl } from "./built/interactive-segments/action.js";
2
- /** @internal Legacy static helpers; not part of Agent resource authoring. */
3
- export var Message;
4
- (function (Message) {
5
- /**
6
- * 工具方法:合并自定义字段与基础消息结构
7
- */
8
- function from(input, format) {
9
- return Object.assign({}, input, format);
10
- }
11
- Message.from = from;
12
- function actionPayload(message) {
13
- for (const item of message.$content ?? []) {
14
- if (typeof item === 'string')
15
- continue;
16
- if (item.type === 'action' && item.data?.payload) {
17
- return String(item.data.payload);
18
- }
19
- }
20
- return undefined;
21
- }
22
- Message.actionPayload = actionPayload;
23
- function isAction(message) {
24
- return isActionMessageImpl(message);
25
- }
26
- Message.isAction = isAction;
27
- })(Message || (Message = {}));
1
+ export {};
@@ -1,4 +1,3 @@
1
- import { Definition } from '@zhin.js/database';
2
1
  export interface SystemLog {
3
2
  id?: number;
4
3
  level: string;
@@ -7,4 +6,3 @@ export interface SystemLog {
7
6
  source: string;
8
7
  timestamp: Date;
9
8
  }
10
- export declare const SystemLogDefinition: Definition<SystemLog>;
@@ -1,8 +1 @@
1
- export const SystemLogDefinition = {
2
- id: { type: 'integer', autoIncrement: true, primary: true },
3
- level: { type: 'text', nullable: false },
4
- name: { type: 'text', nullable: false },
5
- message: { type: 'text', nullable: false },
6
- source: { type: 'text', nullable: false },
7
- timestamp: { type: 'date', nullable: false }
8
- };
1
+ export {};
@@ -1,4 +1,3 @@
1
- import { Definition } from '@zhin.js/database';
2
1
  export interface User {
3
2
  id: string;
4
3
  name?: string;
@@ -6,4 +5,3 @@ export interface User {
6
5
  third_part: string[];
7
6
  permissions?: string[];
8
7
  }
9
- export declare const UserDefinition: Definition<User>;
@@ -1,7 +1 @@
1
- export const UserDefinition = {
2
- id: { type: "text", nullable: false },
3
- name: { type: 'text', nullable: true },
4
- password: { type: 'text', nullable: true },
5
- third_part: { type: 'json', default: [] },
6
- permissions: { type: 'json', default: [] }
7
- };
1
+ export {};
package/lib/notice.d.ts CHANGED
@@ -1,38 +1,43 @@
1
- import type { Adapters } from './adapter.js';
2
- import type { NoticeKind } from './side-event/types.js';
3
- import type { SideEventBase } from './side-event/base.js';
1
+ import type { ComposedNoticeName } from './side-event/types.js';
2
+ import { RuntimeSideEvent, type IncomingSideEvent, type SideEventBase, type EndpointEventContext } from './side-event/base.js';
4
3
  export type { NoticeKind, ComposedNoticeName } from './side-event/types.js';
5
- export type { SideEventBase } from './side-event/base.js';
6
- export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventSendChannel, } from './side-event/base.js';
7
- /**
8
- * 通知基础结构 — 继承 SideEventBase。
9
- *
10
- * @example
11
- * ```typescript
12
- * const notice = Notice.from(rawEvent, {
13
- * $id: rawEvent.id,
14
- * $adapter: 'icqq',
15
- * $endpoint: endpointKey,
16
- * $type: 'notice',
17
- * $scene_id: groupId,
18
- * $scene_type: 'group',
19
- * $sub_type: 'member_decrease',
20
- * $actor: { id: operatorId, name: '管理员' },
21
- * $target: { id: userId, name: '被踢者' },
22
- * $timestamp: Date.now(),
23
- * });
24
- * // formatSideEventName(notice) === 'notice.group.member_decrease'
25
- * this.adapter.emit('notice.receive', notice);
26
- * ```
27
- */
4
+ export type { SideEventBase, IncomingSideEvent } from './side-event/base.js';
5
+ export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventConversation, sideEventSendChannel } from './side-event/base.js';
6
+ export interface IncomingNotice extends IncomingSideEvent {
7
+ readonly type: 'notice';
8
+ readonly name: ComposedNoticeName;
9
+ readonly messageId?: string;
10
+ readonly reaction?: string;
11
+ readonly operation?: 'added' | 'removed';
12
+ readonly durationSeconds?: number;
13
+ readonly role?: string;
14
+ readonly enabled?: boolean;
15
+ /** Short new value of a card/title/remark change or a notice body (adapter-truncated, plain text). */
16
+ readonly value?: string;
17
+ }
28
18
  export interface NoticeBase extends SideEventBase {
29
- $adapter: keyof Adapters;
30
- $type: NoticeKind;
19
+ readonly type: 'notice';
20
+ readonly name: ComposedNoticeName;
21
+ readonly messageId?: string;
22
+ readonly reaction?: string;
23
+ readonly operation?: 'added' | 'removed';
24
+ readonly durationSeconds?: number;
25
+ readonly role?: string;
26
+ readonly enabled?: boolean;
27
+ readonly value?: string;
31
28
  }
32
- /**
33
- * 完整通知类型,支持平台原始数据扩展
34
- */
35
29
  export type Notice<T extends object = {}> = NoticeBase & T;
36
- export declare namespace Notice {
37
- function from<T extends object>(input: T, format: NoticeBase): Notice<T>;
30
+ /** @internal Generation-scoped implementation of the public Notice contract. */
31
+ export declare class RuntimeNotice extends RuntimeSideEvent implements NoticeBase {
32
+ readonly type: 'notice';
33
+ readonly name: ComposedNoticeName;
34
+ readonly messageId?: string;
35
+ readonly reaction?: string;
36
+ readonly operation?: 'added' | 'removed';
37
+ readonly durationSeconds?: number;
38
+ readonly role?: string;
39
+ readonly enabled?: boolean;
40
+ readonly value?: string;
41
+ constructor(input: IncomingNotice, context: EndpointEventContext);
38
42
  }
43
+ export declare const Notice: typeof RuntimeNotice;
package/lib/notice.js CHANGED
@@ -1,8 +1,24 @@
1
- export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventSendChannel, } from './side-event/base.js';
2
- export var Notice;
3
- (function (Notice) {
4
- function from(input, format) {
5
- return Object.assign(input, format);
1
+ import { RuntimeSideEvent } from './side-event/base.js';
2
+ export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventConversation, sideEventSendChannel } from './side-event/base.js';
3
+ /** @internal Generation-scoped implementation of the public Notice contract. */
4
+ export class RuntimeNotice extends RuntimeSideEvent {
5
+ messageId;
6
+ reaction;
7
+ operation;
8
+ durationSeconds;
9
+ role;
10
+ enabled;
11
+ value;
12
+ constructor(input, context) {
13
+ super(input, context);
14
+ this.messageId = input.messageId;
15
+ this.reaction = input.reaction;
16
+ this.operation = input.operation;
17
+ this.durationSeconds = input.durationSeconds;
18
+ this.role = input.role;
19
+ this.enabled = input.enabled;
20
+ this.value = input.value;
21
+ Object.freeze(this);
6
22
  }
7
- Notice.from = from;
8
- })(Notice || (Notice = {}));
23
+ }
24
+ export const Notice = RuntimeNotice;
@@ -0,0 +1,59 @@
1
+ import type { CommandDispatchResult, CommandExecutionLimit, CommandIndex, CommandMenuPage, CommandValidationIssue } from '@zhin.js/command';
2
+ import type { ConversationRef } from '@zhin.js/im-contract';
3
+ import { type Locale, type PluginId, type RuntimeSnapshot } from '@zhin.js/plugin-runtime';
4
+ import type { Message, MessageSenderRef, SendContent } from './contracts.js';
5
+ interface CommandFeedbackIdentity {
6
+ readonly command?: string;
7
+ /** The command's owner, not the author of the replacement reply. */
8
+ readonly owner?: PluginId;
9
+ }
10
+ /** Execution facts are read-only; formatting cannot change admission or permission decisions. */
11
+ export type CommandFeedback = CommandFeedbackIdentity & ({
12
+ readonly status: 'invalid';
13
+ readonly issues: readonly CommandValidationIssue[];
14
+ readonly help?: string;
15
+ } | {
16
+ readonly status: 'denied';
17
+ readonly permit?: string;
18
+ readonly reason?: string;
19
+ } | {
20
+ readonly status: 'limited';
21
+ readonly limit?: CommandExecutionLimit;
22
+ });
23
+ /** A presentation context deliberately without message bodies, sending methods or executors. */
24
+ export interface CommandFeedbackContext {
25
+ readonly locale: Locale;
26
+ readonly conversation: ConversationRef;
27
+ readonly sender?: MessageSenderRef;
28
+ readonly clientAdapter?: string;
29
+ readonly generation: number;
30
+ }
31
+ /** Return undefined to retain the built-in feedback. Exceptions also fall back to it. */
32
+ export type CommandFeedbackRenderer = (feedback: CommandFeedback, context: CommandFeedbackContext) => SendContent | undefined | Promise<SendContent | undefined>;
33
+ /** Explicitly provide this resource in Root setup; descendant bindings are not selected. */
34
+ export declare const commandFeedbackToken: import("@zhin.js/plugin-runtime").Token<CommandFeedbackRenderer>;
35
+ /** @internal Resolve once from the operation snapshot; never redispatch or send from here. */
36
+ export declare function renderCommandFeedback(result: CommandDispatchResult, message: Message, snapshot: RuntimeSnapshot): Promise<{
37
+ readonly content: SendContent;
38
+ readonly owner?: PluginId;
39
+ } | undefined>;
40
+ export interface CommandMenuPresentationInput {
41
+ readonly page: CommandMenuPage;
42
+ readonly conversation: ConversationRef;
43
+ readonly generation: number;
44
+ }
45
+ /** Root-selected menu content. `undefined` retains the built-in presentation. */
46
+ export type CommandMenuPresenter = (input: CommandMenuPresentationInput) => SendContent | undefined | Promise<SendContent | undefined>;
47
+ export declare const commandMenuPresentationToken: import("@zhin.js/plugin-runtime").Token<CommandMenuPresenter>;
48
+ /** The current Root owns both the selected presenter and the resulting content. */
49
+ export declare function presentCommandMenu(page: CommandMenuPage, fallback: SendContent, snapshot: RuntimeSnapshot, conversation: ConversationRef): Promise<SendContent>;
50
+ /** Rendering dependencies for one menu response; callbacks retain the same generation. */
51
+ export interface CommandMenuReplyContext {
52
+ readonly commands: CommandIndex;
53
+ readonly snapshot: RuntimeSnapshot;
54
+ readonly conversation: ConversationRef;
55
+ readonly prefix: string;
56
+ }
57
+ /** IM-only presentation: Command remains independent of JSX, adapters and callback registries. */
58
+ export declare function commandMenuReply(result: CommandDispatchResult, { commands, snapshot, conversation, prefix }: CommandMenuReplyContext): Promise<SendContent>;
59
+ export {};