multiclaws 0.4.7 → 0.4.8
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.
|
@@ -53,6 +53,11 @@ export declare class MulticlawsService extends EventEmitter {
|
|
|
53
53
|
}): Promise<DelegateTaskResult>;
|
|
54
54
|
getTaskStatus(taskId: string): import("../task/tracker").TaskRecord | null;
|
|
55
55
|
getProfile(): Promise<AgentProfile>;
|
|
56
|
+
/**
|
|
57
|
+
* Throws if the profile is incomplete (ownerName or bio missing).
|
|
58
|
+
* Call this before any action that exposes the user's identity to other agents.
|
|
59
|
+
*/
|
|
60
|
+
private requireCompleteProfile;
|
|
56
61
|
setProfile(patch: {
|
|
57
62
|
ownerName?: string;
|
|
58
63
|
bio?: string;
|
|
@@ -195,6 +195,7 @@ class MulticlawsService extends node_events_1.EventEmitter {
|
|
|
195
195
|
/* Task delegation */
|
|
196
196
|
/* ---------------------------------------------------------------- */
|
|
197
197
|
async delegateTask(params) {
|
|
198
|
+
await this.requireCompleteProfile();
|
|
198
199
|
const agentRecord = await this.agentRegistry.get(params.agentUrl);
|
|
199
200
|
if (!agentRecord) {
|
|
200
201
|
return { status: "failed", error: `unknown agent: ${params.agentUrl}` };
|
|
@@ -232,6 +233,16 @@ class MulticlawsService extends node_events_1.EventEmitter {
|
|
|
232
233
|
async getProfile() {
|
|
233
234
|
return await this.profileStore.load();
|
|
234
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Throws if the profile is incomplete (ownerName or bio missing).
|
|
238
|
+
* Call this before any action that exposes the user's identity to other agents.
|
|
239
|
+
*/
|
|
240
|
+
async requireCompleteProfile() {
|
|
241
|
+
const profile = await this.profileStore.load();
|
|
242
|
+
if (!profile.ownerName?.trim() || !profile.bio?.trim()) {
|
|
243
|
+
throw new Error("档案未完成设置。请先调用 multiclaws_profile_set(ownerName=\"你的名字\", bio=\"你的介绍\") 完成设置后再继续。");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
235
246
|
async setProfile(patch) {
|
|
236
247
|
const profile = await this.profileStore.update(patch);
|
|
237
248
|
this.updateProfileDescription(profile);
|
|
@@ -242,6 +253,9 @@ class MulticlawsService extends node_events_1.EventEmitter {
|
|
|
242
253
|
this.profileDescription = (0, agent_profile_1.renderProfileDescription)(profile);
|
|
243
254
|
if (this.agentCard) {
|
|
244
255
|
this.agentCard.description = this.profileDescription;
|
|
256
|
+
if (profile.ownerName?.trim()) {
|
|
257
|
+
this.agentCard.name = profile.ownerName.trim();
|
|
258
|
+
}
|
|
245
259
|
}
|
|
246
260
|
}
|
|
247
261
|
/* ---------------------------------------------------------------- */
|
|
@@ -280,6 +294,7 @@ class MulticlawsService extends node_events_1.EventEmitter {
|
|
|
280
294
|
/* Team management */
|
|
281
295
|
/* ---------------------------------------------------------------- */
|
|
282
296
|
async createTeam(name) {
|
|
297
|
+
await this.requireCompleteProfile();
|
|
283
298
|
const team = await this.teamStore.createTeam({
|
|
284
299
|
teamName: name,
|
|
285
300
|
selfUrl: this.selfUrl,
|
|
@@ -298,6 +313,7 @@ class MulticlawsService extends node_events_1.EventEmitter {
|
|
|
298
313
|
return (0, team_store_1.encodeInvite)(team.teamId, this.selfUrl);
|
|
299
314
|
}
|
|
300
315
|
async joinTeam(inviteCode) {
|
|
316
|
+
await this.requireCompleteProfile();
|
|
301
317
|
const invite = (0, team_store_1.decodeInvite)(inviteCode);
|
|
302
318
|
const seedUrl = invite.u.replace(/\/+$/, "");
|
|
303
319
|
// 1. Fetch member list from seed
|
|
@@ -705,13 +721,17 @@ function getLocalIp() {
|
|
|
705
721
|
if (tsIp)
|
|
706
722
|
return tsIp;
|
|
707
723
|
const interfaces = node_os_1.default.networkInterfaces();
|
|
724
|
+
let fallback;
|
|
708
725
|
for (const addrs of Object.values(interfaces)) {
|
|
709
726
|
if (!addrs)
|
|
710
727
|
continue;
|
|
711
728
|
for (const addr of addrs) {
|
|
712
|
-
if (addr.family === "IPv4" && !addr.internal)
|
|
713
|
-
|
|
729
|
+
if (addr.family === "IPv4" && !addr.internal) {
|
|
730
|
+
if (addr.address.startsWith("192.168."))
|
|
731
|
+
return addr.address;
|
|
732
|
+
fallback ??= addr.address;
|
|
733
|
+
}
|
|
714
734
|
}
|
|
715
735
|
}
|
|
716
|
-
return node_os_1.default.hostname();
|
|
736
|
+
return fallback ?? node_os_1.default.hostname();
|
|
717
737
|
}
|