openclaw-weiyuan-init 1.0.110 → 1.0.112
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/lib/commands.js +4 -0
- package/lib/identity.js +36 -0
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -674,6 +674,10 @@ async function runInit(options) {
|
|
|
674
674
|
let spinner = ora('检测到已接入微元系统,直接加入项目...').start();
|
|
675
675
|
try {
|
|
676
676
|
await runAcrossServerCandidates(serverCandidates, 'join_existing_workspace', async (candidate) => {
|
|
677
|
+
const refreshed = await createIdentityFile(identityPath, candidate, workspacePath);
|
|
678
|
+
if (!refreshed || !refreshed.created) {
|
|
679
|
+
throw new Error(refreshed && refreshed.error ? refreshed.error : 'identity_refresh_failed');
|
|
680
|
+
}
|
|
677
681
|
const identity = await fs.readJson(identityPath);
|
|
678
682
|
identity.serverBaseUrl = normalizeBusinessServerUrl(candidate);
|
|
679
683
|
await fs.writeJson(identityPath, identity, { spaces: 2 });
|
package/lib/identity.js
CHANGED
|
@@ -133,6 +133,24 @@ async function createIdentityFile(identityPath, serverUrl, workspacePath) {
|
|
|
133
133
|
identity.lobsterId = serverLobsterId;
|
|
134
134
|
identity.identityHash = sha256Hex(JSON.stringify({ lobsterId: serverLobsterId, publicKeyBase64: identity.publicKeyBase64 }));
|
|
135
135
|
}
|
|
136
|
+
if (initInfo && Array.isArray(initInfo.joinedProjectIds)) {
|
|
137
|
+
identity.joinedProjectIds = initInfo.joinedProjectIds.map((x) => String(x || '').trim()).filter(Boolean);
|
|
138
|
+
} else {
|
|
139
|
+
delete identity.joinedProjectIds;
|
|
140
|
+
}
|
|
141
|
+
if (initInfo && typeof initInfo.currentProjectId === 'string' && initInfo.currentProjectId.trim()) {
|
|
142
|
+
identity.currentProjectId = String(initInfo.currentProjectId).trim();
|
|
143
|
+
} else {
|
|
144
|
+
delete identity.currentProjectId;
|
|
145
|
+
}
|
|
146
|
+
identity.projectCursors =
|
|
147
|
+
initInfo && initInfo.projectCursors && typeof initInfo.projectCursors === 'object' && !Array.isArray(initInfo.projectCursors)
|
|
148
|
+
? Object.fromEntries(
|
|
149
|
+
Object.entries(initInfo.projectCursors)
|
|
150
|
+
.map(([k, v]) => [String(k || '').trim(), Number(v || 0)])
|
|
151
|
+
.filter(([k, v]) => k && Number.isFinite(v))
|
|
152
|
+
)
|
|
153
|
+
: {};
|
|
136
154
|
await fs.writeJson(identityPath, identity, { spaces: 2 });
|
|
137
155
|
return { created: true, initInfo: initInfo || null };
|
|
138
156
|
}
|
|
@@ -164,6 +182,24 @@ async function createIdentityFile(identityPath, serverUrl, workspacePath) {
|
|
|
164
182
|
identity.lobsterId = serverLobsterId;
|
|
165
183
|
identity.identityHash = sha256Hex(JSON.stringify({ lobsterId: serverLobsterId, publicKeyBase64: identity.publicKeyBase64 }));
|
|
166
184
|
}
|
|
185
|
+
if (initInfo && Array.isArray(initInfo.joinedProjectIds)) {
|
|
186
|
+
identity.joinedProjectIds = initInfo.joinedProjectIds.map((x) => String(x || '').trim()).filter(Boolean);
|
|
187
|
+
} else {
|
|
188
|
+
delete identity.joinedProjectIds;
|
|
189
|
+
}
|
|
190
|
+
if (initInfo && typeof initInfo.currentProjectId === 'string' && initInfo.currentProjectId.trim()) {
|
|
191
|
+
identity.currentProjectId = String(initInfo.currentProjectId).trim();
|
|
192
|
+
} else {
|
|
193
|
+
delete identity.currentProjectId;
|
|
194
|
+
}
|
|
195
|
+
identity.projectCursors =
|
|
196
|
+
initInfo && initInfo.projectCursors && typeof initInfo.projectCursors === 'object' && !Array.isArray(initInfo.projectCursors)
|
|
197
|
+
? Object.fromEntries(
|
|
198
|
+
Object.entries(initInfo.projectCursors)
|
|
199
|
+
.map(([k, v]) => [String(k || '').trim(), Number(v || 0)])
|
|
200
|
+
.filter(([k, v]) => k && Number.isFinite(v))
|
|
201
|
+
)
|
|
202
|
+
: {};
|
|
167
203
|
await fs.writeJson(identityPath, identity, { spaces: 2 });
|
|
168
204
|
return { created: true, initInfo: initInfo || null };
|
|
169
205
|
} catch (error) {
|