@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,84 @@
1
+ import type { PeerRegistry } from '@zhin.js/adapter';
2
+ import type { ConversationRef } from '@zhin.js/im-contract';
3
+ import type { RuntimeSnapshot } from '@zhin.js/plugin-runtime';
4
+ import type { IncomingMessage, MessageSenderRef } from './contracts.js';
5
+ import { requireAdapters } from './endpoint-runtime.js';
6
+ import { type RoomInboundRouteInput, type RoomMembershipPort } from './inbound-origin.js';
7
+ import type { InboundInteractionPort } from './inbound-spine.js';
8
+ export { roomMembershipToken, type ResolvedRoomInfo, type RoomArbitrationInput, type RoomClaimInput, type RoomInboundRouteInput, type RoomMembershipPort, type RoomReadinessResult, type RoomRouteDecision, } from './inbound-origin.js';
9
+ export type InboundClaim = 'first' | 'same_endpoint' | 'duplicate' | 'unkeyed';
10
+ /** Room Router decision as seen by the deduper (the Endpoint ids only). */
11
+ export interface InboundArbitrationDecision {
12
+ readonly target: string;
13
+ /** Takeover candidates after the target, by priority. */
14
+ readonly fallbacks: readonly string[];
15
+ }
16
+ export type InboundArbitration =
17
+ /** Not keyed (private chat / no sender / no message id): caller keeps per-Endpoint handling. */
18
+ {
19
+ readonly kind: 'unkeyed';
20
+ }
21
+ /** Handle this copy. `routed` is true when the Room Router chose (or a fallback took over for) this Endpoint. */
22
+ | {
23
+ readonly kind: 'handle';
24
+ readonly routed: boolean;
25
+ } | {
26
+ readonly kind: 'duplicate';
27
+ }
28
+ /** Non-target copy that arrived before the target: wait for the target or the grace period. */
29
+ | {
30
+ readonly kind: 'wait';
31
+ readonly target: string;
32
+ /** False when this Endpoint is neither the target nor in `fallbacks` (lowest-priority takeover candidate). */
33
+ readonly listed: boolean;
34
+ readonly settle: () => Promise<'handle' | 'duplicate'>;
35
+ };
36
+ export declare class InboundDeduper {
37
+ #private;
38
+ private readonly now;
39
+ private readonly graceMs;
40
+ constructor(now?: () => number, graceMs?: number);
41
+ get size(): number;
42
+ /**
43
+ * 不变量:本方法完全同步,调用方必须在任何 await 之前调用,
44
+ * 这样 N 个 Endpoint 的并发到达会被原子地判定。
45
+ */
46
+ claim(conversation: ConversationRef, senderId: string, messageId: unknown): InboundClaim;
47
+ /**
48
+ * Room 内按 Router 决策仲裁:目标 Endpoint 的副本处理,其余副本只记录;
49
+ * 但目标可能根本没收到副本(如 Telegram 隐私模式),所以非目标副本不是立刻丢弃,
50
+ * 而是等待目标到达,宽限期(`graceMs`)后由优先级最高的已到达成员 Endpoint 接管。
51
+ *
52
+ * 与 `claim` 同样完全同步(返回的 `settle` 才是异步的),必须在任何 await 之前调用。
53
+ * `compute` 仅在第一个副本到达时调用一次,结果(含 undefined)按消息缓存。
54
+ * `compute` 返回 undefined(无可用成员)时退化为 `claim` 语义:先到先得,同 Endpoint 重投仍处理。
55
+ * decision 之外的 Endpoint 视为最低优先级的接管候选;非成员由 hasRoom 在 core 之外过滤。
56
+ */
57
+ arbitrate(conversation: ConversationRef, senderId: string, messageId: unknown, compute: () => InboundArbitrationDecision | undefined): InboundArbitration;
58
+ }
59
+ /** Facts required to route this message within its captured account directory. */
60
+ export interface InboundRoomRouteRequest {
61
+ readonly conversation: IncomingMessage['conversation'];
62
+ readonly senderId: string;
63
+ readonly input: IncomingMessage;
64
+ readonly adapters: ReturnType<typeof requireAdapters>;
65
+ readonly generation: number;
66
+ readonly interactions: InboundInteractionPort;
67
+ readonly registry?: Pick<PeerRegistry, 'isReady' | 'selfOf'>;
68
+ readonly inboundClaimPending?: (conversation: IncomingMessage['conversation'], senderId: string) => boolean;
69
+ readonly resolveReplyTarget?: (conversation: IncomingMessage['conversation'], messageId: string) => string | undefined;
70
+ }
71
+ export declare function buildRoomInboundRouteInput({ conversation, senderId, input, adapters, generation, interactions, registry, inboundClaimPending, resolveReplyTarget, }: InboundRoomRouteRequest): RoomInboundRouteInput;
72
+ export declare function arbitrateRoomInboundDeduplication(input: {
73
+ readonly origin: string | undefined;
74
+ readonly deduper?: Pick<InboundDeduper, 'claim'> & Partial<Pick<InboundDeduper, 'arbitrate'>>;
75
+ readonly roomMembership: RoomMembershipPort | undefined;
76
+ readonly conversation: IncomingMessage['conversation'];
77
+ readonly enrichedSender: MessageSenderRef | undefined;
78
+ readonly incoming: IncomingMessage;
79
+ readonly routeRequest: InboundRoomRouteRequest;
80
+ }): Promise<{
81
+ readonly recordOnly?: 'duplicate' | 'dedup_error';
82
+ readonly routedTarget: boolean;
83
+ }>;
84
+ export declare function resolveRoomMembership(snapshot: RuntimeSnapshot): RoomMembershipPort | undefined;
@@ -0,0 +1,322 @@
1
+ import { formatCompact, getLogger } from '@zhin.js/logger';
2
+ import { readMentionSegmentTarget } from '../../built/segment-contract/mention.js';
3
+ import { ledgerScopeOf, roomMembershipToken, } from './inbound-origin.js';
4
+ import { actionPayloadFromSegments } from './interactive-router.js';
5
+ import { formatConversationLog } from './message-events.js';
6
+ export { roomMembershipToken, } from './inbound-origin.js';
7
+ const logger = getLogger('im.inbound');
8
+ /**
9
+ * @internal 入站去重:同一条人类群消息会到达 N 个成员 Endpoint,
10
+ * 按 平台 + 会话 + 发送者 + 平台消息 id 只放行第一个 Endpoint,其余仅记录。
11
+ *
12
+ * 只对 group / channel 生效。私聊刻意排除:部分平台(如 OneBot)的消息 id 是
13
+ * 账号级的,两个 Bot 在同一私聊里可能拿到相同 id 的不同消息,去重会误合并。
14
+ * 缺少发送者或消息 id 时同样不去重(保持原有路由行为)。
15
+ */
16
+ const TTL_MS = 60_000;
17
+ const MAX_ENTRIES = 2000;
18
+ const DEFAULT_GRACE_MS = 2000;
19
+ export class InboundDeduper {
20
+ now;
21
+ graceMs;
22
+ #entries = new Map();
23
+ #arbitrations = new Map();
24
+ constructor(now = Date.now, graceMs = DEFAULT_GRACE_MS) {
25
+ this.now = now;
26
+ this.graceMs = graceMs;
27
+ }
28
+ get size() {
29
+ return this.#entries.size;
30
+ }
31
+ /**
32
+ * 不变量:本方法完全同步,调用方必须在任何 await 之前调用,
33
+ * 这样 N 个 Endpoint 的并发到达会被原子地判定。
34
+ */
35
+ claim(conversation, senderId, messageId) {
36
+ const key = this.#keyOf(conversation, senderId, messageId);
37
+ if (key === undefined)
38
+ return 'unkeyed';
39
+ const at = this.now();
40
+ this.#prune(at);
41
+ const existing = this.#entries.get(key);
42
+ if (existing) {
43
+ return existing.endpointId === conversation.endpoint.id ? 'same_endpoint' : 'duplicate';
44
+ }
45
+ this.#entries.set(key, { endpointId: conversation.endpoint.id, at });
46
+ while (this.#entries.size > MAX_ENTRIES) {
47
+ const oldest = this.#entries.keys().next().value;
48
+ if (oldest === undefined)
49
+ break;
50
+ this.#entries.delete(oldest);
51
+ }
52
+ return 'first';
53
+ }
54
+ /**
55
+ * Room 内按 Router 决策仲裁:目标 Endpoint 的副本处理,其余副本只记录;
56
+ * 但目标可能根本没收到副本(如 Telegram 隐私模式),所以非目标副本不是立刻丢弃,
57
+ * 而是等待目标到达,宽限期(`graceMs`)后由优先级最高的已到达成员 Endpoint 接管。
58
+ *
59
+ * 与 `claim` 同样完全同步(返回的 `settle` 才是异步的),必须在任何 await 之前调用。
60
+ * `compute` 仅在第一个副本到达时调用一次,结果(含 undefined)按消息缓存。
61
+ * `compute` 返回 undefined(无可用成员)时退化为 `claim` 语义:先到先得,同 Endpoint 重投仍处理。
62
+ * decision 之外的 Endpoint 视为最低优先级的接管候选;非成员由 hasRoom 在 core 之外过滤。
63
+ */
64
+ arbitrate(conversation, senderId, messageId, compute) {
65
+ const key = this.#keyOf(conversation, senderId, messageId);
66
+ if (key === undefined)
67
+ return { kind: 'unkeyed' };
68
+ const at = this.now();
69
+ this.#prune(at);
70
+ const endpointId = conversation.endpoint.id;
71
+ let entry = this.#arbitrations.get(key);
72
+ if (!entry) {
73
+ entry = {
74
+ at,
75
+ decision: compute(),
76
+ firstEndpoint: endpointId,
77
+ targetSeen: false,
78
+ takenOverBy: undefined,
79
+ waiters: [],
80
+ timer: undefined,
81
+ };
82
+ this.#arbitrations.set(key, entry);
83
+ while (this.#arbitrations.size > MAX_ENTRIES) {
84
+ const oldest = this.#arbitrations.keys().next().value;
85
+ if (oldest === undefined)
86
+ break;
87
+ this.#evict(oldest);
88
+ }
89
+ }
90
+ const { decision } = entry;
91
+ if (!decision) {
92
+ return entry.firstEndpoint === endpointId
93
+ ? { kind: 'handle', routed: false }
94
+ : { kind: 'duplicate' };
95
+ }
96
+ if (endpointId === decision.target) {
97
+ if (entry.takenOverBy !== undefined)
98
+ return { kind: 'duplicate' };
99
+ entry.targetSeen = true;
100
+ this.#settleWaiters(entry, 'duplicate');
101
+ return { kind: 'handle', routed: true };
102
+ }
103
+ if (entry.takenOverBy !== undefined) {
104
+ return entry.takenOverBy === endpointId ? { kind: 'handle', routed: true } : { kind: 'duplicate' };
105
+ }
106
+ if (entry.targetSeen)
107
+ return { kind: 'duplicate' };
108
+ const target = entry.waiters;
109
+ const settle = new Promise((resolve) => {
110
+ target.push({ endpointId, resolve });
111
+ });
112
+ if (entry.timer === undefined) {
113
+ const owned = entry;
114
+ owned.timer = setTimeout(() => this.#takeOver(owned), this.graceMs);
115
+ owned.timer.unref?.();
116
+ }
117
+ return {
118
+ kind: 'wait',
119
+ target: decision.target,
120
+ listed: decision.fallbacks.includes(endpointId),
121
+ settle: () => settle,
122
+ };
123
+ }
124
+ #keyOf(conversation, senderId, messageId) {
125
+ if (conversation.kind !== 'group' && conversation.kind !== 'channel')
126
+ return undefined;
127
+ if (typeof senderId !== 'string' || senderId === '')
128
+ return undefined;
129
+ if (typeof messageId !== 'string' && typeof messageId !== 'number')
130
+ return undefined;
131
+ const id = String(messageId);
132
+ if (id === '')
133
+ return undefined;
134
+ return `${ledgerScopeOf(conversation)}\0${senderId}\0${id}`;
135
+ }
136
+ #settleWaiters(entry, outcome) {
137
+ if (entry.timer !== undefined)
138
+ clearTimeout(entry.timer);
139
+ entry.timer = undefined;
140
+ const waiters = entry.waiters;
141
+ entry.waiters = [];
142
+ for (const waiter of waiters)
143
+ waiter.resolve(outcome);
144
+ }
145
+ /** Synchronous: the best-priority waiting copy takes over unless the target showed up or someone already did. */
146
+ #takeOver(entry) {
147
+ if (entry.timer !== undefined)
148
+ clearTimeout(entry.timer);
149
+ entry.timer = undefined;
150
+ const waiters = entry.waiters;
151
+ entry.waiters = [];
152
+ const decision = entry.decision;
153
+ if (!decision || entry.targetSeen || entry.takenOverBy !== undefined || waiters.length === 0) {
154
+ for (const waiter of waiters)
155
+ waiter.resolve('duplicate');
156
+ return;
157
+ }
158
+ const rank = (id) => {
159
+ const index = decision.fallbacks.indexOf(id);
160
+ return index === -1 ? decision.fallbacks.length : index;
161
+ };
162
+ let winner = waiters[0];
163
+ for (const waiter of waiters) {
164
+ if (rank(waiter.endpointId) < rank(winner.endpointId))
165
+ winner = waiter;
166
+ }
167
+ entry.takenOverBy = winner.endpointId;
168
+ for (const waiter of waiters)
169
+ waiter.resolve(waiter === winner ? 'handle' : 'duplicate');
170
+ }
171
+ /** Dropping an entry must not strand a waiting copy: resolve it by taking over now. */
172
+ #evict(key) {
173
+ const entry = this.#arbitrations.get(key);
174
+ this.#arbitrations.delete(key);
175
+ if (entry)
176
+ this.#takeOver(entry);
177
+ }
178
+ #prune(at) {
179
+ for (const [key, entry] of this.#arbitrations) {
180
+ if (at - entry.at <= TTL_MS)
181
+ break;
182
+ this.#evict(key);
183
+ }
184
+ for (const [key, entry] of this.#entries) {
185
+ if (at - entry.at <= TTL_MS)
186
+ break;
187
+ this.#entries.delete(key);
188
+ }
189
+ }
190
+ }
191
+ export function buildRoomInboundRouteInput({ conversation, senderId, input, adapters, generation, interactions, registry, inboundClaimPending, resolveReplyTarget, }) {
192
+ const mentionTargets = (input.segments ?? [])
193
+ .map((segment) => readMentionSegmentTarget(segment))
194
+ .filter((target) => target !== '' && target !== 'all');
195
+ const replyToId = input.replyTo?.id;
196
+ const replyToEndpointId = replyToId !== undefined && resolveReplyTarget
197
+ ? resolveReplyTarget(conversation, replyToId)
198
+ : undefined;
199
+ return {
200
+ conversation,
201
+ senderId,
202
+ content: input.content,
203
+ mentionTargets,
204
+ ...(replyToEndpointId !== undefined ? { replyToEndpointId } : {}),
205
+ pending: (endpointId) => {
206
+ try {
207
+ const adapter = adapters.clientAdapter(endpointId);
208
+ const probe = Object.freeze({ ...conversation, endpoint: Object.freeze({ id: endpointId, adapter }) });
209
+ return interactions.hasPendingAnswer?.(probe, senderId, generation, { content: input.content, segments: input.segments }) === true || inboundClaimPending?.(probe, senderId) === true;
210
+ }
211
+ catch {
212
+ return false;
213
+ }
214
+ },
215
+ accountOf: (endpointId) => registry?.selfOf(endpointId),
216
+ isAvailable: (endpointId) => registry?.isReady(endpointId) === true,
217
+ };
218
+ }
219
+ export async function arbitrateRoomInboundDeduplication(input) {
220
+ const { origin, deduper, roomMembership, conversation, enrichedSender, incoming, routeRequest } = input;
221
+ let recordOnly;
222
+ let routedTarget = false;
223
+ let pendingSettle;
224
+ const platformCallback = actionPayloadFromSegments(incoming.segments) !== undefined;
225
+ if ((origin === 'human' || origin === undefined) && deduper && !platformCallback
226
+ && (conversation.kind === 'group' || conversation.kind === 'channel')) {
227
+ try {
228
+ if (roomMembership?.hasRoom?.(conversation) === true) {
229
+ const senderId = String(enrichedSender?.id ?? '');
230
+ if (typeof roomMembership.route === 'function' && typeof deduper.arbitrate === 'function') {
231
+ const route = roomMembership.route.bind(roomMembership);
232
+ const routeInput = buildRoomInboundRouteInput(routeRequest);
233
+ const verdict = deduper.arbitrate(conversation, senderId, incoming.message?.id, () => {
234
+ try {
235
+ const decision = route(routeInput);
236
+ return decision
237
+ ? { target: decision.endpointId, fallbacks: decision.fallbackEndpointIds ?? [] }
238
+ : undefined;
239
+ }
240
+ catch (error) {
241
+ logger.warn(formatCompact({
242
+ op: 'room_route_error',
243
+ conv: formatConversationLog(conversation),
244
+ error: error instanceof Error ? error.message : String(error),
245
+ }));
246
+ return undefined;
247
+ }
248
+ });
249
+ switch (verdict.kind) {
250
+ case 'handle':
251
+ routedTarget = verdict.routed;
252
+ break;
253
+ case 'duplicate':
254
+ recordOnly = 'duplicate';
255
+ logger.debug(formatCompact({
256
+ op: 'room_non_target_copy',
257
+ conv: formatConversationLog(conversation),
258
+ }));
259
+ break;
260
+ case 'wait':
261
+ pendingSettle = verdict;
262
+ break;
263
+ case 'unkeyed':
264
+ break;
265
+ }
266
+ }
267
+ else {
268
+ const claim = deduper.claim(conversation, senderId, incoming.message?.id);
269
+ if (claim === 'duplicate')
270
+ recordOnly = 'duplicate';
271
+ }
272
+ }
273
+ }
274
+ catch (error) {
275
+ logger.warn(formatCompact({
276
+ op: 'inbound_dedup_error',
277
+ conv: formatConversationLog(conversation),
278
+ error: error instanceof Error ? error.message : String(error),
279
+ }));
280
+ recordOnly = 'dedup_error';
281
+ }
282
+ }
283
+ if (pendingSettle) {
284
+ const outcome = await pendingSettle.settle();
285
+ if (outcome === 'handle') {
286
+ routedTarget = true;
287
+ if (!pendingSettle.listed) {
288
+ logger.warn(formatCompact({
289
+ op: 'room_unlisted_member_takeover',
290
+ conv: formatConversationLog(conversation),
291
+ target: pendingSettle.target,
292
+ takeover: conversation.endpoint.id,
293
+ }));
294
+ }
295
+ logger.debug(formatCompact({
296
+ op: 'room_target_missing_takeover',
297
+ conv: formatConversationLog(conversation),
298
+ target: pendingSettle.target,
299
+ takeover: conversation.endpoint.id,
300
+ }));
301
+ }
302
+ else {
303
+ recordOnly = 'duplicate';
304
+ }
305
+ }
306
+ return { recordOnly, routedTarget };
307
+ }
308
+ export function resolveRoomMembership(snapshot) {
309
+ try {
310
+ const candidate = snapshot.resources.get(snapshot.root)?.get(roomMembershipToken.id);
311
+ return candidate
312
+ && typeof candidate === 'object'
313
+ && (typeof candidate.isMember === 'function'
314
+ || typeof candidate.resolveRoom === 'function'
315
+ || typeof candidate.isRoomReady === 'function')
316
+ ? candidate
317
+ : undefined;
318
+ }
319
+ catch {
320
+ return undefined;
321
+ }
322
+ }
@@ -0,0 +1,150 @@
1
+ import { type CapabilityId } from '@zhin.js/plugin-runtime';
2
+ import type { ConversationRef, DeliveryReceipt } from '@zhin.js/im-contract';
3
+ import type { PeerRegistry } from '@zhin.js/adapter';
4
+ /**
5
+ * scope 键不含 endpoint id:同一个群里不同 Bot 的 conversationRefKey 不同,
6
+ * 但它们互相的回显仍属同一会话。
7
+ */
8
+ export declare function ledgerScopeOf(conversation: ConversationRef): string;
9
+ export declare function digestText(text: string): string | undefined;
10
+ export interface LedgerMatch {
11
+ readonly endpointId: string;
12
+ }
13
+ export declare class OutboundLedger {
14
+ #private;
15
+ private readonly now;
16
+ constructor(now?: () => number);
17
+ get size(): number;
18
+ /** 仅在 `receipt.status === 'sent'` 时记录;`payload` 应为最终投影后的 payload。 */
19
+ record(conversation: ConversationRef, receipt: DeliveryReceipt, payload: unknown): void;
20
+ matchById(scope: string, messageId: unknown): LedgerMatch | undefined;
21
+ /**
22
+ * 摘要兜底(“账号 id 对不上”时):30 秒窗口、一次性。
23
+ * 权衡:人类在窗口内原样复读 Bot 刚发的文本,会被当作回显丢弃一次。
24
+ */
25
+ matchByDigest(scope: string, text: string, now?: number): LedgerMatch | undefined;
26
+ }
27
+ /** 入站消息来源。仅 `human` 能触发 agent turn;其余只记录。 */
28
+ export type MessageOrigin = 'self' | 'member' | 'peer_bot' | 'human';
29
+ /** @internal */
30
+ export declare const MESSAGE_ORIGINS: readonly MessageOrigin[];
31
+ export declare function isMessageOrigin(value: unknown): value is MessageOrigin;
32
+ export interface RoomClaimInput {
33
+ readonly platform: string;
34
+ readonly sceneType?: string;
35
+ readonly sceneId: string;
36
+ readonly threadId?: string;
37
+ }
38
+ export interface RoomArbitrationInput extends RoomClaimInput {
39
+ readonly endpointId: string;
40
+ readonly rawText?: string;
41
+ readonly mentions?: readonly string[];
42
+ readonly replyToSenderId?: string;
43
+ }
44
+ export interface ResolvedRoomInfo {
45
+ readonly roomId: string;
46
+ readonly defaultEndpointId: string;
47
+ readonly memberEndpoints: readonly string[];
48
+ }
49
+ export interface RoomReadinessResult {
50
+ readonly ready: boolean;
51
+ readonly unreadyEndpoints?: readonly string[];
52
+ }
53
+ /**
54
+ * Room 成员端口。由 Room 激活(后续条目,workroom)通过 root resources 提供;
55
+ * 未提供时没有任何 member:Registry 命中的账号全部是 `peer_bot`。
56
+ * core 不导入 workroom,故以 Token 端口注入。
57
+ */
58
+ export interface RoomMembershipPort {
59
+ isMember(peer: {
60
+ adapter: string;
61
+ userId: string;
62
+ endpointIds: readonly CapabilityId[];
63
+ }, conversation: ConversationRef): boolean;
64
+ /**
65
+ * 该会话是否属于某个启用的 Room。仅当返回 true 时,入站才做跨 Endpoint 去重 / 路由;
66
+ * 应按“会话 + 接收 Endpoint(`conversation.endpoint`)”的成员关系判定:同一会话里
67
+ * 非成员 Endpoint 收到的副本必须返回 false,按普通群自行处理;
68
+ * 缺省(未实现)等同 false:普通群保持每个 Endpoint 各自处理。
69
+ *
70
+ * `hasRoom` 与 `route` 必须成对实现(B2b Room Router 已实现):去重落败的 Endpoint 上
71
+ * 待回答的 interaction / prompt 与 @ 只有在 `route` 把目标 Endpoint 解析出来时才会被消费。
72
+ * 仅实现 `hasRoom` 而没有 `route` 时回退到 B2 的先到先得,落败 Endpoint 上的状态不会被消费。
73
+ *
74
+ * 带 action 段的入站(平台按钮回调)不经过 hasRoom / route:它只投递给发出键盘的那个 Endpoint,
75
+ * 永远由接收它的 Endpoint 处理。
76
+ */
77
+ hasRoom?(conversation: ConversationRef): boolean;
78
+ /**
79
+ * Room 内一条人类群消息应由哪个成员 Endpoint 处理。必须同步、无副作用。
80
+ *
81
+ * 返回 `undefined`(无可用成员)退化为先到先得。抛错同样退化为先到先得并告警(不丢消息)。
82
+ * Router 只能保证“实际收到副本的成员 Endpoint”里有人处理:core 无法预知哪些 Endpoint 会收到副本
83
+ * (例如 Telegram 隐私模式下未 @ 的消息只投递给部分 Bot),所以目标没收到副本时,
84
+ * `fallbackEndpointIds` 中的成员在宽限期后按优先级接管。决策按消息缓存,每条消息只决定一次。
85
+ */
86
+ route?(input: RoomInboundRouteInput): RoomRouteDecision | undefined;
87
+ /** Resolve a conversation to its Venue / Room definition summary. */
88
+ resolveRoom?(input: RoomClaimInput): ResolvedRoomInfo | undefined;
89
+ /** Check whether an endpoint in a Venue / Room is directly addressed by @mention or reply. */
90
+ isAddressedEndpoint?(input: RoomArbitrationInput): boolean;
91
+ /** Fail-closed readiness check for Venue member endpoints (ADR 0048 §3.4 invariant 7). */
92
+ isRoomReady?(input: RoomClaimInput): RoomReadinessResult;
93
+ }
94
+ /** core 用可信数据构造的路由输入;不信任正文。 */
95
+ export interface RoomInboundRouteInput {
96
+ /** 接收副本的会话(endpoint 为接收副本的 Endpoint)。 */
97
+ readonly conversation: ConversationRef;
98
+ readonly senderId: string;
99
+ readonly content: string;
100
+ /** 取自 segments 中 `type==='mention'` 的 `data.target`。 */
101
+ readonly mentionTargets: readonly string[];
102
+ /** 被回复的消息若是本进程某 Bot 发的(出站 ledger 命中),为该 Bot 的 Endpoint id。 */
103
+ readonly replyToEndpointId?: string;
104
+ /** 该 Endpoint 上该发送者是否有待回答的 interaction / claim / prompt。 */
105
+ pending(endpointId: string): boolean;
106
+ /** Endpoint 的 Bot 账号(registry.selfOf)。 */
107
+ accountOf(endpointId: string): string | undefined;
108
+ /** Endpoint 是否就绪(registry.isReady)。 */
109
+ isAvailable(endpointId: string): boolean;
110
+ }
111
+ export interface RoomRouteDecision {
112
+ readonly endpointId: string;
113
+ readonly reason: 'pending' | 'mention' | 'reply' | 'coordinator' | 'role';
114
+ /** 目标之后的其余可用成员 Endpoint,按接管优先级排序(不含目标)。 */
115
+ readonly fallbackEndpointIds: readonly string[];
116
+ }
117
+ export declare const roomMembershipToken: import("@zhin.js/plugin-runtime").Token<RoomMembershipPort>;
118
+ /** @internal */
119
+ export type OriginBasis = 'registry' | 'ledger' | 'none' | 'error';
120
+ /** @internal */
121
+ export interface InboundOriginInput {
122
+ readonly conversation: ConversationRef;
123
+ readonly sender?: {
124
+ readonly id?: unknown;
125
+ } | undefined;
126
+ readonly messageId?: unknown;
127
+ readonly content?: string;
128
+ }
129
+ /** @internal */
130
+ export interface InboundOriginResult {
131
+ readonly origin: MessageOrigin;
132
+ readonly basis: OriginBasis;
133
+ /**
134
+ * 接收 Endpoint 是否已向 Registry 上报账号。供 Room 激活使用
135
+ * (“Registry 未就绪的 Endpoint,它所在的 Room 不开始协作”,后续条目);
136
+ * 普通会话不据此判非 human,否则未上报 selfUserId 的适配器会全部失效。
137
+ */
138
+ readonly ready: boolean;
139
+ }
140
+ /** @internal */
141
+ export interface InboundOriginClassifier {
142
+ classify(input: InboundOriginInput, membership?: RoomMembershipPort): InboundOriginResult;
143
+ }
144
+ /** @internal */
145
+ export interface InboundOriginClassifierOptions {
146
+ readonly registry: Pick<PeerRegistry, 'lookup' | 'isReady' | 'selfOf'>;
147
+ readonly ledger: OutboundLedger;
148
+ }
149
+ /** @internal */
150
+ export declare function createInboundOriginClassifier(options: InboundOriginClassifierOptions): InboundOriginClassifier;