@silicaclaw/cli 1.0.0-beta.4 → 1.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/packages/storage/tsconfig.json +6 -1
  3. package/scripts/quickstart.sh +41 -1
  4. package/packages/storage/dist/core/src/crypto.d.ts +0 -6
  5. package/packages/storage/dist/core/src/crypto.js +0 -50
  6. package/packages/storage/dist/core/src/directory.d.ts +0 -17
  7. package/packages/storage/dist/core/src/directory.js +0 -145
  8. package/packages/storage/dist/core/src/identity.d.ts +0 -2
  9. package/packages/storage/dist/core/src/identity.js +0 -18
  10. package/packages/storage/dist/core/src/index.d.ts +0 -11
  11. package/packages/storage/dist/core/src/index.js +0 -27
  12. package/packages/storage/dist/core/src/indexing.d.ts +0 -6
  13. package/packages/storage/dist/core/src/indexing.js +0 -43
  14. package/packages/storage/dist/core/src/presence.d.ts +0 -4
  15. package/packages/storage/dist/core/src/presence.js +0 -23
  16. package/packages/storage/dist/core/src/profile.d.ts +0 -4
  17. package/packages/storage/dist/core/src/profile.js +0 -39
  18. package/packages/storage/dist/core/src/publicProfileSummary.d.ts +0 -70
  19. package/packages/storage/dist/core/src/publicProfileSummary.js +0 -103
  20. package/packages/storage/dist/core/src/socialConfig.d.ts +0 -99
  21. package/packages/storage/dist/core/src/socialConfig.js +0 -287
  22. package/packages/storage/dist/core/src/socialResolver.d.ts +0 -46
  23. package/packages/storage/dist/core/src/socialResolver.js +0 -227
  24. package/packages/storage/dist/core/src/socialTemplate.d.ts +0 -2
  25. package/packages/storage/dist/core/src/socialTemplate.js +0 -88
  26. package/packages/storage/dist/core/src/types.d.ts +0 -37
  27. package/packages/storage/dist/core/src/types.js +0 -2
  28. /package/packages/storage/dist/{storage/src/index.d.ts → index.d.ts} +0 -0
  29. /package/packages/storage/dist/{storage/src/index.js → index.js} +0 -0
  30. /package/packages/storage/dist/{storage/src/jsonRepo.d.ts → jsonRepo.d.ts} +0 -0
  31. /package/packages/storage/dist/{storage/src/jsonRepo.js → jsonRepo.js} +0 -0
  32. /package/packages/storage/dist/{storage/src/repos.d.ts → repos.d.ts} +0 -0
  33. /package/packages/storage/dist/{storage/src/repos.js → repos.js} +0 -0
  34. /package/packages/storage/dist/{storage/src/socialRuntimeRepo.d.ts → socialRuntimeRepo.d.ts} +0 -0
  35. /package/packages/storage/dist/{storage/src/socialRuntimeRepo.js → socialRuntimeRepo.js} +0 -0
