@mem9/mem9 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.
- package/README.md +26 -17
- package/backend.ts +14 -0
- package/hooks.ts +78 -6
- package/index.test.ts +694 -0
- package/index.ts +391 -21
- package/openclaw.plugin.json +29 -0
- package/package.json +3 -1
- package/server-backend.test.ts +82 -0
- package/server-backend.ts +21 -4
- package/types.ts +5 -0
package/server-backend.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface BackendTimeouts {
|
|
|
22
22
|
searchTimeoutMs?: number;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
interface ServerBackendOptions {
|
|
26
|
+
timeouts?: BackendTimeouts;
|
|
27
|
+
provisionQueryParams?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
interface RequestOptions {
|
|
26
31
|
timeoutMs?: number;
|
|
27
32
|
}
|
|
@@ -30,25 +35,37 @@ export class ServerBackend implements MemoryBackend {
|
|
|
30
35
|
private baseUrl: string;
|
|
31
36
|
private apiKey: string;
|
|
32
37
|
private agentName: string;
|
|
38
|
+
private provisionQueryParams: Record<string, string>;
|
|
33
39
|
private timeouts: Required<BackendTimeouts>;
|
|
34
40
|
|
|
35
41
|
constructor(
|
|
36
42
|
apiUrl: string,
|
|
37
43
|
apiKey: string,
|
|
38
44
|
agentName: string,
|
|
39
|
-
|
|
45
|
+
options: ServerBackendOptions = {},
|
|
40
46
|
) {
|
|
41
47
|
this.baseUrl = apiUrl.replace(/\/+$/, "");
|
|
42
48
|
this.apiKey = apiKey;
|
|
43
49
|
this.agentName = agentName;
|
|
50
|
+
this.provisionQueryParams = options.provisionQueryParams ?? {};
|
|
44
51
|
this.timeouts = {
|
|
45
|
-
defaultTimeoutMs: timeouts
|
|
46
|
-
searchTimeoutMs: timeouts
|
|
52
|
+
defaultTimeoutMs: options.timeouts?.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
53
|
+
searchTimeoutMs: options.timeouts?.searchTimeoutMs ?? DEFAULT_SEARCH_TIMEOUT_MS,
|
|
47
54
|
};
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
async register(): Promise<ProvisionMem9sResponse> {
|
|
51
|
-
const
|
|
58
|
+
const query = new URLSearchParams();
|
|
59
|
+
for (const [key, value] of Object.entries(this.provisionQueryParams)) {
|
|
60
|
+
if (!key.startsWith("utm_") || typeof value !== "string" || value === "") {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
query.set(key, value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const qs = query.toString();
|
|
68
|
+
const resp = await fetch(this.baseUrl + "/v1alpha1/mem9s" + (qs ? `?${qs}` : ""), {
|
|
52
69
|
method: "POST",
|
|
53
70
|
signal: AbortSignal.timeout(this.timeouts.defaultTimeoutMs),
|
|
54
71
|
});
|
package/types.ts
CHANGED
|
@@ -2,9 +2,14 @@ export interface PluginConfig {
|
|
|
2
2
|
// Server mode (apiUrl present → server)
|
|
3
3
|
apiUrl?: string;
|
|
4
4
|
apiKey?: string;
|
|
5
|
+
provisionToken?: string;
|
|
6
|
+
provisionQueryParams?: Record<string, string>;
|
|
5
7
|
tenantID?: string;
|
|
6
8
|
defaultTimeoutMs?: number;
|
|
7
9
|
searchTimeoutMs?: number;
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
// Deprecated: use debug
|
|
12
|
+
debugRecall?: boolean;
|
|
8
13
|
|
|
9
14
|
tenantName?: string;
|
|
10
15
|
|