@silicaclaw/cli 2026.3.19-2 → 2026.3.19-22

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 (1075) hide show
  1. package/CHANGELOG.md +91 -1
  2. package/INSTALL.md +70 -10
  3. package/README.md +109 -15
  4. package/VERSION +1 -1
  5. package/apps/local-console/dist/apps/local-console/src/server.d.ts +752 -0
  6. package/apps/local-console/dist/apps/local-console/src/server.js +3101 -0
  7. package/apps/local-console/dist/apps/local-console/src/socialRoutes.d.ts +16 -0
  8. package/apps/local-console/dist/apps/local-console/src/socialRoutes.js +72 -0
  9. package/apps/local-console/dist/config/silicaclaw-defaults.json +19 -0
  10. package/apps/local-console/dist/packages/core/src/crypto.d.ts +6 -0
  11. package/apps/local-console/dist/packages/core/src/crypto.js +50 -0
  12. package/apps/local-console/dist/packages/core/src/directory.d.ts +17 -0
  13. package/apps/local-console/dist/packages/core/src/directory.js +145 -0
  14. package/apps/local-console/dist/packages/core/src/identity.d.ts +2 -0
  15. package/apps/local-console/dist/packages/core/src/identity.js +18 -0
  16. package/apps/local-console/dist/packages/core/src/index.d.ts +12 -0
  17. package/apps/local-console/dist/packages/core/src/index.js +28 -0
  18. package/apps/local-console/dist/packages/core/src/indexing.d.ts +6 -0
  19. package/apps/local-console/dist/packages/core/src/indexing.js +43 -0
  20. package/apps/local-console/dist/packages/core/src/presence.d.ts +4 -0
  21. package/apps/local-console/dist/packages/core/src/presence.js +23 -0
  22. package/apps/local-console/dist/packages/core/src/profile.d.ts +4 -0
  23. package/apps/local-console/dist/packages/core/src/profile.js +39 -0
  24. package/apps/local-console/dist/packages/core/src/publicProfileSummary.d.ts +70 -0
  25. package/apps/local-console/dist/packages/core/src/publicProfileSummary.js +103 -0
  26. package/apps/local-console/dist/packages/core/src/socialConfig.d.ts +100 -0
  27. package/apps/local-console/dist/packages/core/src/socialConfig.js +300 -0
  28. package/apps/local-console/dist/packages/core/src/socialMessage.d.ts +19 -0
  29. package/apps/local-console/dist/packages/core/src/socialMessage.js +69 -0
  30. package/apps/local-console/dist/packages/core/src/socialResolver.d.ts +46 -0
  31. package/apps/local-console/dist/packages/core/src/socialResolver.js +237 -0
  32. package/apps/local-console/dist/packages/core/src/socialTemplate.d.ts +2 -0
  33. package/apps/local-console/dist/packages/core/src/socialTemplate.js +90 -0
  34. package/apps/local-console/dist/packages/core/src/types.d.ts +59 -0
  35. package/apps/local-console/dist/packages/core/src/types.js +2 -0
  36. package/apps/local-console/dist/packages/network/src/abstractions/messageEnvelope.d.ts +28 -0
  37. package/apps/local-console/dist/packages/network/src/abstractions/messageEnvelope.js +36 -0
  38. package/apps/local-console/dist/packages/network/src/abstractions/peerDiscovery.d.ts +43 -0
  39. package/apps/local-console/dist/packages/network/src/abstractions/peerDiscovery.js +2 -0
  40. package/apps/local-console/dist/packages/network/src/abstractions/topicCodec.d.ts +4 -0
  41. package/apps/local-console/dist/packages/network/src/abstractions/topicCodec.js +2 -0
  42. package/apps/local-console/dist/packages/network/src/abstractions/transport.d.ts +36 -0
  43. package/apps/local-console/dist/packages/network/src/abstractions/transport.js +2 -0
  44. package/apps/local-console/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.d.ts +5 -0
  45. package/apps/local-console/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.js +24 -0
  46. package/apps/local-console/dist/packages/network/src/codec/jsonTopicCodec.d.ts +5 -0
  47. package/apps/local-console/dist/packages/network/src/codec/jsonTopicCodec.js +12 -0
  48. package/apps/local-console/dist/packages/network/src/discovery/heartbeatPeerDiscovery.d.ts +28 -0
  49. package/apps/local-console/dist/packages/network/src/discovery/heartbeatPeerDiscovery.js +144 -0
  50. package/apps/local-console/dist/packages/network/src/index.d.ts +14 -0
  51. package/apps/local-console/dist/packages/network/src/index.js +30 -0
  52. package/apps/local-console/dist/packages/network/src/localEventBus.d.ts +9 -0
  53. package/apps/local-console/dist/packages/network/src/localEventBus.js +47 -0
  54. package/apps/local-console/dist/packages/network/src/mock.d.ts +8 -0
  55. package/apps/local-console/dist/packages/network/src/mock.js +24 -0
  56. package/apps/local-console/dist/packages/network/src/realPreview.d.ts +105 -0
  57. package/apps/local-console/dist/packages/network/src/realPreview.js +331 -0
  58. package/apps/local-console/dist/packages/network/src/relayPreview.d.ts +166 -0
  59. package/apps/local-console/dist/packages/network/src/relayPreview.js +448 -0
  60. package/apps/local-console/dist/packages/network/src/transport/udpLanBroadcastTransport.d.ts +23 -0
  61. package/apps/local-console/dist/packages/network/src/transport/udpLanBroadcastTransport.js +154 -0
  62. package/apps/local-console/dist/packages/network/src/types.d.ts +6 -0
  63. package/apps/local-console/dist/packages/network/src/types.js +2 -0
  64. package/apps/local-console/dist/packages/network/src/webrtcPreview.d.ts +163 -0
  65. package/apps/local-console/dist/packages/network/src/webrtcPreview.js +848 -0
  66. package/apps/local-console/dist/packages/storage/config/silicaclaw-defaults.json +19 -0
  67. package/apps/local-console/dist/packages/storage/src/index.d.ts +3 -0
  68. package/apps/local-console/dist/packages/storage/src/index.js +19 -0
  69. package/apps/local-console/dist/packages/storage/src/jsonRepo.d.ts +7 -0
  70. package/apps/local-console/dist/packages/storage/src/jsonRepo.js +29 -0
  71. package/apps/local-console/dist/packages/storage/src/repos.d.ts +61 -0
  72. package/apps/local-console/dist/packages/storage/src/repos.js +67 -0
  73. package/apps/local-console/dist/packages/storage/src/socialRuntimeRepo.d.ts +5 -0
  74. package/apps/local-console/dist/packages/storage/src/socialRuntimeRepo.js +57 -0
  75. package/apps/local-console/package.json +1 -1
  76. package/apps/local-console/public/app/app.js +493 -0
  77. package/apps/local-console/public/app/events.js +460 -0
  78. package/apps/local-console/public/app/i18n.js +43 -0
  79. package/apps/local-console/public/app/network.js +241 -0
  80. package/apps/local-console/public/app/overview.js +339 -0
  81. package/apps/local-console/public/app/profile.js +234 -0
  82. package/apps/local-console/public/app/shell.js +128 -0
  83. package/apps/local-console/public/app/social.js +664 -0
  84. package/apps/local-console/public/app/styles.css +2534 -0
  85. package/apps/local-console/public/app/template.js +838 -0
  86. package/apps/local-console/public/app/translations.js +1124 -0
  87. package/apps/local-console/public/app/utils.js +77 -0
  88. package/apps/local-console/public/index.html +3 -5826
  89. package/apps/local-console/src/server.ts +824 -158
  90. package/apps/public-explorer/dist/apps/public-explorer/src/server.d.ts +1 -0
  91. package/apps/public-explorer/dist/apps/public-explorer/src/server.js +41 -0
  92. package/apps/public-explorer/dist/config/silicaclaw-defaults.json +19 -0
  93. package/apps/public-explorer/dist/server.d.ts +1 -0
  94. package/apps/public-explorer/dist/server.js +31 -0
  95. package/apps/public-explorer/package.json +1 -0
  96. package/apps/public-explorer/public/app/app.js +322 -0
  97. package/apps/public-explorer/public/app/i18n.js +46 -0
  98. package/apps/public-explorer/public/app/styles.css +297 -0
  99. package/apps/public-explorer/public/app/template.js +45 -0
  100. package/apps/public-explorer/public/app/translations.js +192 -0
  101. package/apps/public-explorer/public/app/utils.js +37 -0
  102. package/apps/public-explorer/public/index.html +3 -831
  103. package/apps/public-explorer/src/server.ts +11 -1
  104. package/config/silicaclaw-defaults.json +19 -0
  105. package/dist/apps/local-console/src/server.d.ts +1 -0
  106. package/dist/apps/local-console/src/server.js +555 -0
  107. package/docs/NEW_USER_INSTALL.md +14 -10
  108. package/docs/NEW_USER_OPERATIONS.md +4 -4
  109. package/docs/OPENCLAW_BRIDGE.md +15 -0
  110. package/docs/OPENCLAW_BRIDGE_ZH.md +15 -0
  111. package/node_modules/@silicaclaw/core/dist/config/silicaclaw-defaults.json +19 -0
  112. package/node_modules/@silicaclaw/core/dist/crypto.d.ts +6 -0
  113. package/node_modules/@silicaclaw/core/dist/crypto.js +50 -0
  114. package/node_modules/@silicaclaw/core/dist/directory.d.ts +17 -0
  115. package/node_modules/@silicaclaw/core/dist/directory.js +145 -0
  116. package/node_modules/@silicaclaw/core/dist/identity.d.ts +2 -0
  117. package/node_modules/@silicaclaw/core/dist/identity.js +18 -0
  118. package/node_modules/@silicaclaw/core/dist/index.d.ts +12 -0
  119. package/node_modules/@silicaclaw/core/dist/index.js +28 -0
  120. package/node_modules/@silicaclaw/core/dist/indexing.d.ts +6 -0
  121. package/node_modules/@silicaclaw/core/dist/indexing.js +43 -0
  122. package/node_modules/@silicaclaw/core/dist/packages/core/src/crypto.d.ts +6 -0
  123. package/node_modules/@silicaclaw/core/dist/packages/core/src/crypto.js +50 -0
  124. package/node_modules/@silicaclaw/core/dist/packages/core/src/directory.d.ts +17 -0
  125. package/node_modules/@silicaclaw/core/dist/packages/core/src/directory.js +145 -0
  126. package/node_modules/@silicaclaw/core/dist/packages/core/src/identity.d.ts +2 -0
  127. package/node_modules/@silicaclaw/core/dist/packages/core/src/identity.js +18 -0
  128. package/node_modules/@silicaclaw/core/dist/packages/core/src/index.d.ts +12 -0
  129. package/node_modules/@silicaclaw/core/dist/packages/core/src/index.js +28 -0
  130. package/node_modules/@silicaclaw/core/dist/packages/core/src/indexing.d.ts +6 -0
  131. package/node_modules/@silicaclaw/core/dist/packages/core/src/indexing.js +43 -0
  132. package/node_modules/@silicaclaw/core/dist/packages/core/src/presence.d.ts +4 -0
  133. package/node_modules/@silicaclaw/core/dist/packages/core/src/presence.js +23 -0
  134. package/node_modules/@silicaclaw/core/dist/packages/core/src/profile.d.ts +4 -0
  135. package/node_modules/@silicaclaw/core/dist/packages/core/src/profile.js +39 -0
  136. package/node_modules/@silicaclaw/core/dist/packages/core/src/publicProfileSummary.d.ts +70 -0
  137. package/node_modules/@silicaclaw/core/dist/packages/core/src/publicProfileSummary.js +103 -0
  138. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialConfig.d.ts +100 -0
  139. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialConfig.js +300 -0
  140. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialMessage.d.ts +19 -0
  141. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialMessage.js +69 -0
  142. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialResolver.d.ts +46 -0
  143. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialResolver.js +237 -0
  144. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialTemplate.d.ts +2 -0
  145. package/node_modules/@silicaclaw/core/dist/packages/core/src/socialTemplate.js +90 -0
  146. package/node_modules/@silicaclaw/core/dist/packages/core/src/types.d.ts +59 -0
  147. package/node_modules/@silicaclaw/core/dist/packages/core/src/types.js +2 -0
  148. package/node_modules/@silicaclaw/core/dist/presence.d.ts +4 -0
  149. package/node_modules/@silicaclaw/core/dist/presence.js +23 -0
  150. package/node_modules/@silicaclaw/core/dist/profile.d.ts +4 -0
  151. package/node_modules/@silicaclaw/core/dist/profile.js +39 -0
  152. package/node_modules/@silicaclaw/core/dist/publicProfileSummary.d.ts +70 -0
  153. package/node_modules/@silicaclaw/core/dist/publicProfileSummary.js +103 -0
  154. package/node_modules/@silicaclaw/core/dist/socialConfig.d.ts +100 -0
  155. package/node_modules/@silicaclaw/core/dist/socialConfig.js +296 -0
  156. package/node_modules/@silicaclaw/core/dist/socialMessage.d.ts +19 -0
  157. package/node_modules/@silicaclaw/core/dist/socialMessage.js +69 -0
  158. package/node_modules/@silicaclaw/core/dist/socialResolver.d.ts +46 -0
  159. package/node_modules/@silicaclaw/core/dist/socialResolver.js +237 -0
  160. package/node_modules/@silicaclaw/core/dist/socialTemplate.d.ts +2 -0
  161. package/node_modules/@silicaclaw/core/dist/socialTemplate.js +90 -0
  162. package/node_modules/@silicaclaw/core/dist/types.d.ts +59 -0
  163. package/node_modules/@silicaclaw/core/dist/types.js +2 -0
  164. package/node_modules/@silicaclaw/core/package.json +13 -0
  165. package/node_modules/@silicaclaw/core/src/crypto.ts +55 -0
  166. package/node_modules/@silicaclaw/core/src/directory.ts +171 -0
  167. package/node_modules/@silicaclaw/core/src/identity.ts +14 -0
  168. package/node_modules/@silicaclaw/core/src/index.ts +12 -0
  169. package/node_modules/@silicaclaw/core/src/indexing.ts +42 -0
  170. package/node_modules/@silicaclaw/core/src/presence.ts +24 -0
  171. package/node_modules/@silicaclaw/core/src/profile.ts +39 -0
  172. package/node_modules/@silicaclaw/core/src/publicProfileSummary.ts +180 -0
  173. package/node_modules/@silicaclaw/core/src/socialConfig.ts +455 -0
  174. package/node_modules/@silicaclaw/core/src/socialMessage.ts +86 -0
  175. package/node_modules/@silicaclaw/core/src/socialResolver.ts +293 -0
  176. package/node_modules/@silicaclaw/core/src/socialTemplate.ts +99 -0
  177. package/node_modules/@silicaclaw/core/src/types.ts +67 -0
  178. package/node_modules/@silicaclaw/core/tsconfig.json +7 -0
  179. package/node_modules/@silicaclaw/network/dist/abstractions/messageEnvelope.d.ts +28 -0
  180. package/node_modules/@silicaclaw/network/dist/abstractions/messageEnvelope.js +36 -0
  181. package/node_modules/@silicaclaw/network/dist/abstractions/peerDiscovery.d.ts +43 -0
  182. package/node_modules/@silicaclaw/network/dist/abstractions/peerDiscovery.js +2 -0
  183. package/node_modules/@silicaclaw/network/dist/abstractions/topicCodec.d.ts +4 -0
  184. package/node_modules/@silicaclaw/network/dist/abstractions/topicCodec.js +2 -0
  185. package/node_modules/@silicaclaw/network/dist/abstractions/transport.d.ts +36 -0
  186. package/node_modules/@silicaclaw/network/dist/abstractions/transport.js +2 -0
  187. package/node_modules/@silicaclaw/network/dist/codec/jsonMessageEnvelopeCodec.d.ts +5 -0
  188. package/node_modules/@silicaclaw/network/dist/codec/jsonMessageEnvelopeCodec.js +24 -0
  189. package/node_modules/@silicaclaw/network/dist/codec/jsonTopicCodec.d.ts +5 -0
  190. package/node_modules/@silicaclaw/network/dist/codec/jsonTopicCodec.js +12 -0
  191. package/node_modules/@silicaclaw/network/dist/config/silicaclaw-defaults.json +19 -0
  192. package/node_modules/@silicaclaw/network/dist/discovery/heartbeatPeerDiscovery.d.ts +28 -0
  193. package/node_modules/@silicaclaw/network/dist/discovery/heartbeatPeerDiscovery.js +144 -0
  194. package/node_modules/@silicaclaw/network/dist/index.d.ts +14 -0
  195. package/node_modules/@silicaclaw/network/dist/index.js +30 -0
  196. package/node_modules/@silicaclaw/network/dist/localEventBus.d.ts +9 -0
  197. package/node_modules/@silicaclaw/network/dist/localEventBus.js +47 -0
  198. package/node_modules/@silicaclaw/network/dist/mock.d.ts +8 -0
  199. package/node_modules/@silicaclaw/network/dist/mock.js +24 -0
  200. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/messageEnvelope.d.ts +28 -0
  201. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/messageEnvelope.js +36 -0
  202. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/peerDiscovery.d.ts +43 -0
  203. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/peerDiscovery.js +2 -0
  204. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/topicCodec.d.ts +4 -0
  205. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/topicCodec.js +2 -0
  206. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/transport.d.ts +36 -0
  207. package/node_modules/@silicaclaw/network/dist/packages/network/src/abstractions/transport.js +2 -0
  208. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.d.ts +5 -0
  209. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.js +24 -0
  210. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonTopicCodec.d.ts +5 -0
  211. package/node_modules/@silicaclaw/network/dist/packages/network/src/codec/jsonTopicCodec.js +12 -0
  212. package/node_modules/@silicaclaw/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.d.ts +28 -0
  213. package/node_modules/@silicaclaw/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.js +144 -0
  214. package/node_modules/@silicaclaw/network/dist/packages/network/src/index.d.ts +14 -0
  215. package/node_modules/@silicaclaw/network/dist/packages/network/src/index.js +30 -0
  216. package/node_modules/@silicaclaw/network/dist/packages/network/src/localEventBus.d.ts +9 -0
  217. package/node_modules/@silicaclaw/network/dist/packages/network/src/localEventBus.js +47 -0
  218. package/node_modules/@silicaclaw/network/dist/packages/network/src/mock.d.ts +8 -0
  219. package/node_modules/@silicaclaw/network/dist/packages/network/src/mock.js +24 -0
  220. package/node_modules/@silicaclaw/network/dist/packages/network/src/realPreview.d.ts +105 -0
  221. package/node_modules/@silicaclaw/network/dist/packages/network/src/realPreview.js +331 -0
  222. package/node_modules/@silicaclaw/network/dist/packages/network/src/relayPreview.d.ts +166 -0
  223. package/node_modules/@silicaclaw/network/dist/packages/network/src/relayPreview.js +448 -0
  224. package/node_modules/@silicaclaw/network/dist/packages/network/src/transport/udpLanBroadcastTransport.d.ts +23 -0
  225. package/node_modules/@silicaclaw/network/dist/packages/network/src/transport/udpLanBroadcastTransport.js +154 -0
  226. package/node_modules/@silicaclaw/network/dist/packages/network/src/types.d.ts +6 -0
  227. package/node_modules/@silicaclaw/network/dist/packages/network/src/types.js +2 -0
  228. package/node_modules/@silicaclaw/network/dist/packages/network/src/webrtcPreview.d.ts +163 -0
  229. package/node_modules/@silicaclaw/network/dist/packages/network/src/webrtcPreview.js +848 -0
  230. package/node_modules/@silicaclaw/network/dist/realPreview.d.ts +105 -0
  231. package/node_modules/@silicaclaw/network/dist/realPreview.js +327 -0
  232. package/node_modules/@silicaclaw/network/dist/relayPreview.d.ts +166 -0
  233. package/node_modules/@silicaclaw/network/dist/relayPreview.js +442 -0
  234. package/node_modules/@silicaclaw/network/dist/transport/udpLanBroadcastTransport.d.ts +23 -0
  235. package/node_modules/@silicaclaw/network/dist/transport/udpLanBroadcastTransport.js +153 -0
  236. package/node_modules/@silicaclaw/network/dist/types.d.ts +6 -0
  237. package/node_modules/@silicaclaw/network/dist/types.js +2 -0
  238. package/node_modules/@silicaclaw/network/dist/webrtcPreview.d.ts +163 -0
  239. package/node_modules/@silicaclaw/network/dist/webrtcPreview.js +844 -0
  240. package/node_modules/@silicaclaw/network/package.json +10 -0
  241. package/node_modules/@silicaclaw/network/src/abstractions/messageEnvelope.ts +80 -0
  242. package/node_modules/@silicaclaw/network/src/abstractions/peerDiscovery.ts +49 -0
  243. package/node_modules/@silicaclaw/network/src/abstractions/topicCodec.ts +4 -0
  244. package/node_modules/@silicaclaw/network/src/abstractions/transport.ts +40 -0
  245. package/node_modules/@silicaclaw/network/src/codec/jsonMessageEnvelopeCodec.ts +22 -0
  246. package/node_modules/@silicaclaw/network/src/codec/jsonTopicCodec.ts +11 -0
  247. package/node_modules/@silicaclaw/network/src/discovery/heartbeatPeerDiscovery.ts +173 -0
  248. package/node_modules/@silicaclaw/network/src/index.ts +17 -0
  249. package/node_modules/@silicaclaw/network/src/localEventBus.ts +61 -0
  250. package/node_modules/@silicaclaw/network/src/mock.ts +27 -0
  251. package/node_modules/@silicaclaw/network/src/realPreview.ts +437 -0
  252. package/node_modules/@silicaclaw/network/src/relayPreview.ts +568 -0
  253. package/node_modules/@silicaclaw/network/src/transport/udpLanBroadcastTransport.ts +174 -0
  254. package/node_modules/@silicaclaw/network/src/types.ts +6 -0
  255. package/node_modules/@silicaclaw/network/src/webrtcPreview.ts +1053 -0
  256. package/node_modules/@silicaclaw/network/tsconfig.json +7 -0
  257. package/node_modules/@silicaclaw/storage/config/silicaclaw-defaults.json +19 -0
  258. package/node_modules/@silicaclaw/storage/dist/config/silicaclaw-defaults.json +19 -0
  259. package/node_modules/@silicaclaw/storage/dist/index.d.ts +3 -0
  260. package/node_modules/@silicaclaw/storage/dist/index.js +19 -0
  261. package/node_modules/@silicaclaw/storage/dist/jsonRepo.d.ts +7 -0
  262. package/node_modules/@silicaclaw/storage/dist/jsonRepo.js +29 -0
  263. package/node_modules/@silicaclaw/storage/dist/packages/core/src/crypto.d.ts +6 -0
  264. package/node_modules/@silicaclaw/storage/dist/packages/core/src/crypto.js +50 -0
  265. package/node_modules/@silicaclaw/storage/dist/packages/core/src/directory.d.ts +17 -0
  266. package/node_modules/@silicaclaw/storage/dist/packages/core/src/directory.js +145 -0
  267. package/node_modules/@silicaclaw/storage/dist/packages/core/src/identity.d.ts +2 -0
  268. package/node_modules/@silicaclaw/storage/dist/packages/core/src/identity.js +18 -0
  269. package/node_modules/@silicaclaw/storage/dist/packages/core/src/index.d.ts +12 -0
  270. package/node_modules/@silicaclaw/storage/dist/packages/core/src/index.js +28 -0
  271. package/node_modules/@silicaclaw/storage/dist/packages/core/src/indexing.d.ts +6 -0
  272. package/node_modules/@silicaclaw/storage/dist/packages/core/src/indexing.js +43 -0
  273. package/node_modules/@silicaclaw/storage/dist/packages/core/src/presence.d.ts +4 -0
  274. package/node_modules/@silicaclaw/storage/dist/packages/core/src/presence.js +23 -0
  275. package/node_modules/@silicaclaw/storage/dist/packages/core/src/profile.d.ts +4 -0
  276. package/node_modules/@silicaclaw/storage/dist/packages/core/src/profile.js +39 -0
  277. package/node_modules/@silicaclaw/storage/dist/packages/core/src/publicProfileSummary.d.ts +70 -0
  278. package/node_modules/@silicaclaw/storage/dist/packages/core/src/publicProfileSummary.js +103 -0
  279. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialConfig.d.ts +100 -0
  280. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialConfig.js +300 -0
  281. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialMessage.d.ts +19 -0
  282. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialMessage.js +69 -0
  283. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialResolver.d.ts +46 -0
  284. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialResolver.js +237 -0
  285. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialTemplate.d.ts +2 -0
  286. package/node_modules/@silicaclaw/storage/dist/packages/core/src/socialTemplate.js +90 -0
  287. package/node_modules/@silicaclaw/storage/dist/packages/core/src/types.d.ts +59 -0
  288. package/node_modules/@silicaclaw/storage/dist/packages/core/src/types.js +2 -0
  289. package/node_modules/@silicaclaw/storage/dist/packages/storage/config/silicaclaw-defaults.json +19 -0
  290. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/index.d.ts +3 -0
  291. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/index.js +19 -0
  292. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/jsonRepo.d.ts +7 -0
  293. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/jsonRepo.js +29 -0
  294. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/repos.d.ts +61 -0
  295. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/repos.js +67 -0
  296. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/socialRuntimeRepo.d.ts +5 -0
  297. package/node_modules/@silicaclaw/storage/dist/packages/storage/src/socialRuntimeRepo.js +57 -0
  298. package/node_modules/@silicaclaw/storage/dist/repos.d.ts +61 -0
  299. package/node_modules/@silicaclaw/storage/dist/repos.js +67 -0
  300. package/node_modules/@silicaclaw/storage/dist/socialRuntimeRepo.d.ts +5 -0
  301. package/node_modules/@silicaclaw/storage/dist/socialRuntimeRepo.js +57 -0
  302. package/node_modules/@silicaclaw/storage/package.json +13 -0
  303. package/node_modules/@silicaclaw/storage/src/index.ts +3 -0
  304. package/node_modules/@silicaclaw/storage/src/jsonRepo.ts +25 -0
  305. package/node_modules/@silicaclaw/storage/src/repos.ts +106 -0
  306. package/node_modules/@silicaclaw/storage/src/socialRuntimeRepo.ts +53 -0
  307. package/node_modules/@silicaclaw/storage/tsconfig.json +7 -0
  308. package/node_modules/accepts/HISTORY.md +243 -0
  309. package/node_modules/accepts/LICENSE +23 -0
  310. package/node_modules/accepts/README.md +140 -0
  311. package/node_modules/accepts/index.js +238 -0
  312. package/node_modules/accepts/package.json +47 -0
  313. package/node_modules/array-flatten/LICENSE +21 -0
  314. package/node_modules/array-flatten/README.md +43 -0
  315. package/node_modules/array-flatten/array-flatten.js +64 -0
  316. package/node_modules/array-flatten/package.json +39 -0
  317. package/node_modules/body-parser/HISTORY.md +680 -0
  318. package/node_modules/body-parser/LICENSE +23 -0
  319. package/node_modules/body-parser/README.md +476 -0
  320. package/node_modules/body-parser/index.js +156 -0
  321. package/node_modules/body-parser/lib/read.js +205 -0
  322. package/node_modules/body-parser/lib/types/json.js +247 -0
  323. package/node_modules/body-parser/lib/types/raw.js +101 -0
  324. package/node_modules/body-parser/lib/types/text.js +121 -0
  325. package/node_modules/body-parser/lib/types/urlencoded.js +300 -0
  326. package/node_modules/body-parser/package.json +55 -0
  327. package/node_modules/bytes/History.md +97 -0
  328. package/node_modules/bytes/LICENSE +23 -0
  329. package/node_modules/bytes/Readme.md +152 -0
  330. package/node_modules/bytes/index.js +170 -0
  331. package/node_modules/bytes/package.json +42 -0
  332. package/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
  333. package/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
  334. package/node_modules/call-bind-apply-helpers/.nycrc +9 -0
  335. package/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
  336. package/node_modules/call-bind-apply-helpers/LICENSE +21 -0
  337. package/node_modules/call-bind-apply-helpers/README.md +62 -0
  338. package/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
  339. package/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  340. package/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
  341. package/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  342. package/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
  343. package/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  344. package/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
  345. package/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  346. package/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
  347. package/node_modules/call-bind-apply-helpers/index.js +15 -0
  348. package/node_modules/call-bind-apply-helpers/package.json +85 -0
  349. package/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
  350. package/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  351. package/node_modules/call-bind-apply-helpers/test/index.js +63 -0
  352. package/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
  353. package/node_modules/call-bound/.eslintrc +13 -0
  354. package/node_modules/call-bound/.github/FUNDING.yml +12 -0
  355. package/node_modules/call-bound/.nycrc +9 -0
  356. package/node_modules/call-bound/CHANGELOG.md +42 -0
  357. package/node_modules/call-bound/LICENSE +21 -0
  358. package/node_modules/call-bound/README.md +53 -0
  359. package/node_modules/call-bound/index.d.ts +94 -0
  360. package/node_modules/call-bound/index.js +19 -0
  361. package/node_modules/call-bound/package.json +99 -0
  362. package/node_modules/call-bound/test/index.js +61 -0
  363. package/node_modules/call-bound/tsconfig.json +10 -0
  364. package/node_modules/content-disposition/HISTORY.md +60 -0
  365. package/node_modules/content-disposition/LICENSE +22 -0
  366. package/node_modules/content-disposition/README.md +142 -0
  367. package/node_modules/content-disposition/index.js +458 -0
  368. package/node_modules/content-disposition/package.json +44 -0
  369. package/node_modules/content-type/HISTORY.md +29 -0
  370. package/node_modules/content-type/LICENSE +22 -0
  371. package/node_modules/content-type/README.md +94 -0
  372. package/node_modules/content-type/index.js +225 -0
  373. package/node_modules/content-type/package.json +42 -0
  374. package/node_modules/cookie/LICENSE +24 -0
  375. package/node_modules/cookie/README.md +317 -0
  376. package/node_modules/cookie/SECURITY.md +25 -0
  377. package/node_modules/cookie/index.js +335 -0
  378. package/node_modules/cookie/package.json +44 -0
  379. package/node_modules/cookie-signature/History.md +42 -0
  380. package/node_modules/cookie-signature/Readme.md +42 -0
  381. package/node_modules/cookie-signature/index.js +51 -0
  382. package/node_modules/cookie-signature/package.json +18 -0
  383. package/node_modules/cors/LICENSE +22 -0
  384. package/node_modules/cors/README.md +277 -0
  385. package/node_modules/cors/lib/index.js +238 -0
  386. package/node_modules/cors/package.json +42 -0
  387. package/node_modules/debug/.coveralls.yml +1 -0
  388. package/node_modules/debug/.eslintrc +11 -0
  389. package/node_modules/debug/.npmignore +9 -0
  390. package/node_modules/debug/.travis.yml +14 -0
  391. package/node_modules/debug/CHANGELOG.md +362 -0
  392. package/node_modules/debug/LICENSE +19 -0
  393. package/node_modules/debug/Makefile +50 -0
  394. package/node_modules/debug/README.md +312 -0
  395. package/node_modules/debug/component.json +19 -0
  396. package/node_modules/debug/karma.conf.js +70 -0
  397. package/node_modules/debug/node.js +1 -0
  398. package/node_modules/debug/package.json +49 -0
  399. package/node_modules/debug/src/browser.js +185 -0
  400. package/node_modules/debug/src/debug.js +202 -0
  401. package/node_modules/debug/src/index.js +10 -0
  402. package/node_modules/debug/src/inspector-log.js +15 -0
  403. package/node_modules/debug/src/node.js +248 -0
  404. package/node_modules/depd/History.md +103 -0
  405. package/node_modules/depd/LICENSE +22 -0
  406. package/node_modules/depd/Readme.md +280 -0
  407. package/node_modules/depd/index.js +538 -0
  408. package/node_modules/depd/lib/browser/index.js +77 -0
  409. package/node_modules/depd/package.json +45 -0
  410. package/node_modules/destroy/LICENSE +23 -0
  411. package/node_modules/destroy/README.md +63 -0
  412. package/node_modules/destroy/index.js +209 -0
  413. package/node_modules/destroy/package.json +48 -0
  414. package/node_modules/dunder-proto/.eslintrc +5 -0
  415. package/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
  416. package/node_modules/dunder-proto/.nycrc +13 -0
  417. package/node_modules/dunder-proto/CHANGELOG.md +24 -0
  418. package/node_modules/dunder-proto/LICENSE +21 -0
  419. package/node_modules/dunder-proto/README.md +54 -0
  420. package/node_modules/dunder-proto/get.d.ts +5 -0
  421. package/node_modules/dunder-proto/get.js +30 -0
  422. package/node_modules/dunder-proto/package.json +76 -0
  423. package/node_modules/dunder-proto/set.d.ts +5 -0
  424. package/node_modules/dunder-proto/set.js +35 -0
  425. package/node_modules/dunder-proto/test/get.js +34 -0
  426. package/node_modules/dunder-proto/test/index.js +4 -0
  427. package/node_modules/dunder-proto/test/set.js +50 -0
  428. package/node_modules/dunder-proto/tsconfig.json +9 -0
  429. package/node_modules/ee-first/LICENSE +22 -0
  430. package/node_modules/ee-first/README.md +80 -0
  431. package/node_modules/ee-first/index.js +95 -0
  432. package/node_modules/ee-first/package.json +29 -0
  433. package/node_modules/encodeurl/LICENSE +22 -0
  434. package/node_modules/encodeurl/README.md +109 -0
  435. package/node_modules/encodeurl/index.js +60 -0
  436. package/node_modules/encodeurl/package.json +40 -0
  437. package/node_modules/es-define-property/.eslintrc +13 -0
  438. package/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  439. package/node_modules/es-define-property/.nycrc +9 -0
  440. package/node_modules/es-define-property/CHANGELOG.md +29 -0
  441. package/node_modules/es-define-property/LICENSE +21 -0
  442. package/node_modules/es-define-property/README.md +49 -0
  443. package/node_modules/es-define-property/index.d.ts +3 -0
  444. package/node_modules/es-define-property/index.js +14 -0
  445. package/node_modules/es-define-property/package.json +81 -0
  446. package/node_modules/es-define-property/test/index.js +56 -0
  447. package/node_modules/es-define-property/tsconfig.json +10 -0
  448. package/node_modules/es-errors/.eslintrc +5 -0
  449. package/node_modules/es-errors/.github/FUNDING.yml +12 -0
  450. package/node_modules/es-errors/CHANGELOG.md +40 -0
  451. package/node_modules/es-errors/LICENSE +21 -0
  452. package/node_modules/es-errors/README.md +55 -0
  453. package/node_modules/es-errors/eval.d.ts +3 -0
  454. package/node_modules/es-errors/eval.js +4 -0
  455. package/node_modules/es-errors/index.d.ts +3 -0
  456. package/node_modules/es-errors/index.js +4 -0
  457. package/node_modules/es-errors/package.json +80 -0
  458. package/node_modules/es-errors/range.d.ts +3 -0
  459. package/node_modules/es-errors/range.js +4 -0
  460. package/node_modules/es-errors/ref.d.ts +3 -0
  461. package/node_modules/es-errors/ref.js +4 -0
  462. package/node_modules/es-errors/syntax.d.ts +3 -0
  463. package/node_modules/es-errors/syntax.js +4 -0
  464. package/node_modules/es-errors/test/index.js +19 -0
  465. package/node_modules/es-errors/tsconfig.json +49 -0
  466. package/node_modules/es-errors/type.d.ts +3 -0
  467. package/node_modules/es-errors/type.js +4 -0
  468. package/node_modules/es-errors/uri.d.ts +3 -0
  469. package/node_modules/es-errors/uri.js +4 -0
  470. package/node_modules/es-object-atoms/.eslintrc +16 -0
  471. package/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  472. package/node_modules/es-object-atoms/CHANGELOG.md +37 -0
  473. package/node_modules/es-object-atoms/LICENSE +21 -0
  474. package/node_modules/es-object-atoms/README.md +63 -0
  475. package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  476. package/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  477. package/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  478. package/node_modules/es-object-atoms/ToObject.js +10 -0
  479. package/node_modules/es-object-atoms/index.d.ts +3 -0
  480. package/node_modules/es-object-atoms/index.js +4 -0
  481. package/node_modules/es-object-atoms/isObject.d.ts +3 -0
  482. package/node_modules/es-object-atoms/isObject.js +6 -0
  483. package/node_modules/es-object-atoms/package.json +80 -0
  484. package/node_modules/es-object-atoms/test/index.js +38 -0
  485. package/node_modules/es-object-atoms/tsconfig.json +6 -0
  486. package/node_modules/escape-html/LICENSE +24 -0
  487. package/node_modules/escape-html/Readme.md +43 -0
  488. package/node_modules/escape-html/index.js +78 -0
  489. package/node_modules/escape-html/package.json +24 -0
  490. package/node_modules/etag/HISTORY.md +83 -0
  491. package/node_modules/etag/LICENSE +22 -0
  492. package/node_modules/etag/README.md +159 -0
  493. package/node_modules/etag/index.js +131 -0
  494. package/node_modules/etag/package.json +47 -0
  495. package/node_modules/express/History.md +3667 -0
  496. package/node_modules/express/LICENSE +24 -0
  497. package/node_modules/express/Readme.md +260 -0
  498. package/node_modules/express/index.js +11 -0
  499. package/node_modules/express/lib/application.js +661 -0
  500. package/node_modules/express/lib/express.js +116 -0
  501. package/node_modules/express/lib/middleware/init.js +43 -0
  502. package/node_modules/express/lib/middleware/query.js +47 -0
  503. package/node_modules/express/lib/request.js +525 -0
  504. package/node_modules/express/lib/response.js +1179 -0
  505. package/node_modules/express/lib/router/index.js +673 -0
  506. package/node_modules/express/lib/router/layer.js +181 -0
  507. package/node_modules/express/lib/router/route.js +230 -0
  508. package/node_modules/express/lib/utils.js +303 -0
  509. package/node_modules/express/lib/view.js +182 -0
  510. package/node_modules/express/package.json +102 -0
  511. package/node_modules/finalhandler/HISTORY.md +216 -0
  512. package/node_modules/finalhandler/LICENSE +22 -0
  513. package/node_modules/finalhandler/README.md +147 -0
  514. package/node_modules/finalhandler/SECURITY.md +25 -0
  515. package/node_modules/finalhandler/index.js +341 -0
  516. package/node_modules/finalhandler/package.json +47 -0
  517. package/node_modules/forwarded/HISTORY.md +21 -0
  518. package/node_modules/forwarded/LICENSE +22 -0
  519. package/node_modules/forwarded/README.md +57 -0
  520. package/node_modules/forwarded/index.js +90 -0
  521. package/node_modules/forwarded/package.json +45 -0
  522. package/node_modules/fresh/HISTORY.md +70 -0
  523. package/node_modules/fresh/LICENSE +23 -0
  524. package/node_modules/fresh/README.md +119 -0
  525. package/node_modules/fresh/index.js +137 -0
  526. package/node_modules/fresh/package.json +46 -0
  527. package/node_modules/function-bind/.eslintrc +21 -0
  528. package/node_modules/function-bind/.github/FUNDING.yml +12 -0
  529. package/node_modules/function-bind/.github/SECURITY.md +3 -0
  530. package/node_modules/function-bind/.nycrc +13 -0
  531. package/node_modules/function-bind/CHANGELOG.md +136 -0
  532. package/node_modules/function-bind/LICENSE +20 -0
  533. package/node_modules/function-bind/README.md +46 -0
  534. package/node_modules/function-bind/implementation.js +84 -0
  535. package/node_modules/function-bind/index.js +5 -0
  536. package/node_modules/function-bind/package.json +87 -0
  537. package/node_modules/function-bind/test/.eslintrc +9 -0
  538. package/node_modules/function-bind/test/index.js +252 -0
  539. package/node_modules/get-intrinsic/.eslintrc +42 -0
  540. package/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  541. package/node_modules/get-intrinsic/.nycrc +9 -0
  542. package/node_modules/get-intrinsic/CHANGELOG.md +186 -0
  543. package/node_modules/get-intrinsic/LICENSE +21 -0
  544. package/node_modules/get-intrinsic/README.md +71 -0
  545. package/node_modules/get-intrinsic/index.js +378 -0
  546. package/node_modules/get-intrinsic/package.json +97 -0
  547. package/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  548. package/node_modules/get-proto/.eslintrc +10 -0
  549. package/node_modules/get-proto/.github/FUNDING.yml +12 -0
  550. package/node_modules/get-proto/.nycrc +9 -0
  551. package/node_modules/get-proto/CHANGELOG.md +21 -0
  552. package/node_modules/get-proto/LICENSE +21 -0
  553. package/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
  554. package/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  555. package/node_modules/get-proto/README.md +50 -0
  556. package/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
  557. package/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  558. package/node_modules/get-proto/index.d.ts +5 -0
  559. package/node_modules/get-proto/index.js +27 -0
  560. package/node_modules/get-proto/package.json +81 -0
  561. package/node_modules/get-proto/test/index.js +68 -0
  562. package/node_modules/get-proto/tsconfig.json +9 -0
  563. package/node_modules/gopd/.eslintrc +16 -0
  564. package/node_modules/gopd/.github/FUNDING.yml +12 -0
  565. package/node_modules/gopd/CHANGELOG.md +45 -0
  566. package/node_modules/gopd/LICENSE +21 -0
  567. package/node_modules/gopd/README.md +40 -0
  568. package/node_modules/gopd/gOPD.d.ts +1 -0
  569. package/node_modules/gopd/gOPD.js +4 -0
  570. package/node_modules/gopd/index.d.ts +5 -0
  571. package/node_modules/gopd/index.js +15 -0
  572. package/node_modules/gopd/package.json +77 -0
  573. package/node_modules/gopd/test/index.js +36 -0
  574. package/node_modules/gopd/tsconfig.json +9 -0
  575. package/node_modules/has-symbols/.eslintrc +11 -0
  576. package/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  577. package/node_modules/has-symbols/.nycrc +9 -0
  578. package/node_modules/has-symbols/CHANGELOG.md +91 -0
  579. package/node_modules/has-symbols/LICENSE +21 -0
  580. package/node_modules/has-symbols/README.md +46 -0
  581. package/node_modules/has-symbols/index.d.ts +3 -0
  582. package/node_modules/has-symbols/index.js +14 -0
  583. package/node_modules/has-symbols/package.json +111 -0
  584. package/node_modules/has-symbols/shams.d.ts +3 -0
  585. package/node_modules/has-symbols/shams.js +45 -0
  586. package/node_modules/has-symbols/test/index.js +22 -0
  587. package/node_modules/has-symbols/test/shams/core-js.js +29 -0
  588. package/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  589. package/node_modules/has-symbols/test/tests.js +58 -0
  590. package/node_modules/has-symbols/tsconfig.json +10 -0
  591. package/node_modules/hasown/.eslintrc +5 -0
  592. package/node_modules/hasown/.github/FUNDING.yml +12 -0
  593. package/node_modules/hasown/.nycrc +13 -0
  594. package/node_modules/hasown/CHANGELOG.md +40 -0
  595. package/node_modules/hasown/LICENSE +21 -0
  596. package/node_modules/hasown/README.md +40 -0
  597. package/node_modules/hasown/index.d.ts +3 -0
  598. package/node_modules/hasown/index.js +8 -0
  599. package/node_modules/hasown/package.json +92 -0
  600. package/node_modules/hasown/tsconfig.json +6 -0
  601. package/node_modules/http-errors/HISTORY.md +186 -0
  602. package/node_modules/http-errors/LICENSE +23 -0
  603. package/node_modules/http-errors/README.md +169 -0
  604. package/node_modules/http-errors/index.js +290 -0
  605. package/node_modules/http-errors/package.json +54 -0
  606. package/node_modules/iconv-lite/Changelog.md +162 -0
  607. package/node_modules/iconv-lite/LICENSE +21 -0
  608. package/node_modules/iconv-lite/README.md +156 -0
  609. package/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
  610. package/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
  611. package/node_modules/iconv-lite/encodings/index.js +22 -0
  612. package/node_modules/iconv-lite/encodings/internal.js +188 -0
  613. package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  614. package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  615. package/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
  616. package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  617. package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  618. package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  619. package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  620. package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  621. package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  622. package/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
  623. package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  624. package/node_modules/iconv-lite/encodings/utf16.js +177 -0
  625. package/node_modules/iconv-lite/encodings/utf7.js +290 -0
  626. package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  627. package/node_modules/iconv-lite/lib/extend-node.js +217 -0
  628. package/node_modules/iconv-lite/lib/index.d.ts +24 -0
  629. package/node_modules/iconv-lite/lib/index.js +153 -0
  630. package/node_modules/iconv-lite/lib/streams.js +121 -0
  631. package/node_modules/iconv-lite/package.json +46 -0
  632. package/node_modules/inherits/LICENSE +16 -0
  633. package/node_modules/inherits/README.md +42 -0
  634. package/node_modules/inherits/inherits.js +9 -0
  635. package/node_modules/inherits/inherits_browser.js +27 -0
  636. package/node_modules/inherits/package.json +29 -0
  637. package/node_modules/ipaddr.js/LICENSE +19 -0
  638. package/node_modules/ipaddr.js/README.md +233 -0
  639. package/node_modules/ipaddr.js/ipaddr.min.js +1 -0
  640. package/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
  641. package/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
  642. package/node_modules/ipaddr.js/package.json +35 -0
  643. package/node_modules/math-intrinsics/.eslintrc +16 -0
  644. package/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
  645. package/node_modules/math-intrinsics/CHANGELOG.md +24 -0
  646. package/node_modules/math-intrinsics/LICENSE +21 -0
  647. package/node_modules/math-intrinsics/README.md +50 -0
  648. package/node_modules/math-intrinsics/abs.d.ts +1 -0
  649. package/node_modules/math-intrinsics/abs.js +4 -0
  650. package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
  651. package/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
  652. package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
  653. package/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
  654. package/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
  655. package/node_modules/math-intrinsics/constants/maxValue.js +5 -0
  656. package/node_modules/math-intrinsics/floor.d.ts +1 -0
  657. package/node_modules/math-intrinsics/floor.js +4 -0
  658. package/node_modules/math-intrinsics/isFinite.d.ts +3 -0
  659. package/node_modules/math-intrinsics/isFinite.js +12 -0
  660. package/node_modules/math-intrinsics/isInteger.d.ts +3 -0
  661. package/node_modules/math-intrinsics/isInteger.js +16 -0
  662. package/node_modules/math-intrinsics/isNaN.d.ts +1 -0
  663. package/node_modules/math-intrinsics/isNaN.js +6 -0
  664. package/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
  665. package/node_modules/math-intrinsics/isNegativeZero.js +6 -0
  666. package/node_modules/math-intrinsics/max.d.ts +1 -0
  667. package/node_modules/math-intrinsics/max.js +4 -0
  668. package/node_modules/math-intrinsics/min.d.ts +1 -0
  669. package/node_modules/math-intrinsics/min.js +4 -0
  670. package/node_modules/math-intrinsics/mod.d.ts +3 -0
  671. package/node_modules/math-intrinsics/mod.js +9 -0
  672. package/node_modules/math-intrinsics/package.json +86 -0
  673. package/node_modules/math-intrinsics/pow.d.ts +1 -0
  674. package/node_modules/math-intrinsics/pow.js +4 -0
  675. package/node_modules/math-intrinsics/round.d.ts +1 -0
  676. package/node_modules/math-intrinsics/round.js +4 -0
  677. package/node_modules/math-intrinsics/sign.d.ts +3 -0
  678. package/node_modules/math-intrinsics/sign.js +11 -0
  679. package/node_modules/math-intrinsics/test/index.js +192 -0
  680. package/node_modules/math-intrinsics/tsconfig.json +3 -0
  681. package/node_modules/media-typer/HISTORY.md +22 -0
  682. package/node_modules/media-typer/LICENSE +22 -0
  683. package/node_modules/media-typer/README.md +81 -0
  684. package/node_modules/media-typer/index.js +270 -0
  685. package/node_modules/media-typer/package.json +26 -0
  686. package/node_modules/merge-descriptors/HISTORY.md +21 -0
  687. package/node_modules/merge-descriptors/LICENSE +23 -0
  688. package/node_modules/merge-descriptors/README.md +49 -0
  689. package/node_modules/merge-descriptors/index.js +60 -0
  690. package/node_modules/merge-descriptors/package.json +39 -0
  691. package/node_modules/methods/HISTORY.md +29 -0
  692. package/node_modules/methods/LICENSE +24 -0
  693. package/node_modules/methods/README.md +51 -0
  694. package/node_modules/methods/index.js +69 -0
  695. package/node_modules/methods/package.json +36 -0
  696. package/node_modules/mime/.npmignore +0 -0
  697. package/node_modules/mime/CHANGELOG.md +164 -0
  698. package/node_modules/mime/LICENSE +21 -0
  699. package/node_modules/mime/README.md +90 -0
  700. package/node_modules/mime/cli.js +8 -0
  701. package/node_modules/mime/mime.js +108 -0
  702. package/node_modules/mime/package.json +44 -0
  703. package/node_modules/mime/src/build.js +53 -0
  704. package/node_modules/mime/src/test.js +60 -0
  705. package/node_modules/mime/types.json +1 -0
  706. package/node_modules/mime-db/HISTORY.md +507 -0
  707. package/node_modules/mime-db/LICENSE +23 -0
  708. package/node_modules/mime-db/README.md +100 -0
  709. package/node_modules/mime-db/db.json +8519 -0
  710. package/node_modules/mime-db/index.js +12 -0
  711. package/node_modules/mime-db/package.json +60 -0
  712. package/node_modules/mime-types/HISTORY.md +397 -0
  713. package/node_modules/mime-types/LICENSE +23 -0
  714. package/node_modules/mime-types/README.md +113 -0
  715. package/node_modules/mime-types/index.js +188 -0
  716. package/node_modules/mime-types/package.json +44 -0
  717. package/node_modules/ms/index.js +152 -0
  718. package/node_modules/ms/license.md +21 -0
  719. package/node_modules/ms/package.json +37 -0
  720. package/node_modules/ms/readme.md +51 -0
  721. package/node_modules/negotiator/HISTORY.md +108 -0
  722. package/node_modules/negotiator/LICENSE +24 -0
  723. package/node_modules/negotiator/README.md +203 -0
  724. package/node_modules/negotiator/index.js +82 -0
  725. package/node_modules/negotiator/lib/charset.js +169 -0
  726. package/node_modules/negotiator/lib/encoding.js +184 -0
  727. package/node_modules/negotiator/lib/language.js +179 -0
  728. package/node_modules/negotiator/lib/mediaType.js +294 -0
  729. package/node_modules/negotiator/package.json +42 -0
  730. package/node_modules/object-assign/index.js +90 -0
  731. package/node_modules/object-assign/license +21 -0
  732. package/node_modules/object-assign/package.json +42 -0
  733. package/node_modules/object-assign/readme.md +61 -0
  734. package/node_modules/object-inspect/.eslintrc +53 -0
  735. package/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  736. package/node_modules/object-inspect/.nycrc +13 -0
  737. package/node_modules/object-inspect/CHANGELOG.md +424 -0
  738. package/node_modules/object-inspect/LICENSE +21 -0
  739. package/node_modules/object-inspect/example/all.js +23 -0
  740. package/node_modules/object-inspect/example/circular.js +6 -0
  741. package/node_modules/object-inspect/example/fn.js +5 -0
  742. package/node_modules/object-inspect/example/inspect.js +10 -0
  743. package/node_modules/object-inspect/index.js +544 -0
  744. package/node_modules/object-inspect/package-support.json +20 -0
  745. package/node_modules/object-inspect/package.json +105 -0
  746. package/node_modules/object-inspect/readme.markdown +84 -0
  747. package/node_modules/object-inspect/test/bigint.js +58 -0
  748. package/node_modules/object-inspect/test/browser/dom.js +15 -0
  749. package/node_modules/object-inspect/test/circular.js +16 -0
  750. package/node_modules/object-inspect/test/deep.js +12 -0
  751. package/node_modules/object-inspect/test/element.js +53 -0
  752. package/node_modules/object-inspect/test/err.js +48 -0
  753. package/node_modules/object-inspect/test/fakes.js +29 -0
  754. package/node_modules/object-inspect/test/fn.js +76 -0
  755. package/node_modules/object-inspect/test/global.js +17 -0
  756. package/node_modules/object-inspect/test/has.js +15 -0
  757. package/node_modules/object-inspect/test/holes.js +15 -0
  758. package/node_modules/object-inspect/test/indent-option.js +271 -0
  759. package/node_modules/object-inspect/test/inspect.js +139 -0
  760. package/node_modules/object-inspect/test/lowbyte.js +12 -0
  761. package/node_modules/object-inspect/test/number.js +58 -0
  762. package/node_modules/object-inspect/test/quoteStyle.js +26 -0
  763. package/node_modules/object-inspect/test/toStringTag.js +40 -0
  764. package/node_modules/object-inspect/test/undef.js +12 -0
  765. package/node_modules/object-inspect/test/values.js +261 -0
  766. package/node_modules/object-inspect/test-core-js.js +26 -0
  767. package/node_modules/object-inspect/util.inspect.js +1 -0
  768. package/node_modules/on-finished/HISTORY.md +98 -0
  769. package/node_modules/on-finished/LICENSE +23 -0
  770. package/node_modules/on-finished/README.md +162 -0
  771. package/node_modules/on-finished/index.js +234 -0
  772. package/node_modules/on-finished/package.json +39 -0
  773. package/node_modules/parseurl/HISTORY.md +58 -0
  774. package/node_modules/parseurl/LICENSE +24 -0
  775. package/node_modules/parseurl/README.md +133 -0
  776. package/node_modules/parseurl/index.js +158 -0
  777. package/node_modules/parseurl/package.json +40 -0
  778. package/node_modules/path-to-regexp/LICENSE +21 -0
  779. package/node_modules/path-to-regexp/Readme.md +35 -0
  780. package/node_modules/path-to-regexp/index.js +156 -0
  781. package/node_modules/path-to-regexp/package.json +30 -0
  782. package/node_modules/proxy-addr/HISTORY.md +161 -0
  783. package/node_modules/proxy-addr/LICENSE +22 -0
  784. package/node_modules/proxy-addr/README.md +139 -0
  785. package/node_modules/proxy-addr/index.js +327 -0
  786. package/node_modules/proxy-addr/package.json +47 -0
  787. package/node_modules/qs/.editorconfig +46 -0
  788. package/node_modules/qs/.github/FUNDING.yml +12 -0
  789. package/node_modules/qs/.github/SECURITY.md +11 -0
  790. package/node_modules/qs/.github/THREAT_MODEL.md +78 -0
  791. package/node_modules/qs/.nycrc +13 -0
  792. package/node_modules/qs/CHANGELOG.md +644 -0
  793. package/node_modules/qs/LICENSE.md +29 -0
  794. package/node_modules/qs/README.md +740 -0
  795. package/node_modules/qs/dist/qs.js +141 -0
  796. package/node_modules/qs/eslint.config.mjs +56 -0
  797. package/node_modules/qs/lib/formats.js +23 -0
  798. package/node_modules/qs/lib/index.js +11 -0
  799. package/node_modules/qs/lib/parse.js +371 -0
  800. package/node_modules/qs/lib/stringify.js +356 -0
  801. package/node_modules/qs/lib/utils.js +340 -0
  802. package/node_modules/qs/package.json +94 -0
  803. package/node_modules/qs/test/empty-keys-cases.js +267 -0
  804. package/node_modules/qs/test/parse.js +1512 -0
  805. package/node_modules/qs/test/stringify.js +1310 -0
  806. package/node_modules/qs/test/utils.js +397 -0
  807. package/node_modules/range-parser/HISTORY.md +56 -0
  808. package/node_modules/range-parser/LICENSE +23 -0
  809. package/node_modules/range-parser/README.md +84 -0
  810. package/node_modules/range-parser/index.js +162 -0
  811. package/node_modules/range-parser/package.json +44 -0
  812. package/node_modules/raw-body/LICENSE +22 -0
  813. package/node_modules/raw-body/README.md +223 -0
  814. package/node_modules/raw-body/index.d.ts +87 -0
  815. package/node_modules/raw-body/index.js +336 -0
  816. package/node_modules/raw-body/package.json +47 -0
  817. package/node_modules/safe-buffer/LICENSE +21 -0
  818. package/node_modules/safe-buffer/README.md +584 -0
  819. package/node_modules/safe-buffer/index.d.ts +187 -0
  820. package/node_modules/safe-buffer/index.js +65 -0
  821. package/node_modules/safe-buffer/package.json +51 -0
  822. package/node_modules/safer-buffer/LICENSE +21 -0
  823. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  824. package/node_modules/safer-buffer/Readme.md +156 -0
  825. package/node_modules/safer-buffer/dangerous.js +58 -0
  826. package/node_modules/safer-buffer/package.json +34 -0
  827. package/node_modules/safer-buffer/safer.js +77 -0
  828. package/node_modules/safer-buffer/tests.js +406 -0
  829. package/node_modules/send/HISTORY.md +538 -0
  830. package/node_modules/send/LICENSE +23 -0
  831. package/node_modules/send/README.md +327 -0
  832. package/node_modules/send/SECURITY.md +24 -0
  833. package/node_modules/send/index.js +1142 -0
  834. package/node_modules/send/node_modules/ms/index.js +162 -0
  835. package/node_modules/send/node_modules/ms/license.md +21 -0
  836. package/node_modules/send/node_modules/ms/package.json +38 -0
  837. package/node_modules/send/node_modules/ms/readme.md +59 -0
  838. package/node_modules/send/package.json +62 -0
  839. package/node_modules/serve-static/HISTORY.md +493 -0
  840. package/node_modules/serve-static/LICENSE +25 -0
  841. package/node_modules/serve-static/README.md +257 -0
  842. package/node_modules/serve-static/index.js +209 -0
  843. package/node_modules/serve-static/package.json +42 -0
  844. package/node_modules/setprototypeof/LICENSE +13 -0
  845. package/node_modules/setprototypeof/README.md +31 -0
  846. package/node_modules/setprototypeof/index.d.ts +2 -0
  847. package/node_modules/setprototypeof/index.js +17 -0
  848. package/node_modules/setprototypeof/package.json +38 -0
  849. package/node_modules/setprototypeof/test/index.js +24 -0
  850. package/node_modules/side-channel/.editorconfig +9 -0
  851. package/node_modules/side-channel/.eslintrc +12 -0
  852. package/node_modules/side-channel/.github/FUNDING.yml +12 -0
  853. package/node_modules/side-channel/.nycrc +13 -0
  854. package/node_modules/side-channel/CHANGELOG.md +110 -0
  855. package/node_modules/side-channel/LICENSE +21 -0
  856. package/node_modules/side-channel/README.md +61 -0
  857. package/node_modules/side-channel/index.d.ts +14 -0
  858. package/node_modules/side-channel/index.js +43 -0
  859. package/node_modules/side-channel/package.json +85 -0
  860. package/node_modules/side-channel/test/index.js +104 -0
  861. package/node_modules/side-channel/tsconfig.json +9 -0
  862. package/node_modules/side-channel-list/.editorconfig +9 -0
  863. package/node_modules/side-channel-list/.eslintrc +11 -0
  864. package/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  865. package/node_modules/side-channel-list/.nycrc +13 -0
  866. package/node_modules/side-channel-list/CHANGELOG.md +15 -0
  867. package/node_modules/side-channel-list/LICENSE +21 -0
  868. package/node_modules/side-channel-list/README.md +62 -0
  869. package/node_modules/side-channel-list/index.d.ts +13 -0
  870. package/node_modules/side-channel-list/index.js +113 -0
  871. package/node_modules/side-channel-list/list.d.ts +14 -0
  872. package/node_modules/side-channel-list/package.json +77 -0
  873. package/node_modules/side-channel-list/test/index.js +104 -0
  874. package/node_modules/side-channel-list/tsconfig.json +9 -0
  875. package/node_modules/side-channel-map/.editorconfig +9 -0
  876. package/node_modules/side-channel-map/.eslintrc +11 -0
  877. package/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
  878. package/node_modules/side-channel-map/.nycrc +13 -0
  879. package/node_modules/side-channel-map/CHANGELOG.md +22 -0
  880. package/node_modules/side-channel-map/LICENSE +21 -0
  881. package/node_modules/side-channel-map/README.md +62 -0
  882. package/node_modules/side-channel-map/index.d.ts +15 -0
  883. package/node_modules/side-channel-map/index.js +68 -0
  884. package/node_modules/side-channel-map/package.json +80 -0
  885. package/node_modules/side-channel-map/test/index.js +114 -0
  886. package/node_modules/side-channel-map/tsconfig.json +9 -0
  887. package/node_modules/side-channel-weakmap/.editorconfig +9 -0
  888. package/node_modules/side-channel-weakmap/.eslintrc +12 -0
  889. package/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
  890. package/node_modules/side-channel-weakmap/.nycrc +13 -0
  891. package/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
  892. package/node_modules/side-channel-weakmap/LICENSE +21 -0
  893. package/node_modules/side-channel-weakmap/README.md +62 -0
  894. package/node_modules/side-channel-weakmap/index.d.ts +15 -0
  895. package/node_modules/side-channel-weakmap/index.js +84 -0
  896. package/node_modules/side-channel-weakmap/package.json +87 -0
  897. package/node_modules/side-channel-weakmap/test/index.js +114 -0
  898. package/node_modules/side-channel-weakmap/tsconfig.json +9 -0
  899. package/node_modules/statuses/HISTORY.md +87 -0
  900. package/node_modules/statuses/LICENSE +23 -0
  901. package/node_modules/statuses/README.md +139 -0
  902. package/node_modules/statuses/codes.json +65 -0
  903. package/node_modules/statuses/index.js +146 -0
  904. package/node_modules/statuses/package.json +49 -0
  905. package/node_modules/toidentifier/HISTORY.md +9 -0
  906. package/node_modules/toidentifier/LICENSE +21 -0
  907. package/node_modules/toidentifier/README.md +61 -0
  908. package/node_modules/toidentifier/index.js +32 -0
  909. package/node_modules/toidentifier/package.json +38 -0
  910. package/node_modules/tweetnacl/AUTHORS.md +27 -0
  911. package/node_modules/tweetnacl/CHANGELOG.md +283 -0
  912. package/node_modules/tweetnacl/LICENSE +24 -0
  913. package/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
  914. package/node_modules/tweetnacl/README.md +494 -0
  915. package/node_modules/tweetnacl/nacl-fast.js +2391 -0
  916. package/node_modules/tweetnacl/nacl-fast.min.js +1 -0
  917. package/node_modules/tweetnacl/nacl.d.ts +98 -0
  918. package/node_modules/tweetnacl/nacl.js +1178 -0
  919. package/node_modules/tweetnacl/nacl.min.js +1 -0
  920. package/node_modules/tweetnacl/package.json +56 -0
  921. package/node_modules/type-is/HISTORY.md +259 -0
  922. package/node_modules/type-is/LICENSE +23 -0
  923. package/node_modules/type-is/README.md +170 -0
  924. package/node_modules/type-is/index.js +266 -0
  925. package/node_modules/type-is/package.json +45 -0
  926. package/node_modules/unpipe/HISTORY.md +4 -0
  927. package/node_modules/unpipe/LICENSE +22 -0
  928. package/node_modules/unpipe/README.md +43 -0
  929. package/node_modules/unpipe/index.js +69 -0
  930. package/node_modules/unpipe/package.json +27 -0
  931. package/node_modules/utils-merge/.npmignore +9 -0
  932. package/node_modules/utils-merge/LICENSE +20 -0
  933. package/node_modules/utils-merge/README.md +34 -0
  934. package/node_modules/utils-merge/index.js +23 -0
  935. package/node_modules/utils-merge/package.json +40 -0
  936. package/node_modules/vary/HISTORY.md +39 -0
  937. package/node_modules/vary/LICENSE +22 -0
  938. package/node_modules/vary/README.md +101 -0
  939. package/node_modules/vary/index.js +149 -0
  940. package/node_modules/vary/package.json +43 -0
  941. package/openclaw-skills/silicaclaw-bridge-setup/SKILL.md +147 -0
  942. package/openclaw-skills/silicaclaw-bridge-setup/VERSION +1 -0
  943. package/openclaw-skills/silicaclaw-bridge-setup/agents/openai.yaml +6 -0
  944. package/openclaw-skills/silicaclaw-bridge-setup/manifest.json +27 -0
  945. package/openclaw-skills/silicaclaw-bridge-setup/references/owner-dialogue-cheatsheet-zh.md +58 -0
  946. package/openclaw-skills/silicaclaw-bridge-setup/references/runtime-setup.md +43 -0
  947. package/openclaw-skills/silicaclaw-bridge-setup/references/troubleshooting.md +24 -0
  948. package/openclaw-skills/silicaclaw-broadcast/SKILL.md +132 -0
  949. package/openclaw-skills/silicaclaw-broadcast/VERSION +1 -1
  950. package/openclaw-skills/silicaclaw-broadcast/agents/openai.yaml +2 -2
  951. package/openclaw-skills/silicaclaw-broadcast/manifest.json +3 -2
  952. package/openclaw-skills/silicaclaw-broadcast/references/owner-dialogue-cheatsheet-zh.md +81 -0
  953. package/openclaw-skills/silicaclaw-owner-push/SKILL.md +217 -0
  954. package/openclaw-skills/silicaclaw-owner-push/VERSION +1 -0
  955. package/openclaw-skills/silicaclaw-owner-push/agents/openai.yaml +6 -0
  956. package/openclaw-skills/silicaclaw-owner-push/manifest.json +30 -0
  957. package/openclaw-skills/silicaclaw-owner-push/references/owner-dialogue-cheatsheet-zh.md +87 -0
  958. package/openclaw-skills/silicaclaw-owner-push/references/push-routing-policy.md +43 -0
  959. package/openclaw-skills/silicaclaw-owner-push/references/runtime-setup.md +41 -0
  960. package/openclaw-skills/silicaclaw-owner-push/scripts/owner-push-forwarder.mjs +214 -0
  961. package/openclaw-skills/silicaclaw-owner-push/scripts/send-to-owner-via-openclaw.mjs +69 -0
  962. package/package.json +24 -2
  963. package/packages/core/dist/config/silicaclaw-defaults.json +19 -0
  964. package/packages/core/dist/packages/core/src/crypto.d.ts +6 -0
  965. package/packages/core/dist/packages/core/src/crypto.js +50 -0
  966. package/packages/core/dist/packages/core/src/directory.d.ts +17 -0
  967. package/packages/core/dist/packages/core/src/directory.js +145 -0
  968. package/packages/core/dist/packages/core/src/identity.d.ts +2 -0
  969. package/packages/core/dist/packages/core/src/identity.js +18 -0
  970. package/packages/core/dist/packages/core/src/index.d.ts +12 -0
  971. package/packages/core/dist/packages/core/src/index.js +28 -0
  972. package/packages/core/dist/packages/core/src/indexing.d.ts +6 -0
  973. package/packages/core/dist/packages/core/src/indexing.js +43 -0
  974. package/packages/core/dist/packages/core/src/presence.d.ts +4 -0
  975. package/packages/core/dist/packages/core/src/presence.js +23 -0
  976. package/packages/core/dist/packages/core/src/profile.d.ts +4 -0
  977. package/packages/core/dist/packages/core/src/profile.js +39 -0
  978. package/packages/core/dist/packages/core/src/publicProfileSummary.d.ts +70 -0
  979. package/packages/core/dist/packages/core/src/publicProfileSummary.js +103 -0
  980. package/packages/core/dist/packages/core/src/socialConfig.d.ts +100 -0
  981. package/packages/core/dist/packages/core/src/socialConfig.js +300 -0
  982. package/packages/core/dist/packages/core/src/socialMessage.d.ts +19 -0
  983. package/packages/core/dist/packages/core/src/socialMessage.js +69 -0
  984. package/packages/core/dist/packages/core/src/socialResolver.d.ts +46 -0
  985. package/packages/core/dist/packages/core/src/socialResolver.js +237 -0
  986. package/packages/core/dist/packages/core/src/socialTemplate.d.ts +2 -0
  987. package/packages/core/dist/packages/core/src/socialTemplate.js +90 -0
  988. package/packages/core/dist/packages/core/src/types.d.ts +59 -0
  989. package/packages/core/dist/packages/core/src/types.js +2 -0
  990. package/packages/core/src/socialConfig.ts +7 -5
  991. package/packages/network/dist/config/silicaclaw-defaults.json +19 -0
  992. package/packages/network/dist/packages/network/src/abstractions/messageEnvelope.d.ts +28 -0
  993. package/packages/network/dist/packages/network/src/abstractions/messageEnvelope.js +36 -0
  994. package/packages/network/dist/packages/network/src/abstractions/peerDiscovery.d.ts +43 -0
  995. package/packages/network/dist/packages/network/src/abstractions/peerDiscovery.js +2 -0
  996. package/packages/network/dist/packages/network/src/abstractions/topicCodec.d.ts +4 -0
  997. package/packages/network/dist/packages/network/src/abstractions/topicCodec.js +2 -0
  998. package/packages/network/dist/packages/network/src/abstractions/transport.d.ts +36 -0
  999. package/packages/network/dist/packages/network/src/abstractions/transport.js +2 -0
  1000. package/packages/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.d.ts +5 -0
  1001. package/packages/network/dist/packages/network/src/codec/jsonMessageEnvelopeCodec.js +24 -0
  1002. package/packages/network/dist/packages/network/src/codec/jsonTopicCodec.d.ts +5 -0
  1003. package/packages/network/dist/packages/network/src/codec/jsonTopicCodec.js +12 -0
  1004. package/packages/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.d.ts +28 -0
  1005. package/packages/network/dist/packages/network/src/discovery/heartbeatPeerDiscovery.js +144 -0
  1006. package/packages/network/dist/packages/network/src/index.d.ts +14 -0
  1007. package/packages/network/dist/packages/network/src/index.js +30 -0
  1008. package/packages/network/dist/packages/network/src/localEventBus.d.ts +9 -0
  1009. package/packages/network/dist/packages/network/src/localEventBus.js +47 -0
  1010. package/packages/network/dist/packages/network/src/mock.d.ts +8 -0
  1011. package/packages/network/dist/packages/network/src/mock.js +24 -0
  1012. package/packages/network/dist/packages/network/src/realPreview.d.ts +105 -0
  1013. package/packages/network/dist/packages/network/src/realPreview.js +331 -0
  1014. package/packages/network/dist/packages/network/src/relayPreview.d.ts +166 -0
  1015. package/packages/network/dist/packages/network/src/relayPreview.js +448 -0
  1016. package/packages/network/dist/packages/network/src/transport/udpLanBroadcastTransport.d.ts +23 -0
  1017. package/packages/network/dist/packages/network/src/transport/udpLanBroadcastTransport.js +154 -0
  1018. package/packages/network/dist/packages/network/src/types.d.ts +6 -0
  1019. package/packages/network/dist/packages/network/src/types.js +2 -0
  1020. package/packages/network/dist/packages/network/src/webrtcPreview.d.ts +163 -0
  1021. package/packages/network/dist/packages/network/src/webrtcPreview.js +848 -0
  1022. package/packages/network/src/realPreview.ts +3 -2
  1023. package/packages/network/src/relayPreview.ts +5 -2
  1024. package/packages/network/src/transport/udpLanBroadcastTransport.ts +2 -1
  1025. package/packages/network/src/webrtcPreview.ts +2 -1
  1026. package/packages/storage/config/silicaclaw-defaults.json +19 -0
  1027. package/packages/storage/dist/config/silicaclaw-defaults.json +19 -0
  1028. package/packages/storage/dist/packages/core/src/crypto.d.ts +6 -0
  1029. package/packages/storage/dist/packages/core/src/crypto.js +50 -0
  1030. package/packages/storage/dist/packages/core/src/directory.d.ts +17 -0
  1031. package/packages/storage/dist/packages/core/src/directory.js +145 -0
  1032. package/packages/storage/dist/packages/core/src/identity.d.ts +2 -0
  1033. package/packages/storage/dist/packages/core/src/identity.js +18 -0
  1034. package/packages/storage/dist/packages/core/src/index.d.ts +12 -0
  1035. package/packages/storage/dist/packages/core/src/index.js +28 -0
  1036. package/packages/storage/dist/packages/core/src/indexing.d.ts +6 -0
  1037. package/packages/storage/dist/packages/core/src/indexing.js +43 -0
  1038. package/packages/storage/dist/packages/core/src/presence.d.ts +4 -0
  1039. package/packages/storage/dist/packages/core/src/presence.js +23 -0
  1040. package/packages/storage/dist/packages/core/src/profile.d.ts +4 -0
  1041. package/packages/storage/dist/packages/core/src/profile.js +39 -0
  1042. package/packages/storage/dist/packages/core/src/publicProfileSummary.d.ts +70 -0
  1043. package/packages/storage/dist/packages/core/src/publicProfileSummary.js +103 -0
  1044. package/packages/storage/dist/packages/core/src/socialConfig.d.ts +100 -0
  1045. package/packages/storage/dist/packages/core/src/socialConfig.js +300 -0
  1046. package/packages/storage/dist/packages/core/src/socialMessage.d.ts +19 -0
  1047. package/packages/storage/dist/packages/core/src/socialMessage.js +69 -0
  1048. package/packages/storage/dist/packages/core/src/socialResolver.d.ts +46 -0
  1049. package/packages/storage/dist/packages/core/src/socialResolver.js +237 -0
  1050. package/packages/storage/dist/packages/core/src/socialTemplate.d.ts +2 -0
  1051. package/packages/storage/dist/packages/core/src/socialTemplate.js +90 -0
  1052. package/packages/storage/dist/packages/core/src/types.d.ts +59 -0
  1053. package/packages/storage/dist/packages/core/src/types.js +2 -0
  1054. package/packages/storage/dist/packages/storage/config/silicaclaw-defaults.json +19 -0
  1055. package/packages/storage/dist/packages/storage/src/index.d.ts +3 -0
  1056. package/packages/storage/dist/packages/storage/src/index.js +19 -0
  1057. package/packages/storage/dist/packages/storage/src/jsonRepo.d.ts +7 -0
  1058. package/packages/storage/dist/packages/storage/src/jsonRepo.js +29 -0
  1059. package/packages/storage/dist/packages/storage/src/repos.d.ts +61 -0
  1060. package/packages/storage/dist/packages/storage/src/repos.js +67 -0
  1061. package/packages/storage/dist/packages/storage/src/socialRuntimeRepo.d.ts +5 -0
  1062. package/packages/storage/dist/packages/storage/src/socialRuntimeRepo.js +57 -0
  1063. package/packages/storage/dist/socialRuntimeRepo.js +8 -4
  1064. package/packages/storage/src/socialRuntimeRepo.ts +5 -4
  1065. package/packages/storage/tsconfig.json +1 -6
  1066. package/scripts/functional-check.mjs +35 -6
  1067. package/scripts/install-openclaw-skill.mjs +9 -2
  1068. package/scripts/openclaw-bridge-adapter.mjs +3 -1
  1069. package/scripts/openclaw-bridge-client.mjs +3 -1
  1070. package/scripts/openclaw-runtime-demo.mjs +3 -1
  1071. package/scripts/quickstart.sh +14 -10
  1072. package/scripts/release-pack.mjs +147 -0
  1073. package/scripts/silicaclaw-cli.mjs +75 -31
  1074. package/scripts/silicaclaw-gateway.mjs +369 -94
  1075. package/scripts/validate-openclaw-skill.mjs +79 -21
