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