@@ -1,227 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSocialConfigSearchPaths = getSocialConfigSearchPaths;
4
- exports.findSocialMd = findSocialMd;
5
- exports.loadSocialConfig = loadSocialConfig;
6
- exports.findOpenClawIdentity = findOpenClawIdentity;
7
- exports.findOpenClawProfile = findOpenClawProfile;
8
- exports.resolveIdentityWithSocial = resolveIdentityWithSocial;
9
- exports.resolveProfileInputWithSocial = resolveProfileInputWithSocial;
10
- exports.ensureDefaultSocialMd = ensureDefaultSocialMd;
11
- const fs_1 = require("fs");
12
- const os_1 = require("os");
13
- const path_1 = require("path");
14
- const crypto_1 = require("./crypto");
15
- const socialConfig_1 = require("./socialConfig");
16
- function getSocialConfigSearchPaths(rootDir = process.cwd(), homeDir = (0, os_1.homedir)()) {
17
- return [
18
- (0, path_1.resolve)(rootDir, "social.md"),
19
- (0, path_1.resolve)(rootDir, ".openclaw", "social.md"),
20
- (0, path_1.resolve)(homeDir, ".openclaw", "social.md"),
21
- ];
22
- }
23
- function findSocialMd(rootDir = process.cwd()) {
24
- const candidates = getSocialConfigSearchPaths(rootDir);
25
- for (const path of candidates) {
26
- if (!(0, fs_1.existsSync)(path))
27
- continue;
28
- return {
29
- found: true,
30
- source_path: path,
31
- content: (0, fs_1.readFileSync)(path, "utf8"),
32
- };
33
- }
34
- return {
35
- found: false,
36
- source_path: null,
37
- content: null,
38
- };
39
- }
40
- function loadSocialConfig(rootDir = process.cwd()) {
41
- const lookup = findSocialMd(rootDir);
42
- if (!lookup.found || !lookup.content || !lookup.source_path) {
43
- return {
44
- config: (0, socialConfig_1.normalizeSocialConfig)({}),
45
- meta: {
46
- found: false,
47
- source_path: null,
48
- parse_error: null,
49
- loaded_at: Date.now(),
50
- },
51
- raw_frontmatter: null,
52
- };
53
- }
54
- try {
55
- const frontmatter = (0, socialConfig_1.extractFrontmatter)(lookup.content);
56
- if (!frontmatter) {
57
- return {
58
- config: (0, socialConfig_1.normalizeSocialConfig)({}),
59
- meta: {
60
- found: true,
61
- source_path: lookup.source_path,
62
- parse_error: "frontmatter_not_found",
63
- loaded_at: Date.now(),
64
- },
65
- raw_frontmatter: null,
66
- };
67
- }
68
- const parsed = (0, socialConfig_1.parseFrontmatterObject)(frontmatter);
69
- return {
70
- config: (0, socialConfig_1.normalizeSocialConfig)(parsed),
71
- meta: {
72
- found: true,
73
- source_path: lookup.source_path,
74
- parse_error: null,
75
- loaded_at: Date.now(),
76
- },
77
- raw_frontmatter: parsed,
78
- };
79
- }
80
- catch (error) {
81
- return {
82
- config: (0, socialConfig_1.normalizeSocialConfig)({}),
83
- meta: {
84
- found: true,
85
- source_path: lookup.source_path,
86
- parse_error: error instanceof Error ? error.message : "social_parse_failed",
87
- loaded_at: Date.now(),
88
- },
89
- raw_frontmatter: null,
90
- };
91
- }
92
- }
93
- function readJson(path) {
94
- if (!(0, fs_1.existsSync)(path))
95
- return null;
96
- try {
97
- return JSON.parse((0, fs_1.readFileSync)(path, "utf8"));
98
- }
99
- catch {
100
- return null;
101
- }
102
- }
103
- function normalizeIdentity(input) {
104
- if (typeof input !== "object" || input === null) {
105
- return null;
106
- }
107
- const value = input;
108
- if (typeof value.public_key !== "string" || typeof value.private_key !== "string") {
109
- return null;
110
- }
111
- let agentId = typeof value.agent_id === "string" ? value.agent_id : "";
112
- if (!agentId) {
113
- try {
114
- agentId = (0, crypto_1.hashPublicKey)((0, crypto_1.fromBase64)(value.public_key));
115
- }
116
- catch {
117
- return null;
118
- }
119
- }
120
- return {
121
- agent_id: agentId,
122
- public_key: value.public_key,
123
- private_key: value.private_key,
124
- created_at: Number.isFinite(value.created_at) ? Number(value.created_at) : Date.now(),
125
- };
126
- }
127
- function findOpenClawIdentity(rootDir = process.cwd(), homeDir = (0, os_1.homedir)()) {
128
- const candidates = [
129
- (0, path_1.resolve)(rootDir, ".openclaw", "identity.json"),
130
- (0, path_1.resolve)(rootDir, "identity.json"),
131
- (0, path_1.resolve)(homeDir, ".openclaw", "identity.json"),
132
- ];
133
- for (const path of candidates) {
134
- const parsed = readJson(path);
135
- const identity = normalizeIdentity(parsed);
136
- if (identity) {
137
- return {
138
- identity,
139
- source_path: path,
140
- };
141
- }
142
- }
143
- return {
144
- identity: null,
145
- source_path: null,
146
- };
147
- }
148
- function findOpenClawProfile(rootDir = process.cwd(), homeDir = (0, os_1.homedir)()) {
149
- const candidates = [
150
- (0, path_1.resolve)(rootDir, ".openclaw", "profile.json"),
151
- (0, path_1.resolve)(rootDir, "profile.json"),
152
- (0, path_1.resolve)(homeDir, ".openclaw", "profile.json"),
153
- ];
154
- for (const path of candidates) {
155
- const parsed = readJson(path);
156
- if (typeof parsed !== "object" || parsed === null)
157
- continue;
158
- const profile = parsed;
159
- return {
160
- source_path: path,
161
- profile: {
162
- display_name: typeof profile.display_name === "string" ? profile.display_name : "",
163
- bio: typeof profile.bio === "string" ? profile.bio : "",
164
- avatar_url: typeof profile.avatar_url === "string" ? profile.avatar_url : "",
165
- tags: Array.isArray(profile.tags)
166
- ? profile.tags.map((tag) => String(tag).trim()).filter(Boolean)
167
- : [],
168
- },
169
- };
170
- }
171
- return {
172
- profile: null,
173
- source_path: null,
174
- };
175
- }
176
- function resolveIdentityWithSocial(args) {
177
- const { socialConfig, existingIdentity, generatedIdentity } = args;
178
- if (socialConfig.openclaw.bind_existing_identity) {
179
- const openclaw = findOpenClawIdentity(args.rootDir ?? process.cwd());
180
- if (openclaw.identity) {
181
- return {
182
- identity: openclaw.identity,
183
- source: "openclaw-existing",
184
- openclaw_source_path: openclaw.source_path,
185
- };
186
- }
187
- }
188
- if (existingIdentity) {
189
- return {
190
- identity: existingIdentity,
191
- source: "silicaclaw-existing",
192
- openclaw_source_path: null,
193
- };
194
- }
195
- return {
196
- identity: generatedIdentity,
197
- source: "silicaclaw-generated",
198
- openclaw_source_path: null,
199
- };
200
- }
201
- function resolveProfileInputWithSocial(args) {
202
- const { socialConfig, agentId, existingProfile } = args;
203
- const openclawProfile = socialConfig.openclaw.use_openclaw_profile_if_available
204
- ? findOpenClawProfile(args.rootDir ?? process.cwd()).profile
205
- : null;
206
- const baseDisplayName = existingProfile?.display_name || "";
207
- const baseBio = existingProfile?.bio || "";
208
- const baseAvatarUrl = existingProfile?.avatar_url || "";
209
- const baseTags = existingProfile?.tags || [];
210
- return {
211
- agent_id: agentId,
212
- display_name: socialConfig.identity.display_name || openclawProfile?.display_name || baseDisplayName,
213
- bio: socialConfig.identity.bio || openclawProfile?.bio || baseBio,
214
- avatar_url: socialConfig.identity.avatar_url || openclawProfile?.avatar_url || baseAvatarUrl,
215
- tags: socialConfig.identity.tags.length > 0 ? socialConfig.identity.tags : openclawProfile?.tags || baseTags,
216
- public_enabled: socialConfig.public_enabled,
217
- };
218
- }
219
- function ensureDefaultSocialMd(rootDir = process.cwd(), options = {}) {
220
- const targetPath = (0, path_1.resolve)(rootDir, "social.md");
221
- if ((0, fs_1.existsSync)(targetPath)) {
222
- return { path: targetPath, created: false };
223
- }
224
- (0, fs_1.mkdirSync)(rootDir, { recursive: true });
225
- (0, fs_1.writeFileSync)(targetPath, (0, socialConfig_1.generateDefaultSocialMdTemplate)(options), "utf8");
226
- return { path: targetPath, created: true };
227
- }
@@ -1,2 +0,0 @@
1
- import { SocialRuntimeConfig } from "./socialConfig";
2
- export declare function generateSocialMdTemplate(runtimeConfig: SocialRuntimeConfig | null | undefined): string;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSocialMdTemplate = generateSocialMdTemplate;
4
- function asBool(value, fallback) {
5
- return typeof value === "boolean" ? value : fallback;
6
- }
7
- function asString(value, fallback) {
8
- return typeof value === "string" ? value : fallback;
9
- }
10
- function asStringArray(value, fallback) {
11
- if (!Array.isArray(value))
12
- return fallback;
13
- return value.map((item) => String(item).trim()).filter(Boolean);
14
- }
15
- function yamlString(input) {
16
- return JSON.stringify(input ?? "");
17
- }
18
- function yamlStringList(values, indent = " ") {
19
- if (!values.length) {
20
- return `${indent}[]`;
21
- }
22
- return values.map((value) => `${indent}- ${yamlString(value)}`).join("\n");
23
- }
24
- function generateSocialMdTemplate(runtimeConfig) {
25
- const enabled = asBool(runtimeConfig?.enabled, true);
26
- const publicEnabled = asBool(runtimeConfig?.public_enabled, false);
27
- const profile = runtimeConfig?.resolved_profile ?? null;
28
- const network = runtimeConfig?.resolved_network ?? null;
29
- const discovery = runtimeConfig?.resolved_discovery ?? null;
30
- const visibility = runtimeConfig?.visibility ?? null;
31
- const openclaw = runtimeConfig?.openclaw ?? null;
32
- const displayName = asString(profile?.display_name, "");
33
- const bio = asString(profile?.bio, "");
34
- const tags = asStringArray(profile?.tags, ["openclaw", "local-first"]);
35
- const mode = network?.mode === "local" || network?.mode === "lan" || network?.mode === "global-preview"
36
- ? network.mode
37
- : "lan";
38
- const discoverable = asBool(discovery?.discoverable, true);
39
- const allowProfileBroadcast = asBool(discovery?.allow_profile_broadcast, true);
40
- const allowPresenceBroadcast = asBool(discovery?.allow_presence_broadcast, true);
41
- const showDisplayName = asBool(visibility?.show_display_name, true);
42
- const showBio = asBool(visibility?.show_bio, true);
43
- const showTags = asBool(visibility?.show_tags, true);
44
- const showAgentId = asBool(visibility?.show_agent_id, true);
45
- const showLastSeen = asBool(visibility?.show_last_seen, true);
46
- const showCapabilitiesSummary = asBool(visibility?.show_capabilities_summary, true);
47
- const bindExistingIdentity = asBool(openclaw?.bind_existing_identity, true);
48
- const useOpenClawProfile = asBool(openclaw?.use_openclaw_profile_if_available, true);
49
- return `---
50
- enabled: ${enabled}
51
- public_enabled: ${publicEnabled}
52
-
53
- identity:
54
- display_name: ${yamlString(displayName)}
55
- bio: ${yamlString(bio)}
56
- tags:
57
- ${yamlStringList(tags.map((tag) => asString(tag, "")), " ")}
58
-
59
- network:
60
- mode: ${yamlString(mode)}
61
-
62
- discovery:
63
- discoverable: ${discoverable}
64
- allow_profile_broadcast: ${allowProfileBroadcast}
65
- allow_presence_broadcast: ${allowPresenceBroadcast}
66
-
67
- visibility:
68
- show_display_name: ${showDisplayName}
69
- show_bio: ${showBio}
70
- show_tags: ${showTags}
71
- show_agent_id: ${showAgentId}
72
- show_last_seen: ${showLastSeen}
73
- show_capabilities_summary: ${showCapabilitiesSummary}
74
-
75
- openclaw:
76
- bind_existing_identity: ${bindExistingIdentity}
77
- use_openclaw_profile_if_available: ${useOpenClawProfile}
78
- ---
79
-
80
- # Social
81
-
82
- Generated from current SilicaClaw runtime state.
83
-
84
- - Save as \`social.md\` in your OpenClaw workspace.
85
- - This export does not auto-overwrite any existing file.
86
- - Advanced network fields are intentionally hidden in template and resolved in runtime.
87
- `;
88
- }
@@ -1,37 +0,0 @@
1
- export type AgentIdentity = {
2
- agent_id: string;
3
- public_key: string;
4
- private_key: string;
5
- created_at: number;
6
- };
7
- export type PublicProfile = {
8
- agent_id: string;
9
- display_name: string;
10
- bio: string;
11
- tags: string[];
12
- avatar_url?: string;
13
- public_enabled: boolean;
14
- updated_at: number;
15
- signature: string;
16
- };
17
- export type SignedProfileRecord = {
18
- type: "profile";
19
- profile: PublicProfile;
20
- };
21
- export type PresenceRecord = {
22
- type: "presence";
23
- agent_id: string;
24
- timestamp: number;
25
- signature: string;
26
- };
27
- export type IndexRefRecord = {
28
- type: "index";
29
- key: string;
30
- agent_id: string;
31
- };
32
- export type DirectoryState = {
33
- profiles: Record<string, PublicProfile>;
34
- presence: Record<string, number>;
35
- index: Record<string, string[]>;
36
- };
37
- export type ProfileInput = Omit<PublicProfile, "signature" | "updated_at">;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });