@memtensor/memos-local-openclaw-plugin 1.0.4-beta.4 → 1.0.4-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.
- package/README.md +22 -39
- package/dist/capture/index.d.ts.map +1 -1
- package/dist/capture/index.js +6 -0
- package/dist/capture/index.js.map +1 -1
- package/dist/config.d.ts +1 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -72
- package/dist/config.js.map +1 -1
- package/dist/embedding/index.d.ts +2 -4
- package/dist/embedding/index.d.ts.map +1 -1
- package/dist/embedding/index.js +1 -17
- package/dist/embedding/index.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/ingest/providers/index.d.ts +2 -10
- package/dist/ingest/providers/index.d.ts.map +1 -1
- package/dist/ingest/providers/index.js +43 -209
- package/dist/ingest/providers/index.js.map +1 -1
- package/dist/ingest/providers/openai.d.ts +0 -1
- package/dist/ingest/providers/openai.d.ts.map +1 -1
- package/dist/ingest/providers/openai.js +0 -1
- package/dist/ingest/providers/openai.js.map +1 -1
- package/dist/ingest/task-processor.js +1 -1
- package/dist/ingest/task-processor.js.map +1 -1
- package/dist/recall/engine.js +1 -1
- package/dist/recall/engine.js.map +1 -1
- package/dist/shared/llm-call.d.ts +2 -4
- package/dist/shared/llm-call.d.ts.map +1 -1
- package/dist/shared/llm-call.js +81 -20
- package/dist/shared/llm-call.js.map +1 -1
- package/dist/skill/evaluator.d.ts.map +1 -1
- package/dist/skill/evaluator.js +2 -2
- package/dist/skill/evaluator.js.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 +3 -0
- package/dist/skill/evolver.js.map +1 -1
- package/dist/skill/generator.d.ts.map +1 -1
- package/dist/skill/generator.js +4 -4
- package/dist/skill/generator.js.map +1 -1
- package/dist/skill/upgrader.js +1 -1
- package/dist/skill/upgrader.js.map +1 -1
- package/dist/skill/validator.js +1 -1
- package/dist/skill/validator.js.map +1 -1
- package/dist/storage/ensure-binding.d.ts.map +1 -1
- package/dist/storage/ensure-binding.js +1 -3
- package/dist/storage/ensure-binding.js.map +1 -1
- package/dist/storage/sqlite.d.ts +0 -294
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +0 -821
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/telemetry.d.ts +12 -5
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +135 -38
- package/dist/telemetry.js.map +1 -1
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/memory-search.d.ts +2 -3
- package/dist/tools/memory-search.d.ts.map +1 -1
- package/dist/tools/memory-search.js +7 -48
- package/dist/tools/memory-search.js.map +1 -1
- package/dist/types.d.ts +2 -49
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/viewer/html.d.ts.map +1 -1
- package/dist/viewer/html.js +471 -2974
- package/dist/viewer/html.js.map +1 -1
- package/dist/viewer/server.d.ts +0 -45
- package/dist/viewer/server.d.ts.map +1 -1
- package/dist/viewer/server.js +18 -1155
- package/dist/viewer/server.js.map +1 -1
- package/index.ts +42 -430
- package/openclaw.plugin.json +1 -2
- package/package.json +3 -4
- package/scripts/postinstall.cjs +46 -283
- package/skill/memos-memory-guide/SKILL.md +2 -26
- package/src/capture/index.ts +8 -0
- package/src/config.ts +3 -94
- package/src/embedding/index.ts +1 -21
- package/src/index.ts +4 -7
- package/src/ingest/providers/index.ts +46 -246
- package/src/ingest/providers/openai.ts +1 -1
- package/src/ingest/task-processor.ts +1 -1
- package/src/recall/engine.ts +1 -1
- package/src/shared/llm-call.ts +95 -23
- package/src/skill/evaluator.ts +2 -3
- package/src/skill/evolver.ts +5 -0
- package/src/skill/generator.ts +4 -6
- package/src/skill/upgrader.ts +1 -1
- package/src/skill/validator.ts +1 -1
- package/src/storage/ensure-binding.ts +1 -3
- package/src/storage/sqlite.ts +0 -1085
- package/src/telemetry.ts +152 -39
- package/src/tools/index.ts +0 -1
- package/src/tools/memory-search.ts +8 -57
- package/src/types.ts +2 -44
- package/src/viewer/html.ts +471 -2974
- package/src/viewer/server.ts +21 -1070
- package/dist/client/connector.d.ts +0 -30
- package/dist/client/connector.d.ts.map +0 -1
- package/dist/client/connector.js +0 -219
- package/dist/client/connector.js.map +0 -1
- package/dist/client/hub.d.ts +0 -61
- package/dist/client/hub.d.ts.map +0 -1
- package/dist/client/hub.js +0 -148
- package/dist/client/hub.js.map +0 -1
- package/dist/client/skill-sync.d.ts +0 -29
- package/dist/client/skill-sync.d.ts.map +0 -1
- package/dist/client/skill-sync.js +0 -216
- package/dist/client/skill-sync.js.map +0 -1
- package/dist/hub/auth.d.ts +0 -19
- package/dist/hub/auth.d.ts.map +0 -1
- package/dist/hub/auth.js +0 -70
- package/dist/hub/auth.js.map +0 -1
- package/dist/hub/server.d.ts +0 -41
- package/dist/hub/server.d.ts.map +0 -1
- package/dist/hub/server.js +0 -747
- package/dist/hub/server.js.map +0 -1
- package/dist/hub/user-manager.d.ts +0 -29
- package/dist/hub/user-manager.d.ts.map +0 -1
- package/dist/hub/user-manager.js +0 -125
- package/dist/hub/user-manager.js.map +0 -1
- package/dist/openclaw-api.d.ts +0 -53
- package/dist/openclaw-api.d.ts.map +0 -1
- package/dist/openclaw-api.js +0 -189
- package/dist/openclaw-api.js.map +0 -1
- package/dist/sharing/types.contract.d.ts +0 -2
- package/dist/sharing/types.contract.d.ts.map +0 -1
- package/dist/sharing/types.contract.js +0 -3
- package/dist/sharing/types.contract.js.map +0 -1
- package/dist/sharing/types.d.ts +0 -80
- package/dist/sharing/types.d.ts.map +0 -1
- package/dist/sharing/types.js +0 -3
- package/dist/sharing/types.js.map +0 -1
- package/dist/tools/network-memory-detail.d.ts +0 -4
- package/dist/tools/network-memory-detail.d.ts.map +0 -1
- package/dist/tools/network-memory-detail.js +0 -34
- package/dist/tools/network-memory-detail.js.map +0 -1
- package/src/client/connector.ts +0 -218
- package/src/client/hub.ts +0 -189
- package/src/client/skill-sync.ts +0 -202
- package/src/hub/auth.ts +0 -78
- package/src/hub/server.ts +0 -740
- package/src/hub/user-manager.ts +0 -139
- package/src/openclaw-api.ts +0 -287
- package/src/sharing/types.contract.ts +0 -40
- package/src/sharing/types.ts +0 -102
- package/src/tools/network-memory-detail.ts +0 -34
package/src/telemetry.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Telemetry module — anonymous usage analytics via
|
|
2
|
+
* Telemetry module — anonymous usage analytics via Aliyun ARMS RUM.
|
|
3
3
|
*
|
|
4
4
|
* Privacy-first design:
|
|
5
5
|
* - Enabled by default with anonymous data only; opt-out via TELEMETRY_ENABLED=false
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* - Only sends aggregate counts, tool names, latencies, and version info
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { PostHog } from "posthog-node";
|
|
12
11
|
import * as fs from "fs";
|
|
13
12
|
import * as path from "path";
|
|
14
13
|
import * as os from "os";
|
|
@@ -17,45 +16,61 @@ import type { Logger } from "./types";
|
|
|
17
16
|
|
|
18
17
|
export interface TelemetryConfig {
|
|
19
18
|
enabled?: boolean;
|
|
20
|
-
posthogApiKey?: string;
|
|
21
|
-
posthogHost?: string;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
const
|
|
25
|
-
|
|
21
|
+
const ARMS_ENDPOINT =
|
|
22
|
+
"https://proj-xtrace-e218d9316b328f196a3c640cc7ca84-cn-hangzhou.cn-hangzhou.log.aliyuncs.com" +
|
|
23
|
+
"/rum/web/v2" +
|
|
24
|
+
"?workspace=default-cms-1026429231103299-cn-hangzhou" +
|
|
25
|
+
"&service_id=a3u72ukxmr@066657d42a13a9a9f337f";
|
|
26
|
+
|
|
27
|
+
const ARMS_PID = "a3u72ukxmr@066657d42a13a9a9f337f";
|
|
28
|
+
const ARMS_ENV = "prod";
|
|
29
|
+
|
|
30
|
+
const FLUSH_AT = 10;
|
|
31
|
+
const FLUSH_INTERVAL_MS = 30_000;
|
|
32
|
+
const SEND_TIMEOUT_MS = 30_000;
|
|
33
|
+
const SESSION_TTL_MS = 30 * 60_000; // 30 min inactivity → new session
|
|
34
|
+
interface ArmsEvent {
|
|
35
|
+
event_type: "custom";
|
|
36
|
+
type: string;
|
|
37
|
+
name: string;
|
|
38
|
+
group: string;
|
|
39
|
+
value: number;
|
|
40
|
+
properties: Record<string, string | number | boolean>;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
event_id: string;
|
|
43
|
+
times: number;
|
|
44
|
+
}
|
|
26
45
|
|
|
27
46
|
export class Telemetry {
|
|
28
|
-
private client: PostHog | null = null;
|
|
29
47
|
private distinctId: string;
|
|
30
48
|
private enabled: boolean;
|
|
31
49
|
private pluginVersion: string;
|
|
32
50
|
private log: Logger;
|
|
33
51
|
private dailyPingSent = false;
|
|
34
52
|
private dailyPingDate = "";
|
|
53
|
+
private buffer: ArmsEvent[] = [];
|
|
54
|
+
private flushTimer: ReturnType<typeof setInterval> | null = null;
|
|
55
|
+
private sessionId: string;
|
|
56
|
+
private firstSeenDate: string;
|
|
35
57
|
|
|
36
58
|
constructor(config: TelemetryConfig, stateDir: string, pluginVersion: string, log: Logger) {
|
|
37
59
|
this.log = log;
|
|
38
60
|
this.pluginVersion = pluginVersion;
|
|
39
61
|
this.enabled = config.enabled !== false;
|
|
40
62
|
this.distinctId = this.loadOrCreateAnonymousId(stateDir);
|
|
63
|
+
this.firstSeenDate = this.loadOrCreateFirstSeen(stateDir);
|
|
64
|
+
this.sessionId = this.loadOrCreateSessionId(stateDir);
|
|
41
65
|
|
|
42
66
|
if (!this.enabled) {
|
|
43
67
|
this.log.debug("Telemetry disabled (opt-out via TELEMETRY_ENABLED=false)");
|
|
44
68
|
return;
|
|
45
69
|
}
|
|
46
70
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
host: config.posthogHost || DEFAULT_POSTHOG_HOST,
|
|
51
|
-
flushAt: 10,
|
|
52
|
-
flushInterval: 30_000,
|
|
53
|
-
});
|
|
54
|
-
this.log.debug("Telemetry initialized (PostHog)");
|
|
55
|
-
} catch (err) {
|
|
56
|
-
this.log.warn(`Telemetry init failed: ${err}`);
|
|
57
|
-
this.enabled = false;
|
|
58
|
-
}
|
|
71
|
+
this.flushTimer = setInterval(() => this.flush(), FLUSH_INTERVAL_MS);
|
|
72
|
+
if (this.flushTimer.unref) this.flushTimer.unref();
|
|
73
|
+
this.log.debug("Telemetry initialized (ARMS)");
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
private loadOrCreateAnonymousId(stateDir: string): string {
|
|
@@ -81,24 +96,113 @@ export class Telemetry {
|
|
|
81
96
|
return newId;
|
|
82
97
|
}
|
|
83
98
|
|
|
99
|
+
private loadOrCreateSessionId(stateDir: string): string {
|
|
100
|
+
const filePath = path.join(stateDir, "memos-local", ".session");
|
|
101
|
+
try {
|
|
102
|
+
const raw = fs.readFileSync(filePath, "utf-8").trim();
|
|
103
|
+
const sep = raw.indexOf("|");
|
|
104
|
+
if (sep > 0) {
|
|
105
|
+
const ts = parseInt(raw.slice(0, sep), 10);
|
|
106
|
+
const id = raw.slice(sep + 1);
|
|
107
|
+
if (id.length > 10 && Date.now() - ts < SESSION_TTL_MS) {
|
|
108
|
+
this.touchSession(filePath, id);
|
|
109
|
+
return id;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch {}
|
|
113
|
+
const newId = uuidv4();
|
|
114
|
+
this.touchSession(filePath, newId);
|
|
115
|
+
return newId;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private touchSession(filePath: string, id: string): void {
|
|
119
|
+
try {
|
|
120
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
121
|
+
fs.writeFileSync(filePath, `${Date.now()}|${id}`, "utf-8");
|
|
122
|
+
} catch {}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private loadOrCreateFirstSeen(stateDir: string): string {
|
|
126
|
+
const filePath = path.join(stateDir, "memos-local", ".first-seen");
|
|
127
|
+
try {
|
|
128
|
+
const existing = fs.readFileSync(filePath, "utf-8").trim();
|
|
129
|
+
if (existing.length === 10) return existing;
|
|
130
|
+
} catch {}
|
|
131
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
132
|
+
try {
|
|
133
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
134
|
+
fs.writeFileSync(filePath, today, "utf-8");
|
|
135
|
+
} catch {}
|
|
136
|
+
return today;
|
|
137
|
+
}
|
|
138
|
+
|
|
84
139
|
private capture(event: string, properties?: Record<string, unknown>): void {
|
|
85
|
-
if (!this.enabled
|
|
140
|
+
if (!this.enabled) return;
|
|
141
|
+
|
|
142
|
+
const safeProps: Record<string, string | number | boolean> = {
|
|
143
|
+
plugin_version: this.pluginVersion,
|
|
144
|
+
os: os.platform(),
|
|
145
|
+
os_version: os.release(),
|
|
146
|
+
node_version: process.version,
|
|
147
|
+
arch: os.arch(),
|
|
148
|
+
};
|
|
149
|
+
if (properties) {
|
|
150
|
+
for (const [k, v] of Object.entries(properties)) {
|
|
151
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
152
|
+
safeProps[k] = v;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this.buffer.push({
|
|
158
|
+
event_type: "custom",
|
|
159
|
+
type: "memos_plugin",
|
|
160
|
+
name: event,
|
|
161
|
+
group: "memos_local",
|
|
162
|
+
value: 1,
|
|
163
|
+
properties: safeProps,
|
|
164
|
+
timestamp: Date.now(),
|
|
165
|
+
event_id: uuidv4(),
|
|
166
|
+
times: 1,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (this.buffer.length >= FLUSH_AT) {
|
|
170
|
+
this.flush();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private buildPayload(events: ArmsEvent[]): Record<string, unknown> {
|
|
175
|
+
return {
|
|
176
|
+
app: {
|
|
177
|
+
id: ARMS_PID,
|
|
178
|
+
env: ARMS_ENV,
|
|
179
|
+
version: this.pluginVersion,
|
|
180
|
+
type: "node",
|
|
181
|
+
},
|
|
182
|
+
user: { id: this.distinctId },
|
|
183
|
+
session: { id: this.sessionId },
|
|
184
|
+
net: {},
|
|
185
|
+
view: { id: "plugin", name: "memos-local-openclaw" },
|
|
186
|
+
events,
|
|
187
|
+
_v: "1.0.0",
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private async flush(): Promise<void> {
|
|
192
|
+
if (this.buffer.length === 0) return;
|
|
193
|
+
const batch = this.buffer.splice(0);
|
|
194
|
+
const payload = this.buildPayload(batch);
|
|
86
195
|
|
|
87
196
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
os: os.platform(),
|
|
94
|
-
os_version: os.release(),
|
|
95
|
-
node_version: process.version,
|
|
96
|
-
arch: os.arch(),
|
|
97
|
-
...properties,
|
|
98
|
-
},
|
|
197
|
+
const resp = await fetch(ARMS_ENDPOINT, {
|
|
198
|
+
method: "POST",
|
|
199
|
+
headers: { "Content-Type": "text/plain" },
|
|
200
|
+
body: JSON.stringify(payload),
|
|
201
|
+
signal: AbortSignal.timeout(SEND_TIMEOUT_MS),
|
|
99
202
|
});
|
|
100
|
-
|
|
101
|
-
|
|
203
|
+
this.log.debug(`Telemetry flush: ${batch.length} events → ${resp.status}`);
|
|
204
|
+
} catch (err) {
|
|
205
|
+
this.log.debug(`Telemetry flush failed: ${err}`);
|
|
102
206
|
}
|
|
103
207
|
}
|
|
104
208
|
|
|
@@ -131,7 +235,7 @@ export class Telemetry {
|
|
|
131
235
|
});
|
|
132
236
|
}
|
|
133
237
|
|
|
134
|
-
trackSkillEvolved(skillName: string, upgradeType:
|
|
238
|
+
trackSkillEvolved(skillName: string, upgradeType: "created" | "upgraded"): void {
|
|
135
239
|
this.capture("skill_evolved", {
|
|
136
240
|
skill_name: skillName,
|
|
137
241
|
upgrade_type: upgradeType,
|
|
@@ -150,19 +254,28 @@ export class Telemetry {
|
|
|
150
254
|
});
|
|
151
255
|
}
|
|
152
256
|
|
|
257
|
+
trackError(source: string, errorType: string): void {
|
|
258
|
+
this.capture("plugin_error", {
|
|
259
|
+
error_source: source,
|
|
260
|
+
error_type: errorType,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
153
264
|
private maybeSendDailyPing(): void {
|
|
154
265
|
const today = new Date().toISOString().slice(0, 10);
|
|
155
266
|
if (this.dailyPingSent && this.dailyPingDate === today) return;
|
|
156
267
|
this.dailyPingSent = true;
|
|
157
268
|
this.dailyPingDate = today;
|
|
158
|
-
this.capture("daily_active"
|
|
269
|
+
this.capture("daily_active", {
|
|
270
|
+
first_seen_date: this.firstSeenDate,
|
|
271
|
+
});
|
|
159
272
|
}
|
|
160
273
|
|
|
161
274
|
async shutdown(): Promise<void> {
|
|
162
|
-
if (this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
} catch {}
|
|
275
|
+
if (this.flushTimer) {
|
|
276
|
+
clearInterval(this.flushTimer);
|
|
277
|
+
this.flushTimer = null;
|
|
166
278
|
}
|
|
279
|
+
await this.flush();
|
|
167
280
|
}
|
|
168
281
|
}
|
package/src/tools/index.ts
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import { hubSearchMemories } from "../client/hub";
|
|
2
|
-
import type { HubScope, HubSearchResult } from "../sharing/types";
|
|
3
1
|
import type { RecallEngine } from "../recall/engine";
|
|
4
|
-
import type {
|
|
5
|
-
import type { SqliteStore } from "../storage/sqlite";
|
|
2
|
+
import type { ToolDefinition } from "../types";
|
|
6
3
|
|
|
7
4
|
function resolveOwnerFilter(owner: unknown): string[] {
|
|
8
5
|
const resolvedOwner = typeof owner === "string" && owner.trim().length > 0 ? owner : "agent:main";
|
|
9
6
|
return resolvedOwner === "public" ? ["public"] : [resolvedOwner, "public"];
|
|
10
7
|
}
|
|
11
8
|
|
|
12
|
-
function
|
|
13
|
-
return scope === "group" || scope === "all" ? scope : "local";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function emptyHubResult(scope: HubScope): HubSearchResult {
|
|
17
|
-
return {
|
|
18
|
-
hits: [],
|
|
19
|
-
meta: {
|
|
20
|
-
totalCandidates: 0,
|
|
21
|
-
searchedGroups: [],
|
|
22
|
-
includedPublic: scope === "all",
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function createMemorySearchTool(engine: RecallEngine, store?: SqliteStore, ctx?: PluginContext): ToolDefinition {
|
|
9
|
+
export function createMemorySearchTool(engine: RecallEngine): ToolDefinition {
|
|
28
10
|
return {
|
|
29
11
|
name: "memory_search",
|
|
30
12
|
description:
|
|
@@ -45,47 +27,16 @@ export function createMemorySearchTool(engine: RecallEngine, store?: SqliteStore
|
|
|
45
27
|
type: "number",
|
|
46
28
|
description: "Minimum relevance score threshold 0-1 (default 0.45, floor 0.35).",
|
|
47
29
|
},
|
|
48
|
-
scope: {
|
|
49
|
-
type: "string",
|
|
50
|
-
description: "Search scope: local (default), group, or all. Group/all return split local and hub sections.",
|
|
51
|
-
},
|
|
52
|
-
hubAddress: {
|
|
53
|
-
type: "string",
|
|
54
|
-
description: "Optional hub address override for group/all search, integration tests, or manual routing.",
|
|
55
|
-
},
|
|
56
|
-
userToken: {
|
|
57
|
-
type: "string",
|
|
58
|
-
description: "Optional hub bearer token override for group/all search or integration tests.",
|
|
59
|
-
},
|
|
60
30
|
},
|
|
61
31
|
},
|
|
62
32
|
handler: async (input) => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const localSearch = engine.search({
|
|
70
|
-
query,
|
|
71
|
-
maxResults,
|
|
72
|
-
minScore,
|
|
73
|
-
ownerFilter,
|
|
33
|
+
const result = await engine.search({
|
|
34
|
+
query: (input.query as string) ?? "",
|
|
35
|
+
maxResults: input.maxResults as number | undefined,
|
|
36
|
+
minScore: input.minScore as number | undefined,
|
|
37
|
+
ownerFilter: resolveOwnerFilter(input.owner),
|
|
74
38
|
});
|
|
75
|
-
|
|
76
|
-
if (scope === "local" || !store || !ctx) {
|
|
77
|
-
return localSearch;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const [local, hub] = await Promise.all([
|
|
81
|
-
localSearch,
|
|
82
|
-
hubSearchMemories(store, ctx, { query, maxResults, scope, hubAddress: input.hubAddress as string | undefined, userToken: input.userToken as string | undefined }).catch((err) => {
|
|
83
|
-
ctx.log.warn(`Hub search failed, using local-only results: ${err}`);
|
|
84
|
-
return emptyHubResult(scope);
|
|
85
|
-
}),
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
return { local, hub };
|
|
39
|
+
return result;
|
|
89
40
|
},
|
|
90
41
|
};
|
|
91
42
|
}
|
package/src/types.ts
CHANGED
|
@@ -150,8 +150,7 @@ export type SummaryProvider =
|
|
|
150
150
|
| "bailian"
|
|
151
151
|
| "cohere"
|
|
152
152
|
| "mistral"
|
|
153
|
-
| "voyage"
|
|
154
|
-
| "openclaw";
|
|
153
|
+
| "voyage";
|
|
155
154
|
|
|
156
155
|
export type EmbeddingProvider =
|
|
157
156
|
| "openai"
|
|
@@ -161,8 +160,7 @@ export type EmbeddingProvider =
|
|
|
161
160
|
| "cohere"
|
|
162
161
|
| "mistral"
|
|
163
162
|
| "voyage"
|
|
164
|
-
| "local"
|
|
165
|
-
| "openclaw";
|
|
163
|
+
| "local";
|
|
166
164
|
|
|
167
165
|
export interface ProviderConfig {
|
|
168
166
|
provider: string;
|
|
@@ -172,7 +170,6 @@ export interface ProviderConfig {
|
|
|
172
170
|
headers?: Record<string, string>;
|
|
173
171
|
timeoutMs?: number;
|
|
174
172
|
temperature?: number;
|
|
175
|
-
capabilities?: SharingCapabilities;
|
|
176
173
|
}
|
|
177
174
|
|
|
178
175
|
export interface SummarizerConfig extends ProviderConfig {
|
|
@@ -249,43 +246,11 @@ export interface SkillEvolutionConfig {
|
|
|
249
246
|
minConfidence?: number;
|
|
250
247
|
maxSkillLines?: number;
|
|
251
248
|
autoInstall?: boolean;
|
|
252
|
-
/** Optional independent LLM config for skill evaluation/validation. Falls back to main summarizer if not set. */
|
|
253
249
|
summarizer?: SummarizerConfig;
|
|
254
250
|
}
|
|
255
251
|
|
|
256
252
|
export interface TelemetryConfig {
|
|
257
253
|
enabled?: boolean;
|
|
258
|
-
posthogApiKey?: string;
|
|
259
|
-
posthogHost?: string;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export type SharingRole = "hub" | "client";
|
|
263
|
-
|
|
264
|
-
export interface SharingCapabilities {
|
|
265
|
-
hostEmbedding?: boolean;
|
|
266
|
-
hostCompletion?: boolean;
|
|
267
|
-
hostSkill?: boolean;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export interface HubModeConfig {
|
|
271
|
-
port?: number;
|
|
272
|
-
teamName?: string;
|
|
273
|
-
teamToken?: string;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export interface ClientModeConfig {
|
|
277
|
-
hubAddress?: string;
|
|
278
|
-
userToken?: string;
|
|
279
|
-
teamToken?: string;
|
|
280
|
-
pendingUserId?: string;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export interface SharingConfig {
|
|
284
|
-
enabled?: boolean;
|
|
285
|
-
role?: SharingRole;
|
|
286
|
-
hub?: HubModeConfig;
|
|
287
|
-
client?: ClientModeConfig;
|
|
288
|
-
capabilities?: SharingCapabilities;
|
|
289
254
|
}
|
|
290
255
|
|
|
291
256
|
export interface MemosLocalConfig {
|
|
@@ -313,7 +278,6 @@ export interface MemosLocalConfig {
|
|
|
313
278
|
};
|
|
314
279
|
skillEvolution?: SkillEvolutionConfig;
|
|
315
280
|
telemetry?: TelemetryConfig;
|
|
316
|
-
sharing?: SharingConfig;
|
|
317
281
|
}
|
|
318
282
|
|
|
319
283
|
// ─── Defaults ───
|
|
@@ -354,12 +318,6 @@ export interface PluginContext {
|
|
|
354
318
|
workspaceDir: string;
|
|
355
319
|
config: MemosLocalConfig;
|
|
356
320
|
log: Logger;
|
|
357
|
-
openclawAPI?: OpenClawAPI;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export interface OpenClawAPI {
|
|
361
|
-
embed(request: { texts: string[]; model?: string }): Promise<{ embeddings: number[][]; dimensions: number }>;
|
|
362
|
-
complete(request: { prompt: string; maxTokens?: number; temperature?: number; model?: string }): Promise<{ text: string }>;
|
|
363
321
|
}
|
|
364
322
|
|
|
365
323
|
export interface Logger {
|