@silicaclaw/cli 2026.3.19-9 → 2026.3.20-10

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 (331) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/DEMO_GUIDE.md +1 -1
  3. package/INSTALL.md +53 -13
  4. package/README.md +106 -23
  5. package/VERSION +1 -1
  6. package/apps/local-console/dist/apps/local-console/src/server.d.ts +180 -14
  7. package/apps/local-console/dist/apps/local-console/src/server.js +1499 -267
  8. package/apps/local-console/dist/config/silicaclaw-defaults.json +19 -0
  9. package/apps/local-console/dist/packages/core/src/index.d.ts +2 -0
  10. package/apps/local-console/dist/packages/core/src/index.js +2 -0
  11. package/apps/local-console/dist/packages/core/src/privateCrypto.d.ts +17 -0
  12. package/apps/local-console/dist/packages/core/src/privateCrypto.js +40 -0
  13. package/apps/local-console/dist/packages/core/src/privateMessage.d.ts +23 -0
  14. package/apps/local-console/dist/packages/core/src/privateMessage.js +74 -0
  15. package/apps/local-console/dist/packages/core/src/profile.js +2 -0
  16. package/apps/local-console/dist/packages/core/src/publicProfileSummary.d.ts +4 -0
  17. package/apps/local-console/dist/packages/core/src/publicProfileSummary.js +3 -0
  18. package/apps/local-console/dist/packages/core/src/socialConfig.js +9 -5
  19. package/apps/local-console/dist/packages/core/src/types.d.ts +40 -0
  20. package/apps/local-console/dist/packages/network/src/realPreview.js +6 -2
  21. package/apps/local-console/dist/packages/network/src/relayPreview.d.ts +12 -0
  22. package/apps/local-console/dist/packages/network/src/relayPreview.js +116 -10
  23. package/apps/local-console/dist/packages/network/src/transport/udpLanBroadcastTransport.js +2 -1
  24. package/apps/local-console/dist/packages/network/src/types.d.ts +4 -0
  25. package/apps/local-console/dist/packages/network/src/webrtcPreview.js +5 -1
  26. package/apps/local-console/dist/packages/storage/config/silicaclaw-defaults.json +19 -0
  27. package/apps/local-console/dist/packages/storage/src/repos.d.ts +13 -1
  28. package/apps/local-console/dist/packages/storage/src/repos.js +19 -1
  29. package/apps/local-console/dist/packages/storage/src/socialRuntimeRepo.js +8 -4
  30. package/apps/local-console/public/app/app.js +486 -12
  31. package/apps/local-console/public/app/events.js +61 -2
  32. package/apps/local-console/public/app/network.js +176 -35
  33. package/apps/local-console/public/app/overview.js +75 -53
  34. package/apps/local-console/public/app/shell.js +18 -34
  35. package/apps/local-console/public/app/social.js +495 -93
  36. package/apps/local-console/public/app/styles.css +309 -15
  37. package/apps/local-console/public/app/template.js +182 -51
  38. package/apps/local-console/public/app/translations.js +476 -266
  39. package/apps/local-console/src/server.ts +1669 -271
  40. package/apps/public-explorer/dist/apps/public-explorer/src/server.d.ts +1 -0
  41. package/apps/public-explorer/dist/apps/public-explorer/src/server.js +41 -0
  42. package/apps/public-explorer/dist/config/silicaclaw-defaults.json +19 -0
  43. package/apps/public-explorer/public/app/app.js +22 -2
  44. package/apps/public-explorer/public/app/template.js +4 -4
  45. package/apps/public-explorer/public/app/translations.js +29 -29
  46. package/apps/public-explorer/src/server.ts +11 -1
  47. package/config/silicaclaw-defaults.json +19 -0
  48. package/dist/apps/local-console/src/server.d.ts +1 -0
  49. package/dist/apps/local-console/src/server.js +555 -0
  50. package/docs/NEW_USER_INSTALL.md +14 -10
  51. package/docs/NEW_USER_OPERATIONS.md +9 -9
  52. package/docs/OPENCLAW_BRIDGE.md +22 -7
  53. package/docs/OPENCLAW_BRIDGE_ZH.md +21 -6
  54. package/docs/RELEASE_CHECKLIST.md +95 -0
  55. package/node_modules/@silicaclaw/core/dist/config/silicaclaw-defaults.json +19 -0
  56. package/node_modules/@silicaclaw/core/dist/packages/core/src/crypto.d.ts +6 -0
  57. package/node_modules/@silicaclaw/core/dist/packages/core/src/crypto.js +50 -0
  58. package/node_modules/@silicaclaw/core/dist/packages/core/src/directory.d.ts +17 -0
  59. package/node_modules/@silicaclaw/core/dist/packages/core/src/directory.js +145 -0
  60. package/node_modules/@silicaclaw/core/dist/packages/core/src/identity.d.ts +2 -0
  61. package/node_modules/@silicaclaw/core/dist/packages/core/src/identity.js +18 -0
  62. package/node_modules/@silicaclaw/core/dist/packages/core/src/index.d.ts +14 -0
  63. package/node_modules/@silicaclaw/core/dist/packages/core/src/index.js +30 -0
  64. package/node_modules/@silicaclaw/core/dist/packages/core/src/indexing.d.ts +6 -0
  65. package/node_modules/@silicaclaw/core/dist/packages/core/src/indexing.js +43 -0
  66. package/node_modules/@silicaclaw/core/dist/packages/core/src/presence.d.ts +4 -0
  67. package/node_modules/@silicaclaw/core/dist/packages/core/src/presence.js +23 -0
  68. package/node_modules/@silicaclaw/core/dist/packages/core/src/privateCrypto.d.ts +17 -0
  69. package/node_modules/@silicaclaw/core/dist/packages/core/src/privateCrypto.js +40 -0
  70. package/node_modules/@silicaclaw/core/dist/packages/core/src/privateMessage.d.ts +23 -0
  71. package/node_modules/@silicaclaw/core/dist/packages/core/src/privateMessage.js +74 -0
  72. package/node_modules/@silicaclaw/core/dist/packages/core/src/profile.d.ts +4 -0
  73. package/node_modules/@silicaclaw/core/dist/packages/core/src/profile.js +41 -0
  74. package/node_modules/@silicaclaw/core/dist/packages/core/src/publicProfileSummary.d.ts +74 -0
  75. package/node_modules/@silicaclaw/core/dist/packages/core/src/publicProfileSummary.js +106 -0
  76. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialConfig.d.ts +100 -0
  77. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialConfig.js +300 -0
  78. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialMessage.d.ts +19 -0
  79. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialMessage.js +69 -0
  80. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialResolver.d.ts +46 -0
  81. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialResolver.js +237 -0
  82. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialTemplate.d.ts +2 -0
  83. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialTemplate.js +90 -0
  84. package/node_modules/@silicaclaw/core/dist/packages/core/src/types.d.ts +99 -0
  85. package/node_modules/@silicaclaw/core/dist/packages/core/src/types.js +2 -0
  86. package/node_modules/@silicaclaw/core/src/index.ts +2 -0
  87. package/node_modules/@silicaclaw/core/src/privateCrypto.ts +57 -0
  88. package/node_modules/@silicaclaw/core/src/privateMessage.ts +101 -0
  89. package/node_modules/@silicaclaw/core/src/profile.ts +2 -0
  90. package/node_modules/@silicaclaw/core/src/publicProfileSummary.ts +7 -0
  91. package/node_modules/@silicaclaw/core/src/socialConfig.ts +7 -5
  92. package/node_modules/@silicaclaw/core/src/types.ts +44 -0
  93. package/node_modules/@silicaclaw/network/dist/config/silicaclaw-defaults.json +19 -0
  94. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/messageEnvelope.d.ts +28 -0
  95. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/messageEnvelope.js +36 -0
  96. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/peerDiscovery.d.ts +43 -0
  97. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/peerDiscovery.js +2 -0
  98. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/topicCodec.d.ts +4 -0
  99. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/topicCodec.js +2 -0
  100. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/transport.d.ts +36 -0
  101. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/transport.js +2 -0
  102. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.d.ts +5 -0
  103. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.js +24 -0
  104. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonTopicCodec.d.ts +5 -0
  105. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonTopicCodec.js +12 -0
  106. package/node_modules/@silicaclaw/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.d.ts +28 -0
  107. package/node_modules/@silicaclaw/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.js +144 -0
  108. package/node_modules/@silicaclaw/network/dist/packages/network/src/index.d.ts +14 -0
  109. package/node_modules/@silicaclaw/network/dist/packages/network/src/index.js +30 -0
  110. package/node_modules/@silicaclaw/network/dist/packages/network/src/localEventBus.d.ts +9 -0
  111. package/node_modules/@silicaclaw/network/dist/packages/network/src/localEventBus.js +47 -0
  112. package/node_modules/@silicaclaw/network/dist/packages/network/src/mock.d.ts +8 -0
  113. package/node_modules/@silicaclaw/network/dist/packages/network/src/mock.js +24 -0
  114. package/node_modules/@silicaclaw/network/dist/packages/network/src/realPreview.d.ts +105 -0
  115. package/node_modules/@silicaclaw/network/dist/packages/network/src/realPreview.js +331 -0
  116. package/node_modules/@silicaclaw/network/dist/packages/network/src/relayPreview.d.ts +178 -0
  117. package/node_modules/@silicaclaw/network/dist/packages/network/src/relayPreview.js +548 -0
  118. package/node_modules/@silicaclaw/network/dist/packages/network/src/transport/udpLanBroadcastTransport.d.ts +23 -0
  119. package/node_modules/@silicaclaw/network/dist/packages/network/src/transport/udpLanBroadcastTransport.js +154 -0
  120. package/node_modules/@silicaclaw/network/dist/packages/network/src/types.d.ts +10 -0
  121. package/node_modules/@silicaclaw/network/dist/packages/network/src/types.js +2 -0
  122. package/node_modules/@silicaclaw/network/dist/packages/network/src/webrtcPreview.d.ts +163 -0
  123. package/node_modules/@silicaclaw/network/dist/packages/network/src/webrtcPreview.js +848 -0
  124. package/node_modules/@silicaclaw/network/src/realPreview.ts +3 -2
  125. package/node_modules/@silicaclaw/network/src/relayPreview.ts +125 -12
  126. package/node_modules/@silicaclaw/network/src/transport/udpLanBroadcastTransport.ts +2 -1
  127. package/node_modules/@silicaclaw/network/src/types.ts +2 -0
  128. package/node_modules/@silicaclaw/network/src/webrtcPreview.ts +2 -1
  129. package/node_modules/@silicaclaw/storage/config/silicaclaw-defaults.json +19 -0
  130. package/node_modules/@silicaclaw/storage/dist/config/silicaclaw-defaults.json +19 -0
  131. package/node_modules/@silicaclaw/storage/dist/packages/core/src/crypto.d.ts +6 -0
  132. package/node_modules/@silicaclaw/storage/dist/packages/core/src/crypto.js +50 -0
  133. package/node_modules/@silicaclaw/storage/dist/packages/core/src/directory.d.ts +17 -0
  134. package/node_modules/@silicaclaw/storage/dist/packages/core/src/directory.js +145 -0
  135. package/node_modules/@silicaclaw/storage/dist/packages/core/src/identity.d.ts +2 -0
  136. package/node_modules/@silicaclaw/storage/dist/packages/core/src/identity.js +18 -0
  137. package/node_modules/@silicaclaw/storage/dist/packages/core/src/index.d.ts +14 -0
  138. package/node_modules/@silicaclaw/storage/dist/packages/core/src/index.js +30 -0
  139. package/node_modules/@silicaclaw/storage/dist/packages/core/src/indexing.d.ts +6 -0
  140. package/node_modules/@silicaclaw/storage/dist/packages/core/src/indexing.js +43 -0
  141. package/node_modules/@silicaclaw/storage/dist/packages/core/src/presence.d.ts +4 -0
  142. package/node_modules/@silicaclaw/storage/dist/packages/core/src/presence.js +23 -0
  143. package/node_modules/@silicaclaw/storage/dist/packages/core/src/privateCrypto.d.ts +17 -0
  144. package/node_modules/@silicaclaw/storage/dist/packages/core/src/privateCrypto.js +40 -0
  145. package/node_modules/@silicaclaw/storage/dist/packages/core/src/privateMessage.d.ts +23 -0
  146. package/node_modules/@silicaclaw/storage/dist/packages/core/src/privateMessage.js +74 -0
  147. package/node_modules/@silicaclaw/storage/dist/packages/core/src/profile.d.ts +4 -0
  148. package/node_modules/@silicaclaw/storage/dist/packages/core/src/profile.js +41 -0
  149. package/node_modules/@silicaclaw/storage/dist/packages/core/src/publicProfileSummary.d.ts +74 -0
  150. package/node_modules/@silicaclaw/storage/dist/packages/core/src/publicProfileSummary.js +106 -0
  151. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialConfig.d.ts +100 -0
  152. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialConfig.js +300 -0
  153. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialMessage.d.ts +19 -0
  154. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialMessage.js +69 -0
  155. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialResolver.d.ts +46 -0
  156. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialResolver.js +237 -0
  157. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialTemplate.d.ts +2 -0
  158. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialTemplate.js +90 -0
  159. package/node_modules/@silicaclaw/storage/dist/packages/core/src/types.d.ts +99 -0
  160. package/node_modules/@silicaclaw/storage/dist/packages/core/src/types.js +2 -0
  161. package/node_modules/@silicaclaw/storage/dist/packages/storage/config/silicaclaw-defaults.json +19 -0
  162. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/index.d.ts +3 -0
  163. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/index.js +19 -0
  164. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/jsonRepo.d.ts +7 -0
  165. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/jsonRepo.js +29 -0
  166. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/repos.d.ts +73 -0
  167. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/repos.js +85 -0
  168. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/socialRuntimeRepo.d.ts +5 -0
  169. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/socialRuntimeRepo.js +57 -0
  170. package/node_modules/@silicaclaw/storage/dist/socialRuntimeRepo.js +8 -4
  171. package/node_modules/@silicaclaw/storage/src/repos.ts +31 -1
  172. package/node_modules/@silicaclaw/storage/src/socialRuntimeRepo.ts +5 -4
  173. package/node_modules/@silicaclaw/storage/tsconfig.json +1 -6
  174. package/openclaw-skills/silicaclaw-bridge-setup/SKILL.md +165 -0
  175. package/openclaw-skills/silicaclaw-bridge-setup/VERSION +1 -0
  176. package/openclaw-skills/silicaclaw-bridge-setup/agents/openai.yaml +6 -0
  177. package/openclaw-skills/silicaclaw-bridge-setup/manifest.json +27 -0
  178. package/openclaw-skills/silicaclaw-bridge-setup/references/owner-dialogue-cheatsheet-zh.md +58 -0
  179. package/openclaw-skills/silicaclaw-bridge-setup/references/runtime-setup.md +43 -0
  180. package/openclaw-skills/silicaclaw-bridge-setup/references/troubleshooting.md +24 -0
  181. package/openclaw-skills/silicaclaw-broadcast/SKILL.md +150 -0
  182. package/openclaw-skills/silicaclaw-broadcast/VERSION +1 -1
  183. package/openclaw-skills/silicaclaw-broadcast/agents/openai.yaml +2 -2
  184. package/openclaw-skills/silicaclaw-broadcast/manifest.json +4 -3
  185. package/openclaw-skills/silicaclaw-broadcast/references/owner-dialogue-cheatsheet-zh.md +81 -0
  186. package/openclaw-skills/silicaclaw-network-config/SKILL.md +158 -0
  187. package/openclaw-skills/silicaclaw-network-config/VERSION +1 -0
  188. package/openclaw-skills/silicaclaw-network-config/agents/openai.yaml +6 -0
  189. package/openclaw-skills/silicaclaw-network-config/manifest.json +27 -0
  190. package/openclaw-skills/silicaclaw-network-config/references/network-modes.md +22 -0
  191. package/openclaw-skills/silicaclaw-network-config/references/owner-dialogue-cheatsheet-zh.md +47 -0
  192. package/openclaw-skills/silicaclaw-network-config/references/public-discovery.md +22 -0
  193. package/openclaw-skills/silicaclaw-owner-push/SKILL.md +235 -0
  194. package/openclaw-skills/silicaclaw-owner-push/VERSION +1 -0
  195. package/openclaw-skills/silicaclaw-owner-push/agents/openai.yaml +6 -0
  196. package/openclaw-skills/silicaclaw-owner-push/manifest.json +30 -0
  197. package/openclaw-skills/silicaclaw-owner-push/references/owner-dialogue-cheatsheet-zh.md +87 -0
  198. package/openclaw-skills/silicaclaw-owner-push/references/push-routing-policy.md +43 -0
  199. package/openclaw-skills/silicaclaw-owner-push/references/runtime-setup.md +44 -0
  200. package/openclaw-skills/silicaclaw-owner-push/scripts/owner-push-forwarder.mjs +356 -0
  201. package/openclaw-skills/silicaclaw-owner-push/scripts/send-to-owner-via-openclaw.mjs +69 -0
  202. package/package.json +5 -1
  203. package/packages/core/dist/config/silicaclaw-defaults.json +19 -0
  204. package/packages/core/dist/packages/core/src/crypto.d.ts +6 -0
  205. package/packages/core/dist/packages/core/src/crypto.js +50 -0
  206. package/packages/core/dist/packages/core/src/directory.d.ts +17 -0
  207. package/packages/core/dist/packages/core/src/directory.js +145 -0
  208. package/packages/core/dist/packages/core/src/identity.d.ts +2 -0
  209. package/packages/core/dist/packages/core/src/identity.js +18 -0
  210. package/packages/core/dist/packages/core/src/index.d.ts +14 -0
  211. package/packages/core/dist/packages/core/src/index.js +30 -0
  212. package/packages/core/dist/packages/core/src/indexing.d.ts +6 -0
  213. package/packages/core/dist/packages/core/src/indexing.js +43 -0
  214. package/packages/core/dist/packages/core/src/presence.d.ts +4 -0
  215. package/packages/core/dist/packages/core/src/presence.js +23 -0
  216. package/packages/core/dist/packages/core/src/privateCrypto.d.ts +17 -0
  217. package/packages/core/dist/packages/core/src/privateCrypto.js +40 -0
  218. package/packages/core/dist/packages/core/src/privateMessage.d.ts +23 -0
  219. package/packages/core/dist/packages/core/src/privateMessage.js +74 -0
  220. package/packages/core/dist/packages/core/src/profile.d.ts +4 -0
  221. package/packages/core/dist/packages/core/src/profile.js +41 -0
  222. package/packages/core/dist/packages/core/src/publicProfileSummary.d.ts +74 -0
  223. package/packages/core/dist/packages/core/src/publicProfileSummary.js +106 -0
  224. package/packages/core/dist/packages/core/src/socialConfig.d.ts +100 -0
  225. package/packages/core/dist/packages/core/src/socialConfig.js +300 -0
  226. package/packages/core/dist/packages/core/src/socialMessage.d.ts +19 -0
  227. package/packages/core/dist/packages/core/src/socialMessage.js +69 -0
  228. package/packages/core/dist/packages/core/src/socialResolver.d.ts +46 -0
  229. package/packages/core/dist/packages/core/src/socialResolver.js +237 -0
  230. package/packages/core/dist/packages/core/src/socialTemplate.d.ts +2 -0
  231. package/packages/core/dist/packages/core/src/socialTemplate.js +90 -0
  232. package/packages/core/dist/packages/core/src/types.d.ts +99 -0
  233. package/packages/core/dist/packages/core/src/types.js +2 -0
  234. package/packages/core/src/index.ts +2 -0
  235. package/packages/core/src/privateCrypto.ts +57 -0
  236. package/packages/core/src/privateMessage.ts +101 -0
  237. package/packages/core/src/profile.ts +2 -0
  238. package/packages/core/src/publicProfileSummary.ts +7 -0
  239. package/packages/core/src/socialConfig.ts +7 -5
  240. package/packages/core/src/types.ts +44 -0
  241. package/packages/network/dist/config/silicaclaw-defaults.json +19 -0
  242. package/packages/network/dist/packages/network/src/abstractions/messageEnvelope.d.ts +28 -0
  243. package/packages/network/dist/packages/network/src/abstractions/messageEnvelope.js +36 -0
  244. package/packages/network/dist/packages/network/src/abstractions/peerDiscovery.d.ts +43 -0
  245. package/packages/network/dist/packages/network/src/abstractions/peerDiscovery.js +2 -0
  246. package/packages/network/dist/packages/network/src/abstractions/topicCodec.d.ts +4 -0
  247. package/packages/network/dist/packages/network/src/abstractions/topicCodec.js +2 -0
  248. package/packages/network/dist/packages/network/src/abstractions/transport.d.ts +36 -0
  249. package/packages/network/dist/packages/network/src/abstractions/transport.js +2 -0
  250. package/packages/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.d.ts +5 -0
  251. package/packages/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.js +24 -0
  252. package/packages/network/dist/packages/network/src/codec/jsonTopicCodec.d.ts +5 -0
  253. package/packages/network/dist/packages/network/src/codec/jsonTopicCodec.js +12 -0
  254. package/packages/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.d.ts +28 -0
  255. package/packages/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.js +144 -0
  256. package/packages/network/dist/packages/network/src/index.d.ts +14 -0
  257. package/packages/network/dist/packages/network/src/index.js +30 -0
  258. package/packages/network/dist/packages/network/src/localEventBus.d.ts +9 -0
  259. package/packages/network/dist/packages/network/src/localEventBus.js +47 -0
  260. package/packages/network/dist/packages/network/src/mock.d.ts +8 -0
  261. package/packages/network/dist/packages/network/src/mock.js +24 -0
  262. package/packages/network/dist/packages/network/src/realPreview.d.ts +105 -0
  263. package/packages/network/dist/packages/network/src/realPreview.js +331 -0
  264. package/packages/network/dist/packages/network/src/relayPreview.d.ts +178 -0
  265. package/packages/network/dist/packages/network/src/relayPreview.js +548 -0
  266. package/packages/network/dist/packages/network/src/transport/udpLanBroadcastTransport.d.ts +23 -0
  267. package/packages/network/dist/packages/network/src/transport/udpLanBroadcastTransport.js +154 -0
  268. package/packages/network/dist/packages/network/src/types.d.ts +10 -0
  269. package/packages/network/dist/packages/network/src/types.js +2 -0
  270. package/packages/network/dist/packages/network/src/webrtcPreview.d.ts +163 -0
  271. package/packages/network/dist/packages/network/src/webrtcPreview.js +848 -0
  272. package/packages/network/src/realPreview.ts +3 -2
  273. package/packages/network/src/relayPreview.ts +125 -12
  274. package/packages/network/src/transport/udpLanBroadcastTransport.ts +2 -1
  275. package/packages/network/src/types.ts +2 -0
  276. package/packages/network/src/webrtcPreview.ts +2 -1
  277. package/packages/storage/config/silicaclaw-defaults.json +19 -0
  278. package/packages/storage/dist/config/silicaclaw-defaults.json +19 -0
  279. package/packages/storage/dist/packages/core/src/crypto.d.ts +6 -0
  280. package/packages/storage/dist/packages/core/src/crypto.js +50 -0
  281. package/packages/storage/dist/packages/core/src/directory.d.ts +17 -0
  282. package/packages/storage/dist/packages/core/src/directory.js +145 -0
  283. package/packages/storage/dist/packages/core/src/identity.d.ts +2 -0
  284. package/packages/storage/dist/packages/core/src/identity.js +18 -0
  285. package/packages/storage/dist/packages/core/src/index.d.ts +14 -0
  286. package/packages/storage/dist/packages/core/src/index.js +30 -0
  287. package/packages/storage/dist/packages/core/src/indexing.d.ts +6 -0
  288. package/packages/storage/dist/packages/core/src/indexing.js +43 -0
  289. package/packages/storage/dist/packages/core/src/presence.d.ts +4 -0
  290. package/packages/storage/dist/packages/core/src/presence.js +23 -0
  291. package/packages/storage/dist/packages/core/src/privateCrypto.d.ts +17 -0
  292. package/packages/storage/dist/packages/core/src/privateCrypto.js +40 -0
  293. package/packages/storage/dist/packages/core/src/privateMessage.d.ts +23 -0
  294. package/packages/storage/dist/packages/core/src/privateMessage.js +74 -0
  295. package/packages/storage/dist/packages/core/src/profile.d.ts +4 -0
  296. package/packages/storage/dist/packages/core/src/profile.js +41 -0
  297. package/packages/storage/dist/packages/core/src/publicProfileSummary.d.ts +74 -0
  298. package/packages/storage/dist/packages/core/src/publicProfileSummary.js +106 -0
  299. package/packages/storage/dist/packages/core/src/socialConfig.d.ts +100 -0
  300. package/packages/storage/dist/packages/core/src/socialConfig.js +300 -0
  301. package/packages/storage/dist/packages/core/src/socialMessage.d.ts +19 -0
  302. package/packages/storage/dist/packages/core/src/socialMessage.js +69 -0
  303. package/packages/storage/dist/packages/core/src/socialResolver.d.ts +46 -0
  304. package/packages/storage/dist/packages/core/src/socialResolver.js +237 -0
  305. package/packages/storage/dist/packages/core/src/socialTemplate.d.ts +2 -0
  306. package/packages/storage/dist/packages/core/src/socialTemplate.js +90 -0
  307. package/packages/storage/dist/packages/core/src/types.d.ts +99 -0
  308. package/packages/storage/dist/packages/core/src/types.js +2 -0
  309. package/packages/storage/dist/packages/storage/config/silicaclaw-defaults.json +19 -0
  310. package/packages/storage/dist/packages/storage/src/index.d.ts +3 -0
  311. package/packages/storage/dist/packages/storage/src/index.js +19 -0
  312. package/packages/storage/dist/packages/storage/src/jsonRepo.d.ts +7 -0
  313. package/packages/storage/dist/packages/storage/src/jsonRepo.js +29 -0
  314. package/packages/storage/dist/packages/storage/src/repos.d.ts +73 -0
  315. package/packages/storage/dist/packages/storage/src/repos.js +85 -0
  316. package/packages/storage/dist/packages/storage/src/socialRuntimeRepo.d.ts +5 -0
  317. package/packages/storage/dist/packages/storage/src/socialRuntimeRepo.js +57 -0
  318. package/packages/storage/dist/socialRuntimeRepo.js +8 -4
  319. package/packages/storage/src/repos.ts +31 -1
  320. package/packages/storage/src/socialRuntimeRepo.ts +5 -4
  321. package/packages/storage/tsconfig.json +1 -6
  322. package/scripts/functional-check.mjs +35 -6
  323. package/scripts/install-openclaw-skill.mjs +9 -2
  324. package/scripts/openclaw-bridge-adapter.mjs +3 -1
  325. package/scripts/openclaw-bridge-client.mjs +3 -1
  326. package/scripts/openclaw-runtime-demo.mjs +3 -1
  327. package/scripts/quickstart.sh +14 -10
  328. package/scripts/release-pack.mjs +59 -1
  329. package/scripts/silicaclaw-cli.mjs +166 -51
  330. package/scripts/silicaclaw-gateway.mjs +410 -84
  331. package/scripts/validate-openclaw-skill.mjs +98 -21
