@silicaclaw/cli 2026.3.19-9 → 2026.3.20-1

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