@memtensor/memos-local-openclaw-plugin 1.0.4-beta.10 → 1.0.4-beta.12
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/dist/client/connector.d.ts +5 -0
- package/dist/client/connector.d.ts.map +1 -1
- package/dist/client/connector.js +38 -8
- package/dist/client/connector.js.map +1 -1
- package/dist/hub/server.d.ts +1 -0
- package/dist/hub/server.d.ts.map +1 -1
- package/dist/hub/server.js +143 -32
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/user-manager.d.ts +9 -0
- package/dist/hub/user-manager.d.ts.map +1 -1
- package/dist/hub/user-manager.js +26 -2
- package/dist/hub/user-manager.js.map +1 -1
- package/dist/ingest/chunker.d.ts +2 -1
- package/dist/ingest/chunker.d.ts.map +1 -1
- package/dist/ingest/chunker.js +14 -10
- package/dist/ingest/chunker.js.map +1 -1
- package/dist/recall/engine.d.ts.map +1 -1
- package/dist/recall/engine.js +7 -2
- package/dist/recall/engine.js.map +1 -1
- package/dist/sharing/types.d.ts +1 -1
- package/dist/sharing/types.d.ts.map +1 -1
- package/dist/skill/evolver.d.ts +2 -0
- package/dist/skill/evolver.d.ts.map +1 -1
- package/dist/skill/evolver.js +56 -5
- package/dist/skill/evolver.js.map +1 -1
- package/dist/skill/generator.d.ts +2 -0
- package/dist/skill/generator.d.ts.map +1 -1
- package/dist/skill/generator.js +45 -3
- package/dist/skill/generator.js.map +1 -1
- package/dist/skill/installer.d.ts +26 -0
- package/dist/skill/installer.d.ts.map +1 -1
- package/dist/skill/installer.js +80 -4
- package/dist/skill/installer.js.map +1 -1
- package/dist/skill/upgrader.d.ts +2 -0
- package/dist/skill/upgrader.d.ts.map +1 -1
- package/dist/skill/upgrader.js +139 -1
- package/dist/skill/upgrader.js.map +1 -1
- package/dist/skill/validator.d.ts +3 -0
- package/dist/skill/validator.d.ts.map +1 -1
- package/dist/skill/validator.js +75 -0
- package/dist/skill/validator.js.map +1 -1
- package/dist/storage/sqlite.d.ts +28 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +155 -16
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/dist/viewer/html.d.ts.map +1 -1
- package/dist/viewer/html.js +64 -24
- package/dist/viewer/html.js.map +1 -1
- package/dist/viewer/server.d.ts.map +1 -1
- package/dist/viewer/server.js +39 -20
- package/dist/viewer/server.js.map +1 -1
- package/index.ts +338 -33
- package/package.json +1 -1
- package/src/client/connector.ts +43 -8
- package/src/hub/server.ts +142 -31
- package/src/hub/user-manager.ts +42 -6
- package/src/ingest/chunker.ts +19 -13
- package/src/recall/engine.ts +7 -2
- package/src/sharing/types.ts +1 -1
- package/src/skill/evolver.ts +58 -6
- package/src/skill/generator.ts +44 -5
- package/src/skill/installer.ts +107 -4
- package/src/skill/upgrader.ts +139 -1
- package/src/skill/validator.ts +79 -0
- package/src/storage/sqlite.ts +174 -16
- package/src/types.ts +11 -0
- package/src/viewer/html.ts +64 -24
- package/src/viewer/server.ts +39 -20
package/src/viewer/server.ts
CHANGED
|
@@ -1232,7 +1232,7 @@ export class ViewerServer {
|
|
|
1232
1232
|
body: JSON.stringify({ memory: { sourceChunkId: refreshedChunk.id, role: refreshedChunk.role, content: refreshedChunk.content, summary: refreshedChunk.summary, kind: refreshedChunk.kind, groupId: null, visibility: "public" } }),
|
|
1233
1233
|
});
|
|
1234
1234
|
if (!isLocalShared) this.store.markMemorySharedLocally(chunkId);
|
|
1235
|
-
if (hubClient.userId) {
|
|
1235
|
+
if (hubClient.userId && this.ctx?.config?.sharing?.role === "hub") {
|
|
1236
1236
|
const existing = this.store.getHubMemoryBySource(hubClient.userId, chunkId);
|
|
1237
1237
|
this.store.upsertHubMemory({
|
|
1238
1238
|
id: (response as any)?.memoryId ?? existing?.id ?? crypto.randomUUID(),
|
|
@@ -1780,7 +1780,8 @@ export class ViewerServer {
|
|
|
1780
1780
|
localIPs.push("127.0.0.1", "localhost", "0.0.0.0");
|
|
1781
1781
|
try {
|
|
1782
1782
|
const u = new URL(hubUrl);
|
|
1783
|
-
|
|
1783
|
+
const targetPort = u.port || (u.protocol === "https:" ? "443" : "80");
|
|
1784
|
+
if (localIPs.includes(u.hostname) && targetPort === String(this.port)) {
|
|
1784
1785
|
return this.jsonResponse(res, { ok: false, error: "cannot_join_self" });
|
|
1785
1786
|
}
|
|
1786
1787
|
} catch {}
|
|
@@ -1788,10 +1789,13 @@ export class ViewerServer {
|
|
|
1788
1789
|
const nickname = sharing.client?.nickname;
|
|
1789
1790
|
const username = nickname || os.userInfo().username || "user";
|
|
1790
1791
|
const hostname = os.hostname() || "unknown";
|
|
1792
|
+
const persisted = this.store.getClientHubConnection();
|
|
1793
|
+
const existingIdentityKey = persisted?.identityKey || "";
|
|
1791
1794
|
const result = await hubRequestJson(hubUrl, "", "/api/v1/hub/join", {
|
|
1792
1795
|
method: "POST",
|
|
1793
|
-
body: JSON.stringify({ teamToken, username, deviceName: hostname, reapply: true }),
|
|
1796
|
+
body: JSON.stringify({ teamToken, username, deviceName: hostname, reapply: true, identityKey: existingIdentityKey }),
|
|
1794
1797
|
}) as any;
|
|
1798
|
+
const returnedIdentityKey = String(result.identityKey || existingIdentityKey || "");
|
|
1795
1799
|
this.store.setClientHubConnection({
|
|
1796
1800
|
hubUrl,
|
|
1797
1801
|
userId: String(result.userId || ""),
|
|
@@ -1799,6 +1803,8 @@ export class ViewerServer {
|
|
|
1799
1803
|
userToken: result.userToken || "",
|
|
1800
1804
|
role: "member",
|
|
1801
1805
|
connectedAt: Date.now(),
|
|
1806
|
+
identityKey: returnedIdentityKey,
|
|
1807
|
+
lastKnownStatus: result.status || "",
|
|
1802
1808
|
});
|
|
1803
1809
|
this.jsonResponse(res, { ok: true, status: result.status || "pending" });
|
|
1804
1810
|
} catch (err) {
|
|
@@ -2074,14 +2080,13 @@ export class ViewerServer {
|
|
|
2074
2080
|
},
|
|
2075
2081
|
}),
|
|
2076
2082
|
});
|
|
2077
|
-
|
|
2078
|
-
if (hubUserId) {
|
|
2083
|
+
if (hubClient.userId && this.ctx?.config?.sharing?.role === "hub") {
|
|
2079
2084
|
const now = Date.now();
|
|
2080
|
-
const existing = this.store.getHubMemoryBySource(
|
|
2085
|
+
const existing = this.store.getHubMemoryBySource(hubClient.userId, chunk.id);
|
|
2081
2086
|
this.store.upsertHubMemory({
|
|
2082
2087
|
id: (response as any)?.memoryId ?? existing?.id ?? crypto.randomUUID(),
|
|
2083
2088
|
sourceChunkId: chunk.id,
|
|
2084
|
-
sourceUserId:
|
|
2089
|
+
sourceUserId: hubClient.userId,
|
|
2085
2090
|
role: chunk.role,
|
|
2086
2091
|
content: chunk.content,
|
|
2087
2092
|
summary: chunk.summary ?? "",
|
|
@@ -2592,7 +2597,8 @@ export class ViewerServer {
|
|
|
2592
2597
|
localIPs.push("127.0.0.1", "localhost", "0.0.0.0");
|
|
2593
2598
|
try {
|
|
2594
2599
|
const u = new URL(addr.startsWith("http") ? addr : `http://${addr}`);
|
|
2595
|
-
|
|
2600
|
+
const targetPort = u.port || (u.protocol === "https:" ? "443" : "80");
|
|
2601
|
+
if (localIPs.includes(u.hostname) && targetPort === String(this.port)) {
|
|
2596
2602
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
2597
2603
|
res.end(JSON.stringify({ error: "cannot_join_self" }));
|
|
2598
2604
|
return;
|
|
@@ -2618,17 +2624,22 @@ export class ViewerServer {
|
|
|
2618
2624
|
const isClient = newEnabled && newRole === "client";
|
|
2619
2625
|
if (wasClient && !isClient) {
|
|
2620
2626
|
this.notifyHubLeave();
|
|
2621
|
-
this.store.
|
|
2622
|
-
|
|
2627
|
+
const oldConn = this.store.getClientHubConnection();
|
|
2628
|
+
if (oldConn) {
|
|
2629
|
+
this.store.setClientHubConnection({ ...oldConn, userToken: "", lastKnownStatus: "left" });
|
|
2630
|
+
}
|
|
2631
|
+
this.log.info("Client hub connection token cleared (sharing disabled or role changed), identity preserved");
|
|
2623
2632
|
}
|
|
2624
2633
|
|
|
2625
|
-
// Detect switching to a different Hub while still in client mode
|
|
2626
2634
|
if (wasClient && isClient) {
|
|
2627
2635
|
const newClientAddr = String((merged.client as Record<string, unknown>)?.hubAddress || "");
|
|
2628
2636
|
if (newClientAddr && oldClientHubAddress && normalizeHubUrl(newClientAddr) !== normalizeHubUrl(oldClientHubAddress)) {
|
|
2629
2637
|
this.notifyHubLeave();
|
|
2630
|
-
this.store.
|
|
2631
|
-
|
|
2638
|
+
const oldConn = this.store.getClientHubConnection();
|
|
2639
|
+
if (oldConn) {
|
|
2640
|
+
this.store.setClientHubConnection({ ...oldConn, hubUrl: normalizeHubUrl(newClientAddr), userToken: "", lastKnownStatus: "hub_changed" });
|
|
2641
|
+
}
|
|
2642
|
+
this.log.info("Client hub connection token cleared (switched to different Hub), identity preserved");
|
|
2632
2643
|
}
|
|
2633
2644
|
}
|
|
2634
2645
|
|
|
@@ -2645,9 +2656,11 @@ export class ViewerServer {
|
|
|
2645
2656
|
this.log.info("Plugin config updated via Viewer");
|
|
2646
2657
|
this.stopHubHeartbeat();
|
|
2647
2658
|
|
|
2648
|
-
// When switching to client mode,
|
|
2659
|
+
// When switching to client mode or re-enabling sharing as client, send join request
|
|
2649
2660
|
const finalSharing = config.sharing as Record<string, unknown> | undefined;
|
|
2650
|
-
|
|
2661
|
+
const nowClient = Boolean(finalSharing?.enabled) && finalSharing?.role === "client";
|
|
2662
|
+
const previouslyClient = oldSharingEnabled && oldSharingRole === "client";
|
|
2663
|
+
if (nowClient && !previouslyClient) {
|
|
2651
2664
|
this.autoJoinOnSave(finalSharing).catch(e => this.log.warn(`Auto-join on save failed: ${e}`));
|
|
2652
2665
|
}
|
|
2653
2666
|
|
|
@@ -2670,10 +2683,13 @@ export class ViewerServer {
|
|
|
2670
2683
|
const nickname = String(clientCfg?.nickname || "");
|
|
2671
2684
|
const username = nickname || os.userInfo().username || "user";
|
|
2672
2685
|
const hostname = os.hostname() || "unknown";
|
|
2686
|
+
const persisted = this.store.getClientHubConnection();
|
|
2687
|
+
const existingIdentityKey = persisted?.identityKey || "";
|
|
2673
2688
|
const result = await hubRequestJson(hubUrl, "", "/api/v1/hub/join", {
|
|
2674
2689
|
method: "POST",
|
|
2675
|
-
body: JSON.stringify({ teamToken, username, deviceName: hostname }),
|
|
2690
|
+
body: JSON.stringify({ teamToken, username, deviceName: hostname, identityKey: existingIdentityKey }),
|
|
2676
2691
|
}) as any;
|
|
2692
|
+
const returnedIdentityKey = String(result.identityKey || existingIdentityKey || "");
|
|
2677
2693
|
this.store.setClientHubConnection({
|
|
2678
2694
|
hubUrl,
|
|
2679
2695
|
userId: String(result.userId || ""),
|
|
@@ -2681,6 +2697,8 @@ export class ViewerServer {
|
|
|
2681
2697
|
userToken: result.userToken || "",
|
|
2682
2698
|
role: "member",
|
|
2683
2699
|
connectedAt: Date.now(),
|
|
2700
|
+
identityKey: returnedIdentityKey,
|
|
2701
|
+
lastKnownStatus: result.status || "",
|
|
2684
2702
|
});
|
|
2685
2703
|
this.log.info(`Auto-join on save: status=${result.status}, userId=${result.userId}`);
|
|
2686
2704
|
if (result.userToken) {
|
|
@@ -2768,10 +2786,10 @@ export class ViewerServer {
|
|
|
2768
2786
|
this.log.warn(`Failed to update hub-auth.json: ${e}`);
|
|
2769
2787
|
}
|
|
2770
2788
|
} else {
|
|
2771
|
-
const
|
|
2772
|
-
if (
|
|
2789
|
+
const persistedConn = this.store.getClientHubConnection();
|
|
2790
|
+
if (persistedConn) {
|
|
2773
2791
|
this.store.setClientHubConnection({
|
|
2774
|
-
...
|
|
2792
|
+
...persistedConn,
|
|
2775
2793
|
username: result.username,
|
|
2776
2794
|
userToken: result.userToken,
|
|
2777
2795
|
});
|
|
@@ -2798,7 +2816,8 @@ export class ViewerServer {
|
|
|
2798
2816
|
const localIPs = this.getLocalIPs();
|
|
2799
2817
|
localIPs.push("127.0.0.1", "localhost", "0.0.0.0");
|
|
2800
2818
|
const parsed = new URL(hubUrl.startsWith("http") ? hubUrl : `http://${hubUrl}`);
|
|
2801
|
-
|
|
2819
|
+
const targetPort = parsed.port || (parsed.protocol === "https:" ? "443" : "80");
|
|
2820
|
+
if (localIPs.includes(parsed.hostname) && targetPort === String(this.port)) {
|
|
2802
2821
|
this.jsonResponse(res, { ok: false, error: "cannot_join_self" });
|
|
2803
2822
|
return;
|
|
2804
2823
|
}
|