@@ -0,0 +1,3101 @@
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.LocalNodeService = void 0;
7
+ exports.main = main;
8
+ const express_1 = __importDefault(require("express"));
9
+ const cors_1 = __importDefault(require("cors"));
10
+ const child_process_1 = require("child_process");
11
+ const path_1 = require("path");
12
+ const fs_1 = require("fs");
13
+ const crypto_1 = require("crypto");
14
+ const os_1 = require("os");
15
+ const util_1 = require("util");
16
+ const silicaclaw_defaults_json_1 = __importDefault(require("../../../config/silicaclaw-defaults.json"));
17
+ const core_1 = require("@silicaclaw/core");
18
+ const network_1 = require("@silicaclaw/network");
19
+ const storage_1 = require("@silicaclaw/storage");
20
+ const socialRoutes_1 = require("./socialRoutes");
21
+ const BROADCAST_INTERVAL_MS = Number(process.env.BROADCAST_INTERVAL_MS || 20_000);
22
+ const PRESENCE_TTL_MS = Number(process.env.PRESENCE_TTL_MS || 90_000);
23
+ const NETWORK_MAX_MESSAGE_BYTES = Number(process.env.NETWORK_MAX_MESSAGE_BYTES || 64 * 1024);
24
+ const NETWORK_DEDUPE_WINDOW_MS = Number(process.env.NETWORK_DEDUPE_WINDOW_MS || 90_000);
25
+ const NETWORK_DEDUPE_MAX_ENTRIES = Number(process.env.NETWORK_DEDUPE_MAX_ENTRIES || 10_000);
26
+ const NETWORK_MAX_FUTURE_DRIFT_MS = Number(process.env.NETWORK_MAX_FUTURE_DRIFT_MS || 30_000);
27
+ const NETWORK_MAX_PAST_DRIFT_MS = Number(process.env.NETWORK_MAX_PAST_DRIFT_MS || 120_000);
28
+ const NETWORK_HEARTBEAT_INTERVAL_MS = Number(process.env.NETWORK_HEARTBEAT_INTERVAL_MS || 12_000);
29
+ const NETWORK_PEER_STALE_AFTER_MS = Number(process.env.NETWORK_PEER_STALE_AFTER_MS || 45_000);
30
+ const OPENCLAW_GATEWAY_HOST = "127.0.0.1";
31
+ const DEFAULT_NETWORK_MODE = silicaclaw_defaults_json_1.default.network.default_mode;
32
+ const DEFAULT_NETWORK_NAMESPACE = silicaclaw_defaults_json_1.default.network.default_namespace;
33
+ const DEFAULT_NETWORK_PORT = silicaclaw_defaults_json_1.default.ports.network_default;
34
+ const DEFAULT_GLOBAL_SIGNALING_URL = silicaclaw_defaults_json_1.default.network.global_preview.relay_url;
35
+ const DEFAULT_GLOBAL_ROOM = silicaclaw_defaults_json_1.default.network.global_preview.room;
36
+ const DEFAULT_BRIDGE_API_BASE = silicaclaw_defaults_json_1.default.bridge.api_base;
37
+ const OPENCLAW_GATEWAY_PORT = silicaclaw_defaults_json_1.default.ports.openclaw_gateway;
38
+ const OPENCLAW_GATEWAY_URL = `http://${OPENCLAW_GATEWAY_HOST}:${OPENCLAW_GATEWAY_PORT}/`;
39
+ const NETWORK_PEER_REMOVE_AFTER_MS = Number(process.env.NETWORK_PEER_REMOVE_AFTER_MS || 180_000);
40
+ const NETWORK_UDP_BIND_ADDRESS = process.env.NETWORK_UDP_BIND_ADDRESS || "0.0.0.0";
41
+ const NETWORK_UDP_BROADCAST_ADDRESS = process.env.NETWORK_UDP_BROADCAST_ADDRESS || "255.255.255.255";
42
+ const NETWORK_PEER_ID = process.env.NETWORK_PEER_ID;
43
+ const NETWORK_MODE = process.env.NETWORK_MODE || "";
44
+ const WEBRTC_SIGNALING_URL = process.env.WEBRTC_SIGNALING_URL || DEFAULT_GLOBAL_SIGNALING_URL;
45
+ const WEBRTC_SIGNALING_URLS = process.env.WEBRTC_SIGNALING_URLS || "";
46
+ const WEBRTC_ROOM = process.env.WEBRTC_ROOM || DEFAULT_GLOBAL_ROOM;
47
+ const WEBRTC_SEED_PEERS = process.env.WEBRTC_SEED_PEERS || "";
48
+ const WEBRTC_BOOTSTRAP_HINTS = process.env.WEBRTC_BOOTSTRAP_HINTS || "";
49
+ const PROFILE_VERSION = "v0.9";
50
+ const SOCIAL_MESSAGE_TOPIC = "social.message";
51
+ const SOCIAL_MESSAGE_OBSERVATION_TOPIC = "social.message.observation";
52
+ const DEFAULT_SOCIAL_MESSAGE_CHANNEL = "global";
53
+ const SOCIAL_MESSAGE_MAX_BODY_CHARS = Number(process.env.SOCIAL_MESSAGE_MAX_BODY_CHARS || 500);
54
+ const SOCIAL_MESSAGE_HISTORY_LIMIT = Number(process.env.SOCIAL_MESSAGE_HISTORY_LIMIT || 100);
55
+ const SOCIAL_MESSAGE_SEND_WINDOW_MS = Number(process.env.SOCIAL_MESSAGE_SEND_WINDOW_MS || 60_000);
56
+ const SOCIAL_MESSAGE_SEND_MAX_PER_WINDOW = Number(process.env.SOCIAL_MESSAGE_SEND_MAX_PER_WINDOW || 5);
57
+ const SOCIAL_MESSAGE_RECEIVE_WINDOW_MS = Number(process.env.SOCIAL_MESSAGE_RECEIVE_WINDOW_MS || 60_000);
58
+ const SOCIAL_MESSAGE_RECEIVE_MAX_PER_WINDOW = Number(process.env.SOCIAL_MESSAGE_RECEIVE_MAX_PER_WINDOW || 8);
59
+ const SOCIAL_MESSAGE_DUPLICATE_WINDOW_MS = Number(process.env.SOCIAL_MESSAGE_DUPLICATE_WINDOW_MS || 180_000);
60
+ const SOCIAL_MESSAGE_MAX_FUTURE_MS = Number(process.env.SOCIAL_MESSAGE_MAX_FUTURE_MS || 30_000);
61
+ const SOCIAL_MESSAGE_MAX_AGE_MS = Number(process.env.SOCIAL_MESSAGE_MAX_AGE_MS || 15 * 60_000);
62
+ const SOCIAL_MESSAGE_OBSERVATION_HISTORY_LIMIT = Number(process.env.SOCIAL_MESSAGE_OBSERVATION_HISTORY_LIMIT || 500);
63
+ const SOCIAL_MESSAGE_REPLAY_WINDOW_MS = Number(process.env.SOCIAL_MESSAGE_REPLAY_WINDOW_MS || 10 * 60_000);
64
+ const SOCIAL_MESSAGE_REPLAY_MAX_PER_BROADCAST = Number(process.env.SOCIAL_MESSAGE_REPLAY_MAX_PER_BROADCAST || 3);
65
+ const SOCIAL_MESSAGE_BLOCKED_AGENT_IDS = new Set(dedupeStrings(parseListEnv(process.env.SOCIAL_MESSAGE_BLOCKED_AGENT_IDS || "")));
66
+ const SOCIAL_MESSAGE_BLOCKED_TERMS = dedupeStrings(parseListEnv(process.env.SOCIAL_MESSAGE_BLOCKED_TERMS || ""))
67
+ .map((term) => term.trim().toLowerCase())
68
+ .filter(Boolean);
69
+ const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
70
+ const OPENCLAW_SKILL_NAME = "silicaclaw-broadcast";
71
+ function readWorkspaceVersion(workspaceRoot) {
72
+ const candidates = [
73
+ workspaceRoot,
74
+ process.cwd(),
75
+ (0, path_1.resolve)(__dirname, "..", "..", ".."),
76
+ (0, path_1.resolve)(__dirname, "..", "..", "..", ".."),
77
+ ].filter((dir, index, list) => dir && list.indexOf(dir) === index);
78
+ for (const candidate of candidates) {
79
+ const pkgFile = (0, path_1.resolve)(candidate, "package.json");
80
+ if ((0, fs_1.existsSync)(pkgFile)) {
81
+ try {
82
+ const pkg = JSON.parse((0, fs_1.readFileSync)(pkgFile, "utf8"));
83
+ if (pkg.version && (pkg.name === "@silicaclaw/cli" || (0, fs_1.existsSync)((0, path_1.resolve)(candidate, "apps", "local-console")))) {
84
+ return String(pkg.version);
85
+ }
86
+ }
87
+ catch {
88
+ // ignore
89
+ }
90
+ }
91
+ const versionFile = (0, path_1.resolve)(candidate, "VERSION");
92
+ if ((0, fs_1.existsSync)(versionFile)) {
93
+ const raw = (0, fs_1.readFileSync)(versionFile, "utf8").trim();
94
+ if (raw)
95
+ return raw;
96
+ }
97
+ }
98
+ return "unknown";
99
+ }
100
+ function normalizeVersionText(value) {
101
+ const text = String(value || "").trim();
102
+ return text.startsWith("v") ? text.slice(1) : text;
103
+ }
104
+ function tokenizeVersion(value) {
105
+ return normalizeVersionText(value)
106
+ .split(/[^0-9A-Za-z]+/)
107
+ .map((token) => token.trim())
108
+ .filter(Boolean)
109
+ .map((token) => (/^\d+$/.test(token) ? Number(token) : token.toLowerCase()));
110
+ }
111
+ function compareVersionTokens(left, right) {
112
+ const leftTokens = tokenizeVersion(left);
113
+ const rightTokens = tokenizeVersion(right);
114
+ const maxLength = Math.max(leftTokens.length, rightTokens.length);
115
+ for (let index = 0; index < maxLength; index += 1) {
116
+ const leftToken = leftTokens[index];
117
+ const rightToken = rightTokens[index];
118
+ if (leftToken === undefined && rightToken === undefined)
119
+ return 0;
120
+ if (leftToken === undefined)
121
+ return -1;
122
+ if (rightToken === undefined)
123
+ return 1;
124
+ if (typeof leftToken === "number" && typeof rightToken === "number") {
125
+ if (leftToken !== rightToken)
126
+ return leftToken > rightToken ? 1 : -1;
127
+ continue;
128
+ }
129
+ const leftText = String(leftToken);
130
+ const rightText = String(rightToken);
131
+ if (leftText !== rightText)
132
+ return leftText.localeCompare(rightText);
133
+ }
134
+ return 0;
135
+ }
136
+ function resolveWorkspaceRoot(cwd = process.cwd()) {
137
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(cwd, "apps", "local-console", "package.json"))) {
138
+ return cwd;
139
+ }
140
+ const candidate = (0, path_1.resolve)(cwd, "..", "..");
141
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(candidate, "apps", "local-console", "package.json"))) {
142
+ return candidate;
143
+ }
144
+ return cwd;
145
+ }
146
+ function resolveProjectRoot(appRoot, cwd = process.cwd()) {
147
+ const envRoot = String(process.env.SILICACLAW_WORKSPACE_DIR || "").trim();
148
+ if (envRoot) {
149
+ return (0, path_1.resolve)(envRoot);
150
+ }
151
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(appRoot, "apps", "local-console", "package.json")) &&
152
+ (0, fs_1.existsSync)((0, path_1.resolve)(appRoot, "package.json"))) {
153
+ return appRoot;
154
+ }
155
+ if (!(0, fs_1.existsSync)((0, path_1.resolve)(cwd, "apps", "local-console", "package.json"))) {
156
+ return (0, path_1.resolve)(cwd);
157
+ }
158
+ return appRoot;
159
+ }
160
+ function resolveStorageRoot(workspaceRoot, cwd = process.cwd()) {
161
+ const home = process.env.HOME || (0, os_1.homedir)();
162
+ if (home) {
163
+ return (0, path_1.resolve)(home, ".silicaclaw", "local-console");
164
+ }
165
+ const appRoot = (0, path_1.resolve)(workspaceRoot, "apps", "local-console");
166
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(appRoot, "package.json"))) {
167
+ return appRoot;
168
+ }
169
+ return cwd;
170
+ }
171
+ function defaultOpenClawSourceDir(rootDir) {
172
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(rootDir, "openclaw.mjs")) || (0, fs_1.existsSync)((0, path_1.resolve)(rootDir, "package.json"))) {
173
+ return rootDir;
174
+ }
175
+ return (0, path_1.resolve)(rootDir, "..", "openclaw");
176
+ }
177
+ function resolveExecutableInPath(binName) {
178
+ const pathValue = String(process.env.PATH || "").trim();
179
+ if (!pathValue)
180
+ return null;
181
+ const pathEntries = pathValue.split(":").map((item) => item.trim()).filter(Boolean);
182
+ for (const entry of pathEntries) {
183
+ const candidate = (0, path_1.resolve)(entry, binName);
184
+ if (!(0, fs_1.existsSync)(candidate))
185
+ continue;
186
+ try {
187
+ (0, fs_1.accessSync)(candidate, fs_1.constants.X_OK);
188
+ return candidate;
189
+ }
190
+ catch {
191
+ // ignore non-executable matches
192
+ }
193
+ }
194
+ return null;
195
+ }
196
+ function existingPathOrNull(filePath) {
197
+ return (0, fs_1.existsSync)(filePath) ? filePath : null;
198
+ }
199
+ function listDirectories(root) {
200
+ if (!root || !(0, fs_1.existsSync)(root))
201
+ return [];
202
+ try {
203
+ return (0, fs_1.readdirSync)(root)
204
+ .map((name) => {
205
+ const fullPath = (0, path_1.resolve)(root, name);
206
+ try {
207
+ return (0, fs_1.statSync)(fullPath).isDirectory() ? { name, path: fullPath } : null;
208
+ }
209
+ catch {
210
+ return null;
211
+ }
212
+ })
213
+ .filter((item) => Boolean(item));
214
+ }
215
+ catch {
216
+ return [];
217
+ }
218
+ }
219
+ function readJsonFileSafe(filePath) {
220
+ try {
221
+ return JSON.parse((0, fs_1.readFileSync)(filePath, "utf8"));
222
+ }
223
+ catch {
224
+ return null;
225
+ }
226
+ }
227
+ function summarizeSkillReadme(filePath) {
228
+ if (!filePath || !(0, fs_1.existsSync)(filePath))
229
+ return "";
230
+ try {
231
+ const raw = (0, fs_1.readFileSync)(filePath, "utf8");
232
+ const lines = raw
233
+ .split(/\r?\n/)
234
+ .map((line) => line.trim())
235
+ .filter(Boolean)
236
+ .filter((line) => !line.startsWith("#"));
237
+ return String(lines[0] || "").slice(0, 220);
238
+ }
239
+ catch {
240
+ return "";
241
+ }
242
+ }
243
+ function readDialogueCheatsheetPreview(filePath, limit = 6) {
244
+ if (!filePath || !(0, fs_1.existsSync)(filePath))
245
+ return [];
246
+ try {
247
+ return (0, fs_1.readFileSync)(filePath, "utf8")
248
+ .split(/\r?\n/)
249
+ .map((line) => line.trim())
250
+ .filter((line) => line.startsWith("- "))
251
+ .map((line) => line.slice(2).trim())
252
+ .filter(Boolean)
253
+ .slice(0, limit);
254
+ }
255
+ catch {
256
+ return [];
257
+ }
258
+ }
259
+ function readDialogueCheatsheetSections(filePath, maxSections = 3, maxItemsPerSection = 5) {
260
+ if (!filePath || !(0, fs_1.existsSync)(filePath))
261
+ return [];
262
+ try {
263
+ const lines = (0, fs_1.readFileSync)(filePath, "utf8").split(/\r?\n/);
264
+ const sections = [];
265
+ let current = null;
266
+ for (const rawLine of lines) {
267
+ const line = rawLine.trim();
268
+ if (line.startsWith("## ")) {
269
+ if (current && current.items.length)
270
+ sections.push(current);
271
+ current = { title: line.slice(3).trim(), items: [] };
272
+ continue;
273
+ }
274
+ if (line.startsWith("- ")) {
275
+ if (!current) {
276
+ current = { title: "Examples", items: [] };
277
+ }
278
+ if (current.items.length < maxItemsPerSection) {
279
+ current.items.push(line.slice(2).trim());
280
+ }
281
+ }
282
+ }
283
+ if (current && current.items.length)
284
+ sections.push(current);
285
+ return sections.slice(0, maxSections);
286
+ }
287
+ catch {
288
+ return [];
289
+ }
290
+ }
291
+ function detectOpenClawInstallation(workspaceRoot) {
292
+ const workspaceDir = (0, path_1.resolve)(workspaceRoot, ".openclaw");
293
+ const homeDir = (0, path_1.resolve)(process.env.HOME || "", ".openclaw");
294
+ const commandPath = resolveExecutableInPath("openclaw");
295
+ const workspaceIdentityPath = existingPathOrNull((0, path_1.resolve)(workspaceDir, "identity.json"));
296
+ const workspaceProfilePath = existingPathOrNull((0, path_1.resolve)(workspaceDir, "profile.json"));
297
+ const workspaceSocialPath = existingPathOrNull((0, path_1.resolve)(workspaceDir, "social.md"));
298
+ const workspaceSkillsPath = existingPathOrNull((0, path_1.resolve)(workspaceDir, "skills"));
299
+ const homeIdentityPath = existingPathOrNull((0, path_1.resolve)(homeDir, "identity.json"));
300
+ const homeProfilePath = existingPathOrNull((0, path_1.resolve)(homeDir, "profile.json"));
301
+ const homeSocialPath = existingPathOrNull((0, path_1.resolve)(homeDir, "social.md"));
302
+ const homeSkillsPath = existingPathOrNull((0, path_1.resolve)(homeDir, "skills"));
303
+ const workspaceDetected = Boolean((0, fs_1.existsSync)(workspaceDir) ||
304
+ workspaceIdentityPath ||
305
+ workspaceProfilePath ||
306
+ workspaceSocialPath ||
307
+ workspaceSkillsPath);
308
+ const homeDetected = Boolean((0, fs_1.existsSync)(homeDir) || homeIdentityPath || homeProfilePath || homeSocialPath || homeSkillsPath);
309
+ return {
310
+ detected: Boolean(commandPath || workspaceDetected || homeDetected),
311
+ detection_mode: commandPath
312
+ ? "command"
313
+ : workspaceDetected
314
+ ? "workspace"
315
+ : homeDetected
316
+ ? "home"
317
+ : "not_found",
318
+ command_path: commandPath,
319
+ workspace_dir: workspaceDir,
320
+ home_dir: homeDir,
321
+ workspace_dir_exists: (0, fs_1.existsSync)(workspaceDir),
322
+ home_dir_exists: (0, fs_1.existsSync)(homeDir),
323
+ workspace_identity_path: workspaceIdentityPath,
324
+ workspace_profile_path: workspaceProfilePath,
325
+ workspace_social_path: workspaceSocialPath,
326
+ workspace_skills_path: workspaceSkillsPath,
327
+ home_identity_path: homeIdentityPath,
328
+ home_profile_path: homeProfilePath,
329
+ home_social_path: homeSocialPath,
330
+ home_skills_path: homeSkillsPath,
331
+ };
332
+ }
333
+ function readOpenClawConfiguredGateway(workspaceRoot) {
334
+ const configuredSourceDir = String(process.env.OPENCLAW_SOURCE_DIR || "").trim();
335
+ const defaultSourceDir = defaultOpenClawSourceDir(workspaceRoot);
336
+ const sourceDir = configuredSourceDir || defaultSourceDir;
337
+ const homeDir = (0, path_1.resolve)(process.env.HOME || "", ".openclaw");
338
+ const explicitConfigPath = String(process.env.OPENCLAW_CONFIG_PATH || "").trim();
339
+ const explicitStateDir = String(process.env.OPENCLAW_STATE_DIR || "").trim();
340
+ const candidates = dedupeStrings([
341
+ explicitConfigPath,
342
+ explicitStateDir ? (0, path_1.resolve)(explicitStateDir, "openclaw.json") : "",
343
+ (0, path_1.resolve)(homeDir, "openclaw.json"),
344
+ (0, path_1.resolve)(homeDir, "clawdbot.json"),
345
+ (0, path_1.resolve)(sourceDir, ".openclaw", "openclaw.json"),
346
+ ]);
347
+ for (const candidate of candidates) {
348
+ if (!candidate || !(0, fs_1.existsSync)(candidate))
349
+ continue;
350
+ try {
351
+ const raw = (0, fs_1.readFileSync)(candidate, "utf8");
352
+ const portMatch = raw.match(/["']?port["']?\s*:\s*(\d{2,5})/);
353
+ const bindMatch = raw.match(/["']?bind["']?\s*:\s*["']([^"']+)["']/);
354
+ const port = portMatch ? Number(portMatch[1]) : OPENCLAW_GATEWAY_PORT;
355
+ if (!Number.isFinite(port) || port <= 0)
356
+ continue;
357
+ return {
358
+ config_path: candidate,
359
+ gateway_port: port,
360
+ gateway_host: OPENCLAW_GATEWAY_HOST,
361
+ gateway_bind: bindMatch?.[1] || null,
362
+ gateway_url: `http://${OPENCLAW_GATEWAY_HOST}:${port}/`,
363
+ };
364
+ }
365
+ catch {
366
+ continue;
367
+ }
368
+ }
369
+ return {
370
+ config_path: null,
371
+ gateway_port: OPENCLAW_GATEWAY_PORT,
372
+ gateway_host: OPENCLAW_GATEWAY_HOST,
373
+ gateway_bind: null,
374
+ gateway_url: OPENCLAW_GATEWAY_URL,
375
+ };
376
+ }
377
+ function detectOpenClawRuntime(workspaceRoot) {
378
+ const configuredGateway = readOpenClawConfiguredGateway(workspaceRoot);
379
+ const result = (0, child_process_1.spawnSync)("ps", ["-Ao", "pid=,ppid=,command="], {
380
+ encoding: "utf8",
381
+ });
382
+ const stdout = String(result.stdout || "");
383
+ const lines = stdout
384
+ .split("\n")
385
+ .map((line) => line.trim())
386
+ .filter(Boolean);
387
+ const processes = lines
388
+ .map((line) => {
389
+ const match = line.match(/^(\d+)\s+(\d+)\s+(.+)$/);
390
+ if (!match)
391
+ return null;
392
+ const command = match[3] || "";
393
+ const lower = command.toLowerCase();
394
+ const isOpenClaw = lower.includes(" openclaw ") ||
395
+ lower.endsWith(" openclaw") ||
396
+ lower.includes("/openclaw ") ||
397
+ lower.includes("openclaw.mjs") ||
398
+ lower.includes("openclaw gateway") ||
399
+ lower.includes("openclaw agent") ||
400
+ lower.includes("openclaw message");
401
+ if (!isOpenClaw)
402
+ return null;
403
+ return {
404
+ pid: Number(match[1]),
405
+ ppid: Number(match[2]),
406
+ command,
407
+ };
408
+ })
409
+ .filter((item) => Boolean(item));
410
+ const openclawPids = new Set(processes.map((item) => item.pid));
411
+ const gatewayProbe = (0, child_process_1.spawnSync)("lsof", ["-nP", "-iTCP", "-sTCP:LISTEN"], {
412
+ encoding: "utf8",
413
+ });
414
+ const gatewayLines = String(gatewayProbe.stdout || "")
415
+ .split("\n")
416
+ .map((line) => line.trim())
417
+ .filter(Boolean);
418
+ const gatewayListeners = gatewayLines
419
+ .slice(1)
420
+ .map((line) => {
421
+ const parts = line.split(/\s+/);
422
+ const pid = Number(parts[1] || 0);
423
+ const command = parts[0] || "";
424
+ const lowerCommand = command.toLowerCase();
425
+ const endpoint = parts[8] || parts[parts.length - 1] || "";
426
+ const portMatch = endpoint.match(/:(\d+)(?:\s*\(|$)/);
427
+ if (!pid || !command || !portMatch)
428
+ return null;
429
+ const isOpenClawListener = openclawPids.has(pid) ||
430
+ lowerCommand.includes("openclaw");
431
+ if (!isOpenClawListener)
432
+ return null;
433
+ const port = Number(portMatch[1]);
434
+ if (!Number.isFinite(port) || port <= 0)
435
+ return null;
436
+ return {
437
+ pid,
438
+ ppid: 0,
439
+ port,
440
+ command: `${command} listening on ${OPENCLAW_GATEWAY_HOST}:${port}`,
441
+ };
442
+ })
443
+ .filter((item) => Boolean(item));
444
+ const preferredListener = gatewayListeners.find((item) => item.port === configuredGateway.gateway_port) ||
445
+ gatewayListeners[0] ||
446
+ null;
447
+ const combinedProcesses = new Map();
448
+ for (const process of [...processes, ...gatewayListeners]) {
449
+ if (!combinedProcesses.has(process.pid)) {
450
+ combinedProcesses.set(process.pid, process);
451
+ continue;
452
+ }
453
+ const current = combinedProcesses.get(process.pid);
454
+ if (current && current.command.length < process.command.length) {
455
+ combinedProcesses.set(process.pid, process);
456
+ }
457
+ }
458
+ const allProcesses = Array.from(combinedProcesses.values());
459
+ const gatewayReachable = gatewayListeners.length > 0;
460
+ const detectionNotes = [];
461
+ if (result.status !== 0)
462
+ detectionNotes.push(String(result.stderr || "ps failed").trim());
463
+ if (gatewayProbe.status !== 0 && gatewayLines.length === 0) {
464
+ detectionNotes.push(String(gatewayProbe.stderr || "lsof failed").trim());
465
+ }
466
+ const gatewayPort = preferredListener?.port || configuredGateway.gateway_port;
467
+ const gatewayUrl = `http://${OPENCLAW_GATEWAY_HOST}:${gatewayPort}/`;
468
+ return {
469
+ running: allProcesses.length > 0 || gatewayReachable,
470
+ process_count: allProcesses.length,
471
+ processes: allProcesses.slice(0, 10),
472
+ detection_error: detectionNotes.filter(Boolean).join(" | ") || null,
473
+ gateway_url: gatewayUrl,
474
+ gateway_port: gatewayPort,
475
+ gateway_reachable: gatewayReachable,
476
+ configured_gateway_url: configuredGateway.gateway_url,
477
+ configured_gateway_port: configuredGateway.gateway_port,
478
+ configured_gateway_bind: configuredGateway.gateway_bind,
479
+ configured_gateway_config_path: configuredGateway.config_path,
480
+ detection_mode: processes.length > 0 && gatewayReachable
481
+ ? "process+gateway"
482
+ : gatewayReachable
483
+ ? "gateway"
484
+ : processes.length > 0
485
+ ? "process"
486
+ : "not_running",
487
+ };
488
+ }
489
+ function detectOpenClawSkillInstallation() {
490
+ const homeDir = (0, path_1.resolve)(process.env.HOME || "", ".openclaw");
491
+ const workspaceSkillRoot = (0, path_1.resolve)(homeDir, "workspace", "skills");
492
+ const legacySkillRoot = (0, path_1.resolve)(homeDir, "skills");
493
+ const workspaceSkillPath = (0, path_1.resolve)(workspaceSkillRoot, OPENCLAW_SKILL_NAME, "SKILL.md");
494
+ const legacySkillPath = (0, path_1.resolve)(legacySkillRoot, OPENCLAW_SKILL_NAME, "SKILL.md");
495
+ const workspaceInstalled = (0, fs_1.existsSync)(workspaceSkillPath);
496
+ const legacyInstalled = (0, fs_1.existsSync)(legacySkillPath);
497
+ return {
498
+ installed: workspaceInstalled || legacyInstalled,
499
+ install_mode: workspaceInstalled ? "workspace" : legacyInstalled ? "legacy" : "not_installed",
500
+ workspace_skill_root: workspaceSkillRoot,
501
+ legacy_skill_root: legacySkillRoot,
502
+ workspace_skill_path: workspaceInstalled ? workspaceSkillPath : null,
503
+ legacy_skill_path: legacyInstalled ? legacySkillPath : null,
504
+ };
505
+ }
506
+ function detectOwnerDeliveryStatus(params) {
507
+ const forwardCommand = String(process.env.OPENCLAW_OWNER_FORWARD_CMD || "").trim();
508
+ const ownerChannel = String(process.env.OPENCLAW_OWNER_CHANNEL || "").trim();
509
+ const ownerTarget = String(process.env.OPENCLAW_OWNER_TARGET || "").trim();
510
+ const ownerAccount = String(process.env.OPENCLAW_OWNER_ACCOUNT || "").trim();
511
+ const explicitOpenClawBin = String(process.env.OPENCLAW_BIN || "").trim();
512
+ const configuredSourceDir = String(process.env.OPENCLAW_SOURCE_DIR || "").trim();
513
+ const defaultSourceDir = defaultOpenClawSourceDir(params.workspaceRoot);
514
+ const openclawSourceDir = configuredSourceDir || defaultSourceDir;
515
+ const openclawSourceEntry = existingPathOrNull((0, path_1.resolve)(openclawSourceDir, "openclaw.mjs"));
516
+ const openclawCommandResolvable = Boolean(explicitOpenClawBin || resolveExecutableInPath("openclaw") || openclawSourceEntry);
517
+ const bridgeMessagesReadable = params.connectedToSilicaclaw && params.openclawRunning && params.skillInstalled;
518
+ const forwardCommandConfigured = Boolean(forwardCommand);
519
+ const ownerRouteConfigured = Boolean(ownerChannel && ownerTarget);
520
+ const ready = bridgeMessagesReadable && forwardCommandConfigured && ownerRouteConfigured && openclawCommandResolvable;
521
+ let reason = "";
522
+ if (!params.connectedToSilicaclaw) {
523
+ reason = "SilicaClaw social bridge is not connected yet, so there is no broadcast stream for OpenClaw to learn.";
524
+ }
525
+ else if (!params.openclawRunning) {
526
+ reason = "OpenClaw is not running on this machine yet, so broadcast learning and owner forwarding are idle.";
527
+ }
528
+ else if (!params.skillInstalled) {
529
+ reason = "OpenClaw is running, but the silicaclaw-broadcast skill is not installed yet.";
530
+ }
531
+ else if (!forwardCommandConfigured) {
532
+ reason = "Broadcast learning is ready, but OPENCLAW_OWNER_FORWARD_CMD is not configured yet.";
533
+ }
534
+ else if (!ownerRouteConfigured) {
535
+ reason = "The owner forward command exists, but OPENCLAW_OWNER_CHANNEL and OPENCLAW_OWNER_TARGET are still missing.";
536
+ }
537
+ else if (!openclawCommandResolvable) {
538
+ reason = "Owner forwarding is configured, but no runnable OpenClaw CLI or source checkout was found.";
539
+ }
540
+ else {
541
+ reason = "This machine can read SilicaClaw broadcasts and route owner summaries through OpenClaw.";
542
+ }
543
+ return {
544
+ supported: bridgeMessagesReadable,
545
+ mode: "public-broadcast-via-openclaw",
546
+ send_to_owner_via_openclaw: ready,
547
+ bridge_messages_readable: bridgeMessagesReadable,
548
+ forward_command_configured: forwardCommandConfigured,
549
+ openclaw_command_resolvable: openclawCommandResolvable,
550
+ ready,
551
+ forward_command: forwardCommand || null,
552
+ owner_channel: ownerChannel || null,
553
+ owner_target: ownerTarget || null,
554
+ owner_account: ownerAccount || null,
555
+ openclaw_source_dir: openclawSourceEntry ? openclawSourceDir : null,
556
+ reason,
557
+ };
558
+ }
559
+ function hasMeaningfulJson(filePath) {
560
+ if (!(0, fs_1.existsSync)(filePath))
561
+ return false;
562
+ try {
563
+ const raw = (0, fs_1.readFileSync)(filePath, "utf8").trim();
564
+ if (!raw)
565
+ return false;
566
+ const parsed = JSON.parse(raw);
567
+ if (parsed == null)
568
+ return false;
569
+ if (Array.isArray(parsed))
570
+ return parsed.length > 0;
571
+ if (typeof parsed === "object")
572
+ return Object.keys(parsed).length > 0;
573
+ return false;
574
+ }
575
+ catch {
576
+ return false;
577
+ }
578
+ }
579
+ function migrateLegacyDataIfNeeded(appRoot, projectRoot, storageRoot) {
580
+ const homeDir = process.env.HOME || (0, os_1.homedir)();
581
+ const legacyNpxAppRoots = collectLegacyNpxAppRoots(homeDir);
582
+ const targetDataDir = (0, path_1.resolve)(storageRoot, "data");
583
+ const legacyDataDirs = [
584
+ (0, path_1.resolve)(appRoot, "data"),
585
+ (0, path_1.resolve)(appRoot, "apps", "local-console", "data"),
586
+ (0, path_1.resolve)(projectRoot, "data"),
587
+ (0, path_1.resolve)(projectRoot, "apps", "local-console", "data"),
588
+ (0, path_1.resolve)(process.cwd(), "data"),
589
+ ...legacyNpxAppRoots.map((root) => (0, path_1.resolve)(root, "apps", "local-console", "data")),
590
+ ].filter((dir, index, list) => list.indexOf(dir) === index && dir !== targetDataDir);
591
+ const files = [
592
+ "identity.json",
593
+ "profile.json",
594
+ "cache.json",
595
+ "logs.json",
596
+ "social-messages.json",
597
+ "social-message-observations.json",
598
+ ];
599
+ for (const file of files) {
600
+ const dst = (0, path_1.resolve)(targetDataDir, file);
601
+ if (hasMeaningfulJson(dst))
602
+ continue;
603
+ for (const legacyDataDir of legacyDataDirs) {
604
+ const src = (0, path_1.resolve)(legacyDataDir, file);
605
+ if (!(0, fs_1.existsSync)(src))
606
+ continue;
607
+ if (!hasMeaningfulJson(src))
608
+ continue;
609
+ (0, fs_1.mkdirSync)(targetDataDir, { recursive: true });
610
+ (0, fs_1.copyFileSync)(src, dst);
611
+ break;
612
+ }
613
+ }
614
+ const targetDotDir = (0, path_1.resolve)(storageRoot, ".silicaclaw");
615
+ const legacyDotDirs = [
616
+ (0, path_1.resolve)(appRoot, ".silicaclaw"),
617
+ (0, path_1.resolve)(appRoot, "apps", "local-console", ".silicaclaw"),
618
+ (0, path_1.resolve)(projectRoot, ".silicaclaw"),
619
+ (0, path_1.resolve)(projectRoot, "apps", "local-console", ".silicaclaw"),
620
+ (0, path_1.resolve)(process.cwd(), ".silicaclaw"),
621
+ ...legacyNpxAppRoots.map((root) => (0, path_1.resolve)(root, "apps", "local-console", ".silicaclaw")),
622
+ ].filter((dir, index, list) => list.indexOf(dir) === index && dir !== targetDotDir);
623
+ const dotFiles = ["social.runtime.json", "social.message-governance.json"];
624
+ for (const file of dotFiles) {
625
+ const dst = (0, path_1.resolve)(targetDotDir, file);
626
+ if (hasMeaningfulJson(dst))
627
+ continue;
628
+ for (const legacyDotDir of legacyDotDirs) {
629
+ const src = (0, path_1.resolve)(legacyDotDir, file);
630
+ if (!(0, fs_1.existsSync)(src))
631
+ continue;
632
+ if (!hasMeaningfulJson(src))
633
+ continue;
634
+ (0, fs_1.mkdirSync)(targetDotDir, { recursive: true });
635
+ (0, fs_1.copyFileSync)(src, dst);
636
+ break;
637
+ }
638
+ }
639
+ }
640
+ function collectLegacyNpxAppRoots(homeDir) {
641
+ const cacheRoots = [
642
+ (0, path_1.resolve)(homeDir, ".silicaclaw", "npm-cache", "_npx"),
643
+ (0, path_1.resolve)(homeDir, ".npm", "_npx"),
644
+ ];
645
+ const roots = [];
646
+ for (const cacheRoot of cacheRoots) {
647
+ if (!(0, fs_1.existsSync)(cacheRoot))
648
+ continue;
649
+ let entries = [];
650
+ try {
651
+ entries = (0, fs_1.readdirSync)(cacheRoot);
652
+ }
653
+ catch {
654
+ continue;
655
+ }
656
+ for (const entry of entries) {
657
+ const candidate = (0, path_1.resolve)(cacheRoot, entry, "node_modules", "@silicaclaw", "cli");
658
+ if (!(0, fs_1.existsSync)((0, path_1.resolve)(candidate, "apps", "local-console")))
659
+ continue;
660
+ roots.push(candidate);
661
+ }
662
+ }
663
+ return Array.from(new Set(roots));
664
+ }
665
+ function parseListEnv(raw) {
666
+ return raw
667
+ .split(/[,\n]/g)
668
+ .map((item) => item.trim())
669
+ .filter(Boolean);
670
+ }
671
+ function dedupeStrings(values) {
672
+ return Array.from(new Set(values.map((item) => item.trim()).filter(Boolean)));
673
+ }
674
+ class LocalNodeService {
675
+ workspaceRoot;
676
+ projectRoot;
677
+ storageRoot;
678
+ identityRepo;
679
+ profileRepo;
680
+ cacheRepo;
681
+ logRepo;
682
+ socialMessageGovernanceRepo;
683
+ socialMessageRepo;
684
+ socialMessageObservationRepo;
685
+ socialRuntimeRepo;
686
+ identity = null;
687
+ profile = null;
688
+ directory = (0, core_1.createEmptyDirectoryState)();
689
+ socialMessages = [];
690
+ socialMessageObservations = [];
691
+ messageGovernance;
692
+ receivedCount = 0;
693
+ broadcastCount = 0;
694
+ lastMessageAt = 0;
695
+ lastBroadcastAt = 0;
696
+ lastBroadcastErrorAt = 0;
697
+ lastBroadcastError = null;
698
+ broadcastFailureCount = 0;
699
+ broadcaster = null;
700
+ subscriptionsBound = false;
701
+ broadcastEnabled = true;
702
+ receivedByTopic = {};
703
+ publishedByTopic = {};
704
+ outboundMessageTimestamps = [];
705
+ inboundMessageTimestampsByAgent = {};
706
+ initState = {
707
+ identity_auto_created: false,
708
+ profile_auto_created: false,
709
+ social_auto_created: false,
710
+ initialized_at: 0,
711
+ };
712
+ network;
713
+ adapterMode;
714
+ networkMode = DEFAULT_NETWORK_MODE;
715
+ networkNamespace;
716
+ networkPort;
717
+ socialConfig;
718
+ socialSourcePath = null;
719
+ socialFound = false;
720
+ socialParseError = null;
721
+ socialRawFrontmatter = null;
722
+ socialRuntime = null;
723
+ socialNetworkRequiresRestart = false;
724
+ resolvedIdentitySource = "silicaclaw-existing";
725
+ resolvedOpenClawIdentityPath = null;
726
+ webrtcSignalingUrls = [];
727
+ webrtcRoom = DEFAULT_GLOBAL_ROOM;
728
+ webrtcSeedPeers = [];
729
+ webrtcBootstrapHints = [];
730
+ webrtcBootstrapSources = [];
731
+ appVersion = "unknown";
732
+ constructor(options) {
733
+ this.workspaceRoot = options?.workspaceRoot || resolveWorkspaceRoot();
734
+ this.projectRoot = options?.projectRoot || resolveProjectRoot(this.workspaceRoot);
735
+ this.storageRoot = options?.storageRoot || resolveStorageRoot(this.workspaceRoot);
736
+ this.appVersion = readWorkspaceVersion(this.workspaceRoot);
737
+ migrateLegacyDataIfNeeded(this.workspaceRoot, this.projectRoot, this.storageRoot);
738
+ this.identityRepo = new storage_1.IdentityRepo(this.storageRoot);
739
+ this.profileRepo = new storage_1.ProfileRepo(this.storageRoot);
740
+ this.cacheRepo = new storage_1.CacheRepo(this.storageRoot);
741
+ this.logRepo = new storage_1.LogRepo(this.storageRoot);
742
+ this.socialMessageGovernanceRepo = new storage_1.SocialMessageGovernanceRepo(this.storageRoot);
743
+ this.socialMessageRepo = new storage_1.SocialMessageRepo(this.storageRoot);
744
+ this.socialMessageObservationRepo = new storage_1.SocialMessageObservationRepo(this.storageRoot);
745
+ this.socialRuntimeRepo = new storage_1.SocialRuntimeRepo(this.storageRoot);
746
+ this.messageGovernance = this.defaultMessageGovernance();
747
+ let loadedSocial = (0, core_1.loadSocialConfig)(this.projectRoot);
748
+ if (!loadedSocial.meta.found) {
749
+ (0, core_1.ensureDefaultSocialMd)(this.projectRoot, {
750
+ display_name: this.getDefaultDisplayName(),
751
+ bio: "Local AI agent connected to SilicaClaw",
752
+ tags: ["openclaw", "local-first"],
753
+ mode: DEFAULT_NETWORK_MODE,
754
+ public_enabled: false,
755
+ });
756
+ loadedSocial = (0, core_1.loadSocialConfig)(this.projectRoot);
757
+ this.initState.social_auto_created = true;
758
+ }
759
+ this.socialConfig = loadedSocial.config;
760
+ this.socialSourcePath = loadedSocial.meta.source_path;
761
+ this.socialFound = loadedSocial.meta.found;
762
+ this.socialParseError = loadedSocial.meta.parse_error;
763
+ this.socialRawFrontmatter = loadedSocial.raw_frontmatter;
764
+ this.networkNamespace = this.socialConfig.network.namespace || process.env.NETWORK_NAMESPACE || DEFAULT_NETWORK_NAMESPACE;
765
+ this.networkPort = Number(this.socialConfig.network.port || process.env.NETWORK_PORT || DEFAULT_NETWORK_PORT);
766
+ this.applyResolvedNetworkConfig();
767
+ const resolved = this.buildNetworkAdapter();
768
+ this.network = resolved.adapter;
769
+ this.adapterMode = resolved.mode;
770
+ this.networkPort = resolved.port;
771
+ }
772
+ async start() {
773
+ await this.hydrateFromDisk();
774
+ this.bindNetworkSubscriptions();
775
+ await this.network.start();
776
+ await this.log("info", `Local node started (${this.adapterMode}, mode=${this.networkMode}, signaling=${this.webrtcSignalingUrls[0] || "-"}, room=${this.webrtcRoom})`);
777
+ if (this.profile?.public_enabled && this.broadcastEnabled) {
778
+ try {
779
+ await this.broadcastNow("adapter_start");
780
+ }
781
+ catch (error) {
782
+ await this.log("warn", `Initial broadcast failed: ${error instanceof Error ? error.message : String(error)}`);
783
+ }
784
+ }
785
+ this.startBroadcastLoop();
786
+ }
787
+ async stop() {
788
+ if (this.broadcaster) {
789
+ clearInterval(this.broadcaster);
790
+ this.broadcaster = null;
791
+ }
792
+ await this.network.stop();
793
+ }
794
+ ensureLocalDirectoryBaseline() {
795
+ if (this.profile) {
796
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, { type: "profile", profile: this.profile });
797
+ }
798
+ if (this.identity && this.profile?.public_enabled && this.broadcastEnabled) {
799
+ const currentSeenAt = this.directory.presence[this.identity.agent_id] ?? 0;
800
+ const baselineSeenAt = Math.max(currentSeenAt, this.lastBroadcastAt || Date.now());
801
+ this.directory = (0, core_1.ingestPresenceRecord)(this.directory, (0, core_1.signPresence)(this.identity, baselineSeenAt));
802
+ }
803
+ }
804
+ getOverview() {
805
+ const discovered = this.search("");
806
+ const onlineCount = discovered.filter((profile) => profile.online).length;
807
+ return {
808
+ app_version: this.appVersion,
809
+ agent_id: this.identity?.agent_id ?? "",
810
+ public_enabled: Boolean(this.profile?.public_enabled),
811
+ broadcast_enabled: this.broadcastEnabled,
812
+ last_broadcast_at: this.lastBroadcastAt,
813
+ last_broadcast_error_at: this.lastBroadcastErrorAt,
814
+ last_broadcast_error: this.lastBroadcastError,
815
+ broadcast_failure_count: this.broadcastFailureCount,
816
+ discovered_count: discovered.length,
817
+ online_count: onlineCount,
818
+ offline_count: Math.max(0, discovered.length - onlineCount),
819
+ init_state: this.initState,
820
+ presence_ttl_ms: PRESENCE_TTL_MS,
821
+ onboarding: this.getOnboardingSummary(),
822
+ social: {
823
+ found: this.socialFound,
824
+ enabled: this.socialConfig.enabled,
825
+ source_path: this.socialSourcePath,
826
+ network_mode: this.networkMode,
827
+ mode_explainer: this.getModeExplainer(),
828
+ governance: {
829
+ send_limit: { max: this.messageGovernance.send_limit_max, window_ms: this.messageGovernance.send_window_ms },
830
+ receive_limit: { max: this.messageGovernance.receive_limit_max, window_ms: this.messageGovernance.receive_window_ms },
831
+ duplicate_window_ms: this.messageGovernance.duplicate_window_ms,
832
+ blocked_agent_count: this.messageGovernance.blocked_agent_ids.length,
833
+ blocked_term_count: this.messageGovernance.blocked_terms.length,
834
+ },
835
+ },
836
+ };
837
+ }
838
+ getNetworkSummary() {
839
+ const network = this.getResolvedRealtimeNetworkSummary();
840
+ const diagnostics = network.diagnostics;
841
+ const relayCapable = this.adapterMode === "webrtc-preview" || this.adapterMode === "relay-preview";
842
+ const peerCount = diagnostics?.peers.total ?? 0;
843
+ return {
844
+ status: "running",
845
+ adapter: this.adapterMode,
846
+ mode: this.networkMode,
847
+ received_count: this.receivedCount,
848
+ broadcast_count: this.broadcastCount,
849
+ broadcast_failure_count: this.broadcastFailureCount,
850
+ last_message_at: this.lastMessageAt,
851
+ last_broadcast_at: this.lastBroadcastAt,
852
+ last_broadcast_error_at: this.lastBroadcastErrorAt,
853
+ last_broadcast_error: this.lastBroadcastError,
854
+ received_by_topic: this.receivedByTopic,
855
+ published_by_topic: this.publishedByTopic,
856
+ peers_discovered: peerCount,
857
+ namespace: diagnostics?.namespace ?? this.networkNamespace,
858
+ port: this.networkPort,
859
+ components: diagnostics?.components ?? {
860
+ transport: "-",
861
+ discovery: "-",
862
+ envelope_codec: "-",
863
+ topic_codec: "-",
864
+ },
865
+ real_preview_stats: diagnostics?.stats ?? null,
866
+ real_preview_transport_stats: diagnostics?.transport_stats ?? null,
867
+ real_preview_discovery_stats: diagnostics?.discovery_stats ?? null,
868
+ webrtc_preview: relayCapable
869
+ ? {
870
+ signaling_url: network.signaling_url,
871
+ signaling_endpoints: network.signaling_endpoints,
872
+ room: network.room,
873
+ bootstrap_sources: network.bootstrap_sources,
874
+ seed_peers_count: network.seed_peers_count,
875
+ discovery_events_total: diagnostics?.discovery_events_total ?? 0,
876
+ last_discovery_event_at: diagnostics?.last_discovery_event_at ?? 0,
877
+ active_webrtc_peers: diagnostics?.active_webrtc_peers ?? 0,
878
+ reconnect_attempts_total: diagnostics?.reconnect_attempts_total ?? 0,
879
+ last_join_at: diagnostics?.last_join_at ?? 0,
880
+ last_poll_at: diagnostics?.last_poll_at ?? 0,
881
+ last_publish_at: diagnostics?.last_publish_at ?? 0,
882
+ last_peer_refresh_at: diagnostics?.last_peer_refresh_at ?? 0,
883
+ last_error_at: diagnostics?.last_error_at ?? 0,
884
+ last_error: diagnostics?.last_error ?? null,
885
+ }
886
+ : null,
887
+ };
888
+ }
889
+ getNetworkConfig() {
890
+ const network = this.getResolvedRealtimeNetworkSummary();
891
+ const diagnostics = network.diagnostics;
892
+ const relayCapable = this.adapterMode === "webrtc-preview" || this.adapterMode === "relay-preview";
893
+ return {
894
+ adapter: this.adapterMode,
895
+ mode: this.networkMode,
896
+ namespace: diagnostics?.namespace ?? this.networkNamespace,
897
+ port: this.networkPort,
898
+ components: diagnostics?.components ?? {
899
+ transport: "-",
900
+ discovery: "-",
901
+ envelope_codec: "-",
902
+ topic_codec: "-",
903
+ },
904
+ limits: diagnostics?.limits ?? null,
905
+ adapter_config: diagnostics?.config ?? null,
906
+ adapter_extra: relayCapable
907
+ ? {
908
+ signaling_url: network.signaling_url,
909
+ signaling_endpoints: network.signaling_endpoints,
910
+ room: network.room,
911
+ bootstrap_sources: network.bootstrap_sources,
912
+ seed_peers_count: network.seed_peers_count,
913
+ discovery_events_total: diagnostics?.discovery_events_total ?? 0,
914
+ last_discovery_event_at: diagnostics?.last_discovery_event_at ?? 0,
915
+ connection_states_summary: diagnostics?.connection_states_summary ?? null,
916
+ datachannel_states_summary: diagnostics?.datachannel_states_summary ?? null,
917
+ last_join_at: diagnostics?.last_join_at ?? 0,
918
+ last_poll_at: diagnostics?.last_poll_at ?? 0,
919
+ last_publish_at: diagnostics?.last_publish_at ?? 0,
920
+ last_peer_refresh_at: diagnostics?.last_peer_refresh_at ?? 0,
921
+ last_error_at: diagnostics?.last_error_at ?? 0,
922
+ last_error: diagnostics?.last_error ?? null,
923
+ }
924
+ : null,
925
+ env: {
926
+ NETWORK_ADAPTER: this.adapterMode,
927
+ NETWORK_NAMESPACE: this.networkNamespace,
928
+ NETWORK_PORT: this.networkPort,
929
+ NETWORK_MAX_MESSAGE_BYTES,
930
+ NETWORK_DEDUPE_WINDOW_MS,
931
+ NETWORK_DEDUPE_MAX_ENTRIES,
932
+ NETWORK_MAX_FUTURE_DRIFT_MS,
933
+ NETWORK_MAX_PAST_DRIFT_MS,
934
+ NETWORK_HEARTBEAT_INTERVAL_MS,
935
+ NETWORK_PEER_STALE_AFTER_MS,
936
+ NETWORK_PEER_REMOVE_AFTER_MS,
937
+ NETWORK_UDP_BIND_ADDRESS,
938
+ NETWORK_UDP_BROADCAST_ADDRESS,
939
+ NETWORK_PEER_ID: NETWORK_PEER_ID ?? null,
940
+ WEBRTC_SIGNALING_URLS,
941
+ WEBRTC_SIGNALING_URL,
942
+ WEBRTC_ROOM,
943
+ WEBRTC_SEED_PEERS,
944
+ WEBRTC_BOOTSTRAP_HINTS,
945
+ },
946
+ demo_mode: this.adapterMode === "real-preview"
947
+ ? "lan-preview"
948
+ : this.adapterMode === "webrtc-preview" || this.adapterMode === "relay-preview"
949
+ ? "internet-preview"
950
+ : "local-process",
951
+ mode_explainer: this.getModeExplainer(),
952
+ };
953
+ }
954
+ getNetworkStats() {
955
+ const network = this.getResolvedRealtimeNetworkSummary();
956
+ const diagnostics = network.diagnostics;
957
+ const relayCapable = this.adapterMode === "webrtc-preview" || this.adapterMode === "relay-preview";
958
+ const peers = diagnostics?.peers?.items ?? [];
959
+ const online = peers.filter((peer) => peer.status === "online").length;
960
+ return {
961
+ adapter: this.adapterMode,
962
+ mode: this.networkMode,
963
+ message_counters: {
964
+ received_total: this.receivedCount,
965
+ broadcast_total: this.broadcastCount,
966
+ broadcast_failures_total: this.broadcastFailureCount,
967
+ last_message_at: this.lastMessageAt,
968
+ last_broadcast_at: this.lastBroadcastAt,
969
+ last_broadcast_error_at: this.lastBroadcastErrorAt,
970
+ last_broadcast_error: this.lastBroadcastError,
971
+ received_by_topic: this.receivedByTopic,
972
+ published_by_topic: this.publishedByTopic,
973
+ },
974
+ peer_counters: {
975
+ total: peers.length,
976
+ online,
977
+ stale: Math.max(0, peers.length - online),
978
+ },
979
+ adapter_config: diagnostics?.config ?? null,
980
+ adapter_stats: diagnostics?.stats ?? null,
981
+ adapter_transport_stats: diagnostics?.transport_stats ?? null,
982
+ adapter_discovery_stats: diagnostics?.discovery_stats ?? null,
983
+ adapter_diagnostics_summary: relayCapable || diagnostics
984
+ ? {
985
+ signaling_url: network.signaling_url,
986
+ signaling_endpoints: network.signaling_endpoints,
987
+ room: network.room,
988
+ bootstrap_sources: network.bootstrap_sources,
989
+ seed_peers_count: network.seed_peers_count,
990
+ discovery_events_total: diagnostics?.discovery_events_total ?? 0,
991
+ last_discovery_event_at: diagnostics?.last_discovery_event_at ?? 0,
992
+ connection_states_summary: diagnostics?.connection_states_summary ?? null,
993
+ datachannel_states_summary: diagnostics?.datachannel_states_summary ?? null,
994
+ signaling_messages_sent_total: diagnostics?.signaling_messages_sent_total ?? null,
995
+ signaling_messages_received_total: diagnostics?.signaling_messages_received_total ?? null,
996
+ reconnect_attempts_total: diagnostics?.reconnect_attempts_total ?? null,
997
+ active_webrtc_peers: diagnostics?.active_webrtc_peers ?? null,
998
+ last_join_at: diagnostics?.last_join_at ?? 0,
999
+ last_poll_at: diagnostics?.last_poll_at ?? 0,
1000
+ last_publish_at: diagnostics?.last_publish_at ?? 0,
1001
+ last_peer_refresh_at: diagnostics?.last_peer_refresh_at ?? 0,
1002
+ last_error_at: diagnostics?.last_error_at ?? 0,
1003
+ last_error: diagnostics?.last_error ?? null,
1004
+ }
1005
+ : null,
1006
+ };
1007
+ }
1008
+ getPeersSummary() {
1009
+ const network = this.getResolvedRealtimeNetworkSummary();
1010
+ const diagnostics = network.diagnostics;
1011
+ if (!diagnostics) {
1012
+ return {
1013
+ adapter: this.adapterMode,
1014
+ namespace: this.networkNamespace,
1015
+ total: 0,
1016
+ online: 0,
1017
+ stale: 0,
1018
+ items: [],
1019
+ stats: null,
1020
+ };
1021
+ }
1022
+ return {
1023
+ adapter: diagnostics.adapter,
1024
+ namespace: diagnostics.namespace,
1025
+ total: diagnostics.peers.total,
1026
+ online: diagnostics.peers.online,
1027
+ stale: diagnostics.peers.stale,
1028
+ items: diagnostics.peers.items,
1029
+ stats: diagnostics.stats,
1030
+ components: diagnostics.components,
1031
+ limits: diagnostics.limits,
1032
+ diagnostics_summary: {
1033
+ signaling_url: network.signaling_url,
1034
+ signaling_endpoints: network.signaling_endpoints,
1035
+ room: network.room,
1036
+ bootstrap_sources: network.bootstrap_sources,
1037
+ seed_peers_count: network.seed_peers_count,
1038
+ discovery_events_total: diagnostics.discovery_events_total ?? 0,
1039
+ last_discovery_event_at: diagnostics.last_discovery_event_at ?? 0,
1040
+ connection_states_summary: diagnostics.connection_states_summary ?? null,
1041
+ datachannel_states_summary: diagnostics.datachannel_states_summary ?? null,
1042
+ active_webrtc_peers: diagnostics.active_webrtc_peers ?? null,
1043
+ last_join_at: diagnostics.last_join_at ?? 0,
1044
+ last_poll_at: diagnostics.last_poll_at ?? 0,
1045
+ last_publish_at: diagnostics.last_publish_at ?? 0,
1046
+ last_peer_refresh_at: diagnostics.last_peer_refresh_at ?? 0,
1047
+ last_error_at: diagnostics.last_error_at ?? 0,
1048
+ last_error: diagnostics.last_error ?? null,
1049
+ },
1050
+ };
1051
+ }
1052
+ getDiscoveryEvents() {
1053
+ const diagnostics = this.getAdapterDiagnostics();
1054
+ return {
1055
+ adapter: this.adapterMode,
1056
+ mode: this.networkMode,
1057
+ namespace: diagnostics?.namespace ?? this.networkNamespace,
1058
+ total: diagnostics?.discovery_events_total ?? 0,
1059
+ last_event_at: diagnostics?.last_discovery_event_at ?? 0,
1060
+ items: Array.isArray(diagnostics?.discovery_events) ? diagnostics.discovery_events : [],
1061
+ bootstrap_sources: diagnostics?.bootstrap_sources ?? this.webrtcBootstrapSources,
1062
+ signaling_endpoints: diagnostics?.signaling_endpoints ?? this.webrtcSignalingUrls,
1063
+ seed_peers_count: diagnostics?.seed_peers_count ?? this.webrtcSeedPeers.length,
1064
+ };
1065
+ }
1066
+ getSocialConfigView() {
1067
+ return {
1068
+ found: this.socialFound,
1069
+ source_path: this.socialSourcePath,
1070
+ parse_error: this.socialParseError,
1071
+ network_requires_restart: this.socialNetworkRequiresRestart,
1072
+ social_config: this.socialConfig,
1073
+ raw_frontmatter: this.socialRawFrontmatter,
1074
+ runtime: this.socialRuntime,
1075
+ init_state: this.initState,
1076
+ };
1077
+ }
1078
+ getRuntimePaths() {
1079
+ return {
1080
+ workspace_root: this.workspaceRoot,
1081
+ project_root: this.projectRoot,
1082
+ storage_root: this.storageRoot,
1083
+ data_dir: (0, path_1.resolve)(this.storageRoot, "data"),
1084
+ social_runtime_path: (0, path_1.resolve)(this.storageRoot, ".silicaclaw", "social.runtime.json"),
1085
+ local_console_public_dir: (0, path_1.resolve)(this.workspaceRoot, "apps", "local-console", "public"),
1086
+ social_lookup_paths: (0, core_1.getSocialConfigSearchPaths)(this.projectRoot),
1087
+ social_source_path: this.socialSourcePath,
1088
+ };
1089
+ }
1090
+ getIntegrationSummary() {
1091
+ const status = this.getIntegrationStatus();
1092
+ const runtimeGenerated = Boolean(this.socialRuntime && this.socialRuntime.last_loaded_at > 0);
1093
+ const identitySource = this.socialRuntime?.resolved_identity?.source ?? this.resolvedIdentitySource;
1094
+ return {
1095
+ connected: status.connected_to_silicaclaw,
1096
+ discoverable: status.discoverable,
1097
+ summary_line: status.status_line,
1098
+ social_md_found: this.socialFound,
1099
+ social_md_source_path: this.socialSourcePath,
1100
+ runtime_generated: runtimeGenerated,
1101
+ reused_openclaw_identity: identitySource === "openclaw-existing",
1102
+ openclaw_identity_source_path: this.resolvedOpenClawIdentityPath,
1103
+ current_public_enabled: status.public_enabled,
1104
+ current_network_mode: status.network_mode,
1105
+ current_adapter: this.adapterMode,
1106
+ current_namespace: this.networkNamespace,
1107
+ current_broadcast_status: this.broadcastEnabled ? "running" : "paused",
1108
+ configured_enabled: this.socialConfig.enabled,
1109
+ configured_public_enabled: this.socialConfig.public_enabled,
1110
+ configured_discoverable: this.socialConfig.discovery.discoverable,
1111
+ configured: status.configured,
1112
+ running: status.running,
1113
+ configured_reason: status.configured_reason,
1114
+ running_reason: status.running_reason,
1115
+ discoverable_reason: status.discoverable_reason,
1116
+ agent_id: status.agent_id,
1117
+ display_name: status.display_name,
1118
+ };
1119
+ }
1120
+ getIntegrationStatus() {
1121
+ const runtimeGenerated = Boolean(this.socialRuntime && this.socialRuntime.last_loaded_at > 0);
1122
+ const connected = this.socialFound && runtimeGenerated && !this.socialParseError;
1123
+ const configured = connected && this.socialConfig.enabled;
1124
+ const running = configured && this.broadcastEnabled;
1125
+ const publicEnabled = Boolean(this.profile?.public_enabled);
1126
+ const discoveryEnabled = this.socialConfig.discovery.discoverable &&
1127
+ this.socialConfig.discovery.allow_profile_broadcast &&
1128
+ this.socialConfig.discovery.allow_presence_broadcast;
1129
+ const discoverable = running && publicEnabled && discoveryEnabled;
1130
+ const configuredReason = configured
1131
+ ? "configured"
1132
+ : !this.socialFound
1133
+ ? "social.md not found"
1134
+ : this.socialParseError
1135
+ ? "social.md parse error"
1136
+ : !this.socialConfig.enabled
1137
+ ? "integration disabled"
1138
+ : "runtime not ready";
1139
+ const runningReason = running
1140
+ ? "running"
1141
+ : !configured
1142
+ ? "not configured"
1143
+ : !this.broadcastEnabled
1144
+ ? "broadcast paused"
1145
+ : "not running";
1146
+ const discoverableReason = discoverable
1147
+ ? "discoverable"
1148
+ : !running
1149
+ ? "not running"
1150
+ : !publicEnabled
1151
+ ? "Public discovery is disabled"
1152
+ : !this.socialConfig.discovery.discoverable
1153
+ ? "discovery disabled"
1154
+ : !this.socialConfig.discovery.allow_profile_broadcast
1155
+ ? "profile broadcast disabled"
1156
+ : !this.socialConfig.discovery.allow_presence_broadcast
1157
+ ? "presence broadcast disabled"
1158
+ : "not discoverable";
1159
+ return {
1160
+ configured,
1161
+ running,
1162
+ discoverable,
1163
+ network_mode: this.networkMode,
1164
+ public_enabled: publicEnabled,
1165
+ agent_id: this.identity?.agent_id ?? "",
1166
+ display_name: this.profile?.display_name ?? "",
1167
+ connected_to_silicaclaw: connected,
1168
+ configured_reason: configuredReason,
1169
+ running_reason: runningReason,
1170
+ discoverable_reason: discoverableReason,
1171
+ status_line: `${connected ? "Connected to SilicaClaw" : "Not connected to SilicaClaw"} · ${publicEnabled ? "Public discovery enabled" : "Public discovery disabled"} · Using ${this.networkMode}`,
1172
+ };
1173
+ }
1174
+ async setPublicDiscoveryRuntime(enabled) {
1175
+ const profile = await this.updateProfile({ public_enabled: enabled });
1176
+ this.socialConfig.public_enabled = enabled;
1177
+ await this.writeSocialRuntime();
1178
+ return {
1179
+ public_enabled: profile.public_enabled,
1180
+ note: "Runtime public discovery updated. Existing social.md is unchanged.",
1181
+ };
1182
+ }
1183
+ async setNetworkModeRuntime(mode) {
1184
+ const before = {
1185
+ mode: this.networkMode,
1186
+ adapter: this.adapterMode,
1187
+ namespace: this.networkNamespace,
1188
+ port: this.networkPort,
1189
+ };
1190
+ if (mode !== "local" && mode !== "lan" && mode !== "global-preview") {
1191
+ throw new Error("invalid_network_mode");
1192
+ }
1193
+ this.socialConfig.network.mode = mode;
1194
+ this.socialConfig.network.adapter = this.adapterForMode(mode);
1195
+ this.applyResolvedNetworkConfig();
1196
+ const needsRestart = before.mode !== this.networkMode ||
1197
+ before.adapter !== this.socialConfig.network.adapter ||
1198
+ before.namespace !== this.networkNamespace ||
1199
+ (before.port ?? null) !== (this.networkPort ?? null);
1200
+ if (needsRestart) {
1201
+ await this.restartNetworkAdapter("set_network_mode_runtime");
1202
+ }
1203
+ this.socialNetworkRequiresRestart = false;
1204
+ await this.writeSocialRuntime();
1205
+ return {
1206
+ mode: this.networkMode,
1207
+ adapter: this.adapterMode,
1208
+ network_requires_restart: false,
1209
+ note: "Runtime mode updated and adapter restarted. Existing social.md is unchanged.",
1210
+ };
1211
+ }
1212
+ async quickConnectGlobalPreview(options) {
1213
+ const signalingUrl = String(options?.signaling_url || "").trim();
1214
+ const room = String(options?.room || "").trim();
1215
+ if (!signalingUrl) {
1216
+ throw new Error("missing_signaling_url");
1217
+ }
1218
+ this.socialConfig.network.mode = "global-preview";
1219
+ this.socialConfig.network.adapter = "relay-preview";
1220
+ this.socialConfig.network.signaling_url = signalingUrl;
1221
+ this.socialConfig.network.signaling_urls = [signalingUrl];
1222
+ this.socialConfig.network.room = room || DEFAULT_GLOBAL_ROOM;
1223
+ this.applyResolvedNetworkConfig();
1224
+ await this.restartNetworkAdapter("quick_connect_global_preview");
1225
+ this.socialNetworkRequiresRestart = false;
1226
+ await this.writeSocialRuntime();
1227
+ await this.log("info", `Quick connect enabled (relay-preview, room=${this.webrtcRoom})`);
1228
+ return {
1229
+ mode: this.networkMode,
1230
+ adapter: this.adapterMode,
1231
+ signaling_url: this.webrtcSignalingUrls[0] ?? null,
1232
+ room: this.webrtcRoom,
1233
+ network_requires_restart: false,
1234
+ note: "Cross-network preview enabled.",
1235
+ };
1236
+ }
1237
+ async reloadSocialConfig() {
1238
+ const before = {
1239
+ mode: this.networkMode,
1240
+ adapter: this.adapterMode,
1241
+ namespace: this.networkNamespace,
1242
+ port: this.networkPort,
1243
+ };
1244
+ const loaded = (0, core_1.loadSocialConfig)(this.projectRoot);
1245
+ this.socialConfig = loaded.config;
1246
+ this.socialSourcePath = loaded.meta.source_path;
1247
+ this.socialFound = loaded.meta.found;
1248
+ this.socialParseError = loaded.meta.parse_error;
1249
+ this.socialRawFrontmatter = loaded.raw_frontmatter;
1250
+ this.applyResolvedNetworkConfig();
1251
+ await this.applySocialConfigOnCurrentState();
1252
+ const after = {
1253
+ mode: this.networkMode,
1254
+ adapter: this.socialConfig.network.adapter,
1255
+ namespace: this.networkNamespace,
1256
+ port: this.networkPort,
1257
+ };
1258
+ this.socialNetworkRequiresRestart =
1259
+ before.mode !== after.mode ||
1260
+ before.adapter !== after.adapter ||
1261
+ before.namespace !== after.namespace ||
1262
+ (before.port ?? null) !== (after.port ?? null);
1263
+ if (this.socialNetworkRequiresRestart) {
1264
+ await this.restartNetworkAdapter("reload_social_config");
1265
+ this.socialNetworkRequiresRestart = false;
1266
+ }
1267
+ await this.writeSocialRuntime();
1268
+ return this.getSocialConfigView();
1269
+ }
1270
+ async generateDefaultSocialMd() {
1271
+ const result = (0, core_1.ensureDefaultSocialMd)(this.projectRoot, {
1272
+ display_name: this.getDefaultDisplayName(),
1273
+ bio: "Local AI agent connected to SilicaClaw",
1274
+ tags: ["openclaw", "local-first"],
1275
+ mode: this.networkMode,
1276
+ public_enabled: Boolean(this.profile?.public_enabled),
1277
+ });
1278
+ await this.reloadSocialConfig();
1279
+ return result;
1280
+ }
1281
+ exportSocialTemplate() {
1282
+ return {
1283
+ filename: "social.md",
1284
+ content: (0, core_1.generateSocialMdTemplate)(this.socialRuntime),
1285
+ };
1286
+ }
1287
+ getDirectory() {
1288
+ this.ensureLocalDirectoryBaseline();
1289
+ this.compactCacheInMemory();
1290
+ return this.directory;
1291
+ }
1292
+ search(keyword) {
1293
+ this.ensureLocalDirectoryBaseline();
1294
+ this.compactCacheInMemory();
1295
+ const directMatches = (0, core_1.searchDirectory)(this.directory, keyword, { presenceTTLms: PRESENCE_TTL_MS }).map((profile) => {
1296
+ const lastSeenAt = this.directory.presence[profile.agent_id] ?? 0;
1297
+ return this.toPublicProfileSummary(profile, { last_seen_at: lastSeenAt });
1298
+ });
1299
+ return this.mergeMessageOnlyAgentSummaries(directMatches, keyword);
1300
+ }
1301
+ getPublicProfilePreview() {
1302
+ if (!this.profile) {
1303
+ return null;
1304
+ }
1305
+ const lastSeenAt = this.directory.presence[this.profile.agent_id] ?? 0;
1306
+ return this.toPublicProfileSummary(this.profile, { last_seen_at: lastSeenAt });
1307
+ }
1308
+ getAgentPublicSummary(agentId) {
1309
+ const profile = this.directory.profiles[agentId];
1310
+ if (!profile) {
1311
+ return null;
1312
+ }
1313
+ const lastSeenAt = this.directory.presence[agentId] ?? 0;
1314
+ return this.toPublicProfileSummary(profile, { last_seen_at: lastSeenAt });
1315
+ }
1316
+ getProfile() {
1317
+ return this.profile;
1318
+ }
1319
+ getIdentity() {
1320
+ return this.identity;
1321
+ }
1322
+ getSocialMessages(limit = 50, options) {
1323
+ const resolvedLimit = Math.max(1, Math.min(200, Number(limit) || 50));
1324
+ this.ensureLocalDirectoryBaseline();
1325
+ this.compactCacheInMemory();
1326
+ const agentId = String(options?.agent_id || "").trim();
1327
+ const filtered = agentId
1328
+ ? this.socialMessages.filter((message) => message.agent_id === agentId)
1329
+ : this.socialMessages;
1330
+ return {
1331
+ total: filtered.length,
1332
+ items: filtered.slice(0, resolvedLimit).map((message) => {
1333
+ const profile = this.directory.profiles[message.agent_id];
1334
+ const lastSeenAt = this.directory.presence[message.agent_id] ?? 0;
1335
+ const observations = this.socialMessageObservations.filter((item) => item.message_id === message.message_id);
1336
+ const remoteObservationCount = observations.filter((item) => item.observer_agent_id !== message.agent_id).length;
1337
+ const lastObservedAt = observations.length > 0 ? Math.max(...observations.map((item) => item.observed_at)) : 0;
1338
+ return {
1339
+ ...message,
1340
+ display_name: profile?.display_name || message.display_name || "Unnamed",
1341
+ is_self: message.agent_id === this.identity?.agent_id,
1342
+ online: (0, core_1.isAgentOnline)(lastSeenAt, Date.now(), PRESENCE_TTL_MS),
1343
+ last_seen_at: lastSeenAt || null,
1344
+ observation_count: observations.length,
1345
+ remote_observation_count: remoteObservationCount,
1346
+ last_observed_at: lastObservedAt || null,
1347
+ delivery_status: remoteObservationCount > 0 ? "remote-observed" : "local-only",
1348
+ };
1349
+ }),
1350
+ governance: {
1351
+ send_limit: { max: this.messageGovernance.send_limit_max, window_ms: this.messageGovernance.send_window_ms },
1352
+ receive_limit: { max: this.messageGovernance.receive_limit_max, window_ms: this.messageGovernance.receive_window_ms },
1353
+ duplicate_window_ms: this.messageGovernance.duplicate_window_ms,
1354
+ blocked_agent_count: this.messageGovernance.blocked_agent_ids.length,
1355
+ blocked_term_count: this.messageGovernance.blocked_terms.length,
1356
+ },
1357
+ };
1358
+ }
1359
+ getOpenClawBridgeStatus() {
1360
+ const integration = this.getIntegrationStatus();
1361
+ const openclawInstallation = detectOpenClawInstallation(this.projectRoot);
1362
+ const openclawRuntime = detectOpenClawRuntime(this.projectRoot);
1363
+ const skillInstallation = detectOpenClawSkillInstallation();
1364
+ const ownerDelivery = detectOwnerDeliveryStatus({
1365
+ workspaceRoot: this.projectRoot,
1366
+ connectedToSilicaclaw: integration.connected_to_silicaclaw,
1367
+ openclawRunning: openclawRuntime.running,
1368
+ skillInstalled: skillInstallation.installed,
1369
+ });
1370
+ return {
1371
+ enabled: this.socialConfig.enabled,
1372
+ connected_to_silicaclaw: integration.connected_to_silicaclaw,
1373
+ public_enabled: integration.public_enabled,
1374
+ message_broadcast_enabled: this.socialConfig.discovery.allow_message_broadcast && this.broadcastEnabled,
1375
+ network_mode: this.networkMode,
1376
+ adapter: this.adapterMode,
1377
+ agent_id: this.identity?.agent_id ?? "",
1378
+ display_name: this.profile?.display_name ?? "",
1379
+ identity_source: this.resolvedIdentitySource,
1380
+ openclaw_identity_source_path: this.resolvedOpenClawIdentityPath,
1381
+ social_source_path: this.socialSourcePath,
1382
+ openclaw_installation: openclawInstallation,
1383
+ openclaw_runtime: openclawRuntime,
1384
+ skill_learning: {
1385
+ available: integration.connected_to_silicaclaw && openclawRuntime.running,
1386
+ installed: skillInstallation.installed,
1387
+ install_mode: skillInstallation.install_mode,
1388
+ installed_skill_path: skillInstallation.workspace_skill_path || skillInstallation.legacy_skill_path,
1389
+ install_action: {
1390
+ supported: true,
1391
+ endpoint: "/api/openclaw/bridge/skill-install",
1392
+ recommended_command: "silicaclaw openclaw-skill-install",
1393
+ },
1394
+ skills: [
1395
+ {
1396
+ key: "get_profile",
1397
+ summary: "Read SilicaClaw identity/profile so OpenClaw can align its runtime persona.",
1398
+ endpoint: "/api/openclaw/bridge/profile",
1399
+ },
1400
+ {
1401
+ key: "list_messages",
1402
+ summary: "Read recent public broadcast messages observed by this SilicaClaw node.",
1403
+ endpoint: "/api/openclaw/bridge/messages",
1404
+ },
1405
+ {
1406
+ key: "watch_messages",
1407
+ summary: "Poll the recent broadcast feed so OpenClaw can learn from new public messages.",
1408
+ endpoint: "/api/openclaw/bridge/messages",
1409
+ },
1410
+ {
1411
+ key: "send_message",
1412
+ summary: "Publish a signed public broadcast through SilicaClaw on behalf of OpenClaw.",
1413
+ endpoint: "/api/openclaw/bridge/message",
1414
+ },
1415
+ ],
1416
+ },
1417
+ owner_delivery: ownerDelivery,
1418
+ endpoints: {
1419
+ status: "/api/openclaw/bridge",
1420
+ profile: "/api/openclaw/bridge/profile",
1421
+ messages: "/api/openclaw/bridge/messages",
1422
+ send_message: "/api/openclaw/bridge/message",
1423
+ install_skill: "/api/openclaw/bridge/skill-install",
1424
+ },
1425
+ };
1426
+ }
1427
+ async installOpenClawSkill(skillName) {
1428
+ const scriptPath = (0, path_1.resolve)(this.workspaceRoot, "scripts", "install-openclaw-skill.mjs");
1429
+ const args = [scriptPath];
1430
+ if (skillName) {
1431
+ args.push(`--skill=${skillName}`);
1432
+ }
1433
+ const { stdout } = await execFileAsync(process.execPath, args, {
1434
+ cwd: this.workspaceRoot,
1435
+ env: { ...process.env, SILICACLAW_WORKSPACE_DIR: this.projectRoot },
1436
+ maxBuffer: 1024 * 1024,
1437
+ });
1438
+ const parsed = JSON.parse(String(stdout || "{}"));
1439
+ return {
1440
+ ...parsed,
1441
+ bridge: this.getOpenClawBridgeStatus(),
1442
+ };
1443
+ }
1444
+ getOpenClawBridgeProfile() {
1445
+ return {
1446
+ identity: this.getIdentity(),
1447
+ profile: this.getProfile(),
1448
+ public_profile_preview: this.getPublicProfilePreview(),
1449
+ integration: this.getIntegrationSummary(),
1450
+ bridge: this.getOpenClawBridgeStatus(),
1451
+ };
1452
+ }
1453
+ getOpenClawBridgeConfig() {
1454
+ const homeDir = (0, path_1.resolve)(process.env.HOME || "", ".openclaw");
1455
+ const workspaceSkillDir = (0, path_1.resolve)(homeDir, "workspace", "skills");
1456
+ const legacySkillDir = (0, path_1.resolve)(homeDir, "skills");
1457
+ const openclawSourceDir = defaultOpenClawSourceDir(this.projectRoot);
1458
+ const openclawRuntime = detectOpenClawRuntime(this.projectRoot);
1459
+ return {
1460
+ bridge_api_base: DEFAULT_BRIDGE_API_BASE,
1461
+ openclaw_detected: detectOpenClawInstallation(this.projectRoot).detected,
1462
+ openclaw_running: openclawRuntime.running,
1463
+ openclaw_gateway_host: OPENCLAW_GATEWAY_HOST,
1464
+ openclaw_gateway_port: openclawRuntime.configured_gateway_port,
1465
+ openclaw_gateway_url: openclawRuntime.configured_gateway_url,
1466
+ openclaw_gateway_config_path: openclawRuntime.configured_gateway_config_path,
1467
+ openclaw_workspace_skill_dir: workspaceSkillDir,
1468
+ openclaw_legacy_skill_dir: legacySkillDir,
1469
+ silicaclaw_env_template_path: (0, path_1.resolve)(this.workspaceRoot, "openclaw-owner-forward.env.example"),
1470
+ recommended_skill_name: "silicaclaw-bridge-setup",
1471
+ recommended_install_command: "silicaclaw openclaw-skill-install",
1472
+ recommended_owner_forward_env: {
1473
+ OPENCLAW_SOURCE_DIR: openclawSourceDir,
1474
+ OPENCLAW_OWNER_CHANNEL: "<channel>",
1475
+ OPENCLAW_OWNER_TARGET: "<target>",
1476
+ OPENCLAW_OWNER_ACCOUNT: "",
1477
+ OPENCLAW_OWNER_FORWARD_CMD: "node scripts/send-to-owner-via-openclaw.mjs",
1478
+ },
1479
+ owner_forward_command_example: [
1480
+ `OPENCLAW_SOURCE_DIR='${openclawSourceDir}'`,
1481
+ "OPENCLAW_OWNER_CHANNEL='<channel>'",
1482
+ "OPENCLAW_OWNER_TARGET='<target>'",
1483
+ "OPENCLAW_OWNER_FORWARD_CMD='node scripts/send-to-owner-via-openclaw.mjs'",
1484
+ "node scripts/owner-forwarder-demo.mjs",
1485
+ ].join(" "),
1486
+ notes: [
1487
+ "Install and maintain the skill from SilicaClaw; do not edit OpenClaw core source for this integration.",
1488
+ "Use silicaclaw-bridge-setup first when OpenClaw still needs local install, readiness checks, or troubleshooting guidance.",
1489
+ "OpenClaw learns broadcasts via the installed skill under ~/.openclaw/workspace/skills/.",
1490
+ "Runtime detection prefers the actual OpenClaw gateway listener port, then falls back to OpenClaw's own openclaw.json gateway.port.",
1491
+ "Owner delivery runs through OpenClaw's own message channel stack after the skill forwards a summary.",
1492
+ "Sensitive computer control still requires OpenClaw's own owner approval and node permission flow.",
1493
+ ],
1494
+ };
1495
+ }
1496
+ getSkillsView() {
1497
+ const bundledRoot = (0, path_1.resolve)(this.workspaceRoot, "openclaw-skills");
1498
+ const openclawHome = (0, path_1.resolve)(process.env.HOME || "", ".openclaw");
1499
+ const workspaceInstallRoot = (0, path_1.resolve)(openclawHome, "workspace", "skills");
1500
+ const legacyInstallRoot = (0, path_1.resolve)(openclawHome, "skills");
1501
+ const bridge = this.getOpenClawBridgeStatus();
1502
+ const bundledSkills = listDirectories(bundledRoot).map((dir) => {
1503
+ const manifestPath = (0, path_1.resolve)(dir.path, "manifest.json");
1504
+ const skillPath = (0, path_1.resolve)(dir.path, "SKILL.md");
1505
+ const versionPath = (0, path_1.resolve)(dir.path, "VERSION");
1506
+ const manifest = readJsonFileSafe(manifestPath);
1507
+ const references = (manifest?.references && typeof manifest.references === "object")
1508
+ ? manifest.references
1509
+ : null;
1510
+ const ownerDialogueCheatsheetPath = references?.owner_dialogue_cheatsheet_zh
1511
+ ? (0, path_1.resolve)(dir.path, String(references.owner_dialogue_cheatsheet_zh))
1512
+ : null;
1513
+ const name = String(manifest?.name || dir.name);
1514
+ const capabilities = Array.isArray(manifest?.capabilities)
1515
+ ? manifest.capabilities.map((item) => String(item))
1516
+ : [];
1517
+ const installedWorkspacePath = (0, path_1.resolve)(workspaceInstallRoot, name);
1518
+ const installedLegacyPath = (0, path_1.resolve)(legacyInstallRoot, name);
1519
+ const installedInWorkspace = (0, fs_1.existsSync)(installedWorkspacePath);
1520
+ const installedInLegacy = (0, fs_1.existsSync)(installedLegacyPath);
1521
+ return {
1522
+ key: name,
1523
+ name,
1524
+ display_name: String(manifest?.display_name || name),
1525
+ description: String(manifest?.description || summarizeSkillReadme(skillPath) || ""),
1526
+ version: (0, fs_1.existsSync)(versionPath) ? (0, fs_1.readFileSync)(versionPath, "utf8").trim() : String(manifest?.version || ""),
1527
+ source_path: dir.path,
1528
+ manifest_path: (0, fs_1.existsSync)(manifestPath) ? manifestPath : null,
1529
+ skill_path: (0, fs_1.existsSync)(skillPath) ? skillPath : null,
1530
+ capabilities,
1531
+ transport: manifest?.transport || null,
1532
+ owner_dialogue_cheatsheet_path: ownerDialogueCheatsheetPath && (0, fs_1.existsSync)(ownerDialogueCheatsheetPath) ? ownerDialogueCheatsheetPath : null,
1533
+ owner_dialogue_examples_zh: ownerDialogueCheatsheetPath ? readDialogueCheatsheetPreview(ownerDialogueCheatsheetPath) : [],
1534
+ owner_dialogue_sections_zh: ownerDialogueCheatsheetPath ? readDialogueCheatsheetSections(ownerDialogueCheatsheetPath) : [],
1535
+ installed_in_openclaw: installedInWorkspace || installedInLegacy,
1536
+ install_mode: installedInWorkspace ? "workspace" : installedInLegacy ? "legacy" : "not_installed",
1537
+ installed_path: installedInWorkspace ? installedWorkspacePath : installedInLegacy ? installedLegacyPath : null,
1538
+ };
1539
+ });
1540
+ const installedSkills = [
1541
+ ...listDirectories(workspaceInstallRoot).map((dir) => ({ ...dir, install_mode: "workspace" })),
1542
+ ...listDirectories(legacyInstallRoot).map((dir) => ({ ...dir, install_mode: "legacy" })),
1543
+ ].map((dir) => {
1544
+ const manifestPath = (0, path_1.resolve)(dir.path, "manifest.json");
1545
+ const skillPath = (0, path_1.resolve)(dir.path, "SKILL.md");
1546
+ const versionPath = (0, path_1.resolve)(dir.path, "VERSION");
1547
+ const manifest = readJsonFileSafe(manifestPath);
1548
+ const references = (manifest?.references && typeof manifest.references === "object")
1549
+ ? manifest.references
1550
+ : null;
1551
+ const ownerDialogueCheatsheetPath = references?.owner_dialogue_cheatsheet_zh
1552
+ ? (0, path_1.resolve)(dir.path, String(references.owner_dialogue_cheatsheet_zh))
1553
+ : null;
1554
+ return {
1555
+ key: `${dir.install_mode}:${dir.name}`,
1556
+ name: String(manifest?.name || dir.name),
1557
+ display_name: String(manifest?.display_name || dir.name),
1558
+ description: String(manifest?.description || summarizeSkillReadme(skillPath) || ""),
1559
+ version: (0, fs_1.existsSync)(versionPath) ? (0, fs_1.readFileSync)(versionPath, "utf8").trim() : String(manifest?.version || ""),
1560
+ install_mode: dir.install_mode,
1561
+ installed_path: dir.path,
1562
+ manifest_path: (0, fs_1.existsSync)(manifestPath) ? manifestPath : null,
1563
+ skill_path: (0, fs_1.existsSync)(skillPath) ? skillPath : null,
1564
+ capabilities: Array.isArray(manifest?.capabilities) ? manifest.capabilities.map((item) => String(item)) : [],
1565
+ owner_dialogue_cheatsheet_path: ownerDialogueCheatsheetPath && (0, fs_1.existsSync)(ownerDialogueCheatsheetPath) ? ownerDialogueCheatsheetPath : null,
1566
+ owner_dialogue_examples_zh: ownerDialogueCheatsheetPath ? readDialogueCheatsheetPreview(ownerDialogueCheatsheetPath) : [],
1567
+ owner_dialogue_sections_zh: ownerDialogueCheatsheetPath ? readDialogueCheatsheetSections(ownerDialogueCheatsheetPath) : [],
1568
+ bundled_source_path: bundledSkills.find((item) => item.name === String(manifest?.name || dir.name))?.source_path || null,
1569
+ };
1570
+ });
1571
+ const installedSkillVersions = new Map(installedSkills.map((item) => [item.name, item.version]));
1572
+ const bundledSkillsWithUpdateState = bundledSkills.map((skill) => {
1573
+ const installedVersion = installedSkillVersions.get(skill.name) || "";
1574
+ const updateAvailable = Boolean(skill.installed_in_openclaw &&
1575
+ installedVersion &&
1576
+ skill.version &&
1577
+ compareVersionTokens(installedVersion, skill.version) < 0);
1578
+ return {
1579
+ ...skill,
1580
+ installed_version: installedVersion || null,
1581
+ update_available: updateAvailable,
1582
+ };
1583
+ });
1584
+ const bundledSkillVersions = new Map(bundledSkillsWithUpdateState.map((item) => [item.name, item.version]));
1585
+ const installedSkillsWithUpdateState = installedSkills.map((skill) => {
1586
+ const bundledVersion = bundledSkillVersions.get(skill.name) || "";
1587
+ const updateAvailable = Boolean(bundledVersion &&
1588
+ skill.version &&
1589
+ compareVersionTokens(skill.version, bundledVersion) < 0);
1590
+ return {
1591
+ ...skill,
1592
+ bundled_version: bundledVersion || null,
1593
+ update_available: updateAvailable,
1594
+ };
1595
+ });
1596
+ return {
1597
+ openclaw: {
1598
+ detected: bridge.openclaw_installation.detected,
1599
+ running: bridge.openclaw_runtime.running,
1600
+ detection_mode: bridge.openclaw_runtime.detection_mode,
1601
+ gateway_url: bridge.openclaw_runtime.gateway_url,
1602
+ workspace_install_root: workspaceInstallRoot,
1603
+ legacy_install_root: legacyInstallRoot,
1604
+ },
1605
+ summary: {
1606
+ bundled_count: bundledSkillsWithUpdateState.length,
1607
+ installed_count: installedSkillsWithUpdateState.length,
1608
+ installed_bundled_count: bundledSkillsWithUpdateState.filter((item) => item.installed_in_openclaw).length,
1609
+ update_available_count: bundledSkillsWithUpdateState.filter((item) => item.update_available).length,
1610
+ },
1611
+ install_action: bridge.skill_learning.install_action,
1612
+ bundled_skills: bundledSkillsWithUpdateState,
1613
+ installed_skills: installedSkillsWithUpdateState,
1614
+ };
1615
+ }
1616
+ getRuntimeMessageGovernance() {
1617
+ return this.messageGovernance;
1618
+ }
1619
+ async getMessageGovernanceView() {
1620
+ const logs = await this.logRepo.get();
1621
+ const recentEvents = logs
1622
+ .filter((entry) => (entry.message.includes("Rejected social message") ||
1623
+ entry.message.includes("Social message blocked") ||
1624
+ entry.message.includes("Social message throttled")))
1625
+ .slice(0, 20);
1626
+ return {
1627
+ policy: {
1628
+ send_limit: { max: this.messageGovernance.send_limit_max, window_ms: this.messageGovernance.send_window_ms },
1629
+ receive_limit: { max: this.messageGovernance.receive_limit_max, window_ms: this.messageGovernance.receive_window_ms },
1630
+ duplicate_window_ms: this.messageGovernance.duplicate_window_ms,
1631
+ blocked_agent_ids: Array.from(this.messageGovernance.blocked_agent_ids),
1632
+ blocked_terms: Array.from(this.messageGovernance.blocked_terms),
1633
+ },
1634
+ recent_events: recentEvents,
1635
+ };
1636
+ }
1637
+ async updateMessageGovernance(input) {
1638
+ const next = {
1639
+ send_limit_max: Math.max(1, Math.min(100, Number(input.send_limit_max ?? this.messageGovernance.send_limit_max) || this.messageGovernance.send_limit_max)),
1640
+ send_window_ms: Math.max(5_000, Math.min(3_600_000, Number(input.send_window_ms ?? this.messageGovernance.send_window_ms) || this.messageGovernance.send_window_ms)),
1641
+ receive_limit_max: Math.max(1, Math.min(200, Number(input.receive_limit_max ?? this.messageGovernance.receive_limit_max) || this.messageGovernance.receive_limit_max)),
1642
+ receive_window_ms: Math.max(5_000, Math.min(3_600_000, Number(input.receive_window_ms ?? this.messageGovernance.receive_window_ms) || this.messageGovernance.receive_window_ms)),
1643
+ duplicate_window_ms: Math.max(5_000, Math.min(3_600_000, Number(input.duplicate_window_ms ?? this.messageGovernance.duplicate_window_ms) || this.messageGovernance.duplicate_window_ms)),
1644
+ blocked_agent_ids: dedupeStrings(Array.isArray(input.blocked_agent_ids) ? input.blocked_agent_ids.map((item) => String(item || "").trim()) : this.messageGovernance.blocked_agent_ids),
1645
+ blocked_terms: dedupeStrings(Array.isArray(input.blocked_terms) ? input.blocked_terms.map((item) => String(item || "").trim().toLowerCase()) : this.messageGovernance.blocked_terms),
1646
+ };
1647
+ this.messageGovernance = next;
1648
+ await this.socialMessageGovernanceRepo.set(next);
1649
+ await this.log("info", "Runtime message governance updated");
1650
+ return this.getMessageGovernanceView();
1651
+ }
1652
+ async sendSocialMessage(body, topic = DEFAULT_SOCIAL_MESSAGE_CHANNEL) {
1653
+ if (!this.identity || !this.profile) {
1654
+ return { sent: false, reason: "missing_identity_or_profile" };
1655
+ }
1656
+ if (!this.profile.public_enabled) {
1657
+ return { sent: false, reason: "public_disabled" };
1658
+ }
1659
+ if (!this.broadcastEnabled) {
1660
+ return { sent: false, reason: "broadcast_paused" };
1661
+ }
1662
+ if (!this.socialConfig.discovery.allow_message_broadcast) {
1663
+ return { sent: false, reason: "message_broadcast_disabled" };
1664
+ }
1665
+ const normalizedBody = this.normalizeSocialMessageBody(body);
1666
+ const normalizedTopic = String(topic || DEFAULT_SOCIAL_MESSAGE_CHANNEL).trim() || DEFAULT_SOCIAL_MESSAGE_CHANNEL;
1667
+ if (!normalizedBody) {
1668
+ return { sent: false, reason: "empty_message" };
1669
+ }
1670
+ if (normalizedBody.length > SOCIAL_MESSAGE_MAX_BODY_CHARS) {
1671
+ return { sent: false, reason: "message_too_long" };
1672
+ }
1673
+ if (this.containsBlockedMessageTerm(normalizedBody)) {
1674
+ await this.log("warn", `Social message blocked: blocked_term (${this.identity.agent_id.slice(0, 10)})`);
1675
+ return { sent: false, reason: "blocked_term" };
1676
+ }
1677
+ if (this.isRateLimited(this.outboundMessageTimestamps, this.messageGovernance.send_window_ms, this.messageGovernance.send_limit_max)) {
1678
+ await this.log("warn", `Social message throttled: rate_limited (${this.identity.agent_id.slice(0, 10)})`);
1679
+ return { sent: false, reason: "rate_limited" };
1680
+ }
1681
+ if (this.hasRecentDuplicateMessage(this.identity.agent_id, normalizedBody, normalizedTopic)) {
1682
+ await this.log("warn", `Social message blocked: duplicate_recent_message (${this.identity.agent_id.slice(0, 10)})`);
1683
+ return { sent: false, reason: "duplicate_recent_message" };
1684
+ }
1685
+ const message = (0, core_1.signSocialMessage)({
1686
+ identity: this.identity,
1687
+ message_id: (0, crypto_1.createHash)("sha256")
1688
+ .update(`${this.identity.agent_id}:${normalizedTopic}:${Date.now()}:${normalizedBody}:${Math.random()}`, "utf8")
1689
+ .digest("hex"),
1690
+ display_name: this.profile.display_name,
1691
+ topic: normalizedTopic,
1692
+ body: normalizedBody,
1693
+ created_at: Date.now(),
1694
+ });
1695
+ this.recordTimestamp(this.outboundMessageTimestamps, this.messageGovernance.send_window_ms, message.created_at);
1696
+ this.ingestSocialMessage(message);
1697
+ try {
1698
+ await this.publish(SOCIAL_MESSAGE_TOPIC, message);
1699
+ }
1700
+ catch (error) {
1701
+ const messageText = error instanceof Error ? error.message : String(error);
1702
+ this.lastBroadcastErrorAt = Date.now();
1703
+ this.lastBroadcastError = messageText;
1704
+ this.broadcastFailureCount += 1;
1705
+ await this.persistSocialMessages();
1706
+ await this.log("error", `Social message broadcast failed (${message.message_id.slice(0, 10)}): ${messageText}`);
1707
+ return {
1708
+ sent: false,
1709
+ reason: "publish_failed",
1710
+ error: messageText,
1711
+ message: this.getSocialMessages(1).items[0],
1712
+ };
1713
+ }
1714
+ await this.persistSocialMessages();
1715
+ await this.log("info", `Social message broadcast (${message.message_id.slice(0, 10)})`);
1716
+ return {
1717
+ sent: true,
1718
+ reason: "sent",
1719
+ message: this.getSocialMessages(1).items[0],
1720
+ };
1721
+ }
1722
+ async getLogs() {
1723
+ return this.logRepo.get();
1724
+ }
1725
+ async ensureIdentity() {
1726
+ if (this.identity) {
1727
+ return this.identity;
1728
+ }
1729
+ const identity = (0, core_1.createIdentity)();
1730
+ this.identity = identity;
1731
+ await this.identityRepo.set(identity);
1732
+ this.initState.identity_auto_created = true;
1733
+ const seededProfile = (0, core_1.signProfile)((0, core_1.createDefaultProfileInput)(identity.agent_id), identity);
1734
+ this.profile = seededProfile;
1735
+ await this.profileRepo.set(seededProfile);
1736
+ this.initState.profile_auto_created = true;
1737
+ await this.log("info", `Identity created automatically: ${identity.agent_id.slice(0, 12)}`);
1738
+ return identity;
1739
+ }
1740
+ async updateProfile(input) {
1741
+ const identity = await this.ensureIdentity();
1742
+ const base = this.profile ?? (0, core_1.signProfile)((0, core_1.createDefaultProfileInput)(identity.agent_id), identity);
1743
+ const next = (0, core_1.signProfile)({
1744
+ agent_id: identity.agent_id,
1745
+ display_name: input.display_name ?? base.display_name,
1746
+ bio: input.bio ?? base.bio,
1747
+ tags: input.tags ?? base.tags,
1748
+ avatar_url: input.avatar_url ?? base.avatar_url,
1749
+ public_enabled: input.public_enabled ?? base.public_enabled,
1750
+ }, identity);
1751
+ this.profile = next;
1752
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, { type: "profile", profile: next });
1753
+ await this.profileRepo.set(next);
1754
+ await this.persistCache();
1755
+ await this.log("info", `Profile updated (public=${next.public_enabled})`);
1756
+ if (next.public_enabled && this.broadcastEnabled) {
1757
+ await this.broadcastNow("profile_update");
1758
+ }
1759
+ await this.writeSocialRuntime();
1760
+ return next;
1761
+ }
1762
+ async refreshCache() {
1763
+ const removed = this.compactCacheInMemory();
1764
+ await this.persistCache();
1765
+ await this.log("info", `Cache refreshed (expired presence removed=${removed})`);
1766
+ return {
1767
+ removed_presence: removed,
1768
+ profile_count: Object.keys(this.directory.profiles).length,
1769
+ index_key_count: Object.keys(this.directory.index).length,
1770
+ };
1771
+ }
1772
+ async clearDiscoveredCache() {
1773
+ const selfAgentId = this.profile?.agent_id || this.identity?.agent_id || "";
1774
+ const profileEntries = Object.entries(this.directory.profiles);
1775
+ const removedProfiles = profileEntries.filter(([agentId]) => agentId !== selfAgentId).length;
1776
+ const removedPresence = Object.entries(this.directory.presence).filter(([agentId]) => agentId !== selfAgentId).length;
1777
+ const removedIndexRefs = Object.values(this.directory.index).reduce((acc, agentIds) => {
1778
+ const removed = agentIds.filter((agentId) => agentId !== selfAgentId).length;
1779
+ return acc + removed;
1780
+ }, 0);
1781
+ this.directory = (0, core_1.createEmptyDirectoryState)();
1782
+ if (this.profile) {
1783
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, {
1784
+ type: "profile",
1785
+ profile: this.profile,
1786
+ });
1787
+ }
1788
+ await this.persistCache();
1789
+ await this.log("warn", `Discovered cache cleared (profiles=${removedProfiles}, presence=${removedPresence}, index_refs=${removedIndexRefs})`);
1790
+ return {
1791
+ removed_profiles: removedProfiles,
1792
+ removed_presence: removedPresence,
1793
+ removed_index_refs: removedIndexRefs,
1794
+ kept_self_profile: Boolean(this.profile),
1795
+ };
1796
+ }
1797
+ async setBroadcastEnabled(enabled) {
1798
+ this.broadcastEnabled = enabled;
1799
+ if (enabled) {
1800
+ this.startBroadcastLoop();
1801
+ await this.log("info", "Broadcast loop enabled");
1802
+ if (this.profile?.public_enabled) {
1803
+ await this.broadcastNow("manual_start");
1804
+ }
1805
+ }
1806
+ else {
1807
+ if (this.broadcaster) {
1808
+ clearInterval(this.broadcaster);
1809
+ this.broadcaster = null;
1810
+ }
1811
+ await this.log("warn", "Broadcast loop paused");
1812
+ }
1813
+ await this.writeSocialRuntime();
1814
+ return { broadcast_enabled: this.broadcastEnabled };
1815
+ }
1816
+ async broadcastNow(reason = "manual") {
1817
+ if (!this.identity || !this.profile) {
1818
+ return { sent: false, reason: "missing_identity_or_profile" };
1819
+ }
1820
+ if (!this.profile.public_enabled) {
1821
+ return { sent: false, reason: "public_disabled" };
1822
+ }
1823
+ if (!this.broadcastEnabled) {
1824
+ return { sent: false, reason: "broadcast_paused" };
1825
+ }
1826
+ const profileRecord = {
1827
+ type: "profile",
1828
+ profile: this.profile,
1829
+ };
1830
+ const presenceRecord = (0, core_1.signPresence)(this.identity, Date.now());
1831
+ const indexRecords = (0, core_1.buildIndexRecords)(this.profile);
1832
+ const replayMessages = this.getReplayableSelfSocialMessages();
1833
+ try {
1834
+ await this.publish("profile", profileRecord);
1835
+ await this.publish("presence", presenceRecord);
1836
+ for (const record of indexRecords) {
1837
+ await this.publish("index", record);
1838
+ }
1839
+ for (const message of replayMessages) {
1840
+ await this.publish(SOCIAL_MESSAGE_TOPIC, message);
1841
+ }
1842
+ }
1843
+ catch (error) {
1844
+ const message = error instanceof Error ? error.message : String(error);
1845
+ this.lastBroadcastErrorAt = Date.now();
1846
+ this.lastBroadcastError = message;
1847
+ this.broadcastFailureCount += 1;
1848
+ await this.log("error", `Broadcast failed (reason=${reason}): ${message}`);
1849
+ return { sent: false, reason: "publish_failed", error: message };
1850
+ }
1851
+ this.lastBroadcastAt = Date.now();
1852
+ this.broadcastCount += 1;
1853
+ this.lastBroadcastError = null;
1854
+ this.lastBroadcastErrorAt = 0;
1855
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, profileRecord);
1856
+ this.directory = (0, core_1.ingestPresenceRecord)(this.directory, presenceRecord);
1857
+ for (const record of indexRecords) {
1858
+ this.directory = (0, core_1.ingestIndexRecord)(this.directory, record);
1859
+ }
1860
+ this.compactCacheInMemory();
1861
+ await this.persistCache();
1862
+ await this.log("info", `Broadcast sent (${indexRecords.length} index refs, replayed_messages=${replayMessages.length}, reason=${reason})`);
1863
+ return { sent: true, reason };
1864
+ }
1865
+ async hydrateFromDisk() {
1866
+ this.initState = {
1867
+ identity_auto_created: false,
1868
+ profile_auto_created: false,
1869
+ social_auto_created: this.initState.social_auto_created,
1870
+ initialized_at: Date.now(),
1871
+ };
1872
+ if (this.initState.social_auto_created) {
1873
+ await this.log("info", "social.md missing, auto-generated minimal default template");
1874
+ }
1875
+ const existingIdentity = await this.identityRepo.get();
1876
+ const resolvedIdentity = (0, core_1.resolveIdentityWithSocial)({
1877
+ socialConfig: this.socialConfig,
1878
+ existingIdentity,
1879
+ generatedIdentity: (0, core_1.createIdentity)(),
1880
+ rootDir: this.projectRoot,
1881
+ });
1882
+ this.identity = resolvedIdentity.identity;
1883
+ this.resolvedIdentitySource = resolvedIdentity.source;
1884
+ this.resolvedOpenClawIdentityPath = resolvedIdentity.openclaw_source_path;
1885
+ if (resolvedIdentity.source === "silicaclaw-generated") {
1886
+ this.initState.identity_auto_created = true;
1887
+ await this.log("info", "identity.json missing, auto-generated SilicaClaw identity");
1888
+ }
1889
+ if (resolvedIdentity.source === "openclaw-existing" && resolvedIdentity.openclaw_source_path) {
1890
+ await this.log("info", `Bound existing OpenClaw identity: ${resolvedIdentity.openclaw_source_path}`);
1891
+ }
1892
+ await this.identityRepo.set(this.identity);
1893
+ const existingProfile = await this.profileRepo.get();
1894
+ const profileInput = (0, core_1.resolveProfileInputWithSocial)({
1895
+ socialConfig: this.socialConfig,
1896
+ agentId: this.identity.agent_id,
1897
+ existingProfile: existingProfile && existingProfile.agent_id === this.identity.agent_id ? existingProfile : null,
1898
+ rootDir: this.projectRoot,
1899
+ });
1900
+ this.profile = (0, core_1.signProfile)(profileInput, this.identity);
1901
+ if (!existingProfile || existingProfile.agent_id !== this.identity.agent_id) {
1902
+ this.initState.profile_auto_created = true;
1903
+ await this.log("info", "profile.json missing/invalid, initialized from social/default profile");
1904
+ }
1905
+ await this.profileRepo.set(this.profile);
1906
+ this.directory = (0, core_1.createEmptyDirectoryState)();
1907
+ this.messageGovernance = {
1908
+ ...this.defaultMessageGovernance(),
1909
+ ...(await this.socialMessageGovernanceRepo.get()),
1910
+ };
1911
+ this.socialMessages = this.normalizeSocialMessages(await this.socialMessageRepo.get());
1912
+ this.socialMessageObservations = this.normalizeSocialMessageObservations(await this.socialMessageObservationRepo.get());
1913
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, { type: "profile", profile: this.profile });
1914
+ this.compactCacheInMemory();
1915
+ await this.persistCache();
1916
+ await this.applySocialConfigOnCurrentState();
1917
+ await this.writeSocialRuntime();
1918
+ }
1919
+ async applySocialConfigOnCurrentState() {
1920
+ if (!this.identity || !this.profile) {
1921
+ return;
1922
+ }
1923
+ const nextProfileInput = (0, core_1.resolveProfileInputWithSocial)({
1924
+ socialConfig: this.socialConfig,
1925
+ agentId: this.identity.agent_id,
1926
+ existingProfile: this.profile,
1927
+ rootDir: this.projectRoot,
1928
+ });
1929
+ const nextProfile = (0, core_1.signProfile)(nextProfileInput, this.identity);
1930
+ this.profile = nextProfile;
1931
+ await this.profileRepo.set(nextProfile);
1932
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, { type: "profile", profile: nextProfile });
1933
+ this.compactCacheInMemory();
1934
+ await this.persistCache();
1935
+ if (!this.socialConfig.enabled) {
1936
+ await this.setBroadcastEnabled(false);
1937
+ return;
1938
+ }
1939
+ if (!this.broadcastEnabled) {
1940
+ await this.setBroadcastEnabled(true);
1941
+ }
1942
+ }
1943
+ async writeSocialRuntime() {
1944
+ const runtime = {
1945
+ enabled: this.socialConfig.enabled,
1946
+ public_enabled: this.socialConfig.public_enabled,
1947
+ source_path: this.socialSourcePath,
1948
+ last_loaded_at: Date.now(),
1949
+ social_found: this.socialFound,
1950
+ parse_error: this.socialParseError,
1951
+ resolved_identity: this.identity
1952
+ ? {
1953
+ agent_id: this.identity.agent_id,
1954
+ public_key: this.identity.public_key,
1955
+ created_at: this.identity.created_at,
1956
+ source: this.resolvedIdentitySource,
1957
+ }
1958
+ : null,
1959
+ resolved_profile: this.profile
1960
+ ? {
1961
+ display_name: this.profile.display_name,
1962
+ bio: this.profile.bio,
1963
+ avatar_url: this.profile.avatar_url,
1964
+ tags: this.profile.tags,
1965
+ public_enabled: this.profile.public_enabled,
1966
+ }
1967
+ : null,
1968
+ resolved_network: {
1969
+ mode: this.networkMode,
1970
+ adapter: this.adapterMode,
1971
+ namespace: this.networkNamespace,
1972
+ port: this.networkPort,
1973
+ signaling_url: this.webrtcSignalingUrls[0] ?? WEBRTC_SIGNALING_URL,
1974
+ signaling_urls: this.webrtcSignalingUrls,
1975
+ room: this.webrtcRoom,
1976
+ seed_peers: this.webrtcSeedPeers,
1977
+ bootstrap_hints: this.webrtcBootstrapHints,
1978
+ bootstrap_sources: this.webrtcBootstrapSources,
1979
+ },
1980
+ resolved_discovery: this.socialConfig.discovery,
1981
+ visibility: this.socialConfig.visibility,
1982
+ openclaw: this.socialConfig.openclaw,
1983
+ };
1984
+ this.socialRuntime = runtime;
1985
+ await this.socialRuntimeRepo.set(runtime);
1986
+ }
1987
+ async onMessage(topic, data) {
1988
+ this.receivedCount += 1;
1989
+ this.receivedByTopic[topic] = (this.receivedByTopic[topic] ?? 0) + 1;
1990
+ this.lastMessageAt = Date.now();
1991
+ if (topic === "profile") {
1992
+ const record = data;
1993
+ if (!record?.profile?.agent_id || !record?.profile?.signature) {
1994
+ return;
1995
+ }
1996
+ if (record.profile.agent_id === this.identity?.agent_id && this.identity) {
1997
+ if (!(0, core_1.verifyProfile)(record.profile, this.identity.public_key)) {
1998
+ await this.log("warn", "Rejected self profile with invalid signature");
1999
+ return;
2000
+ }
2001
+ }
2002
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, record);
2003
+ this.compactCacheInMemory();
2004
+ await this.persistCache();
2005
+ return;
2006
+ }
2007
+ if (topic === "presence") {
2008
+ const record = data;
2009
+ if (!record?.agent_id || !record?.signature || typeof record.timestamp !== "number") {
2010
+ return;
2011
+ }
2012
+ if (record.agent_id === this.identity?.agent_id && this.identity) {
2013
+ if (!(0, core_1.verifyPresence)(record, this.identity.public_key)) {
2014
+ await this.log("warn", "Rejected invalid self presence signature");
2015
+ return;
2016
+ }
2017
+ }
2018
+ this.directory = (0, core_1.ingestPresenceRecord)(this.directory, record);
2019
+ this.compactCacheInMemory();
2020
+ await this.persistCache();
2021
+ return;
2022
+ }
2023
+ if (topic === SOCIAL_MESSAGE_TOPIC) {
2024
+ const record = this.normalizeIncomingSocialMessage(data);
2025
+ if (!record) {
2026
+ return;
2027
+ }
2028
+ if (!(0, core_1.verifySocialMessage)(record)) {
2029
+ await this.log("warn", `Rejected social message with invalid signature (${record.message_id.slice(0, 10)})`);
2030
+ return;
2031
+ }
2032
+ if (this.hasSocialMessage(record.message_id)) {
2033
+ await this.publishObservationForMessage(record);
2034
+ return;
2035
+ }
2036
+ const governanceReason = this.getIncomingSocialMessageRejectionReason(record);
2037
+ if (governanceReason) {
2038
+ await this.log("warn", `Rejected social message (${record.message_id.slice(0, 10)}): ${governanceReason}`);
2039
+ return;
2040
+ }
2041
+ this.ingestSocialMessage(record);
2042
+ await this.persistSocialMessages();
2043
+ await this.publishObservationForMessage(record);
2044
+ return;
2045
+ }
2046
+ if (topic === SOCIAL_MESSAGE_OBSERVATION_TOPIC) {
2047
+ const record = this.normalizeIncomingSocialMessageObservation(data);
2048
+ if (!record) {
2049
+ return;
2050
+ }
2051
+ if (!(0, core_1.verifySocialMessageObservation)(record)) {
2052
+ await this.log("warn", `Rejected message observation with invalid signature (${record.observation_id.slice(0, 10)})`);
2053
+ return;
2054
+ }
2055
+ this.ingestSocialMessageObservation(record);
2056
+ await this.persistSocialMessageObservations();
2057
+ return;
2058
+ }
2059
+ const record = data;
2060
+ if (!record?.key || !record?.agent_id) {
2061
+ return;
2062
+ }
2063
+ this.directory = (0, core_1.ingestIndexRecord)(this.directory, record);
2064
+ this.directory = (0, core_1.dedupeIndex)(this.directory);
2065
+ await this.persistCache();
2066
+ }
2067
+ startBroadcastLoop() {
2068
+ if (this.broadcaster) {
2069
+ clearInterval(this.broadcaster);
2070
+ }
2071
+ if (!this.broadcastEnabled) {
2072
+ return;
2073
+ }
2074
+ this.broadcaster = setInterval(async () => {
2075
+ try {
2076
+ await this.broadcastNow("interval");
2077
+ }
2078
+ catch (error) {
2079
+ await this.log("warn", `Scheduled broadcast failed: ${error instanceof Error ? error.message : String(error)}`);
2080
+ }
2081
+ }, BROADCAST_INTERVAL_MS);
2082
+ }
2083
+ bindNetworkSubscriptions() {
2084
+ if (this.subscriptionsBound) {
2085
+ return;
2086
+ }
2087
+ this.network.subscribe("profile", (data) => {
2088
+ this.onMessage("profile", data);
2089
+ });
2090
+ this.network.subscribe("presence", (data) => {
2091
+ this.onMessage("presence", data);
2092
+ });
2093
+ this.network.subscribe("index", (data) => {
2094
+ this.onMessage("index", data);
2095
+ });
2096
+ this.network.subscribe(SOCIAL_MESSAGE_TOPIC, (data) => {
2097
+ this.onMessage(SOCIAL_MESSAGE_TOPIC, data);
2098
+ });
2099
+ this.network.subscribe(SOCIAL_MESSAGE_OBSERVATION_TOPIC, (data) => {
2100
+ this.onMessage(SOCIAL_MESSAGE_OBSERVATION_TOPIC, data);
2101
+ });
2102
+ this.subscriptionsBound = true;
2103
+ }
2104
+ buildNetworkAdapter() {
2105
+ const mode = process.env.NETWORK_ADAPTER || this.socialConfig.network.adapter;
2106
+ if (mode === "mock") {
2107
+ return {
2108
+ adapter: new network_1.MockNetworkAdapter(),
2109
+ mode: "mock",
2110
+ port: null,
2111
+ };
2112
+ }
2113
+ if (mode === "real-preview") {
2114
+ return {
2115
+ adapter: new network_1.RealNetworkAdapterPreview({
2116
+ peerId: NETWORK_PEER_ID,
2117
+ namespace: this.networkNamespace,
2118
+ transport: new network_1.UdpLanBroadcastTransport({
2119
+ port: this.networkPort ?? undefined,
2120
+ bindAddress: NETWORK_UDP_BIND_ADDRESS,
2121
+ broadcastAddress: NETWORK_UDP_BROADCAST_ADDRESS,
2122
+ }),
2123
+ peerDiscovery: new network_1.HeartbeatPeerDiscovery({
2124
+ heartbeatIntervalMs: NETWORK_HEARTBEAT_INTERVAL_MS,
2125
+ staleAfterMs: NETWORK_PEER_STALE_AFTER_MS,
2126
+ removeAfterMs: NETWORK_PEER_REMOVE_AFTER_MS,
2127
+ }),
2128
+ maxMessageBytes: NETWORK_MAX_MESSAGE_BYTES,
2129
+ dedupeWindowMs: NETWORK_DEDUPE_WINDOW_MS,
2130
+ dedupeMaxEntries: NETWORK_DEDUPE_MAX_ENTRIES,
2131
+ maxFutureDriftMs: NETWORK_MAX_FUTURE_DRIFT_MS,
2132
+ maxPastDriftMs: NETWORK_MAX_PAST_DRIFT_MS,
2133
+ }),
2134
+ mode: "real-preview",
2135
+ port: this.networkPort,
2136
+ };
2137
+ }
2138
+ if (mode === "webrtc-preview") {
2139
+ return {
2140
+ adapter: new network_1.WebRTCPreviewAdapter({
2141
+ peerId: NETWORK_PEER_ID,
2142
+ namespace: this.networkNamespace,
2143
+ signalingUrl: this.webrtcSignalingUrls[0] ?? WEBRTC_SIGNALING_URL,
2144
+ signalingUrls: this.webrtcSignalingUrls,
2145
+ room: this.webrtcRoom,
2146
+ seedPeers: this.webrtcSeedPeers,
2147
+ bootstrapHints: this.webrtcBootstrapHints,
2148
+ bootstrapSources: this.webrtcBootstrapSources,
2149
+ maxMessageBytes: NETWORK_MAX_MESSAGE_BYTES,
2150
+ maxFutureDriftMs: NETWORK_MAX_FUTURE_DRIFT_MS,
2151
+ maxPastDriftMs: NETWORK_MAX_PAST_DRIFT_MS,
2152
+ }),
2153
+ mode: "webrtc-preview",
2154
+ port: this.networkPort,
2155
+ };
2156
+ }
2157
+ if (mode === "relay-preview") {
2158
+ return {
2159
+ adapter: new network_1.RelayPreviewAdapter({
2160
+ peerId: NETWORK_PEER_ID,
2161
+ namespace: this.networkNamespace,
2162
+ signalingUrl: this.webrtcSignalingUrls[0] ?? WEBRTC_SIGNALING_URL,
2163
+ signalingUrls: this.webrtcSignalingUrls,
2164
+ room: this.webrtcRoom,
2165
+ seedPeers: this.webrtcSeedPeers,
2166
+ bootstrapHints: this.webrtcBootstrapHints,
2167
+ bootstrapSources: this.webrtcBootstrapSources,
2168
+ maxMessageBytes: NETWORK_MAX_MESSAGE_BYTES,
2169
+ maxFutureDriftMs: NETWORK_MAX_FUTURE_DRIFT_MS,
2170
+ maxPastDriftMs: NETWORK_MAX_PAST_DRIFT_MS,
2171
+ }),
2172
+ mode: "relay-preview",
2173
+ port: this.networkPort,
2174
+ };
2175
+ }
2176
+ return {
2177
+ adapter: new network_1.LocalEventBusAdapter(),
2178
+ mode: "local-event-bus",
2179
+ port: null,
2180
+ };
2181
+ }
2182
+ async restartNetworkAdapter(reason) {
2183
+ const previous = this.network;
2184
+ try {
2185
+ await previous.stop();
2186
+ }
2187
+ catch (error) {
2188
+ await this.log("warn", `Old adapter stop error during restart (${reason}): ${error instanceof Error ? error.message : String(error)}`);
2189
+ }
2190
+ const next = this.buildNetworkAdapter();
2191
+ this.network = next.adapter;
2192
+ this.adapterMode = next.mode;
2193
+ this.networkPort = next.port;
2194
+ this.subscriptionsBound = false;
2195
+ await this.network.start();
2196
+ this.bindNetworkSubscriptions();
2197
+ this.startBroadcastLoop();
2198
+ if (this.broadcastEnabled && this.profile?.public_enabled) {
2199
+ await this.broadcastNow("adapter_restart");
2200
+ }
2201
+ }
2202
+ compactCacheInMemory() {
2203
+ const cleaned = (0, core_1.cleanupExpiredPresence)(this.directory, Date.now(), PRESENCE_TTL_MS);
2204
+ this.directory = (0, core_1.dedupeIndex)(cleaned.state);
2205
+ return cleaned.removed;
2206
+ }
2207
+ async publish(topic, data) {
2208
+ await this.network.publish(topic, data);
2209
+ this.publishedByTopic[topic] = (this.publishedByTopic[topic] ?? 0) + 1;
2210
+ }
2211
+ async persistCache() {
2212
+ const persisted = (0, core_1.createEmptyDirectoryState)();
2213
+ if (this.profile) {
2214
+ const selfProfileRecord = {
2215
+ type: "profile",
2216
+ profile: this.profile,
2217
+ };
2218
+ this.directory = (0, core_1.ingestProfileRecord)(this.directory, selfProfileRecord);
2219
+ persisted.profiles[this.profile.agent_id] = this.profile;
2220
+ const selfLastSeenAt = this.directory.presence[this.profile.agent_id];
2221
+ if (typeof selfLastSeenAt === "number" && Number.isFinite(selfLastSeenAt)) {
2222
+ persisted.presence[this.profile.agent_id] = selfLastSeenAt;
2223
+ }
2224
+ const indexed = (0, core_1.rebuildIndexForProfile)(persisted, this.profile);
2225
+ persisted.index = indexed.index;
2226
+ }
2227
+ await this.cacheRepo.set(persisted);
2228
+ }
2229
+ async persistSocialMessages() {
2230
+ await this.socialMessageRepo.set(this.socialMessages);
2231
+ }
2232
+ async persistSocialMessageObservations() {
2233
+ await this.socialMessageObservationRepo.set(this.socialMessageObservations);
2234
+ }
2235
+ async log(level, message) {
2236
+ await this.logRepo.append({
2237
+ level,
2238
+ message,
2239
+ timestamp: Date.now(),
2240
+ });
2241
+ }
2242
+ getAdapterDiagnostics() {
2243
+ if (typeof this.network.getDiagnostics !== "function") {
2244
+ return null;
2245
+ }
2246
+ return this.network.getDiagnostics();
2247
+ }
2248
+ getResolvedRealtimeNetworkSummary() {
2249
+ const diagnostics = this.getAdapterDiagnostics();
2250
+ const relayCapable = this.adapterMode === "webrtc-preview" || this.adapterMode === "relay-preview";
2251
+ return {
2252
+ diagnostics,
2253
+ signaling_url: diagnostics?.signaling_url ?? (relayCapable ? this.webrtcSignalingUrls[0] ?? null : null),
2254
+ signaling_endpoints: diagnostics?.signaling_endpoints ?? (relayCapable ? this.webrtcSignalingUrls : []),
2255
+ room: diagnostics?.room ?? (relayCapable ? this.webrtcRoom : null),
2256
+ bootstrap_sources: diagnostics?.bootstrap_sources ?? (relayCapable ? this.webrtcBootstrapSources : []),
2257
+ seed_peers_count: diagnostics?.seed_peers_count ?? this.webrtcSeedPeers.length,
2258
+ };
2259
+ }
2260
+ toPublicProfileSummary(profile, options) {
2261
+ const lastSeenAt = options?.last_seen_at ?? this.directory.presence[profile.agent_id] ?? 0;
2262
+ const online = (0, core_1.isAgentOnline)(lastSeenAt, Date.now(), PRESENCE_TTL_MS);
2263
+ const isSelf = profile.agent_id === this.identity?.agent_id;
2264
+ const visibility = isSelf
2265
+ ? {
2266
+ show_tags: this.socialConfig.visibility.show_tags,
2267
+ show_last_seen: this.socialConfig.visibility.show_last_seen,
2268
+ show_capabilities_summary: this.socialConfig.visibility.show_capabilities_summary,
2269
+ }
2270
+ : {
2271
+ show_tags: true,
2272
+ show_last_seen: true,
2273
+ show_capabilities_summary: true,
2274
+ };
2275
+ const selfPublicKey = isSelf ? this.identity?.public_key ?? null : null;
2276
+ const verifiedProfile = Boolean(isSelf &&
2277
+ selfPublicKey &&
2278
+ (0, core_1.verifyProfile)(profile, selfPublicKey));
2279
+ return (0, core_1.buildPublicProfileSummary)({
2280
+ profile,
2281
+ online,
2282
+ last_seen_at: lastSeenAt || null,
2283
+ network_mode: isSelf ? this.networkMode : "unknown",
2284
+ openclaw_bound: isSelf
2285
+ ? this.resolvedIdentitySource === "openclaw-existing"
2286
+ : profile.tags.some((tag) => String(tag).trim().toLowerCase() === "openclaw"),
2287
+ visibility,
2288
+ profile_version: PROFILE_VERSION,
2289
+ public_key_fingerprint: selfPublicKey ? this.fingerprintPublicKey(selfPublicKey) : null,
2290
+ verified_profile: verifiedProfile,
2291
+ now: Date.now(),
2292
+ presence_ttl_ms: PRESENCE_TTL_MS,
2293
+ });
2294
+ }
2295
+ mergeMessageOnlyAgentSummaries(summaries, keyword) {
2296
+ const normalizedKeyword = String(keyword || "").trim().toLowerCase();
2297
+ const knownAgentIds = new Set(summaries.map((item) => item.agent_id));
2298
+ const messageOnly = [];
2299
+ for (const message of this.socialMessages) {
2300
+ if (!message?.agent_id || knownAgentIds.has(message.agent_id)) {
2301
+ continue;
2302
+ }
2303
+ const displayName = String(message.display_name || "Unnamed").trim() || "Unnamed";
2304
+ if (normalizedKeyword) {
2305
+ const haystacks = [
2306
+ displayName.toLowerCase(),
2307
+ message.agent_id.toLowerCase(),
2308
+ String(message.topic || "").toLowerCase(),
2309
+ ];
2310
+ if (!haystacks.some((value) => value.includes(normalizedKeyword))) {
2311
+ continue;
2312
+ }
2313
+ }
2314
+ knownAgentIds.add(message.agent_id);
2315
+ messageOnly.push((0, core_1.buildPublicProfileSummary)({
2316
+ profile: {
2317
+ agent_id: message.agent_id,
2318
+ display_name: displayName,
2319
+ bio: "Seen from signed public message. Profile/presence not synced yet.",
2320
+ tags: ["message-only"],
2321
+ avatar_url: "",
2322
+ public_enabled: true,
2323
+ updated_at: message.created_at,
2324
+ signature: "",
2325
+ },
2326
+ online: false,
2327
+ last_seen_at: null,
2328
+ network_mode: "unknown",
2329
+ openclaw_bound: false,
2330
+ profile_version: PROFILE_VERSION,
2331
+ public_key_fingerprint: null,
2332
+ verified_profile: false,
2333
+ now: Date.now(),
2334
+ presence_ttl_ms: PRESENCE_TTL_MS,
2335
+ }));
2336
+ }
2337
+ return [...summaries, ...messageOnly].sort((a, b) => {
2338
+ if (a.online !== b.online) {
2339
+ return a.online ? -1 : 1;
2340
+ }
2341
+ if (a.updated_at !== b.updated_at) {
2342
+ return b.updated_at - a.updated_at;
2343
+ }
2344
+ const byName = a.display_name.localeCompare(b.display_name);
2345
+ if (byName !== 0) {
2346
+ return byName;
2347
+ }
2348
+ return a.agent_id.localeCompare(b.agent_id);
2349
+ });
2350
+ }
2351
+ fingerprintPublicKey(publicKey) {
2352
+ const digest = (0, crypto_1.createHash)("sha256").update(publicKey, "utf8").digest("hex");
2353
+ return `${digest.slice(0, 12)}:${digest.slice(-8)}`;
2354
+ }
2355
+ getOnboardingSummary() {
2356
+ const summary = this.getIntegrationSummary();
2357
+ const publicEnabled = Boolean(this.profile?.public_enabled);
2358
+ const nextSteps = [];
2359
+ if (!String(this.profile?.display_name || "").trim()) {
2360
+ nextSteps.push("Update display name in Profile page");
2361
+ }
2362
+ if (!publicEnabled) {
2363
+ nextSteps.push("Enable Public Enabled in Profile");
2364
+ }
2365
+ if (!summary.running) {
2366
+ nextSteps.push("Start broadcast in Network");
2367
+ }
2368
+ if (!summary.discoverable) {
2369
+ nextSteps.push("Announce node once after the network is running");
2370
+ }
2371
+ if (nextSteps.length === 0) {
2372
+ nextSteps.push("Node is public and discoverable");
2373
+ }
2374
+ return {
2375
+ first_run: Boolean(this.initState.social_auto_created ||
2376
+ this.initState.identity_auto_created ||
2377
+ this.initState.profile_auto_created),
2378
+ connected: summary.connected,
2379
+ discoverable: summary.discoverable,
2380
+ mode: this.networkMode,
2381
+ public_enabled: publicEnabled,
2382
+ can_enable_public_discovery: !publicEnabled,
2383
+ next_steps: nextSteps,
2384
+ };
2385
+ }
2386
+ getDefaultDisplayName() {
2387
+ const host = (0, os_1.hostname)().trim().replace(/\s+/g, "-").slice(0, 24);
2388
+ return host ? `OpenClaw @ ${host}` : "OpenClaw Agent";
2389
+ }
2390
+ getModeExplainer() {
2391
+ if (this.networkMode === "local") {
2392
+ return {
2393
+ mode: "local",
2394
+ short_label: "Local only",
2395
+ summary: "Only nodes inside the same local process bus are visible.",
2396
+ };
2397
+ }
2398
+ if (this.networkMode === "lan") {
2399
+ return {
2400
+ mode: "lan",
2401
+ short_label: "LAN broadcast",
2402
+ summary: "Uses UDP LAN broadcast. Peers usually need to be on the same local network.",
2403
+ };
2404
+ }
2405
+ return {
2406
+ mode: DEFAULT_NETWORK_MODE,
2407
+ short_label: "Relay preview",
2408
+ summary: "Uses the public relay preview room so public nodes can find each other across the internet.",
2409
+ };
2410
+ }
2411
+ defaultMessageGovernance() {
2412
+ return {
2413
+ send_limit_max: SOCIAL_MESSAGE_SEND_MAX_PER_WINDOW,
2414
+ send_window_ms: SOCIAL_MESSAGE_SEND_WINDOW_MS,
2415
+ receive_limit_max: SOCIAL_MESSAGE_RECEIVE_MAX_PER_WINDOW,
2416
+ receive_window_ms: SOCIAL_MESSAGE_RECEIVE_WINDOW_MS,
2417
+ duplicate_window_ms: SOCIAL_MESSAGE_DUPLICATE_WINDOW_MS,
2418
+ blocked_agent_ids: Array.from(SOCIAL_MESSAGE_BLOCKED_AGENT_IDS),
2419
+ blocked_terms: Array.from(SOCIAL_MESSAGE_BLOCKED_TERMS),
2420
+ };
2421
+ }
2422
+ adapterForMode(mode) {
2423
+ if (mode === "local")
2424
+ return "local-event-bus";
2425
+ if (mode === "lan")
2426
+ return "real-preview";
2427
+ return "relay-preview";
2428
+ }
2429
+ applyResolvedNetworkConfig() {
2430
+ const modeEnv = String(NETWORK_MODE || "").trim();
2431
+ const resolvedMode = this.socialConfig.network.mode ||
2432
+ (modeEnv === "local" || modeEnv === "lan" || modeEnv === "global-preview"
2433
+ ? modeEnv
2434
+ : DEFAULT_NETWORK_MODE);
2435
+ this.networkMode = resolvedMode;
2436
+ this.networkNamespace = this.socialConfig.network.namespace || process.env.NETWORK_NAMESPACE || DEFAULT_NETWORK_NAMESPACE;
2437
+ this.networkPort = Number(this.socialConfig.network.port || process.env.NETWORK_PORT || DEFAULT_NETWORK_PORT);
2438
+ const builtInGlobalSignalingUrls = [DEFAULT_GLOBAL_SIGNALING_URL];
2439
+ const builtInGlobalRoom = DEFAULT_GLOBAL_ROOM;
2440
+ const signalingUrlsSocial = dedupeStrings(this.socialConfig.network.signaling_urls || []);
2441
+ const signalingUrlSocial = String(this.socialConfig.network.signaling_url || "").trim();
2442
+ const signalingUrlsEnv = dedupeStrings(parseListEnv(WEBRTC_SIGNALING_URLS));
2443
+ const signalingUrlEnvSingle = String(WEBRTC_SIGNALING_URL || "").trim();
2444
+ let signalingUrls = [];
2445
+ let signalingSource = "";
2446
+ if (signalingUrlsSocial.length > 0) {
2447
+ signalingUrls = signalingUrlsSocial;
2448
+ signalingSource = "social.md:network.signaling_urls";
2449
+ }
2450
+ else if (signalingUrlSocial) {
2451
+ signalingUrls = [signalingUrlSocial];
2452
+ signalingSource = "social.md:network.signaling_url";
2453
+ }
2454
+ else if (signalingUrlsEnv.length > 0) {
2455
+ signalingUrls = signalingUrlsEnv;
2456
+ signalingSource = "env:WEBRTC_SIGNALING_URLS";
2457
+ }
2458
+ else if (signalingUrlEnvSingle) {
2459
+ signalingUrls = [signalingUrlEnvSingle];
2460
+ signalingSource = "env:WEBRTC_SIGNALING_URL";
2461
+ }
2462
+ else if (this.networkMode === "global-preview") {
2463
+ signalingUrls = builtInGlobalSignalingUrls;
2464
+ signalingSource = "built-in-defaults:global-preview.signaling_urls";
2465
+ }
2466
+ else {
2467
+ signalingUrls = [DEFAULT_GLOBAL_SIGNALING_URL];
2468
+ signalingSource = `default:${DEFAULT_GLOBAL_SIGNALING_URL}`;
2469
+ }
2470
+ const roomSocial = String(this.socialConfig.network.room || "").trim();
2471
+ const roomEnv = String(WEBRTC_ROOM || "").trim();
2472
+ const room = roomSocial ||
2473
+ roomEnv ||
2474
+ (this.networkMode === "global-preview" ? builtInGlobalRoom : "") ||
2475
+ DEFAULT_GLOBAL_ROOM;
2476
+ const roomSource = roomSocial
2477
+ ? "social.md:network.room"
2478
+ : roomEnv
2479
+ ? "env:WEBRTC_ROOM"
2480
+ : this.networkMode === "global-preview"
2481
+ ? "built-in-defaults:global-preview.room"
2482
+ : `default:${DEFAULT_GLOBAL_ROOM}`;
2483
+ const seedPeersSocial = dedupeStrings(this.socialConfig.network.seed_peers || []);
2484
+ const seedPeersEnv = dedupeStrings(parseListEnv(WEBRTC_SEED_PEERS));
2485
+ const seedPeers = seedPeersSocial.length > 0 ? seedPeersSocial : seedPeersEnv;
2486
+ const seedPeersSource = seedPeersSocial.length > 0
2487
+ ? "social.md:network.seed_peers"
2488
+ : seedPeersEnv.length > 0
2489
+ ? "env:WEBRTC_SEED_PEERS"
2490
+ : "default:none";
2491
+ const bootstrapHintsSocial = dedupeStrings(this.socialConfig.network.bootstrap_hints || []);
2492
+ const bootstrapHintsEnv = dedupeStrings(parseListEnv(WEBRTC_BOOTSTRAP_HINTS));
2493
+ const bootstrapHints = bootstrapHintsSocial.length > 0 ? bootstrapHintsSocial : bootstrapHintsEnv;
2494
+ const bootstrapHintsSource = bootstrapHintsSocial.length > 0
2495
+ ? "social.md:network.bootstrap_hints"
2496
+ : bootstrapHintsEnv.length > 0
2497
+ ? "env:WEBRTC_BOOTSTRAP_HINTS"
2498
+ : "default:none";
2499
+ this.webrtcSignalingUrls = signalingUrls;
2500
+ this.webrtcRoom = room;
2501
+ this.webrtcSeedPeers = seedPeers;
2502
+ this.webrtcBootstrapHints = bootstrapHints;
2503
+ this.webrtcBootstrapSources = [signalingSource, roomSource, seedPeersSource, bootstrapHintsSource];
2504
+ }
2505
+ normalizeSocialMessageBody(body) {
2506
+ return String(body || "")
2507
+ .replace(/\r\n/g, "\n")
2508
+ .split("\n")
2509
+ .map((line) => line.trimEnd())
2510
+ .join("\n")
2511
+ .trim();
2512
+ }
2513
+ normalizeWindowTimestamps(timestamps, windowMs, now = Date.now()) {
2514
+ return timestamps.filter((timestamp) => now - timestamp <= windowMs);
2515
+ }
2516
+ recordTimestamp(timestamps, windowMs, at = Date.now()) {
2517
+ const cleaned = this.normalizeWindowTimestamps(timestamps, windowMs, at);
2518
+ cleaned.push(at);
2519
+ timestamps.splice(0, timestamps.length, ...cleaned);
2520
+ }
2521
+ isRateLimited(timestamps, windowMs, maxCount, now = Date.now()) {
2522
+ const cleaned = this.normalizeWindowTimestamps(timestamps, windowMs, now);
2523
+ timestamps.splice(0, timestamps.length, ...cleaned);
2524
+ return cleaned.length >= maxCount;
2525
+ }
2526
+ containsBlockedMessageTerm(body) {
2527
+ const normalized = String(body || "").toLowerCase();
2528
+ return this.messageGovernance.blocked_terms.some((term) => normalized.includes(term));
2529
+ }
2530
+ hasSocialMessage(messageId) {
2531
+ return this.socialMessages.some((item) => item.message_id === messageId);
2532
+ }
2533
+ getReplayableSelfSocialMessages(now = Date.now()) {
2534
+ const maxCount = Math.max(0, SOCIAL_MESSAGE_REPLAY_MAX_PER_BROADCAST);
2535
+ if (!this.identity || maxCount === 0) {
2536
+ return [];
2537
+ }
2538
+ return this.socialMessages
2539
+ .filter((item) => (item.agent_id === this.identity?.agent_id &&
2540
+ now - item.created_at <= SOCIAL_MESSAGE_REPLAY_WINDOW_MS))
2541
+ .sort((a, b) => a.created_at - b.created_at)
2542
+ .slice(-maxCount);
2543
+ }
2544
+ hasRecentDuplicateMessage(agentId, body, topic, now = Date.now()) {
2545
+ return this.socialMessages.some((item) => (item.agent_id === agentId &&
2546
+ item.topic === topic &&
2547
+ item.body === body &&
2548
+ now - item.created_at <= this.messageGovernance.duplicate_window_ms));
2549
+ }
2550
+ getIncomingSocialMessageRejectionReason(record) {
2551
+ const now = Date.now();
2552
+ if (this.messageGovernance.blocked_agent_ids.includes(record.agent_id)) {
2553
+ return "blocked_agent";
2554
+ }
2555
+ if (this.containsBlockedMessageTerm(record.body)) {
2556
+ return "blocked_term";
2557
+ }
2558
+ if (record.created_at - now > SOCIAL_MESSAGE_MAX_FUTURE_MS) {
2559
+ return "message_from_future";
2560
+ }
2561
+ if (now - record.created_at > SOCIAL_MESSAGE_MAX_AGE_MS) {
2562
+ return "message_too_old";
2563
+ }
2564
+ const timestamps = this.inboundMessageTimestampsByAgent[record.agent_id] || [];
2565
+ this.inboundMessageTimestampsByAgent[record.agent_id] = timestamps;
2566
+ if (this.isRateLimited(timestamps, this.messageGovernance.receive_window_ms, this.messageGovernance.receive_limit_max, now)) {
2567
+ return "remote_rate_limited";
2568
+ }
2569
+ if (this.hasRecentDuplicateMessage(record.agent_id, record.body, record.topic, now)) {
2570
+ return "duplicate_recent_message";
2571
+ }
2572
+ this.recordTimestamp(timestamps, this.messageGovernance.receive_window_ms, now);
2573
+ return null;
2574
+ }
2575
+ canPublishMessageObservation() {
2576
+ return Boolean(this.identity &&
2577
+ this.profile?.public_enabled &&
2578
+ this.broadcastEnabled &&
2579
+ this.socialConfig.discovery.allow_message_broadcast);
2580
+ }
2581
+ async publishObservationForMessage(message) {
2582
+ if (!this.identity || !this.profile || !this.canPublishMessageObservation()) {
2583
+ return;
2584
+ }
2585
+ if (message.agent_id === this.identity.agent_id) {
2586
+ return;
2587
+ }
2588
+ const existing = this.socialMessageObservations.find((item) => (item.message_id === message.message_id && item.observer_agent_id === this.identity?.agent_id));
2589
+ if (existing) {
2590
+ return;
2591
+ }
2592
+ const observation = (0, core_1.signSocialMessageObservation)({
2593
+ identity: this.identity,
2594
+ observation_id: (0, crypto_1.createHash)("sha256")
2595
+ .update(`${message.message_id}:${this.identity.agent_id}:${Date.now()}`, "utf8")
2596
+ .digest("hex"),
2597
+ message_id: message.message_id,
2598
+ observed_agent_id: message.agent_id,
2599
+ observer_display_name: this.profile.display_name,
2600
+ observed_at: Date.now(),
2601
+ });
2602
+ this.ingestSocialMessageObservation(observation);
2603
+ await this.publish(SOCIAL_MESSAGE_OBSERVATION_TOPIC, observation);
2604
+ await this.persistSocialMessageObservations();
2605
+ }
2606
+ normalizeIncomingSocialMessage(value) {
2607
+ if (typeof value !== "object" || value === null) {
2608
+ return null;
2609
+ }
2610
+ const record = value;
2611
+ const body = this.normalizeSocialMessageBody(String(record.body || ""));
2612
+ const agentId = String(record.agent_id || "").trim();
2613
+ const displayName = String(record.display_name || "").trim();
2614
+ const topic = String(record.topic || DEFAULT_SOCIAL_MESSAGE_CHANNEL).trim() || DEFAULT_SOCIAL_MESSAGE_CHANNEL;
2615
+ const messageId = String(record.message_id || "").trim();
2616
+ const createdAt = Number(record.created_at || 0);
2617
+ if (record.type !== SOCIAL_MESSAGE_TOPIC ||
2618
+ !messageId ||
2619
+ !agentId ||
2620
+ typeof record.public_key !== "string" ||
2621
+ !String(record.public_key).trim() ||
2622
+ !body ||
2623
+ typeof record.signature !== "string" ||
2624
+ !String(record.signature).trim() ||
2625
+ !Number.isFinite(createdAt) ||
2626
+ body.length > SOCIAL_MESSAGE_MAX_BODY_CHARS) {
2627
+ return null;
2628
+ }
2629
+ return {
2630
+ type: SOCIAL_MESSAGE_TOPIC,
2631
+ message_id: messageId,
2632
+ agent_id: agentId,
2633
+ public_key: String(record.public_key).trim(),
2634
+ display_name: displayName || "Unnamed",
2635
+ topic,
2636
+ body,
2637
+ created_at: createdAt,
2638
+ signature: String(record.signature).trim(),
2639
+ };
2640
+ }
2641
+ normalizeSocialMessages(items) {
2642
+ if (!Array.isArray(items)) {
2643
+ return [];
2644
+ }
2645
+ const deduped = new Set();
2646
+ return items
2647
+ .map((item) => this.normalizeIncomingSocialMessage(item))
2648
+ .filter((item) => Boolean(item))
2649
+ .sort((a, b) => b.created_at - a.created_at)
2650
+ .filter((item) => {
2651
+ if (deduped.has(item.message_id)) {
2652
+ return false;
2653
+ }
2654
+ deduped.add(item.message_id);
2655
+ return true;
2656
+ })
2657
+ .slice(0, SOCIAL_MESSAGE_HISTORY_LIMIT);
2658
+ }
2659
+ normalizeIncomingSocialMessageObservation(value) {
2660
+ if (typeof value !== "object" || value === null) {
2661
+ return null;
2662
+ }
2663
+ const record = value;
2664
+ const observationId = String(record.observation_id || "").trim();
2665
+ const messageId = String(record.message_id || "").trim();
2666
+ const observedAgentId = String(record.observed_agent_id || "").trim();
2667
+ const observerAgentId = String(record.observer_agent_id || "").trim();
2668
+ const observerDisplayName = String(record.observer_display_name || "").trim();
2669
+ const observedAt = Number(record.observed_at || 0);
2670
+ if (record.type !== SOCIAL_MESSAGE_OBSERVATION_TOPIC ||
2671
+ !observationId ||
2672
+ !messageId ||
2673
+ !observedAgentId ||
2674
+ !observerAgentId ||
2675
+ typeof record.observer_public_key !== "string" ||
2676
+ !String(record.observer_public_key).trim() ||
2677
+ typeof record.signature !== "string" ||
2678
+ !String(record.signature).trim() ||
2679
+ !Number.isFinite(observedAt)) {
2680
+ return null;
2681
+ }
2682
+ return {
2683
+ type: SOCIAL_MESSAGE_OBSERVATION_TOPIC,
2684
+ observation_id: observationId,
2685
+ message_id: messageId,
2686
+ observed_agent_id: observedAgentId,
2687
+ observer_agent_id: observerAgentId,
2688
+ observer_public_key: String(record.observer_public_key).trim(),
2689
+ observer_display_name: observerDisplayName || "Unnamed",
2690
+ observed_at: observedAt,
2691
+ signature: String(record.signature).trim(),
2692
+ };
2693
+ }
2694
+ normalizeSocialMessageObservations(items) {
2695
+ if (!Array.isArray(items)) {
2696
+ return [];
2697
+ }
2698
+ const deduped = new Set();
2699
+ return items
2700
+ .map((item) => this.normalizeIncomingSocialMessageObservation(item))
2701
+ .filter((item) => Boolean(item))
2702
+ .sort((a, b) => b.observed_at - a.observed_at)
2703
+ .filter((item) => {
2704
+ if (deduped.has(item.observation_id)) {
2705
+ return false;
2706
+ }
2707
+ deduped.add(item.observation_id);
2708
+ return true;
2709
+ })
2710
+ .slice(0, SOCIAL_MESSAGE_OBSERVATION_HISTORY_LIMIT);
2711
+ }
2712
+ ingestSocialMessage(message) {
2713
+ const existing = this.socialMessages.findIndex((item) => item.message_id === message.message_id);
2714
+ if (existing >= 0) {
2715
+ this.socialMessages[existing] = message;
2716
+ }
2717
+ else {
2718
+ this.socialMessages.unshift(message);
2719
+ }
2720
+ this.socialMessages = this.normalizeSocialMessages(this.socialMessages);
2721
+ }
2722
+ ingestSocialMessageObservation(observation) {
2723
+ const existing = this.socialMessageObservations.findIndex((item) => item.observation_id === observation.observation_id);
2724
+ if (existing >= 0) {
2725
+ this.socialMessageObservations[existing] = observation;
2726
+ }
2727
+ else {
2728
+ this.socialMessageObservations.unshift(observation);
2729
+ }
2730
+ this.socialMessageObservations = this.normalizeSocialMessageObservations(this.socialMessageObservations);
2731
+ }
2732
+ }
2733
+ exports.LocalNodeService = LocalNodeService;
2734
+ function sendOk(res, data, meta) {
2735
+ res.json({ ok: true, data, meta });
2736
+ }
2737
+ function sendError(res, status, code, message, details) {
2738
+ const error = { code, message };
2739
+ if (details !== undefined) {
2740
+ error.details = details;
2741
+ }
2742
+ res.status(status).json({ ok: false, error });
2743
+ }
2744
+ function asyncRoute(handler) {
2745
+ return (req, res, next) => {
2746
+ Promise.resolve(handler(req, res)).catch(next);
2747
+ };
2748
+ }
2749
+ function resolveLocalConsoleStaticDir() {
2750
+ const candidates = [
2751
+ (0, path_1.resolve)(process.cwd(), "public"),
2752
+ (0, path_1.resolve)(process.cwd(), "apps", "local-console", "public"),
2753
+ (0, path_1.resolve)(__dirname, "..", "public"),
2754
+ (0, path_1.resolve)(__dirname, "..", "..", "apps", "local-console", "public"),
2755
+ ];
2756
+ for (const dir of candidates) {
2757
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(dir, "index.html"))) {
2758
+ return dir;
2759
+ }
2760
+ }
2761
+ return candidates[0];
2762
+ }
2763
+ function escapeHtml(text) {
2764
+ return String(text)
2765
+ .replace(/&/g, "&amp;")
2766
+ .replace(/</g, "&lt;")
2767
+ .replace(/>/g, "&gt;")
2768
+ .replace(/"/g, "&quot;")
2769
+ .replace(/'/g, "&#39;");
2770
+ }
2771
+ function shortId(id) {
2772
+ if (!id)
2773
+ return "-";
2774
+ return `${id.slice(0, 10)}...${id.slice(-6)}`;
2775
+ }
2776
+ function ago(ts) {
2777
+ if (!ts)
2778
+ return "-";
2779
+ const seconds = Math.max(0, Math.floor((Date.now() - ts) / 1000));
2780
+ if (seconds < 60)
2781
+ return `${seconds}s ago`;
2782
+ if (seconds < 3600)
2783
+ return `${Math.floor(seconds / 60)}m ago`;
2784
+ return `${Math.floor(seconds / 3600)}h ago`;
2785
+ }
2786
+ function renderBootstrapScript(payload) {
2787
+ const encoded = JSON.stringify(payload).replace(/</g, "\\u003c");
2788
+ return `
2789
+ <script>
2790
+ (() => {
2791
+ const data = ${encoded};
2792
+ if (!data) return;
2793
+ const setText = (id, value) => {
2794
+ const el = document.getElementById(id);
2795
+ if (el) el.textContent = value;
2796
+ };
2797
+ const setHtml = (id, value) => {
2798
+ const el = document.getElementById(id);
2799
+ if (el) el.innerHTML = value;
2800
+ };
2801
+ if (data.integrationStatusText) {
2802
+ const bar = document.getElementById('integrationStatusBar');
2803
+ if (bar) {
2804
+ bar.textContent = data.integrationStatusText;
2805
+ if (data.integrationStatusClassName) bar.className = data.integrationStatusClassName;
2806
+ }
2807
+ }
2808
+ setText('socialStatusLine', data.socialStatusLineText || '');
2809
+ setText('socialStatusSubline', data.socialStatusSublineText || '');
2810
+ setText('brandVersion', data.brandVersionText || '-');
2811
+ setText('snapshot', data.snapshotText || '');
2812
+ setText('heroMode', data.heroModeText || '-');
2813
+ setText('heroAdapter', data.heroAdapterText || '-');
2814
+ setText('heroRelay', data.heroRelayText || '-');
2815
+ setText('heroRoom', data.heroRoomText || '-');
2816
+ setText('pillAdapter', data.pillAdapterText || 'adapter: -');
2817
+ const pillBroadcast = document.getElementById('pillBroadcast');
2818
+ if (pillBroadcast) {
2819
+ pillBroadcast.textContent = data.pillBroadcastText || 'broadcast: -';
2820
+ if (data.pillBroadcastClassName) pillBroadcast.className = data.pillBroadcastClassName;
2821
+ }
2822
+ setHtml('overviewCards', data.overviewCardsHtml || '');
2823
+ setText('agentsCountHint', data.agentsCountHintText || '0 nodes');
2824
+ setHtml('agentsWrap', data.agentsWrapHtml || '<div class="label">No discovered nodes yet.</div>');
2825
+ })();
2826
+ </script>`;
2827
+ }
2828
+ async function main() {
2829
+ const app = (0, express_1.default)();
2830
+ const port = Number(process.env.PORT || silicaclaw_defaults_json_1.default.ports.local_console);
2831
+ const staticDir = resolveLocalConsoleStaticDir();
2832
+ const staticIndexFile = (0, path_1.resolve)(staticDir, "index.html");
2833
+ const node = new LocalNodeService();
2834
+ await node.start();
2835
+ app.use((0, cors_1.default)({ origin: true }));
2836
+ app.use(express_1.default.json());
2837
+ app.get("/api/identity", (_req, res) => {
2838
+ sendOk(res, node.getIdentity());
2839
+ });
2840
+ app.post("/api/identity/create", asyncRoute(async (_req, res) => {
2841
+ const identity = await node.ensureIdentity();
2842
+ sendOk(res, identity, { message: "Identity is ready" });
2843
+ }));
2844
+ app.get("/api/profile", (_req, res) => {
2845
+ sendOk(res, node.getProfile());
2846
+ });
2847
+ app.get("/api/public-profile/preview", (_req, res) => {
2848
+ sendOk(res, node.getPublicProfilePreview());
2849
+ });
2850
+ app.get("/api/runtime/paths", (_req, res) => {
2851
+ sendOk(res, node.getRuntimePaths());
2852
+ });
2853
+ app.put("/api/profile", asyncRoute(async (req, res) => {
2854
+ const body = req.body;
2855
+ const tags = Array.isArray(body.tags)
2856
+ ? body.tags.map((tag) => String(tag).trim()).filter(Boolean)
2857
+ : undefined;
2858
+ const profile = await node.updateProfile({
2859
+ ...body,
2860
+ tags,
2861
+ display_name: body.display_name?.toString() ?? undefined,
2862
+ bio: body.bio?.toString() ?? undefined,
2863
+ avatar_url: body.avatar_url?.toString() ?? undefined,
2864
+ public_enabled: typeof body.public_enabled === "boolean" ? body.public_enabled : undefined,
2865
+ });
2866
+ sendOk(res, profile, { message: "Profile saved" });
2867
+ }));
2868
+ app.get("/api/overview", (_req, res) => {
2869
+ sendOk(res, node.getOverview());
2870
+ });
2871
+ app.get("/api/integration/status", (_req, res) => {
2872
+ sendOk(res, node.getIntegrationStatus());
2873
+ });
2874
+ app.get("/api/network", (_req, res) => {
2875
+ sendOk(res, node.getNetworkSummary());
2876
+ });
2877
+ app.get("/api/network/config", (_req, res) => {
2878
+ sendOk(res, node.getNetworkConfig());
2879
+ });
2880
+ app.get("/api/network/stats", (_req, res) => {
2881
+ sendOk(res, node.getNetworkStats());
2882
+ });
2883
+ app.get("/api/skills", (_req, res) => {
2884
+ sendOk(res, node.getSkillsView());
2885
+ });
2886
+ app.post("/api/network/quick-connect-global-preview", asyncRoute(async (req, res) => {
2887
+ const body = (req.body ?? {});
2888
+ const signalingUrl = String(body.signaling_url || "").trim();
2889
+ const room = String(body.room || "").trim();
2890
+ if (!signalingUrl) {
2891
+ sendError(res, 400, "invalid_request", "signaling_url is required");
2892
+ return;
2893
+ }
2894
+ const result = await node.quickConnectGlobalPreview({
2895
+ signaling_url: signalingUrl,
2896
+ room,
2897
+ });
2898
+ sendOk(res, result, { message: "Cross-network preview enabled" });
2899
+ }));
2900
+ app.get("/api/peers", (_req, res) => {
2901
+ sendOk(res, node.getPeersSummary());
2902
+ });
2903
+ app.get("/api/discovery/events", (_req, res) => {
2904
+ sendOk(res, node.getDiscoveryEvents());
2905
+ });
2906
+ (0, socialRoutes_1.registerSocialRoutes)(app, {
2907
+ getSocialConfigView: () => node.getSocialConfigView(),
2908
+ getIntegrationSummary: () => node.getIntegrationSummary(),
2909
+ getMessageGovernanceView: () => node.getMessageGovernanceView(),
2910
+ updateMessageGovernance: (input) => node.updateMessageGovernance(input),
2911
+ exportSocialTemplate: () => node.exportSocialTemplate(),
2912
+ setNetworkModeRuntime: (mode) => node.setNetworkModeRuntime(mode),
2913
+ reloadSocialConfig: () => node.reloadSocialConfig(),
2914
+ generateDefaultSocialMd: () => node.generateDefaultSocialMd(),
2915
+ });
2916
+ app.post("/api/broadcast/start", asyncRoute(async (_req, res) => {
2917
+ const summary = await node.setBroadcastEnabled(true);
2918
+ sendOk(res, summary, { message: "Broadcast started" });
2919
+ }));
2920
+ app.post("/api/public-discovery/enable", asyncRoute(async (_req, res) => {
2921
+ const result = await node.setPublicDiscoveryRuntime(true);
2922
+ sendOk(res, result, { message: "Public discovery enabled (runtime)" });
2923
+ }));
2924
+ app.post("/api/public-discovery/disable", asyncRoute(async (_req, res) => {
2925
+ const result = await node.setPublicDiscoveryRuntime(false);
2926
+ sendOk(res, result, { message: "Public discovery disabled (runtime)" });
2927
+ }));
2928
+ app.post("/api/broadcast/stop", asyncRoute(async (_req, res) => {
2929
+ const summary = await node.setBroadcastEnabled(false);
2930
+ sendOk(res, summary, { message: "Broadcast stopped" });
2931
+ }));
2932
+ app.post("/api/broadcast/now", asyncRoute(async (_req, res) => {
2933
+ const result = await node.broadcastNow("manual_button");
2934
+ sendOk(res, result, {
2935
+ message: result.sent ? "Broadcast published" : `Broadcast skipped: ${result.reason}`,
2936
+ });
2937
+ }));
2938
+ app.post("/api/messages/broadcast", asyncRoute(async (req, res) => {
2939
+ const body = String(req.body?.body || "");
2940
+ const topic = String(req.body?.topic || DEFAULT_SOCIAL_MESSAGE_CHANNEL);
2941
+ const result = await node.sendSocialMessage(body, topic);
2942
+ sendOk(res, result, {
2943
+ message: result.sent ? "Message broadcast published" : `Message broadcast skipped: ${result.reason}`,
2944
+ });
2945
+ }));
2946
+ app.get("/api/messages", (req, res) => {
2947
+ const limit = Number(req.query.limit ?? 50);
2948
+ const agentId = String(req.query.agent_id ?? "").trim();
2949
+ sendOk(res, node.getSocialMessages(limit, { agent_id: agentId || null }));
2950
+ });
2951
+ app.get("/api/openclaw/bridge", (_req, res) => {
2952
+ sendOk(res, node.getOpenClawBridgeStatus());
2953
+ });
2954
+ app.get("/api/openclaw/bridge/config", (_req, res) => {
2955
+ sendOk(res, node.getOpenClawBridgeConfig());
2956
+ });
2957
+ app.get("/api/openclaw/bridge/profile", (_req, res) => {
2958
+ sendOk(res, node.getOpenClawBridgeProfile());
2959
+ });
2960
+ app.get("/api/openclaw/bridge/messages", (req, res) => {
2961
+ const limit = Number(req.query.limit ?? 50);
2962
+ const agentId = String(req.query.agent_id ?? "").trim();
2963
+ sendOk(res, node.getSocialMessages(limit, { agent_id: agentId || null }));
2964
+ });
2965
+ app.post("/api/openclaw/bridge/message", asyncRoute(async (req, res) => {
2966
+ const body = String(req.body?.body || "");
2967
+ const topic = String(req.body?.topic || DEFAULT_SOCIAL_MESSAGE_CHANNEL);
2968
+ const result = await node.sendSocialMessage(body, topic);
2969
+ sendOk(res, result, {
2970
+ message: result.sent ? "OpenClaw bridge message published" : `OpenClaw bridge message skipped: ${result.reason}`,
2971
+ });
2972
+ }));
2973
+ app.post("/api/openclaw/bridge/skill-install", asyncRoute(async (req, res) => {
2974
+ try {
2975
+ const skillName = String(req.body?.skill_name || "").trim();
2976
+ const result = await node.installOpenClawSkill(skillName || undefined);
2977
+ sendOk(res, result, {
2978
+ message: "OpenClaw skill installed",
2979
+ });
2980
+ }
2981
+ catch (error) {
2982
+ sendError(res, 500, "OPENCLAW_SKILL_INSTALL_FAILED", error instanceof Error ? error.message : "OpenClaw skill install failed");
2983
+ }
2984
+ }));
2985
+ app.post("/api/cache/refresh", asyncRoute(async (_req, res) => {
2986
+ const result = await node.refreshCache();
2987
+ sendOk(res, result, { message: "Cache refreshed" });
2988
+ }));
2989
+ app.post("/api/cache/clear", asyncRoute(async (_req, res) => {
2990
+ const result = await node.clearDiscoveredCache();
2991
+ sendOk(res, result, { message: "Discovered cache cleared (self profile kept)" });
2992
+ }));
2993
+ app.get("/api/logs", asyncRoute(async (_req, res) => {
2994
+ sendOk(res, await node.getLogs());
2995
+ }));
2996
+ app.get("/api/search", (req, res) => {
2997
+ const q = String(req.query.q ?? "");
2998
+ sendOk(res, node.search(q));
2999
+ });
3000
+ app.get("/api/agents/:agentId", (req, res) => {
3001
+ const state = node.getDirectory();
3002
+ const agentId = req.params.agentId;
3003
+ const profile = state.profiles[agentId];
3004
+ if (!profile) {
3005
+ sendError(res, 404, "AGENT_NOT_FOUND", "Node not found", { agent_id: agentId });
3006
+ return;
3007
+ }
3008
+ const lastSeenAt = state.presence[agentId] ?? 0;
3009
+ const summary = node.getAgentPublicSummary(agentId);
3010
+ sendOk(res, {
3011
+ profile,
3012
+ summary,
3013
+ last_seen_at: summary?.last_seen_at ?? null,
3014
+ online: (0, core_1.isAgentOnline)(lastSeenAt, Date.now(), PRESENCE_TTL_MS),
3015
+ presence_ttl_ms: PRESENCE_TTL_MS,
3016
+ });
3017
+ });
3018
+ app.get("/api/health", (_req, res) => {
3019
+ sendOk(res, { ok: true });
3020
+ });
3021
+ app.get(["/", "/index.html"], (_req, res) => {
3022
+ const overview = node.getOverview();
3023
+ const discovered = node.search("");
3024
+ const network = node.getNetworkConfig();
3025
+ const integration = node.getIntegrationStatus();
3026
+ const overviewCardsHtml = [
3027
+ ["Discovered", overview.discovered_count],
3028
+ ["Online", overview.online_count],
3029
+ ["Offline", overview.offline_count],
3030
+ ["Presence TTL", `${Math.floor(overview.presence_ttl_ms / 1000)}s`],
3031
+ ]
3032
+ .map(([k, v]) => `<div class="card"><div class="label">${escapeHtml(String(k))}</div><div class="value">${escapeHtml(String(v))}</div></div>`)
3033
+ .join("");
3034
+ const agentsWrapHtml = discovered.length === 0
3035
+ ? `<div class="label">No discovered nodes yet.</div>`
3036
+ : `
3037
+ <table class="table">
3038
+ <thead><tr><th>Name</th><th>Agent ID</th><th>Status</th><th>Updated</th></tr></thead>
3039
+ <tbody>
3040
+ ${discovered
3041
+ .map((agent) => `
3042
+ <tr>
3043
+ <td>${escapeHtml(agent.display_name || "Unnamed")}</td>
3044
+ <td class="mono">${escapeHtml(shortId(agent.agent_id || ""))}</td>
3045
+ <td class="${agent.online ? "online" : "offline"}">${agent.online ? "online" : "offline"}</td>
3046
+ <td>${escapeHtml(ago(agent.updated_at))}</td>
3047
+ </tr>`)
3048
+ .join("")}
3049
+ </tbody>
3050
+ </table>
3051
+ `;
3052
+ const payload = {
3053
+ brandVersionText: overview.app_version ? `v${overview.app_version}` : "-",
3054
+ snapshotText: [
3055
+ `app_version: ${overview.app_version || "-"}`,
3056
+ `agent_id: ${overview.agent_id || "-"}`,
3057
+ `public_enabled: ${overview.public_enabled}`,
3058
+ `broadcast_enabled: ${overview.broadcast_enabled}`,
3059
+ `last_broadcast: ${ago(overview.last_broadcast_at)}`,
3060
+ ].join("\n"),
3061
+ heroModeText: overview.social?.network_mode || "-",
3062
+ heroAdapterText: network.adapter || "-",
3063
+ heroRelayText: network.adapter_extra?.signaling_url || "-",
3064
+ heroRoomText: network.adapter_extra?.room || "-",
3065
+ pillAdapterText: `adapter: ${network.adapter || "-"}`,
3066
+ pillBroadcastText: overview.broadcast_enabled ? "broadcast: running" : "broadcast: paused",
3067
+ pillBroadcastClassName: `pill ${overview.broadcast_enabled ? "ok" : "warn"}`,
3068
+ overviewCardsHtml,
3069
+ agentsCountHintText: `${discovered.length} nodes discovered`,
3070
+ agentsWrapHtml,
3071
+ integrationStatusText: `Connected to SilicaClaw: ${integration.connected_to_silicaclaw ? "yes" : "no"} · Network mode: ${integration.network_mode || "-"} · Public discovery: ${integration.public_enabled ? "enabled" : "disabled"}`,
3072
+ integrationStatusClassName: `integration-strip ${integration.connected_to_silicaclaw && integration.public_enabled ? "ok" : "warn"}`,
3073
+ socialStatusLineText: integration.status_line || "",
3074
+ socialStatusSublineText: `Connected to SilicaClaw · ${integration.public_enabled ? "Public discovery enabled" : "Public discovery disabled"} · mode ${integration.network_mode || "-"}`,
3075
+ };
3076
+ let html = (0, fs_1.readFileSync)(staticIndexFile, "utf8");
3077
+ html = html.replace("</body>", `${renderBootstrapScript(payload)}\n</body>`);
3078
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
3079
+ res.send(html);
3080
+ });
3081
+ app.use(express_1.default.static(staticDir));
3082
+ app.use((error, _req, res, _next) => {
3083
+ const message = error instanceof Error ? error.message : "Unknown error";
3084
+ sendError(res, 500, "INTERNAL_ERROR", message);
3085
+ });
3086
+ app.listen(port, () => {
3087
+ // eslint-disable-next-line no-console
3088
+ console.log(`SilicaClaw local-console running: http://localhost:${port}`);
3089
+ });
3090
+ process.on("SIGINT", async () => {
3091
+ await node.stop();
3092
+ process.exit(0);
3093
+ });
3094
+ }
3095
+ if (require.main === module) {
3096
+ main().catch((error) => {
3097
+ // eslint-disable-next-line no-console
3098
+ console.error(error);
3099
+ process.exit(1);
3100
+ });
3101
+ }