memorylake-openclaw 0.0.8 → 0.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorylake-openclaw",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "description": "MemoryLake memory backend for OpenClaw",
6
6
  "license": "MIT",
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync, existsSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { homedir } from "node:os";
6
+
7
+ // Parse --agent
8
+ const args = process.argv.slice(2);
9
+ const agentIdx = args.indexOf("--agent");
10
+ if (agentIdx === -1 || !args[agentIdx + 1]) {
11
+ console.error("Usage: node get-config.mjs --agent <agentId>");
12
+ process.exit(1);
13
+ }
14
+ const agentId = args[agentIdx + 1];
15
+
16
+ // Read global config
17
+ const openclawPath = join(homedir(), ".openclaw", "openclaw.json");
18
+ const openclaw = JSON.parse(readFileSync(openclawPath, "utf-8"));
19
+ const globalCfg = openclaw?.plugins?.entries?.["memorylake-openclaw"]?.config;
20
+ if (!globalCfg) {
21
+ console.error("Error: memorylake-openclaw plugin config not found");
22
+ process.exit(1);
23
+ }
24
+
25
+ // Resolve workspace
26
+ const agents = openclaw?.agents;
27
+ const agentEntry = agents?.list?.find((a) => a.id === agentId);
28
+ const workspace = agentEntry?.workspace || agents?.defaults?.workspace;
29
+ if (!workspace) {
30
+ console.error(`Error: no workspace found for agent "${agentId}"`);
31
+ process.exit(1);
32
+ }
33
+
34
+ // Merge per-agent overrides
35
+ const merged = { ...globalCfg };
36
+ const localPath = join(workspace, ".memorylake", "config.json");
37
+ if (existsSync(localPath)) {
38
+ const raw = JSON.parse(readFileSync(localPath, "utf-8"));
39
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
40
+ Object.assign(merged, raw);
41
+ }
42
+ }
43
+ merged.host = merged.host || "https://app.memorylake.ai";
44
+ merged.workspace = workspace;
45
+
46
+ // Validate required fields
47
+ if (!merged.apiKey || !merged.projectId) {
48
+ console.error("Error: apiKey and projectId are required");
49
+ process.exit(1);
50
+ }
51
+
52
+ console.log(JSON.stringify(merged, null, 2));
@@ -19,21 +19,15 @@ Directly call MemoryLake's REST APIs by discovering endpoints from the live Open
19
19
 
20
20
  ## Step 1 — Read MemoryLake Config
21
21
 