@@ -0,0 +1,548 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RelayPreviewAdapter = void 0;
7
+ const crypto_1 = require("crypto");
8
+ const messageEnvelope_1 = require("./abstractions/messageEnvelope");
9
+ const jsonMessageEnvelopeCodec_1 = require("./codec/jsonMessageEnvelopeCodec");
10
+ const jsonTopicCodec_1 = require("./codec/jsonTopicCodec");
11
+ const silicaclaw_defaults_json_1 = __importDefault(require("../../../config/silicaclaw-defaults.json"));
12
+ function dedupe(values) {
13
+ return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
14
+ }
15
+ class RelayPreviewAdapter {
16
+ peerId;
17
+ namespace;
18
+ signalingEndpoints;
19
+ room;
20
+ seedPeers;
21
+ bootstrapHints;
22
+ bootstrapSources;
23
+ maxMessageBytes;
24
+ pollIntervalMs;
25
+ maxFutureDriftMs;
26
+ maxPastDriftMs;
27
+ requestTimeoutMs;
28
+ peerRefreshIntervalMs;
29
+ envelopeCodec;
30
+ topicCodec;
31
+ started = false;
32
+ poller = null;
33
+ handlers = new Map();
34
+ directHandlers = new Map();
35
+ peers = new Map();
36
+ seenMessageIds = new Set();
37
+ activeEndpoint = "";
38
+ discoveryEvents = [];
39
+ discoveryEventsTotal = 0;
40
+ lastDiscoveryEventAt = 0;
41
+ signalingMessagesSentTotal = 0;
42
+ signalingMessagesReceivedTotal = 0;
43
+ reconnectAttemptsTotal = 0;
44
+ activeEndpointIndex = 0;
45
+ lastJoinAt = 0;
46
+ lastPollAt = 0;
47
+ lastPublishAt = 0;
48
+ lastPeerRefreshAt = 0;
49
+ lastErrorAt = 0;
50
+ lastError = null;
51
+ pollInFlight = false;
52
+ currentPollDelayMs = 0;
53
+ stats = {
54
+ publish_attempted: 0,
55
+ publish_sent: 0,
56
+ received_total: 0,
57
+ delivered_total: 0,
58
+ dropped_malformed: 0,
59
+ dropped_oversized: 0,
60
+ dropped_namespace_mismatch: 0,
61
+ dropped_timestamp_future_drift: 0,
62
+ dropped_timestamp_past_drift: 0,
63
+ dropped_decode_failed: 0,
64
+ dropped_self: 0,
65
+ dropped_topic_decode_error: 0,
66
+ dropped_handler_error: 0,
67
+ signaling_errors: 0,
68
+ invalid_signaling_payload_total: 0,
69
+ duplicate_sdp_total: 0,
70
+ duplicate_ice_total: 0,
71
+ start_errors: 0,
72
+ stop_errors: 0,
73
+ received_validated: 0,
74
+ join_attempted: 0,
75
+ join_succeeded: 0,
76
+ poll_attempted: 0,
77
+ poll_succeeded: 0,
78
+ peers_refresh_attempted: 0,
79
+ peers_refresh_succeeded: 0,
80
+ publish_succeeded: 0,
81
+ poll_skipped_inflight: 0,
82
+ };
83
+ constructor(options = {}) {
84
+ this.peerId = options.peerId ?? `peer-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
85
+ this.namespace =
86
+ String(options.namespace || silicaclaw_defaults_json_1.default.network.default_namespace).trim() || silicaclaw_defaults_json_1.default.network.default_namespace;
87
+ this.signalingEndpoints = dedupe((options.signalingUrls && options.signalingUrls.length > 0
88
+ ? options.signalingUrls
89
+ : [options.signalingUrl || "http://localhost:4510"]));
90
+ this.activeEndpoint = this.signalingEndpoints[0] || "http://localhost:4510";
91
+ this.activeEndpointIndex = 0;
92
+ this.room =
93
+ String(options.room || silicaclaw_defaults_json_1.default.network.global_preview.room).trim() || silicaclaw_defaults_json_1.default.network.global_preview.room;
94
+ this.seedPeers = dedupe(options.seedPeers || []);
95
+ this.bootstrapHints = dedupe(options.bootstrapHints || []);
96
+ this.bootstrapSources = dedupe(options.bootstrapSources || []);
97
+ this.maxMessageBytes = options.maxMessageBytes ?? 64 * 1024;
98
+ this.pollIntervalMs = options.pollIntervalMs ?? 5000;
99
+ this.maxFutureDriftMs = options.maxFutureDriftMs ?? 30_000;
100
+ this.maxPastDriftMs = options.maxPastDriftMs ?? 120_000;
101
+ this.requestTimeoutMs = options.requestTimeoutMs ?? 4000;
102
+ this.peerRefreshIntervalMs = options.peerRefreshIntervalMs ?? 30_000;
103
+ this.envelopeCodec = new jsonMessageEnvelopeCodec_1.JsonMessageEnvelopeCodec();
104
+ this.topicCodec = new jsonTopicCodec_1.JsonTopicCodec();
105
+ this.currentPollDelayMs = this.pollIntervalMs;
106
+ }
107
+ async start() {
108
+ if (this.started)
109
+ return;
110
+ try {
111
+ await this.joinRoom("start");
112
+ this.started = true;
113
+ await this.pollOnce();
114
+ this.scheduleNextPoll(this.pollIntervalMs);
115
+ this.recordDiscovery("signaling_connected", { endpoint: this.activeEndpoint });
116
+ }
117
+ catch (error) {
118
+ this.stats.start_errors += 1;
119
+ throw new Error(`Relay start failed: ${error instanceof Error ? error.message : String(error)}`);
120
+ }
121
+ }
122
+ async stop() {
123
+ if (!this.started)
124
+ return;
125
+ if (this.poller) {
126
+ clearTimeout(this.poller);
127
+ this.poller = null;
128
+ }
129
+ try {
130
+ await this.post("/leave", { room: this.room, peer_id: this.peerId });
131
+ }
132
+ catch {
133
+ this.stats.stop_errors += 1;
134
+ }
135
+ this.started = false;
136
+ this.recordDiscovery("signaling_disconnected", { endpoint: this.activeEndpoint });
137
+ }
138
+ async publish(topic, data) {
139
+ if (!this.started)
140
+ return;
141
+ this.stats.publish_attempted += 1;
142
+ await this.maybeRefreshJoin("publish");
143
+ const envelope = {
144
+ version: 1,
145
+ message_id: (0, crypto_1.randomUUID)(),
146
+ topic: `${this.namespace}:${topic}`,
147
+ source_peer_id: this.peerId,
148
+ timestamp: Date.now(),
149
+ payload: this.topicCodec.encode(topic, data),
150
+ };
151
+ const raw = this.envelopeCodec.encode(envelope);
152
+ if (raw.length > this.maxMessageBytes) {
153
+ this.stats.dropped_oversized += 1;
154
+ return;
155
+ }
156
+ await this.post("/relay/publish", { room: this.room, peer_id: this.peerId, envelope });
157
+ this.lastPublishAt = Date.now();
158
+ this.stats.publish_sent += 1;
159
+ this.stats.publish_succeeded += 1;
160
+ this.signalingMessagesSentTotal += 1;
161
+ }
162
+ subscribe(topic, handler) {
163
+ const key = `${this.namespace}:${topic}`;
164
+ if (!this.handlers.has(key)) {
165
+ this.handlers.set(key, new Set());
166
+ }
167
+ this.handlers.get(key)?.add(handler);
168
+ }
169
+ async sendDirect(peerId, topic, data) {
170
+ if (!this.started)
171
+ return;
172
+ const targetPeerId = String(peerId || "").trim();
173
+ if (!targetPeerId)
174
+ return;
175
+ await this.maybeRefreshJoin("direct_send");
176
+ const envelope = {
177
+ version: 1,
178
+ message_id: (0, crypto_1.randomUUID)(),
179
+ topic: `${this.namespace}:${topic}`,
180
+ source_peer_id: this.peerId,
181
+ timestamp: Date.now(),
182
+ payload: this.topicCodec.encode(topic, data),
183
+ };
184
+ const raw = this.envelopeCodec.encode(envelope);
185
+ if (raw.length > this.maxMessageBytes) {
186
+ this.stats.dropped_oversized += 1;
187
+ return;
188
+ }
189
+ await this.post("/direct/send", {
190
+ room: this.room,
191
+ from_peer_id: this.peerId,
192
+ to_peer_id: targetPeerId,
193
+ envelope,
194
+ });
195
+ this.lastPublishAt = Date.now();
196
+ this.signalingMessagesSentTotal += 1;
197
+ }
198
+ subscribeDirect(topic, handler) {
199
+ const key = `${this.namespace}:${topic}`;
200
+ if (!this.directHandlers.has(key)) {
201
+ this.directHandlers.set(key, new Set());
202
+ }
203
+ this.directHandlers.get(key)?.add(handler);
204
+ }
205
+ getDiagnostics() {
206
+ const peerItems = Array.from(this.peers.values()).sort((a, b) => b.last_seen_at - a.last_seen_at);
207
+ return {
208
+ adapter: "relay-preview",
209
+ peer_id: this.peerId,
210
+ namespace: this.namespace,
211
+ room: this.room,
212
+ signaling_url: this.activeEndpoint,
213
+ signaling_endpoints: this.signalingEndpoints,
214
+ active_endpoint_index: this.activeEndpointIndex,
215
+ bootstrap_sources: this.bootstrapSources,
216
+ seed_peers_count: this.seedPeers.length,
217
+ bootstrap_hints_count: this.bootstrapHints.length,
218
+ discovery_events_total: this.discoveryEventsTotal,
219
+ last_discovery_event_at: this.lastDiscoveryEventAt,
220
+ last_join_at: this.lastJoinAt,
221
+ last_poll_at: this.lastPollAt,
222
+ last_publish_at: this.lastPublishAt,
223
+ last_peer_refresh_at: this.lastPeerRefreshAt,
224
+ last_error_at: this.lastErrorAt,
225
+ last_error: this.lastError,
226
+ discovery_events: this.discoveryEvents,
227
+ signaling_messages_sent_total: this.signalingMessagesSentTotal,
228
+ signaling_messages_received_total: this.signalingMessagesReceivedTotal,
229
+ reconnect_attempts_total: this.reconnectAttemptsTotal,
230
+ active_webrtc_peers: peerItems.length,
231
+ components: {
232
+ transport: "HttpRelayTransport",
233
+ discovery: "RelayRoomPeerList",
234
+ envelope_codec: this.envelopeCodec.constructor.name,
235
+ topic_codec: this.topicCodec.constructor.name,
236
+ },
237
+ limits: {
238
+ max_message_bytes: this.maxMessageBytes,
239
+ max_future_drift_ms: this.maxFutureDriftMs,
240
+ max_past_drift_ms: this.maxPastDriftMs,
241
+ },
242
+ config: {
243
+ started: this.started,
244
+ topic_handler_count: this.handlers.size,
245
+ poll_interval_ms: this.pollIntervalMs,
246
+ },
247
+ peers: {
248
+ total: peerItems.length,
249
+ online: peerItems.length,
250
+ stale: 0,
251
+ items: peerItems,
252
+ },
253
+ stats: { ...this.stats },
254
+ };
255
+ }
256
+ async pollOnce() {
257
+ if (this.pollInFlight) {
258
+ this.stats.poll_skipped_inflight += 1;
259
+ return;
260
+ }
261
+ this.pollInFlight = true;
262
+ await this.maybeRefreshJoin("poll");
263
+ this.stats.poll_attempted += 1;
264
+ try {
265
+ const payload = await this.get(`/relay/poll?room=${encodeURIComponent(this.room)}&peer_id=${encodeURIComponent(this.peerId)}`);
266
+ this.lastPollAt = Date.now();
267
+ this.stats.poll_succeeded += 1;
268
+ this.currentPollDelayMs = this.pollIntervalMs;
269
+ const messages = Array.isArray(payload?.messages) ? payload.messages : [];
270
+ for (const message of messages) {
271
+ this.signalingMessagesReceivedTotal += 1;
272
+ this.onEnvelope(message?.envelope);
273
+ }
274
+ let directMessages = Array.isArray(payload?.direct_messages) ? payload.direct_messages : null;
275
+ if (!directMessages) {
276
+ const directPayload = await this.get(`/direct/poll?room=${encodeURIComponent(this.room)}&peer_id=${encodeURIComponent(this.peerId)}`);
277
+ directMessages = Array.isArray(directPayload?.messages) ? directPayload.messages : [];
278
+ }
279
+ for (const message of directMessages) {
280
+ this.signalingMessagesReceivedTotal += 1;
281
+ this.onDirectEnvelope(message?.envelope, { peerId: String(message?.from_peer_id || "") || undefined });
282
+ }
283
+ if (Array.isArray(payload?.peers)) {
284
+ this.updatePeersFromList(payload.peers);
285
+ }
286
+ else if (!this.lastPeerRefreshAt || Date.now() - this.lastPeerRefreshAt >= this.peerRefreshIntervalMs) {
287
+ await this.refreshPeers();
288
+ }
289
+ }
290
+ catch (error) {
291
+ this.currentPollDelayMs = Math.min(15_000, Math.max(this.pollIntervalMs, this.currentPollDelayMs * 2));
292
+ throw error;
293
+ }
294
+ finally {
295
+ this.pollInFlight = false;
296
+ if (this.started) {
297
+ this.scheduleNextPoll(this.currentPollDelayMs);
298
+ }
299
+ }
300
+ }
301
+ async refreshPeers() {
302
+ this.stats.peers_refresh_attempted += 1;
303
+ const payload = await this.get(`/peers?room=${encodeURIComponent(this.room)}`);
304
+ this.lastPeerRefreshAt = Date.now();
305
+ this.stats.peers_refresh_succeeded += 1;
306
+ const peerItems = Array.isArray(payload?.peer_details) && payload.peer_details.length
307
+ ? payload.peer_details
308
+ : Array.isArray(payload?.peers) ? payload.peers : [];
309
+ this.updatePeersFromList(peerItems);
310
+ }
311
+ onEnvelope(envelope) {
312
+ this.dispatchEnvelope(envelope, this.handlers);
313
+ }
314
+ onDirectEnvelope(envelope, meta) {
315
+ this.dispatchEnvelope(envelope, this.directHandlers, meta);
316
+ }
317
+ dispatchEnvelope(envelope, handlersByTopic, meta) {
318
+ this.stats.received_total += 1;
319
+ const validated = (0, messageEnvelope_1.validateNetworkMessageEnvelope)(envelope, {
320
+ max_future_drift_ms: this.maxFutureDriftMs,
321
+ max_past_drift_ms: this.maxPastDriftMs,
322
+ });
323
+ if (!validated.ok || !validated.envelope) {
324
+ if (validated.reason === "timestamp_future_drift") {
325
+ this.stats.dropped_timestamp_future_drift += 1;
326
+ }
327
+ else if (validated.reason === "timestamp_past_drift") {
328
+ this.stats.dropped_timestamp_past_drift += 1;
329
+ }
330
+ else {
331
+ this.stats.dropped_malformed += 1;
332
+ }
333
+ return;
334
+ }
335
+ const message = validated.envelope;
336
+ if (message.source_peer_id === this.peerId) {
337
+ this.stats.dropped_self += 1;
338
+ return;
339
+ }
340
+ if (!message.topic.startsWith(`${this.namespace}:`)) {
341
+ this.stats.dropped_namespace_mismatch += 1;
342
+ return;
343
+ }
344
+ if (this.seenMessageIds.has(message.message_id)) {
345
+ return;
346
+ }
347
+ this.seenMessageIds.add(message.message_id);
348
+ if (this.seenMessageIds.size > 10000) {
349
+ const first = this.seenMessageIds.values().next().value;
350
+ if (first)
351
+ this.seenMessageIds.delete(first);
352
+ }
353
+ this.stats.received_validated += 1;
354
+ const topicKey = message.topic;
355
+ const topic = topicKey.slice(this.namespace.length + 1);
356
+ const handlers = handlersByTopic.get(topicKey);
357
+ if (!handlers || handlers.size === 0)
358
+ return;
359
+ const peer = this.peers.get(message.source_peer_id);
360
+ if (peer) {
361
+ peer.last_seen_at = Date.now();
362
+ peer.messages_seen += 1;
363
+ }
364
+ let payload;
365
+ try {
366
+ payload = this.topicCodec.decode(topic, message.payload);
367
+ }
368
+ catch {
369
+ this.stats.dropped_topic_decode_error += 1;
370
+ return;
371
+ }
372
+ for (const handler of handlers) {
373
+ try {
374
+ handler(payload, meta || { peerId: message.source_peer_id });
375
+ this.stats.delivered_total += 1;
376
+ }
377
+ catch {
378
+ this.stats.dropped_handler_error += 1;
379
+ }
380
+ }
381
+ }
382
+ recordDiscovery(type, extra = {}) {
383
+ const event = {
384
+ id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
385
+ type,
386
+ at: Date.now(),
387
+ ...extra,
388
+ };
389
+ this.discoveryEvents.unshift(event);
390
+ this.discoveryEvents = this.discoveryEvents.slice(0, 200);
391
+ this.discoveryEventsTotal += 1;
392
+ this.lastDiscoveryEventAt = event.at;
393
+ }
394
+ async joinRoom(reason) {
395
+ this.stats.join_attempted += 1;
396
+ const payload = await this.post("/join", { room: this.room, peer_id: this.peerId });
397
+ this.lastJoinAt = Date.now();
398
+ this.stats.join_succeeded += 1;
399
+ if (Array.isArray(payload?.peers)) {
400
+ this.updatePeersFromList(payload.peers);
401
+ this.lastPeerRefreshAt = this.lastJoinAt;
402
+ }
403
+ this.recordDiscovery("join_ok", { endpoint: this.activeEndpoint, detail: reason });
404
+ }
405
+ async maybeRefreshJoin(reason) {
406
+ if (!this.lastJoinAt || Date.now() - this.lastJoinAt > Math.max(45_000, this.pollIntervalMs * 6)) {
407
+ await this.joinRoom(reason);
408
+ }
409
+ this.ensurePollingAlive(reason);
410
+ }
411
+ async get(path) {
412
+ return this.requestJson("GET", path);
413
+ }
414
+ async post(path, body) {
415
+ return this.requestJson("POST", path, body);
416
+ }
417
+ async requestJson(method, path, body) {
418
+ const errors = [];
419
+ for (let offset = 0; offset < this.signalingEndpoints.length; offset += 1) {
420
+ const index = (this.activeEndpointIndex + offset) % this.signalingEndpoints.length;
421
+ const endpoint = this.signalingEndpoints[index]?.replace(/\/+$/, "");
422
+ if (!endpoint)
423
+ continue;
424
+ let timeout = null;
425
+ try {
426
+ const controller = new AbortController();
427
+ timeout = setTimeout(() => controller.abort(), this.requestTimeoutMs);
428
+ const response = await fetch(`${endpoint}${path}`, {
429
+ method,
430
+ headers: method === "POST" ? { "content-type": "application/json" } : undefined,
431
+ body: method === "POST" ? JSON.stringify(body) : undefined,
432
+ signal: controller.signal,
433
+ });
434
+ if (!response.ok) {
435
+ const responseText = (await response.text().catch(() => "")).trim();
436
+ const detail = responseText ? `: ${responseText.slice(0, 200)}` : "";
437
+ throw new Error(`${method} ${path} failed (${response.status})${detail}`);
438
+ }
439
+ this.activeEndpointIndex = index;
440
+ this.activeEndpoint = endpoint;
441
+ this.lastError = null;
442
+ return response.json();
443
+ }
444
+ catch (error) {
445
+ const isAbort = error instanceof Error && (error.name === "AbortError" || error.message === "This operation was aborted");
446
+ const message = isAbort
447
+ ? `${method} ${path} timed out after ${this.requestTimeoutMs}ms`
448
+ : error instanceof Error
449
+ ? error.message
450
+ : String(error);
451
+ errors.push(`${endpoint}: ${message}`);
452
+ this.stats.signaling_errors += 1;
453
+ this.lastError = message;
454
+ this.lastErrorAt = Date.now();
455
+ this.reconnectAttemptsTotal += 1;
456
+ this.recordDiscovery("signaling_error", { endpoint, detail: message });
457
+ }
458
+ finally {
459
+ if (timeout) {
460
+ clearTimeout(timeout);
461
+ }
462
+ }
463
+ }
464
+ throw new Error(errors.join(" | "));
465
+ }
466
+ updatePeersFromList(values) {
467
+ const parsedPeers = [];
468
+ for (const value of values) {
469
+ if (typeof value === "string") {
470
+ const peerId = String(value || "").trim();
471
+ if (peerId) {
472
+ parsedPeers.push({ peer_id: peerId });
473
+ }
474
+ continue;
475
+ }
476
+ if (value && typeof value === "object") {
477
+ const raw = value;
478
+ const peerId = String(raw.peer_id || "").trim();
479
+ if (!peerId) {
480
+ continue;
481
+ }
482
+ parsedPeers.push({
483
+ peer_id: peerId,
484
+ meta: {
485
+ signal_queue_size: Number(raw.signal_queue_size ?? 0),
486
+ relay_queue_size: Number(raw.relay_queue_size ?? 0),
487
+ },
488
+ });
489
+ }
490
+ }
491
+ const peerIds = parsedPeers.map((peer) => peer.peer_id);
492
+ if (!peerIds.includes(this.peerId)) {
493
+ void this.joinRoom("self_missing_from_peers").catch(() => { });
494
+ }
495
+ const now = Date.now();
496
+ const next = new Map();
497
+ for (const peerInfo of parsedPeers) {
498
+ const peerId = peerInfo.peer_id;
499
+ if (peerId === this.peerId)
500
+ continue;
501
+ const existing = this.peers.get(peerId);
502
+ if (!existing) {
503
+ this.recordDiscovery("peer_joined", { peer_id: peerId });
504
+ }
505
+ next.set(peerId, {
506
+ peer_id: peerId,
507
+ status: "online",
508
+ first_seen_at: existing?.first_seen_at ?? now,
509
+ last_seen_at: now,
510
+ messages_seen: existing?.messages_seen ?? 0,
511
+ reconnect_attempts: existing?.reconnect_attempts ?? 0,
512
+ meta: peerInfo.meta || existing?.meta,
513
+ });
514
+ }
515
+ for (const peerId of this.peers.keys()) {
516
+ if (!next.has(peerId)) {
517
+ this.recordDiscovery("peer_removed", { peer_id: peerId });
518
+ }
519
+ }
520
+ this.peers = next;
521
+ }
522
+ scheduleNextPoll(delayMs) {
523
+ if (this.poller) {
524
+ clearTimeout(this.poller);
525
+ }
526
+ const jitterMs = Math.floor(Math.random() * 400);
527
+ this.poller = setTimeout(() => {
528
+ this.pollOnce().catch(() => { });
529
+ }, Math.max(1000, delayMs + jitterMs));
530
+ }
531
+ ensurePollingAlive(reason) {
532
+ if (!this.started)
533
+ return;
534
+ const pollStaleMs = Math.max(45_000, this.pollIntervalMs * 6);
535
+ const pollMissing = !this.poller;
536
+ const pollStale = Boolean(this.lastPollAt) && Date.now() - this.lastPollAt > pollStaleMs;
537
+ if (!pollMissing && !pollStale) {
538
+ return;
539
+ }
540
+ this.recordDiscovery("poll_recover_scheduled", {
541
+ endpoint: this.activeEndpoint,
542
+ detail: `${reason}:${pollMissing ? "missing" : "stale"}`,
543
+ });
544
+ this.currentPollDelayMs = this.pollIntervalMs;
545
+ this.scheduleNextPoll(0);
546
+ }
547
+ }
548
+ exports.RelayPreviewAdapter = RelayPreviewAdapter;
@@ -0,0 +1,23 @@
1
+ import { NetworkTransport, TransportConfigSnapshot, TransportMessageMeta, TransportStats } from "../abstractions/transport";
2
+ type UdpLanBroadcastTransportOptions = {
3
+ port?: number;
4
+ bindAddress?: string;
5
+ broadcastAddress?: string;
6
+ };
7
+ export declare class UdpLanBroadcastTransport implements NetworkTransport {
8
+ private socket;
9
+ private handlers;
10
+ private state;
11
+ private stats;
12
+ private port;
13
+ private bindAddress;
14
+ private broadcastAddress;
15
+ constructor(options?: UdpLanBroadcastTransportOptions);
16
+ start(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ send(data: Buffer): Promise<void>;
19
+ onMessage(handler: (data: Buffer, meta: TransportMessageMeta) => void): () => void;
20
+ getStats(): TransportStats;
21
+ getConfig(): TransportConfigSnapshot;
22
+ }
23
+ export {};