@silicaclaw/cli 2026.3.19-15 → 2026.3.19-16
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 +6 -0
- package/INSTALL.md +44 -11
- package/README.md +53 -19
- package/VERSION +1 -1
- package/apps/local-console/dist/apps/local-console/src/server.d.ts +30 -12
- package/apps/local-console/dist/apps/local-console/src/server.js +265 -48
- package/apps/local-console/dist/config/silicaclaw-defaults.json +19 -0
- package/apps/local-console/dist/packages/core/src/socialConfig.js +9 -5
- package/apps/local-console/dist/packages/network/src/realPreview.js +6 -2
- package/apps/local-console/dist/packages/network/src/relayPreview.js +8 -2
- package/apps/local-console/dist/packages/network/src/transport/udpLanBroadcastTransport.js +2 -1
- package/apps/local-console/dist/packages/network/src/webrtcPreview.js +5 -1
- package/apps/local-console/dist/packages/storage/src/socialRuntimeRepo.js +8 -4
- package/apps/local-console/public/app/app.js +17 -1
- package/apps/local-console/public/app/events.js +38 -2
- package/apps/local-console/public/app/network.js +32 -3
- package/apps/local-console/public/app/overview.js +4 -2
- package/apps/local-console/public/app/social.js +175 -26
- package/apps/local-console/public/app/styles.css +182 -14
- package/apps/local-console/public/app/template.js +70 -30
- package/apps/local-console/public/app/translations.js +131 -43
- package/apps/local-console/src/server.ts +281 -50
- 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/public/app/app.js +22 -2
- package/apps/public-explorer/public/app/template.js +4 -4
- package/apps/public-explorer/public/app/translations.js +15 -15
- package/apps/public-explorer/src/server.ts +11 -1
- package/docs/NEW_USER_INSTALL.md +14 -10
- package/docs/NEW_USER_OPERATIONS.md +3 -3
- 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/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/src/socialConfig.ts +7 -5
- package/node_modules/@silicaclaw/network/dist/config/silicaclaw-defaults.json +19 -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/src/realPreview.ts +3 -2
- package/node_modules/@silicaclaw/network/src/relayPreview.ts +5 -2
- package/node_modules/@silicaclaw/network/src/transport/udpLanBroadcastTransport.ts +2 -1
- package/node_modules/@silicaclaw/network/src/webrtcPreview.ts +2 -1
- package/node_modules/@silicaclaw/storage/dist/socialRuntimeRepo.js +8 -4
- package/node_modules/@silicaclaw/storage/src/socialRuntimeRepo.ts +5 -4
- 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 +1 -1
- 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/dist/socialRuntimeRepo.js +8 -4
- package/packages/storage/src/socialRuntimeRepo.ts +5 -4
- 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 +13 -9
- package/scripts/release-pack.mjs +13 -1
- package/scripts/silicaclaw-cli.mjs +23 -18
- package/scripts/silicaclaw-gateway.mjs +33 -27
- package/scripts/validate-openclaw-skill.mjs +79 -21
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { dirname, resolve } from "node:path";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
const API_BASE = String(process.env.SILICACLAW_API_BASE || "http://localhost:4310").replace(/\/+$/, "");
|
|
9
|
+
const POLL_INTERVAL_MS = Math.max(1000, Number(process.env.OPENCLAW_FORWARDER_INTERVAL_MS || 5000) || 5000);
|
|
10
|
+
const LIMIT = Math.max(1, Number(process.env.OPENCLAW_FORWARDER_LIMIT || 30) || 30);
|
|
11
|
+
const OWNER_FORWARD_CMD = String(process.env.OPENCLAW_OWNER_FORWARD_CMD || "").trim();
|
|
12
|
+
const STATE_PATH = resolve(
|
|
13
|
+
String(process.env.OPENCLAW_OWNER_FORWARD_STATE_PATH || resolve(homedir(), ".openclaw", "workspace", "state", "silicaclaw-owner-push.json"))
|
|
14
|
+
);
|
|
15
|
+
const ONCE = process.argv.includes("--once");
|
|
16
|
+
const VERBOSE = process.argv.includes("--verbose");
|
|
17
|
+
|
|
18
|
+
function parseListEnv(name) {
|
|
19
|
+
return String(process.env[name] || "")
|
|
20
|
+
.split(",")
|
|
21
|
+
.map((item) => item.trim().toLowerCase())
|
|
22
|
+
.filter(Boolean);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const TOPIC_FILTERS = parseListEnv("OPENCLAW_FORWARD_TOPICS");
|
|
26
|
+
const INCLUDE_TERMS = parseListEnv("OPENCLAW_FORWARD_INCLUDE");
|
|
27
|
+
const EXCLUDE_TERMS = parseListEnv("OPENCLAW_FORWARD_EXCLUDE");
|
|
28
|
+
const DEFAULT_SIGNAL_TERMS = [
|
|
29
|
+
"approval",
|
|
30
|
+
"approve",
|
|
31
|
+
"blocked",
|
|
32
|
+
"error",
|
|
33
|
+
"failed",
|
|
34
|
+
"failure",
|
|
35
|
+
"complete",
|
|
36
|
+
"completed",
|
|
37
|
+
"deploy",
|
|
38
|
+
"security",
|
|
39
|
+
"credential",
|
|
40
|
+
"fund",
|
|
41
|
+
"payment",
|
|
42
|
+
"risk",
|
|
43
|
+
"urgent",
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
function request(path, options = {}) {
|
|
47
|
+
return fetch(`${API_BASE}${path}`, {
|
|
48
|
+
headers: { "Content-Type": "application/json" },
|
|
49
|
+
...options,
|
|
50
|
+
}).then(async (res) => {
|
|
51
|
+
const json = await res.json().catch(() => null);
|
|
52
|
+
if (!res.ok || !json?.ok) {
|
|
53
|
+
throw new Error(json?.error?.message || `Request failed (${res.status})`);
|
|
54
|
+
}
|
|
55
|
+
return json.data;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function loadState() {
|
|
60
|
+
if (!existsSync(STATE_PATH)) {
|
|
61
|
+
return {
|
|
62
|
+
seen_ids: [],
|
|
63
|
+
pushed_at: {},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(readFileSync(STATE_PATH, "utf8"));
|
|
68
|
+
} catch {
|
|
69
|
+
return {
|
|
70
|
+
seen_ids: [],
|
|
71
|
+
pushed_at: {},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function saveState(state) {
|
|
77
|
+
mkdirSync(dirname(STATE_PATH), { recursive: true });
|
|
78
|
+
writeFileSync(STATE_PATH, JSON.stringify(state, null, 2), "utf8");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function trimState(state) {
|
|
82
|
+
const recentIds = Array.isArray(state.seen_ids) ? state.seen_ids.slice(-500) : [];
|
|
83
|
+
const pushedEntries = Object.entries(state.pushed_at || {}).slice(-500);
|
|
84
|
+
state.seen_ids = recentIds;
|
|
85
|
+
state.pushed_at = Object.fromEntries(pushedEntries);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function shouldWatchTopic(message) {
|
|
89
|
+
if (!TOPIC_FILTERS.length) return true;
|
|
90
|
+
return TOPIC_FILTERS.includes(String(message?.topic || "global").toLowerCase());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function scoreRoute(message) {
|
|
94
|
+
const text = [
|
|
95
|
+
String(message?.topic || ""),
|
|
96
|
+
String(message?.display_name || ""),
|
|
97
|
+
String(message?.body || ""),
|
|
98
|
+
].join(" ").toLowerCase();
|
|
99
|
+
|
|
100
|
+
if (!text.trim()) return "ignore";
|
|
101
|
+
if (EXCLUDE_TERMS.some((term) => text.includes(term))) return "ignore";
|
|
102
|
+
|
|
103
|
+
if (INCLUDE_TERMS.length && INCLUDE_TERMS.some((term) => text.includes(term))) {
|
|
104
|
+
return "push_summary";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (DEFAULT_SIGNAL_TERMS.some((term) => text.includes(term))) {
|
|
108
|
+
return "push_summary";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return "ignore";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function summarizeForOwner(message) {
|
|
115
|
+
const source = `${message.display_name || "Unknown"} · ${message.topic || "global"}`;
|
|
116
|
+
const body = String(message.body || "").trim();
|
|
117
|
+
const priority = scoreRoute(message) === "push_summary"
|
|
118
|
+
? "Owner-relevant SilicaClaw broadcast"
|
|
119
|
+
: "Routine";
|
|
120
|
+
return [
|
|
121
|
+
`Source: ${source}`,
|
|
122
|
+
`Priority: ${priority}`,
|
|
123
|
+
`What happened: ${body.slice(0, 240)}${body.length > 240 ? "..." : ""}`,
|
|
124
|
+
"Action: Review whether owner follow-up or approval is needed.",
|
|
125
|
+
].join("\n");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function dispatchToOwner(route, summary, message) {
|
|
129
|
+
if (!OWNER_FORWARD_CMD) {
|
|
130
|
+
console.log("");
|
|
131
|
+
console.log(`[${route}] ${message.message_id || "-"}`);
|
|
132
|
+
console.log(summary);
|
|
133
|
+
return Promise.resolve();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
const child = spawn(OWNER_FORWARD_CMD, {
|
|
138
|
+
shell: true,
|
|
139
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
140
|
+
env: process.env,
|
|
141
|
+
});
|
|
142
|
+
child.on("error", reject);
|
|
143
|
+
child.on("exit", (code) => {
|
|
144
|
+
if (code === 0) {
|
|
145
|
+
resolve();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
reject(new Error(`owner dispatch failed (exit=${code ?? "unknown"})`));
|
|
149
|
+
});
|
|
150
|
+
child.stdin.write(JSON.stringify({
|
|
151
|
+
route,
|
|
152
|
+
summary,
|
|
153
|
+
message: {
|
|
154
|
+
message_id: message.message_id || "",
|
|
155
|
+
display_name: message.display_name || "",
|
|
156
|
+
topic: message.topic || "global",
|
|
157
|
+
body: message.body || "",
|
|
158
|
+
created_at: message.created_at || Date.now(),
|
|
159
|
+
},
|
|
160
|
+
}, null, 2));
|
|
161
|
+
child.stdin.end();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function pollOnce(state) {
|
|
166
|
+
const payload = await request(`/api/openclaw/bridge/messages?limit=${LIMIT}`);
|
|
167
|
+
const items = Array.isArray(payload?.items) ? payload.items.slice().reverse() : [];
|
|
168
|
+
|
|
169
|
+
for (const item of items) {
|
|
170
|
+
const messageId = String(item?.message_id || "").trim();
|
|
171
|
+
if (!messageId) continue;
|
|
172
|
+
if (state.seen_ids.includes(messageId)) continue;
|
|
173
|
+
|
|
174
|
+
state.seen_ids.push(messageId);
|
|
175
|
+
|
|
176
|
+
if (!shouldWatchTopic(item)) {
|
|
177
|
+
if (VERBOSE) console.log(`skip topic: ${messageId}`);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const route = scoreRoute(item);
|
|
182
|
+
if (route === "ignore") {
|
|
183
|
+
if (VERBOSE) console.log(`ignore low-signal: ${messageId}`);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const summary = summarizeForOwner(item);
|
|
188
|
+
await dispatchToOwner(route, summary, item);
|
|
189
|
+
state.pushed_at[messageId] = new Date().toISOString();
|
|
190
|
+
if (VERBOSE) console.log(`pushed to owner: ${messageId}`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
trimState(state);
|
|
194
|
+
saveState(state);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function main() {
|
|
198
|
+
const state = loadState();
|
|
199
|
+
if (VERBOSE) {
|
|
200
|
+
console.log(`SilicaClaw owner push watching ${API_BASE}`);
|
|
201
|
+
console.log(`State file: ${STATE_PATH}`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
do {
|
|
205
|
+
await pollOnce(state);
|
|
206
|
+
if (ONCE) break;
|
|
207
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
208
|
+
} while (true);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
main().catch((error) => {
|
|
212
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
213
|
+
process.exit(1);
|
|
214
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
|
|
7
|
+
function requiredEnv(name) {
|
|
8
|
+
const value = String(process.env[name] || "").trim();
|
|
9
|
+
if (!value) {
|
|
10
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function resolveOpenClawCommand() {
|
|
16
|
+
const explicitBin = String(process.env.OPENCLAW_BIN || "").trim();
|
|
17
|
+
if (explicitBin) {
|
|
18
|
+
return { cmd: explicitBin, args: [] };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const sourceDir = String(process.env.OPENCLAW_SOURCE_DIR || "").trim();
|
|
22
|
+
if (sourceDir) {
|
|
23
|
+
return {
|
|
24
|
+
cmd: "node",
|
|
25
|
+
args: [resolve(sourceDir, "openclaw.mjs")],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return { cmd: "openclaw", args: [] };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function main() {
|
|
33
|
+
const payload = JSON.parse(readFileSync(0, "utf8"));
|
|
34
|
+
const channel = requiredEnv("OPENCLAW_OWNER_CHANNEL");
|
|
35
|
+
const target = requiredEnv("OPENCLAW_OWNER_TARGET");
|
|
36
|
+
const account = String(process.env.OPENCLAW_OWNER_ACCOUNT || "").trim();
|
|
37
|
+
const message = String(payload?.summary || "").trim();
|
|
38
|
+
if (!message) {
|
|
39
|
+
throw new Error("Missing summary in stdin payload");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const command = resolveOpenClawCommand();
|
|
43
|
+
const args = [
|
|
44
|
+
...command.args,
|
|
45
|
+
"message",
|
|
46
|
+
"send",
|
|
47
|
+
"--channel",
|
|
48
|
+
channel,
|
|
49
|
+
"--target",
|
|
50
|
+
target,
|
|
51
|
+
"--message",
|
|
52
|
+
message,
|
|
53
|
+
];
|
|
54
|
+
if (account) {
|
|
55
|
+
args.push("--account", account);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const result = spawnSync(command.cmd, args, {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
env: process.env,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (result.error) {
|
|
64
|
+
throw result.error;
|
|
65
|
+
}
|
|
66
|
+
process.exit(result.status ?? 1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main();
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ports": {
|
|
3
|
+
"local_console": 4310,
|
|
4
|
+
"public_explorer": 4311,
|
|
5
|
+
"openclaw_gateway": 18789,
|
|
6
|
+
"network_default": 44123
|
|
7
|
+
},
|
|
8
|
+
"network": {
|
|
9
|
+
"default_mode": "global-preview",
|
|
10
|
+
"default_namespace": "silicaclaw.preview",
|
|
11
|
+
"global_preview": {
|
|
12
|
+
"relay_url": "https://relay.silicaclaw.com",
|
|
13
|
+
"room": "silicaclaw-global-preview"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"bridge": {
|
|
17
|
+
"api_base": "http://localhost:4310"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function toBase64(input: Uint8Array): string;
|
|
2
|
+
export declare function fromBase64(input: string): Uint8Array;
|
|
3
|
+
export declare function hashPublicKey(publicKey: Uint8Array): string;
|
|
4
|
+
export declare function stableStringify(input: unknown): string;
|
|
5
|
+
export declare function signPayload(payload: unknown, privateKeyBase64: string): string;
|
|
6
|
+
export declare function verifyPayload(payload: unknown, signatureBase64: string, publicKeyBase64: string): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
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.toBase64 = toBase64;
|
|
7
|
+
exports.fromBase64 = fromBase64;
|
|
8
|
+
exports.hashPublicKey = hashPublicKey;
|
|
9
|
+
exports.stableStringify = stableStringify;
|
|
10
|
+
exports.signPayload = signPayload;
|
|
11
|
+
exports.verifyPayload = verifyPayload;
|
|
12
|
+
const crypto_1 = require("crypto");
|
|
13
|
+
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
14
|
+
function toBase64(input) {
|
|
15
|
+
return Buffer.from(input).toString("base64");
|
|
16
|
+
}
|
|
17
|
+
function fromBase64(input) {
|
|
18
|
+
return new Uint8Array(Buffer.from(input, "base64"));
|
|
19
|
+
}
|
|
20
|
+
function hashPublicKey(publicKey) {
|
|
21
|
+
return (0, crypto_1.createHash)("sha256").update(publicKey).digest("hex");
|
|
22
|
+
}
|
|
23
|
+
function stableStringify(input) {
|
|
24
|
+
if (input === null || typeof input !== "object") {
|
|
25
|
+
return JSON.stringify(input);
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(input)) {
|
|
28
|
+
return `[${input.map((item) => stableStringify(item)).join(",")}]`;
|
|
29
|
+
}
|
|
30
|
+
const entries = Object.entries(input)
|
|
31
|
+
.filter(([, value]) => value !== undefined)
|
|
32
|
+
.sort(([a], [b]) => a.localeCompare(b));
|
|
33
|
+
return `{${entries
|
|
34
|
+
.map(([key, value]) => `${JSON.stringify(key)}:${stableStringify(value)}`)
|
|
35
|
+
.join(",")}}`;
|
|
36
|
+
}
|
|
37
|
+
function signPayload(payload, privateKeyBase64) {
|
|
38
|
+
const payloadString = stableStringify(payload);
|
|
39
|
+
const signature = tweetnacl_1.default.sign.detached(Buffer.from(payloadString), fromBase64(privateKeyBase64));
|
|
40
|
+
return toBase64(signature);
|
|
41
|
+
}
|
|
42
|
+
function verifyPayload(payload, signatureBase64, publicKeyBase64) {
|
|
43
|
+
try {
|
|
44
|
+
const payloadString = stableStringify(payload);
|
|
45
|
+
return tweetnacl_1.default.sign.detached.verify(Buffer.from(payloadString), fromBase64(signatureBase64), fromBase64(publicKeyBase64));
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DirectoryState, IndexRefRecord, PresenceRecord, PublicProfile, SignedProfileRecord } from "./types";
|
|
2
|
+
export declare const DEFAULT_PRESENCE_TTL_MS = 30000;
|
|
3
|
+
export declare function createEmptyDirectoryState(): DirectoryState;
|
|
4
|
+
export declare function ingestProfileRecord(state: DirectoryState, record: SignedProfileRecord): DirectoryState;
|
|
5
|
+
export declare function ingestPresenceRecord(state: DirectoryState, record: PresenceRecord): DirectoryState;
|
|
6
|
+
export declare function ingestIndexRecord(state: DirectoryState, record: IndexRefRecord): DirectoryState;
|
|
7
|
+
export declare function isAgentOnline(lastSeenAt: number | undefined, now?: number, ttlMs?: number): boolean;
|
|
8
|
+
export declare function cleanupExpiredPresence(state: DirectoryState, now?: number, ttlMs?: number): {
|
|
9
|
+
state: DirectoryState;
|
|
10
|
+
removed: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function rebuildIndexForProfile(state: DirectoryState, profile: PublicProfile): DirectoryState;
|
|
13
|
+
export declare function dedupeIndex(state: DirectoryState): DirectoryState;
|
|
14
|
+
export declare function searchDirectory(state: DirectoryState, keyword: string, options?: {
|
|
15
|
+
now?: number;
|
|
16
|
+
presenceTTLms?: number;
|
|
17
|
+
}): PublicProfile[];
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_PRESENCE_TTL_MS = void 0;
|
|
4
|
+
exports.createEmptyDirectoryState = createEmptyDirectoryState;
|
|
5
|
+
exports.ingestProfileRecord = ingestProfileRecord;
|
|
6
|
+
exports.ingestPresenceRecord = ingestPresenceRecord;
|
|
7
|
+
exports.ingestIndexRecord = ingestIndexRecord;
|
|
8
|
+
exports.isAgentOnline = isAgentOnline;
|
|
9
|
+
exports.cleanupExpiredPresence = cleanupExpiredPresence;
|
|
10
|
+
exports.rebuildIndexForProfile = rebuildIndexForProfile;
|
|
11
|
+
exports.dedupeIndex = dedupeIndex;
|
|
12
|
+
exports.searchDirectory = searchDirectory;
|
|
13
|
+
const indexing_1 = require("./indexing");
|
|
14
|
+
exports.DEFAULT_PRESENCE_TTL_MS = 30_000;
|
|
15
|
+
function createEmptyDirectoryState() {
|
|
16
|
+
return {
|
|
17
|
+
profiles: {},
|
|
18
|
+
presence: {},
|
|
19
|
+
index: {},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function ingestProfileRecord(state, record) {
|
|
23
|
+
const next = {
|
|
24
|
+
profiles: { ...state.profiles },
|
|
25
|
+
presence: { ...state.presence },
|
|
26
|
+
index: { ...state.index },
|
|
27
|
+
};
|
|
28
|
+
next.profiles[record.profile.agent_id] = record.profile;
|
|
29
|
+
return rebuildIndexForProfile(next, record.profile);
|
|
30
|
+
}
|
|
31
|
+
function ingestPresenceRecord(state, record) {
|
|
32
|
+
return {
|
|
33
|
+
profiles: { ...state.profiles },
|
|
34
|
+
presence: {
|
|
35
|
+
...state.presence,
|
|
36
|
+
[record.agent_id]: record.timestamp,
|
|
37
|
+
},
|
|
38
|
+
index: { ...state.index },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function ingestIndexRecord(state, record) {
|
|
42
|
+
const existing = new Set(state.index[record.key] ?? []);
|
|
43
|
+
if (existing.has(record.agent_id)) {
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
existing.add(record.agent_id);
|
|
47
|
+
return {
|
|
48
|
+
profiles: { ...state.profiles },
|
|
49
|
+
presence: { ...state.presence },
|
|
50
|
+
index: {
|
|
51
|
+
...state.index,
|
|
52
|
+
[record.key]: Array.from(existing),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function isAgentOnline(lastSeenAt, now = Date.now(), ttlMs = exports.DEFAULT_PRESENCE_TTL_MS) {
|
|
57
|
+
if (!lastSeenAt) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return now - lastSeenAt <= ttlMs;
|
|
61
|
+
}
|
|
62
|
+
function cleanupExpiredPresence(state, now = Date.now(), ttlMs = exports.DEFAULT_PRESENCE_TTL_MS) {
|
|
63
|
+
let removed = 0;
|
|
64
|
+
const presence = {};
|
|
65
|
+
for (const [agentId, timestamp] of Object.entries(state.presence)) {
|
|
66
|
+
if (isAgentOnline(timestamp, now, ttlMs)) {
|
|
67
|
+
presence[agentId] = timestamp;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
removed += 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (removed === 0) {
|
|
74
|
+
return { state, removed: 0 };
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
state: {
|
|
78
|
+
profiles: { ...state.profiles },
|
|
79
|
+
presence,
|
|
80
|
+
index: { ...state.index },
|
|
81
|
+
},
|
|
82
|
+
removed,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function rebuildIndexForProfile(state, profile) {
|
|
86
|
+
const keys = (0, indexing_1.buildIndexKeys)(profile);
|
|
87
|
+
const nextIndex = {};
|
|
88
|
+
for (const [key, ids] of Object.entries(state.index)) {
|
|
89
|
+
const filtered = ids.filter((id) => id !== profile.agent_id);
|
|
90
|
+
if (filtered.length > 0) {
|
|
91
|
+
nextIndex[key] = Array.from(new Set(filtered));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const key of keys) {
|
|
95
|
+
const existing = new Set(nextIndex[key] ?? []);
|
|
96
|
+
existing.add(profile.agent_id);
|
|
97
|
+
nextIndex[key] = Array.from(existing);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
profiles: { ...state.profiles },
|
|
101
|
+
presence: { ...state.presence },
|
|
102
|
+
index: nextIndex,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function dedupeIndex(state) {
|
|
106
|
+
const index = {};
|
|
107
|
+
for (const [key, ids] of Object.entries(state.index)) {
|
|
108
|
+
index[key] = Array.from(new Set(ids));
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
profiles: { ...state.profiles },
|
|
112
|
+
presence: { ...state.presence },
|
|
113
|
+
index,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function searchDirectory(state, keyword, options) {
|
|
117
|
+
const now = options?.now ?? Date.now();
|
|
118
|
+
const presenceTTLms = options?.presenceTTLms ?? exports.DEFAULT_PRESENCE_TTL_MS;
|
|
119
|
+
const normalized = keyword.trim().toLowerCase();
|
|
120
|
+
const baseList = normalized.length === 0
|
|
121
|
+
? Object.values(state.profiles)
|
|
122
|
+
: Array.from(new Set([
|
|
123
|
+
...(state.index[`tag:${normalized}`] ?? []),
|
|
124
|
+
...(state.index[`name:${normalized.replace(/[^a-z0-9]+/g, "")}`] ?? []),
|
|
125
|
+
]))
|
|
126
|
+
.map((agentId) => state.profiles[agentId])
|
|
127
|
+
.filter((profile) => Boolean(profile));
|
|
128
|
+
return baseList
|
|
129
|
+
.slice()
|
|
130
|
+
.sort((a, b) => {
|
|
131
|
+
const aOnline = isAgentOnline(state.presence[a.agent_id], now, presenceTTLms) ? 1 : 0;
|
|
132
|
+
const bOnline = isAgentOnline(state.presence[b.agent_id], now, presenceTTLms) ? 1 : 0;
|
|
133
|
+
if (aOnline !== bOnline) {
|
|
134
|
+
return bOnline - aOnline;
|
|
135
|
+
}
|
|
136
|
+
if (a.updated_at !== b.updated_at) {
|
|
137
|
+
return b.updated_at - a.updated_at;
|
|
138
|
+
}
|
|
139
|
+
const byName = a.display_name.localeCompare(b.display_name);
|
|
140
|
+
if (byName !== 0) {
|
|
141
|
+
return byName;
|
|
142
|
+
}
|
|
143
|
+
return a.agent_id.localeCompare(b.agent_id);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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.createIdentity = createIdentity;
|
|
7
|
+
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
8
|
+
const crypto_1 = require("./crypto");
|
|
9
|
+
function createIdentity(now = Date.now()) {
|
|
10
|
+
const pair = tweetnacl_1.default.sign.keyPair();
|
|
11
|
+
const publicKey = (0, crypto_1.toBase64)(pair.publicKey);
|
|
12
|
+
return {
|
|
13
|
+
agent_id: (0, crypto_1.hashPublicKey)(pair.publicKey),
|
|
14
|
+
public_key: publicKey,
|
|
15
|
+
private_key: (0, crypto_1.toBase64)(pair.secretKey),
|
|
16
|
+
created_at: now,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./crypto";
|
|
3
|
+
export * from "./identity";
|
|
4
|
+
export * from "./profile";
|
|
5
|
+
export * from "./presence";
|
|
6
|
+
export * from "./socialMessage";
|
|
7
|
+
export * from "./indexing";
|
|
8
|
+
export * from "./directory";
|
|
9
|
+
export * from "./publicProfileSummary";
|
|
10
|
+
export * from "./socialConfig";
|
|
11
|
+
export * from "./socialResolver";
|
|
12
|
+
export * from "./socialTemplate";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./crypto"), exports);
|
|
19
|
+
__exportStar(require("./identity"), exports);
|
|
20
|
+
__exportStar(require("./profile"), exports);
|
|
21
|
+
__exportStar(require("./presence"), exports);
|
|
22
|
+
__exportStar(require("./socialMessage"), exports);
|
|
23
|
+
__exportStar(require("./indexing"), exports);
|
|
24
|
+
__exportStar(require("./directory"), exports);
|
|
25
|
+
__exportStar(require("./publicProfileSummary"), exports);
|
|
26
|
+
__exportStar(require("./socialConfig"), exports);
|
|
27
|
+
__exportStar(require("./socialResolver"), exports);
|
|
28
|
+
__exportStar(require("./socialTemplate"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IndexRefRecord, PublicProfile } from "./types";
|
|
2
|
+
export declare function normalizeTag(tag: string): string;
|
|
3
|
+
export declare function buildTagIndexKeys(tags: string[]): string[];
|
|
4
|
+
export declare function buildNamePrefixKeys(displayName: string): string[];
|
|
5
|
+
export declare function buildIndexKeys(profile: PublicProfile): string[];
|
|
6
|
+
export declare function buildIndexRecords(profile: PublicProfile): IndexRefRecord[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeTag = normalizeTag;
|
|
4
|
+
exports.buildTagIndexKeys = buildTagIndexKeys;
|
|
5
|
+
exports.buildNamePrefixKeys = buildNamePrefixKeys;
|
|
6
|
+
exports.buildIndexKeys = buildIndexKeys;
|
|
7
|
+
exports.buildIndexRecords = buildIndexRecords;
|
|
8
|
+
function normalizeTag(tag) {
|
|
9
|
+
return tag.trim().toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function buildTagIndexKeys(tags) {
|
|
12
|
+
return tags
|
|
13
|
+
.map(normalizeTag)
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.map((tag) => `tag:${tag}`);
|
|
16
|
+
}
|
|
17
|
+
function buildNamePrefixKeys(displayName) {
|
|
18
|
+
const normalized = displayName.trim().toLowerCase().replace(/\s+/g, " ");
|
|
19
|
+
const collapsed = normalized.replace(/[^a-z0-9]+/g, "");
|
|
20
|
+
const source = collapsed || normalized.replace(/\s+/g, "");
|
|
21
|
+
const keys = [];
|
|
22
|
+
for (let i = 1; i <= source.length; i += 1) {
|
|
23
|
+
keys.push(`name:${source.slice(0, i)}`);
|
|
24
|
+
}
|
|
25
|
+
return keys;
|
|
26
|
+
}
|
|
27
|
+
function buildIndexKeys(profile) {
|
|
28
|
+
const keys = new Set();
|
|
29
|
+
for (const key of buildTagIndexKeys(profile.tags)) {
|
|
30
|
+
keys.add(key);
|
|
31
|
+
}
|
|
32
|
+
for (const key of buildNamePrefixKeys(profile.display_name)) {
|
|
33
|
+
keys.add(key);
|
|
34
|
+
}
|
|
35
|
+
return Array.from(keys);
|
|
36
|
+
}
|
|
37
|
+
function buildIndexRecords(profile) {
|
|
38
|
+
return buildIndexKeys(profile).map((key) => ({
|
|
39
|
+
type: "index",
|
|
40
|
+
key,
|
|
41
|
+
agent_id: profile.agent_id,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AgentIdentity } from "./types";
|
|
2
|
+
import { PresenceRecord } from "./types";
|
|
3
|
+
export declare function signPresence(identity: AgentIdentity, timestamp?: number): PresenceRecord;
|
|
4
|
+
export declare function verifyPresence(record: PresenceRecord, publicKey: string): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signPresence = signPresence;
|
|
4
|
+
exports.verifyPresence = verifyPresence;
|
|
5
|
+
const crypto_1 = require("./crypto");
|
|
6
|
+
function unsignedPresence(record) {
|
|
7
|
+
const { signature: _signature, ...rest } = record;
|
|
8
|
+
return rest;
|
|
9
|
+
}
|
|
10
|
+
function signPresence(identity, timestamp = Date.now()) {
|
|
11
|
+
const payload = {
|
|
12
|
+
type: "presence",
|
|
13
|
+
agent_id: identity.agent_id,
|
|
14
|
+
timestamp,
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
...payload,
|
|
18
|
+
signature: (0, crypto_1.signPayload)(payload, identity.private_key),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function verifyPresence(record, publicKey) {
|
|
22
|
+
return (0, crypto_1.verifyPayload)(unsignedPresence(record), record.signature, publicKey);
|
|
23
|
+
}
|