22
- Read `~/.openclaw/openclaw.json` and extract the plugin config:
22
+ Run the common config script (path is relative to **this skill's SKILL.md**, i.e. `../common/get-config.mjs`):
23
23
 
24
24
  ```bash
25
- cat ~/.openclaw/openclaw.json | jq '.plugins.entries["memorylake-openclaw"].config'
25
+ node {path-to-this-skill}/../common/get-config.mjs --agent {agent}
26
26
  ```
27
27
 
28
- Extract these values:
28
+ Where `{agent}` is the current agent ID. The script outputs JSON config with `host`, `apiKey`, `projectId`, etc.
29
29
 
30
- | Variable | Description | Default |
31
- |----------|-------------|---------|
32
- | `host` | API host | `https://app.memorylake.ai` |
33
- | `apiKey` | API key for authentication | (required) |
34
- | `projectId` | MemoryLake project ID | (required) |
35
-
36
- If `apiKey` or `projectId` is missing, stop and inform the user.
30
+ If the script exits with an error, stop and inform the user.
37
31
 
38
32
  Auth header for all requests:
39
33
 
@@ -185,15 +179,14 @@ All responses follow the same wrapper format:
185
179
 
186
180
  - **Wrong base URL**: The full URL must include `/openapi/memorylake` before the API path. E.g., `/openapi/memorylake/api/v1/projects`, NOT just `/api/v1/projects`
187
181
  - **Missing auth header**: Every request requires `Authorization: Bearer {apiKey}`
188
- - **Hardcoded project ID**: Always read `projectId` from `~/.openclaw/openclaw.json` config, not from user input (unless the user explicitly wants a different project)
182
+ - **Hardcoded project ID**: Always read `projectId` from the config script output, not from user input (unless the user explicitly wants a different project)
189
183
  - **Pagination**: List endpoints default to `page=1, size=20`. Pass `page` and `size` query params if the user needs more results
190
184
 
191
185
  ## Quick Reference
192
186
 
193
187
  | Item | Value |
194
188
  |------|-------|
195
- | OpenClaw config | `~/.openclaw/openclaw.json` |
196
- | Plugin config key | `plugins.entries["memorylake-openclaw"].config` |
189
+ | Config script | `{path-to-this-skill}/../common/get-config.mjs --agent {agent}` |
197
190
  | Server base path | `/openapi/memorylake` |
198
191
  | OpenAPI spec URL | `{host}/openapi/memorylake/api-docs/open-api` |
199
192
  | Auth header | `Authorization: Bearer {apiKey}` |
@@ -16,21 +16,15 @@ Upload local files to MemoryLake using the multipart upload API, then associate
16
16
 
17
17
  ## Step 1 -- Read MemoryLake Config
18
18
 
19
- Read `~/.openclaw/openclaw.json` and extract the plugin config:
19
+ Run the common config script (path is relative to **this skill's SKILL.md**, i.e. `../common/get-config.mjs`):
20
20
 
21
21
  ```bash
22
- cat ~/.openclaw/openclaw.json | jq '.plugins.entries["memorylake-openclaw"].config'
22
+ node {path-to-this-skill}/../common/get-config.mjs --agent {agent}
23
23
  ```
24
24
 
25
- Extract these values:
25
+ Where `{agent}` is the current agent ID. The script outputs JSON config with `host`, `apiKey`, `projectId`, etc.
26
26
 
27
- | Variable | Description | Default |
28
- |----------|-------------|---------|
29
- | `host` | API host | `https://app.memorylake.ai` |
30
- | `apiKey` | API key for authentication | (required) |
31
- | `projectId` | MemoryLake project ID | (required) |
32
-
33
- If `apiKey` or `projectId` is missing, stop and inform the user.
27
+ If the script exits with an error, stop and inform the user.
34
28
 
35
29
  ## Step 2 -- Run the Upload Script
36
30
 
@@ -56,5 +50,5 @@ The script prints progress for each step (create upload, upload parts, complete,
56
50
 
57
51
  ## Common Mistakes
58
52
 
59
- - **Skipping Step 1**: Directly hardcoding host/apiKey/projectId instead of reading from `~/.openclaw/openclaw.json`
53
+ - **Skipping Step 1**: Directly hardcoding host/apiKey/projectId instead of using the config script
60
54
  - **Relative file paths**: Always resolve the user's file path to an absolute path before passing to the script
@@ -17,8 +17,8 @@ Extract memory files and conversation history from session files, then submit th
17
17
  ## Prerequisites
18
18
 
19
19
  The caller must provide:
20
+ - **`agent`**: The agent name (e.g., `main`). Used to resolve config (Step 1) and locate session files (Step 2).
20
21
  - **`user_id`**: The user ID for filtering sessions (e.g., a Feishu user ID like `ou_xxx`). **This is only used for session filtering, NOT for the API request.**
21
- - **`agent`**: The agent name (e.g., `main`)
22
22
 
23
23
  ## Preferred: Run the Migration Script
24
24
 
@@ -40,26 +40,15 @@ If the script fails, follow these steps manually.
40
40
 
41
41
  ### Step 1 — Read MemoryLake Config
42
42
 
43
- Read `~/.openclaw/openclaw.json` and extract the plugin config:
43
+ Run the common config script (path is relative to **this skill's SKILL.md**, i.e. `../common/get-config.mjs`):
44
44
 
45
45
  ```bash
46
- cat ~/.openclaw/openclaw.json | jq '.plugins.entries["memorylake-openclaw"].config'
46
+ node {path-to-this-skill}/../common/get-config.mjs --agent {agent}
47
47
  ```
48
48
 
49
- Extract these values:
50
- - **`host`** — API host (default: `https://app.memorylake.ai`)
51
- - **`apiKey`** — API key for authentication
52
- - **`projectId`** — MemoryLake project ID
49
+ The script outputs JSON config with `host`, `apiKey`, `projectId`, `workspace`, etc. If the script exits with an error, stop and inform the user.
53
50
 
54
- ### Step 2 — Identify User and Agent
55
-
56
- Use the `user_id` and `agent` provided by the caller:
57
- - `user_id` — only for filtering sessions in Step 3 (session keys contain the user ID)
58
- - `agent` — determines which agent's session directory to read
59
-
60
- **When POSTing to the API, always use `"user_id": "default"`. Do NOT use the caller-provided `user_id`.**
61
-
62
- ### Step 3 — Filter Sessions by User ID
51
+ ### Step 2 — Filter Sessions by User ID
63
52
 
64
53
  **You MUST use `sessions.json` to filter sessions. Do NOT grep/search JSONL files directly.**
65
54
 
@@ -83,29 +72,21 @@ Use the `user_id` and `agent` provided by the caller:
83
72
  ~/.openclaw/agents/{agent}/sessions/{sessionId}.jsonl
84
73
  ```
85
74
 
86
- ### Step 4 — Read Memory Files
87
-
88
- Resolve the workspace path for the agent:
89
-
90
- 1. Check `agents.list` for an entry with `id` matching the agent. If it has a `workspace` field, use it.
91
- 2. Otherwise, fall back to `agents.defaults.workspace`.
75
+ ### Step 3 — Read Memory Files
92
76
 
93
- ```bash
94
- # Agent-specific workspace (e.g., agent "foo"):
95
- cat ~/.openclaw/openclaw.json | jq -r '.agents.list[] | select(.id == "{agent}") | .workspace'
96
- # Default workspace:
97
- cat ~/.openclaw/openclaw.json | jq -r '.agents.defaults.workspace'
98
- ```
99
-
100
- Then read:
77
+ Use the `workspace` path from the config output in Step 1. Then read:
101
78
  - `{workspace}/MEMORY.md`
102
79
  - All files in `{workspace}/memory/` directory
103
80
 
104
81
  These contain curated memory that should also be migrated.
105
82
 
106
- ### Step 5 — Submit Data to MemoryLake
83
+ ### Step 4 — Submit Data to MemoryLake
84
+
85
+ Use `host`, `apiKey`, `projectId` from the config output in Step 1.
86
+
87
+ **When POSTing to the API, always use `"user_id": "default"`. Do NOT use the caller-provided `user_id`.**
107
88
 
108
- #### 5a — Submit Session Conversations
89
+ #### 4a — Submit Session Conversations
109
90
 
110
91
  For each matched `.jsonl` session file:
111
92
 
@@ -156,7 +137,7 @@ For each matched `.jsonl` session file:
156
137
  }
157
138
  }
158
139
  ```
159
- #### 5b — Submit Memory Files
140
+ #### 4b — Submit Memory Files
160
141
 
161
142
  For each memory file (`MEMORY.md` and files in `memory/`):
162
143
 
@@ -203,11 +184,10 @@ At the end, print a summary:
203
184
 
204
185
  | Item | Path / Value |
205
186
  |------|-------------|
206
- | Config file | `~/.openclaw/openclaw.json` |
207
- | Plugin config key | `plugins.entries["memorylake-openclaw"].config` |
187
+ | Config script | `{path-to-this-skill}/../common/get-config.mjs --agent {agent}` |
208
188
  | Session index | `~/.openclaw/agents/{agent}/sessions/sessions.json` |
209
189
  | Session files | `~/.openclaw/agents/{agent}/sessions/{id}.jsonl` |
210
- | Workspace path | `agents.defaults.workspace` in config |
190
+ | Workspace path | from config script output (`workspace` field) |
211
191
  | API endpoint | `{host}/openapi/memorylake/api/v2/projects/{projectId}/memories` |
212
192
  | Auth header | `Authorization: Bearer {apiKey}` |
213
193
  | Default host | `https://app.memorylake.ai` |