@openviking/openclaw-plugin 2026.5.8 → 2026.5.21

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.
@@ -1,665 +1,665 @@
1
- ---
2
- name: install-openviking-memory
3
- description: >
4
- Install and configure the OpenViking long-term memory plugin for OpenClaw via natural conversation.
5
- Once installed, the plugin automatically captures important facts from chats and recalls relevant
6
- context before each reply (auto-capture + auto-recall, cross-session). Covers prerequisites check,
7
- plugin install through OpenClaw's plugin manager first, with ov-install only as a backup path,
8
- wizard-based configuration, slot activation,
9
- gateway restart, verification, plus multi-tenant root-key support, multi-instance, and uninstall.
10
- Trigger when the user says any of: "install OpenViking", "set up memory", "configure memory plugin",
11
- "add long-term memory", "connect to OpenViking server", "RAG", "semantic memory",
12
- "帮我装 OpenViking", "配置记忆插件", "安装记忆功能", "接入 OpenViking", "我有一台 OpenViking 服务器".
13
- The user does NOT need to know any CLI commands — the agent runs everything and only asks for a few values.
14
- This skill assumes the OpenViking server is already running. If the server is not ready, the skill
15
- tells the user to contact their admin or set it up via the OpenViking docs — it does NOT install the server.
16
- version: 2.0.0
17
- metadata:
18
- openclaw:
19
- requires:
20
- bins:
21
- - node
22
- - openclaw
23
- emoji: "🦣"
24
- homepage: "https://github.com/volcengine/OpenViking"
25
- tags:
26
- - install
27
- - setup
28
- - memory
29
- - openviking
30
- - rag
31
- - long-term-memory
32
- ---
33
-
34
- # Install OpenViking Memory — Agent Installation & Reference Skill
35
-
36
- You are about to help a user install and configure the OpenViking memory plugin for OpenClaw.
37
- The user does NOT know how to use a terminal. You will collect a few values through natural conversation, then run **all** commands yourself using your shell tool.
38
-
39
- **Read this entire document before starting. Follow every step in order. Do NOT skip steps.**
40
-
41
- This skill is split into two halves:
42
-
43
- - **Part 1 (STEP 0–10): Natural-language installation walkthrough.** Use this on first install or reconfigure.
44
- - **Part 2: Reference.** Tools, config schema, multi-tenant, multi-instance, daily ops, uninstall, error recovery. Read on demand.
45
-
46
- > **Server scope.** This skill **does not** install the OpenViking server itself. It assumes the server is already running locally on `127.0.0.1:1933` or on another machine. If the user has no server, see "Server not ready" handling in STEP 5.
47
-
48
- ---
49
-
50
- # Part 1 — Natural-Language Installation Walkthrough
51
-
52
- ## STEP 0: Detect Language
53
-
54
- If the user's first message contains Chinese characters, respond in **Chinese** throughout.
55
- Otherwise respond in **English**.
56
- All user-facing messages below have (CN)/(EN) variants — use the matching one.
57
-
58
- Do NOT show this step to the user.
59
-
60
- ---
61
-
62
- ## STEP 1: Detect Operating System (silently)
63
-
64
- Run this command and remember the result. Do NOT show it to the user.
65
-
66
- ```bash
67
- uname -s 2>/dev/null || echo WINDOWS
68
- ```
69
-
70
- - Output contains `Darwin` → `OS=mac`
71
- - Output contains `Linux` → `OS=linux`
72
- - Output is `WINDOWS` or the command fails → `OS=windows`
73
-
74
- ---
75
-
76
- ## STEP 2: Check Prerequisites (silently)
77
-
78
- Run silently:
79
-
80
- ```bash
81
- node -v
82
- openclaw --version
83
- ```
84
-
85
- **If `node` is missing:**
86
-
87
- > (CN) 你的系统没有安装 Node.js。OpenClaw 和 OpenViking 插件需要 Node.js >= 22。请先安装 Node.js,然后再回来找我。
88
- > (EN) Node.js is not installed. OpenClaw and the OpenViking plugin require Node.js >= 22. Please install Node.js first, then come back.
89
-
90
- **Stop. Do NOT continue.**
91
-
92
- **If `openclaw` is missing:**
93
-
94
- > (CN) 你的系统没有安装 OpenClaw。请先安装 OpenClaw(>= 2026.4.8),然后再回来找我。
95
- > (EN) OpenClaw is not installed. Please install OpenClaw (>= 2026.4.8) first, then come back.
96
-
97
- **Stop. Do NOT continue.**
98
-
99
- If both exist, proceed to STEP 3 silently.
100
-
101
- ---
102
-
103
- ## STEP 3: Greet and Ask for 3 Values
104
-
105
- Send this message:
106
-
107
- > (CN) 好,我来帮你接入 OpenViking 长期记忆。装好之后,我会自动记住对话里的重要信息,下次聊也能回忆起来。
108
- >
109
- > 我需要 3 条信息,不知道的可以问你的管理员:
110
- > 1. **OpenViking 服务地址** —— 例如 `https://ov.example.com` 或 `http://192.168.1.100:1933`,本机服务可以直接说"本机"
111
- > 2. **API Key** —— 用来鉴权;服务没开认证可以说"没有"
112
- > 3. **Agent 标识前缀**(可选) —— 用于区分多个 agent 的记忆命名空间,留空就用默认
113
- >
114
- > 先告诉我服务地址吧?
115
-
116
- > (EN) I'll set up OpenViking long-term memory for you. Once configured, I'll automatically remember important info from our chats and recall it later.
117
- >
118
- > I need 3 things (ask your admin if unsure):
119
- > 1. **OpenViking server URL** — e.g. `https://ov.example.com` or `http://192.168.1.100:1933`. For a local server, just say "local".
120
- > 2. **API Key** — for auth. Say "none" if the server has no auth.
121
- > 3. **Agent prefix** (optional) — used to namespace memories across agents. Leave blank for default.
122
- >
123
- > What's the server URL?
124
-
125
- ---
126
-
127
- ## STEP 4: Collect Values
128
-
129
- Collect 3 values through natural conversation. Be flexible: if the user gives several at once, parse them all. If they correct something, accept the new value.
130
-
131
- ### 4a. `BASE_URL` (REQUIRED)
132
-
133
- - "local" / "本机" / "localhost" → use `http://127.0.0.1:1933`.
134
- - `ov.example.com` without protocol → prepend `https://`.
135
- - Strip trailing `/`, `/health`, or `/api`.
136
- - After normalization must start with `http://` or `https://`.
137
- - If the user says they don't know, ask them to check with the admin or look at how the server was started. **Do NOT make up a URL.**
138
-
139
- ### 4b. `API_KEY` (OPTIONAL)
140
-
141
- > (CN) API Key 是什么?服务没开认证就直接说"没有"。
142
- > (EN) What's the API Key? Say "none" if the server has no auth.
143
-
144
- - "no" / "none" / "没有" / "空" / empty → `API_KEY=""` (you will skip the flag later).
145
- - Otherwise store as-is.
146
-
147
- ### 4c. `AGENT_PREFIX` (OPTIONAL)
148
-
149
- > (CN) 想给这个 agent 一个记忆前缀吗?留空就用默认。只能用字母、数字、`_`、`-`。
150
- > (EN) Want to set an agent prefix? Leave blank for the default. Letters, digits, `_`, `-` only.
151
-
152
- - Empty / "default" / "默认" → leave unset (plugin defaults to `""`).
153
- - Otherwise validate against `/^[A-Za-z0-9_-]+$/`. If invalid, ask again.
154
-
155
- ### 4d. (Conditional) Multi-Tenant Root-Key Fields
156
-
157
- Only ask for these if STEP 7 detects a root key (`Root API key detected. Missing: --account-id, --user-id`). Don't ask up front.
158
-
159
- - `ACCOUNT_ID`
160
- - `USER_ID`
161
-
162
- See **Reference: Multi-Tenant** for what these mean.
163
-
164
- ---
165
-
166
- ## STEP 5: Pre-flight Connectivity Check (silently)
167
-
168
- Tell the user briefly:
169
-
170
- > (CN) 我先测一下能不能连上服务……
171
- > (EN) Let me test the connection to your server...
172
-
173
- Run:
174
-
175
- **If OS=windows:**
176
-
177
- ```powershell
178
- try { (Invoke-WebRequest -Uri "BASE_URL/health" -TimeoutSec 10 -UseBasicParsing -ErrorAction Stop).StatusCode } catch { $_.Exception.Response.StatusCode.value__ }
179
- ```
180
-
181
- **If OS=mac or OS=linux:**
182
-
183
- ```bash
184
- curl -sS -o /dev/null -w "%{http_code}" --connect-timeout 10 "BASE_URL/health"
185
- ```
186
-
187
- Replace `BASE_URL` with the actual value.
188
-
189
- | Status | Meaning | Action |
190
- |---|---|---|
191
- | `200` | Server reachable, no auth on `/health` | Proceed to STEP 6. |
192
- | `401` / `403` | Server reachable but `/health` requires auth | Proceed to STEP 6 — the wizard's key probe will sort it out. |
193
- | `000` / timeout / connection refused | Server unreachable | **Server-not-ready handling** below. |
194
- | Anything else | Unexpected | Show status code to the user, go back to STEP 4a. |
195
-
196
- ### Server-not-ready handling
197
-
198
- This skill **does not install or operate the OpenViking server**. If the user's server is unreachable, present the situation honestly and offer two paths:
199
-
200
- > (CN) ❌ 我连不上 `BASE_URL`。可能是:
201
- > 1) 服务还没启动 —— 请联系你的 OpenViking 服务管理员把它起起来;如果是你自己负责,请参考 OpenViking 官方文档(`https://github.com/volcengine/OpenViking`)的 server 启动指引。
202
- > 2) 地址不对 —— 你可以重新告诉我正确的地址。
203
- > 3) 网络不通(防火墙 / VPN / 内网)—— 你确认一下网络。
204
- >
205
- > 也可以选择"先把配置写下来",等服务起来就自动生效,要这么办吗?
206
-
207
- > (EN) ❌ Cannot reach `BASE_URL`. Likely cause:
208
- > 1) **Server isn't running** — please ask your OpenViking admin to start it. If you own the server, follow the OpenViking official docs (`https://github.com/volcengine/OpenViking`) to start it. **This skill does not install or run the server.**
209
- > 2) **Wrong URL** — give me the correct URL.
210
- > 3) **Network blocked** (firewall / VPN / private network) — please verify connectivity.
211
- >
212
- > Or I can save the config now (`--allow-offline`) so it will activate automatically once the server is up. Want me to do that?
213
-
214
- If the user fixes the URL → back to STEP 4a.
215
- If the user wants `--allow-offline` → remember `ALLOW_OFFLINE=true` and continue to STEP 6.
216
- If the user gives up / cannot fix → stop here. Do NOT continue with a broken state.
217
-
218
- ---
219
-
220
- ## STEP 6: Install the Plugin
221
-
222
- The plugin can be installed two ways. **Always try Path A first.** Use Path B only as a backup when Path A fails because ClawHub is unavailable, rate-limited, or authentication blocks anonymous install. For version conflicts, dependency errors, or other non-registry failures, stop and show the user the error instead of switching paths silently.
223
-
224
- ### Path A — Primary: `openclaw plugins install` (uses ClawHub)
225
-
226
- Tell the user:
227
-
228
- > (CN) 现在开始装插件……
229
- > (EN) Installing the plugin now...
230
-
231
- Run:
232
-
233
- ```bash
234
- openclaw plugins install @openclaw/openviking
235
- ```
236
-
237
- Trigger fallback to Path B only if the output contains any of these strings:
238
-
239
- - `429`
240
- - `rate limit` / `rate-limited` / `Too Many Requests`
241
- - `not logged in` / `please log in` / `please login` / `unauthorized` / `401` / `403` together with `clawhub`
242
- - `ETIMEDOUT` / `ECONNRESET` on a `clawhub`-related host
243
- - generic message indicating the registry refused an anonymous client
244
-
245
- Before falling back, also try the explicit registry prefix once:
246
-
247
- ```bash
248
- openclaw plugins install clawhub:@openclaw/openviking
249
- ```
250
-
251
- If the install **succeeds**, jump to STEP 7.
252
-
253
- If both attempts fail with one of the fallback-eligible errors above, go to Path B. If the failure is a version conflict, missing dependency, package validation error, or another non-registry error, stop and show the last 30 lines to the user.
254
-
255
- ### Path B — Backup: `ov-install` (bypasses ClawHub)
256
-
257
- Tell the user:
258
-
259
- > (CN) ClawHub 现在好像被限流、不可用,或者当前账号不能安装。我改用备用路径,直接从 GitHub 下载插件源码安装。
260
- > (EN) ClawHub looks rate-limited, unavailable, or blocked for this account. I'll use the backup path and install the plugin source directly from GitHub.
261
-
262
- Run the installer with `npx` (no global install needed):
263
-
264
- ```bash
265
- npx -y openclaw-openviking-setup-helper@latest --base-url BASE_URL [--api-key API_KEY] [--agent-prefix AGENT_PREFIX] [--account-id ACCOUNT_ID] [--user-id USER_ID]
266
- ```
267
-
268
- Build the flag list according to what the user gave you:
269
-
270
- - Always pass `--base-url BASE_URL`.
271
- - Pass `--api-key API_KEY` only if `API_KEY` is non-empty.
272
- - Pass `--agent-prefix AGENT_PREFIX` only if the user gave one.
273
- - `--account-id` / `--user-id` only if the root-key path requires them.
274
-
275
- `ov-install` will, in one shot:
276
- 1. Download plugin sources from `raw.githubusercontent.com` into the OpenClaw `extensions/` dir.
277
- 2. Run `npm install --omit=dev` inside the staging dir.
278
- 3. Register the plugin in `openclaw.json` (via `openclaw plugins enable` or direct write).
279
- 4. Run `openclaw openviking setup --json --base-url … [--api-key …] --force-slot` for the user.
280
- 5. Fall back to direct config write if `setup --json` fails.
281
-
282
- This means **STEP 7 is effectively done by `ov-install`**. After `ov-install` exits 0, jump straight to **STEP 9** (gateway restart) and **STEP 10** (verify).
283
-
284
- If `ov-install` exits non-zero, capture the last 30 lines of its output, show them to the user, and stop. Don't retry blindly.
285
-
286
- ---
287
-
288
- ## STEP 7: Configure (only on Path A — Path B did this for you)
289
-
290
- Run the setup wizard non-interactively. Build flags from collected values:
291
-
292
- ```bash
293
- openclaw openviking setup --base-url BASE_URL --json [--api-key API_KEY] [--agent-prefix AGENT_PREFIX] [--account-id ACCOUNT_ID] [--user-id USER_ID] [--allow-offline] [--force-slot]
294
- ```
295
-
296
- Rules:
297
-
298
- - `--base-url BASE_URL` is **required** under `--json`. Without it, the wizard prints `--json requires --base-url for non-interactive mode`.
299
- - `--api-key` only if `API_KEY` is non-empty.
300
- - `--agent-prefix` only if the user gave one. Use **`--agent-prefix`**, not `--agent-id` (deprecated and removed).
301
- - `--account-id` / `--user-id` only after STEP 7 root-key detection (see below).
302
- - `--allow-offline` only if the user explicitly approved it in STEP 5.
303
- - `--force-slot` **never** in the first attempt. Add only after the user confirms (see slot_blocked handling below).
304
-
305
- ### Parse the JSON output
306
-
307
- The wizard prints a single JSON object:
308
-
309
- ```json
310
- {
311
- "success": true | false,
312
- "action": "configured" | "existing" | "error" | "slot_blocked",
313
- "config": { "mode": "remote", "baseUrl": "...", "apiKey": "...", "agent_prefix": "...", "accountId": "...", "userId": "..." },
314
- "health": { "ok": true, "status": 200 },
315
- "keyProbe": { "keyType": "user_key" | "root_key" | "none", "ok": true },
316
- "slot": { "ok": true, "owner": "openviking" },
317
- "error": "..."
318
- }
319
- ```
320
-
321
- ### Decision matrix
322
-
323
- | Condition | Action |
324
- |---|---|
325
- | `success: true` and `action: "configured"` or `"existing"` | Done. Proceed to STEP 9. |
326
- | `success: false` and `action: "slot_blocked"` | **Slot conflict — see below.** |
327
- | `success: false` and `error` contains `"Server unreachable"` | Connectivity broke between STEP 5 and STEP 7. Offer `--allow-offline`; if accepted, retry. Otherwise back to STEP 4a. |
328
- | `success: false` and `error` contains `"Root API key detected"` and `"Missing: --account-id, --user-id"` | **Root-key path — see below.** |
329
- | `success: false` and `error` contains `"Invalid API key"` / `keyProbe.keyType: "none"` with `ok: false` | API key wrong. Back to STEP 4b. |
330
- | `success: false` and any other `action: "error"` | Show `error` to the user, stop. Do NOT pretend success. |
331
-
332
- ### Slot conflict (`slot_blocked`)
333
-
334
- The error text looks like:
335
-
336
- > `contextEngine slot is owned by "<other-plugin>". Config was saved but slot was NOT changed. Use --force-slot to replace.`
337
-
338
- **Do NOT silently use `--force-slot`.** Ask the user:
339
-
340
- > (CN) 你的 OpenClaw 当前 contextEngine 槽被 `<other-plugin>` 占着。如果用 OpenViking 替换它,`<other-plugin>` 就不再生效。要替换吗?
341
- > (EN) Your `contextEngine` slot is currently owned by `<other-plugin>`. Activating OpenViking will disable it. Replace?
342
-
343
- If the user agrees, retry the same setup command with `--force-slot` appended. If they decline, tell them config has been saved but the slot is unchanged, and stop.
344
-
345
- ### Root-key path
346
-
347
- The error text looks like:
348
-
349
- > `Root API key detected. Missing: --account-id, --user-id. Provide both to enable multi-tenant scoping.`
350
-
351
- Ask the user:
352
-
353
- > (CN) 你给的是 root 级 API Key,需要再补两个值才能用:账户 ID(accountId)和用户 ID(userId)。这两个一般是 OpenViking 服务管理员配的,不知道就问他们。
354
- > (EN) Your API key is a root key, which needs two more values: `accountId` and `userId`. Both come from your OpenViking server admin — ask them if unsure.
355
-
356
- After collecting, retry the setup command with `--account-id` and `--user-id` appended.
357
-
358
- ---
359
-
360
- ## STEP 8: (Reserved — done inside STEP 7 or by `ov-install`)
361
-
362
- The setup wizard already wrote `plugins.entries.openviking.config.*` and (if successful) set `plugins.slots.contextEngine = "openviking"`. There is no separate STEP 8 — go to STEP 9.
363
-
364
- ---
365
-
366
- ## STEP 9: Restart the Gateway
367
-
368
- ```bash
369
- openclaw gateway restart
370
- ```
371
-
372
- If it fails, try once more with:
373
-
374
- ```bash
375
- openclaw gateway --force
376
- ```
377
-
378
- If both fail:
379
-
380
- > (CN) Gateway 没能自动重启。请你手动跑一下 `openclaw gateway restart`。重启完告诉我,我来验证。
381
- > (EN) Gateway didn't restart cleanly. Please run `openclaw gateway restart` manually, then tell me when it's done so I can verify.
382
-
383
- Wait ~3 seconds before STEP 10.
384
-
385
- ---
386
-
387
- ## STEP 10: Verify
388
-
389
- ```bash
390
- openclaw openviking status --json
391
- ```
392
-
393
- Expected output:
394
-
395
- ```json
396
- {
397
- "configured": true,
398
- "slotActive": true,
399
- "health": { "ok": true },
400
- "config": { "baseUrl": "...", "agent_prefix": "..." }
401
- }
402
- ```
403
-
404
- ### Decision
405
-
406
- - `configured: true` **and** `slotActive: true` **and** `health.ok: true` → **success.** Send the success message below.
407
- - `configured: true` but `slotActive: false` → if you previously skipped `--force-slot`, ask the user about replacing now and retry STEP 7 with `--force-slot`. Otherwise it's a gateway restart issue — back to STEP 9.
408
- - `configured: true` but `health.ok: false` → server became unreachable. Tell the user; the config will start working as soon as the server is back.
409
- - `configured: false` → setup didn't actually persist. Show full status JSON to the user and stop.
410
-
411
- ### Success message
412
-
413
- > (CN) 🎉 全部搞定!OpenViking 长期记忆已经接好了。
414
- >
415
- > 工作方式:
416
- > - **每一轮**:你的对话会被自动归档到 OpenViking session 里
417
- > - **`/compact` 时**:归档消息会被抽取成长期记忆,写到 `~/.openviking/data/` 下
418
- > - **后续会话**:每次回复前我都会自动搜一下相关记忆并带进上下文
419
- >
420
- > 想验证一下吗?跟我聊几句包含可记忆事实的话(例如"我的邮箱是 test@example.com"),然后调一下 `/compact`,再开新对话问"我的邮箱是?",应该就能召回了。
421
-
422
- > (EN) 🎉 All set! OpenViking long-term memory is connected.
423
- >
424
- > How it works:
425
- > - **Every turn**: our messages are auto-archived into an OpenViking session
426
- > - **On `/compact`**: archived messages are extracted into long-term memories under `~/.openviking/data/`
427
- > - **Future sessions**: relevant memories are auto-retrieved and injected before my replies
428
- >
429
- > Want to verify? Tell me a few facts (e.g. "my email is test@example.com"), run `/compact`, then start a new chat and ask "what's my email?" — it should recall.
430
-
431
- ---
432
-
433
- # Part 2 — Reference
434
-
435
- ## How It Works
436
-
437
- The context-engine pipeline has three distinct stages — keep them apart, especially when telling users when memories actually appear in `~/.openviking/data/`:
438
-
439
- - **Archive / capture (context-engine `afterTurn`)**: at the end of a user turn, the plugin commits user/assistant messages to the OpenViking session via `POST /api/v1/sessions/.../messages`. This is **archive only** — no memory extraction yet. You'll see session message counts grow on the server, but no new files under `viking://user/.../memories/`.
440
- - **Memory extraction (on `/compact`)**: memory extraction runs when the user invokes OpenClaw's `/compact` command. The server-side extraction pipeline reads the archived session and writes new memories. The plugin's `after_compaction` hook is currently reserved; the extraction itself is driven by the server. **No `/compact`, no new memory files.**
441
- - `captureMode: "semantic"` (default): server extraction pipeline filters all qualifying text.
442
- - `captureMode: "keyword"`: only text matching trigger words (e.g. "remember", "preference") is considered.
443
- - **Auto-Recall (context-engine `assemble()`)**: before prompt context is assembled, the plugin queries OpenViking for relevant memories and injects them into context. Recall works even when there are no extracted memories yet — you just won't see anything come back.
444
-
445
- **Practical implication for testing**: if you write down a fact and immediately try to recall it without `/compact`, the plugin will only retrieve it as recent session context (archived messages), not as a long-term memory. To verify long-term memory cross-session, you must run `/compact` first.
446
-
447
- ## Available Tools
448
-
449
- These are the plugin tools the agent can call once installed.
450
-
451
- ### `memory_recall` — Search Memories
452
-
453
- | Parameter | Required | Description |
454
- |---|---|---|
455
- | `query` | Yes | Search query text |
456
- | `limit` | No | Maximum number of results (defaults to plugin config) |
457
- | `scoreThreshold` | No | Minimum relevance score 0–1 (defaults to plugin config) |
458
- | `targetUri` | No | Search scope URI (defaults to plugin config) |
459
-
460
- Example: user asks "What programming language did I say I like?"
461
-
462
- ### `memory_store` — Manual Store
463
-
464
- | Parameter | Required | Description |
465
- |---|---|---|
466
- | `text` | Yes | Information text to store |
467
- | `role` | No | Session role (default `user`) |
468
- | `sessionId` | No | Existing OpenViking session ID |
469
-
470
- Example: user says "Remember my email is xxx@example.com".
471
-
472
- ### `memory_forget` — Delete Memories
473
-
474
- | Parameter | Required | Description |
475
- |---|---|---|
476
- | `uri` | No | Exact memory URI (direct delete) |
477
- | `query` | No | Search query (find then delete) |
478
- | `targetUri` | No | Search scope URI |
479
- | `limit` | No | Search limit (default 5) |
480
- | `scoreThreshold` | No | Minimum relevance score |
481
-
482
- Example: user says "Forget my phone number".
483
-
484
- ## Configuration Schema
485
-
486
- These are the keys under `plugins.entries.openviking.config` in `openclaw.json`. The setup wizard / `ov-install` sets the first few; the rest are tunables.
487
-
488
- | Field | Default | Description |
489
- |---|---|---|
490
- | `mode` | `"remote"` (forced by plugin) | Always remote in this skill. Don't set manually. |
491
- | `baseUrl` | `http://127.0.0.1:1933` | OpenViking server URL. |
492
- | `apiKey` | — | API key. Optional if server has no auth. |
493
- | `agent_prefix` | `""` | Prefix for routing memories per agent. Letters / digits / `_` / `-`. |
494
- | `accountId` | — | Required when `apiKey` is a root key. |
495
- | `userId` | — | Required when `apiKey` is a root key. |
496
- | `targetUri` | `viking://user/memories` | Default search scope URI. |
497
- | `timeoutMs` | (plugin default) | HTTP timeout for OpenViking calls. |
498
- | `autoCapture` | `true` | Auto-archive turn messages to OpenViking session at `afterTurn` (extraction itself runs on `/compact`, not here). |
499
- | `captureMode` | `"semantic"` | Filter mode used by the server-side extraction pipeline: `semantic` or `keyword`. |
500
- | `captureMaxLength` | `24000` | Max text length per archived turn. |
501
- | `autoRecall` | `true` | Auto-recall and inject memories before reply. |
502
- | `recallLimit` | `6` | Max memories injected per recall. |
503
- | `recallScoreThreshold` | `0.15` | Min relevance score to inject. |
504
- | `recallMaxInjectedChars` | (plugin default) | Hard cap on injected character count. |
505
- | `recallPreferAbstract` | (plugin default) | Prefer abstract memories over raw. |
506
- | `recallTokenBudget` | (plugin default) | Token budget for injected memories. |
507
- | `isolateUserScopeByAgent` | (plugin default) | Multi-tenant scoping toggle. |
508
- | `isolateAgentScopeByUser` | (plugin default) | Multi-tenant scoping toggle. |
509
- | `agentScopeMode` | (plugin default) | Agent scope strategy. |
510
- | `bypassSessionPatterns` | — | Glob patterns for sessions skipped by capture. |
511
- | `ingestReplyAssist` | (plugin default) | Reply-assist ingestion toggle. |
512
- | `emitStandardDiagnostics` | (plugin default) | Verbose diagnostic logs. |
513
- | `logFindRequests` | (plugin default) | Log retrieval requests. |
514
-
515
- To change a value:
516
-
517
- ```bash
518
- openclaw config set plugins.entries.openviking.config.<field> <value>
519
- openclaw gateway restart
520
- ```
521
-
522
- ## Multi-Tenant (Root API Keys)
523
-
524
- Some OpenViking deployments use a single **root** API key shared across tenants. In that case the plugin needs both `accountId` and `userId` so it can scope memories correctly. The setup wizard detects this automatically and returns:
525
-
526
- ```
527
- Root API key detected. Missing: --account-id, --user-id
528
- ```
529
-
530
- When you see this:
531
-
532
- 1. Ask the user for both values (they come from the OpenViking admin).
533
- 2. Retry STEP 7 with both flags:
534
-
535
- ```bash
536
- openclaw openviking setup --base-url BASE_URL --api-key API_KEY --account-id ACCOUNT_ID --user-id USER_ID --json
537
- ```
538
-
539
- A **user key** (issued per tenant) does not need these flags.
540
-
541
- ## Multi-Instance (`--workdir` / `OPENCLAW_STATE_DIR`)
542
-
543
- If the user runs multiple OpenClaw instances (e.g. testing several agents in parallel), each has its own state dir.
544
-
545
- To target a non-default instance:
546
-
547
- ```bash
548
- npx -y openclaw-openviking-setup-helper@latest --workdir ~/.openclaw-second --base-url ... --api-key ...
549
- ```
550
-
551
- `ov-install` writes a helper env file when the state dir is non-default:
552
-
553
- - Unix: `~/.openclaw/openviking.env` containing `export OPENCLAW_STATE_DIR='...'`
554
- - Windows: `~/.openclaw/openviking.env.bat` and `.ps1` setting the same variable
555
-
556
- Source it before running `openclaw` commands so they hit the correct state:
557
-
558
- **Unix:**
559
- ```bash
560
- source ~/.openclaw/openviking.env
561
- openclaw status
562
- ```
563
-
564
- **Windows (PowerShell):**
565
- ```powershell
566
- . "$HOME/.openclaw/openviking.env.ps1"
567
- openclaw status
568
- ```
569
-
570
- Or pass `--workdir` directly to each `openclaw` invocation (note: not all `openclaw` subcommands honor `--workdir` consistently — when in doubt, prefer the env var).
571
-
572
- ## Daily Operations
573
-
574
- ```bash
575
- # Start or restart OpenClaw gateway after config changes
576
- openclaw gateway restart
577
-
578
- # Check overall status
579
- openclaw status
580
- openclaw openviking status --json
581
-
582
- # Read current OpenViking slot
583
- openclaw config get plugins.slots.contextEngine
584
-
585
- # Disable OpenViking memory (keep config, deactivate slot)
586
- openclaw config set plugins.slots.contextEngine legacy
587
- openclaw gateway restart
588
-
589
- # Re-enable
590
- openclaw config set plugins.slots.contextEngine openviking
591
- openclaw gateway restart
592
- ```
593
-
594
- ## Uninstall
595
-
596
- ### Preferred: via OpenClaw plugin manager
597
-
598
- ```bash
599
- openclaw plugins uninstall openviking
600
- openclaw config set plugins.slots.contextEngine legacy
601
- openclaw gateway restart
602
- ```
603
-
604
- ### If installed through backup `ov-install`
605
-
606
- ```bash
607
- npx -y openclaw-openviking-setup-helper@latest --uninstall
608
- ```
609
-
610
- This will:
611
-
612
- 1. Stop the OpenClaw gateway.
613
- 2. Back up `openclaw.json`.
614
- 3. Remove all OpenViking plugin config from `openclaw.json` (`plugins.entries.openviking`, `plugins.allow`, `plugins.installs.openviking`, `plugins.slots.contextEngine`).
615
- 4. Move the plugin directory to `disabled-extensions/` as backup.
616
- 5. Remove the helper env files (`openviking.env`, `.bat`, `.ps1`).
617
-
618
- Add `--base-url dummy` for fully non-interactive mode (skips the confirmation prompt).
619
-
620
- ### Manual
621
-
622
- ```bash
623
- openclaw gateway stop
624
- openclaw config set plugins.slots.contextEngine legacy
625
- # Then edit ~/.openclaw/openclaw.json and remove openviking from
626
- # plugins.entries
627
- # plugins.allow
628
- # plugins.installs
629
- openclaw gateway restart
630
- ```
631
-
632
- ## Error Recovery Reference
633
-
634
- Match against actual stderr / JSON `error` strings.
635
-
636
- | Symptom (exact string) | Likely cause | Fix |
637
- |---|---|---|
638
- | `command not found: openclaw` | OpenClaw not installed | Stop. Ask user to install OpenClaw >= 2026.4.8. |
639
- | `command not found: node` / `'node' is not recognized` | Node missing | Stop. Ask user to install Node.js >= 22. |
640
- | `429` / `rate limit` / `Too Many Requests` from `plugins install` | ClawHub throttle | Switch to backup Path B (`ov-install`). |
641
- | `not logged in` / `please log in` from `plugins install` | Anonymous user hit limit | Switch to backup Path B (`ov-install`). |
642
- | `ECONNREFUSED` / `connection refused` on `BASE_URL/health` | Server not running | Server-not-ready handling in STEP 5. |
643
- | `ETIMEDOUT` on `BASE_URL/health` | Network blocked | Ask about firewall / VPN / proxy. |
644
- | `--json requires --base-url for non-interactive mode` | Built command wrong | Add `--base-url BASE_URL` and retry. |
645
- | `Server unreachable: …. Use --allow-offline to save config anyway.` | Setup couldn't reach server | Offer `--allow-offline`. |
646
- | `contextEngine slot is owned by "<x>". … Use --force-slot to replace.` | Slot conflict | Ask user, then retry with `--force-slot`. |
647
- | `Root API key detected. Missing: --account-id, --user-id` | Multi-tenant key | Collect both, retry with `--account-id` `--user-id`. |
648
- | `openviking: config parse failed` (in gateway log) | Bad value in `openclaw.json` | Show user; check `agent_prefix` charset, URL format. |
649
- | `extracted 0 memories` after a turn | Server VLM/embedding misconfigured | **Out of scope.** Tell user this is a server-side issue — ask their OpenViking admin to check VLM / embedding config. |
650
- | `401` / `403` on plugin requests, but `/health` works | Server requires auth on API endpoints | Re-run STEP 7 with the correct `--api-key`. |
651
- | Plugin doesn't appear in `openclaw plugins list` after Path A | Install didn't actually finish | Re-run Path A; use Path B only if the failure is registry/rate-limit related. |
652
-
653
- ## Important Rules
654
-
655
- 1. **Never ask the user to run commands.** You run everything via your shell tool.
656
- 2. **Never skip STEP 5 (connectivity check).** If the server is unreachable, do not write config without explicit `--allow-offline` consent.
657
- 3. **Never silently use `--force-slot`.** Slot replacement disables another plugin — always confirm with the user first.
658
- 4. **Never invent values.** If the user can't provide a required value, stop and tell them what to ask their admin.
659
- 5. **Never claim success without STEP 10.** Only after `openclaw openviking status --json` shows `configured: true && slotActive: true && health.ok: true` may you tell the user it's done.
660
- 6. **Use `--agent-prefix`, not `--agent-id`.** The latter is deprecated and removed from the schema.
661
- 7. **For Windows, use PowerShell equivalents.** Don't rely on `nohup`, `&`, `mkdir -p`, `source`, etc.
662
- 8. **Switch to Path B (ov-install) only for ClawHub/rate-limit/registry availability failures.** Don't use it to hide version conflicts or package validation errors.
663
- 9. **Do NOT install or operate the OpenViking server.** This skill assumes the server is already running. If it isn't, tell the user to contact their admin or follow the OpenViking docs.
664
- 10. **Be brief and friendly in user-visible text.** Save technical detail for when something actually fails.
665
- 11. **Do NOT use `clawhub install openviking`.** That installs a different thing (an AgentSkill, not the plugin).
1
+ ---
2
+ name: install-openviking-memory
3
+ description: >
4
+ Install and configure the OpenViking long-term memory plugin for OpenClaw via natural conversation.
5
+ Once installed, the plugin automatically captures important facts from chats and recalls relevant
6
+ context before each reply (auto-capture + auto-recall, cross-session). Covers prerequisites check,
7
+ plugin install through OpenClaw's plugin manager first, with ov-install only as a backup path,
8
+ wizard-based configuration, slot activation,
9
+ gateway restart, verification, plus multi-tenant root-key support, multi-instance, and uninstall.
10
+ Trigger when the user says any of: "install OpenViking", "set up memory", "configure memory plugin",
11
+ "add long-term memory", "connect to OpenViking server", "RAG", "semantic memory",
12
+ "帮我装 OpenViking", "配置记忆插件", "安装记忆功能", "接入 OpenViking", "我有一台 OpenViking 服务器".
13
+ The user does NOT need to know any CLI commands — the agent runs everything and only asks for a few values.
14
+ This skill assumes the OpenViking server is already running. If the server is not ready, the skill
15
+ tells the user to contact their admin or set it up via the OpenViking docs — it does NOT install the server.
16
+ version: 2.0.1
17
+ metadata:
18
+ openclaw:
19
+ requires:
20
+ bins:
21
+ - node
22
+ - openclaw
23
+ emoji: "🦣"
24
+ homepage: "https://github.com/volcengine/OpenViking"
25
+ tags:
26
+ - install
27
+ - setup
28
+ - memory
29
+ - openviking
30
+ - rag
31
+ - long-term-memory
32
+ ---
33
+
34
+ # Install OpenViking Memory — Agent Installation & Reference Skill
35
+
36
+ You are about to help a user install and configure the OpenViking memory plugin for OpenClaw.
37
+ The user does NOT know how to use a terminal. You will collect a few values through natural conversation, then run **all** commands yourself using your shell tool.
38
+
39
+ **Read this entire document before starting. Follow every step in order. Do NOT skip steps.**
40
+
41
+ This skill is split into two halves:
42
+
43
+ - **Part 1 (STEP 0–10): Natural-language installation walkthrough.** Use this on first install or reconfigure.
44
+ - **Part 2: Reference.** Tools, config schema, multi-tenant, multi-instance, daily ops, uninstall, error recovery. Read on demand.
45
+
46
+ > **Server scope.** This skill **does not** install the OpenViking server itself. It assumes the server is already running locally on `127.0.0.1:1933` or on another machine. If the user has no server, see "Server not ready" handling in STEP 5.
47
+
48
+ ---
49
+
50
+ # Part 1 — Natural-Language Installation Walkthrough
51
+
52
+ ## STEP 0: Detect Language
53
+
54
+ If the user's first message contains Chinese characters, respond in **Chinese** throughout.
55
+ Otherwise respond in **English**.
56
+ All user-facing messages below have (CN)/(EN) variants — use the matching one.
57
+
58
+ Do NOT show this step to the user.
59
+
60
+ ---
61
+
62
+ ## STEP 1: Detect Operating System (silently)
63
+
64
+ Run this command and remember the result. Do NOT show it to the user.
65
+
66
+ ```bash
67
+ uname -s 2>/dev/null || echo WINDOWS
68
+ ```
69
+
70
+ - Output contains `Darwin` → `OS=mac`
71
+ - Output contains `Linux` → `OS=linux`
72
+ - Output is `WINDOWS` or the command fails → `OS=windows`
73
+
74
+ ---
75
+
76
+ ## STEP 2: Check Prerequisites (silently)
77
+
78
+ Run silently:
79
+
80
+ ```bash
81
+ node -v
82
+ openclaw --version
83
+ ```
84
+
85
+ **If `node` is missing:**
86
+
87
+ > (CN) 你的系统没有安装 Node.js。OpenClaw 和 OpenViking 插件需要 Node.js >= 22。请先安装 Node.js,然后再回来找我。
88
+ > (EN) Node.js is not installed. OpenClaw and the OpenViking plugin require Node.js >= 22. Please install Node.js first, then come back.
89
+
90
+ **Stop. Do NOT continue.**
91
+
92
+ **If `openclaw` is missing:**
93
+
94
+ > (CN) 你的系统没有安装 OpenClaw。请先安装 OpenClaw(>= 2026.4.8),然后再回来找我。
95
+ > (EN) OpenClaw is not installed. Please install OpenClaw (>= 2026.4.8) first, then come back.
96
+
97
+ **Stop. Do NOT continue.**
98
+
99
+ If both exist, proceed to STEP 3 silently.
100
+
101
+ ---
102
+
103
+ ## STEP 3: Greet and Ask for 3 Values
104
+
105
+ Send this message:
106
+
107
+ > (CN) 好,我来帮你接入 OpenViking 长期记忆。装好之后,我会自动记住对话里的重要信息,下次聊也能回忆起来。
108
+ >
109
+ > 我需要 3 条信息,不知道的可以问你的管理员:
110
+ > 1. **OpenViking 服务地址** —— 例如 `https://ov.example.com` 或 `http://192.168.1.100:1933`,本机服务可以直接说"本机"
111
+ > 2. **API Key** —— 用来鉴权;服务没开认证可以说"没有"
112
+ > 3. **Agent 标识前缀**(可选) —— 用于区分多个 agent 的记忆命名空间,留空就用默认
113
+ >
114
+ > 先告诉我服务地址吧?
115
+
116
+ > (EN) I'll set up OpenViking long-term memory for you. Once configured, I'll automatically remember important info from our chats and recall it later.
117
+ >
118
+ > I need 3 things (ask your admin if unsure):
119
+ > 1. **OpenViking server URL** — e.g. `https://ov.example.com` or `http://192.168.1.100:1933`. For a local server, just say "local".
120
+ > 2. **API Key** — for auth. Say "none" if the server has no auth.
121
+ > 3. **Agent prefix** (optional) — used to namespace memories across agents. Leave blank for default.
122
+ >
123
+ > What's the server URL?
124
+
125
+ ---
126
+
127
+ ## STEP 4: Collect Values
128
+
129
+ Collect 3 values through natural conversation. Be flexible: if the user gives several at once, parse them all. If they correct something, accept the new value.
130
+
131
+ ### 4a. `BASE_URL` (REQUIRED)
132
+
133
+ - "local" / "本机" / "localhost" → use `http://127.0.0.1:1933`.
134
+ - `ov.example.com` without protocol → prepend `https://`.
135
+ - Strip trailing `/`, `/health`, or `/api`.
136
+ - After normalization must start with `http://` or `https://`.
137
+ - If the user says they don't know, ask them to check with the admin or look at how the server was started. **Do NOT make up a URL.**
138
+
139
+ ### 4b. `API_KEY` (OPTIONAL)
140
+
141
+ > (CN) API Key 是什么?服务没开认证就直接说"没有"。
142
+ > (EN) What's the API Key? Say "none" if the server has no auth.
143
+
144
+ - "no" / "none" / "没有" / "空" / empty → `API_KEY=""` (you will skip the flag later).
145
+ - Otherwise store as-is.
146
+
147
+ ### 4c. `AGENT_PREFIX` (OPTIONAL)
148
+
149
+ > (CN) 想给这个 agent 一个记忆前缀吗?留空就用默认。只能用字母、数字、`_`、`-`。
150
+ > (EN) Want to set an agent prefix? Leave blank for the default. Letters, digits, `_`, `-` only.
151
+
152
+ - Empty / "default" / "默认" → leave unset (plugin defaults to `""`).
153
+ - Otherwise validate against `/^[A-Za-z0-9_-]+$/`. If invalid, ask again.
154
+
155
+ ### 4d. (Conditional) Multi-Tenant Root-Key Fields
156
+
157
+ Only ask for these if STEP 7 detects a root key (`Root API key detected. Missing: --account-id, --user-id`). Don't ask up front.
158
+
159
+ - `ACCOUNT_ID`
160
+ - `USER_ID`
161
+
162
+ See **Reference: Multi-Tenant** for what these mean.
163
+
164
+ ---
165
+
166
+ ## STEP 5: Pre-flight Connectivity Check (silently)
167
+
168
+ Tell the user briefly:
169
+
170
+ > (CN) 我先测一下能不能连上服务……
171
+ > (EN) Let me test the connection to your server...
172
+
173
+ Run:
174
+
175
+ **If OS=windows:**
176
+
177
+ ```powershell
178
+ try { (Invoke-WebRequest -Uri "BASE_URL/health" -TimeoutSec 10 -UseBasicParsing -ErrorAction Stop).StatusCode } catch { $_.Exception.Response.StatusCode.value__ }
179
+ ```
180
+
181
+ **If OS=mac or OS=linux:**
182
+
183
+ ```bash
184
+ curl -sS -o /dev/null -w "%{http_code}" --connect-timeout 10 "BASE_URL/health"
185
+ ```
186
+
187
+ Replace `BASE_URL` with the actual value.
188
+
189
+ | Status | Meaning | Action |
190
+ |---|---|---|
191
+ | `200` | Server reachable, no auth on `/health` | Proceed to STEP 6. |
192
+ | `401` / `403` | Server reachable but `/health` requires auth | Proceed to STEP 6 — the wizard's key probe will sort it out. |
193
+ | `000` / timeout / connection refused | Server unreachable | **Server-not-ready handling** below. |
194
+ | Anything else | Unexpected | Show status code to the user, go back to STEP 4a. |
195
+
196
+ ### Server-not-ready handling
197
+
198
+ This skill **does not install or operate the OpenViking server**. If the user's server is unreachable, present the situation honestly and offer two paths:
199
+
200
+ > (CN) ❌ 我连不上 `BASE_URL`。可能是:
201
+ > 1) 服务还没启动 —— 请联系你的 OpenViking 服务管理员把它起起来;如果是你自己负责,请参考 OpenViking 官方文档(`https://github.com/volcengine/OpenViking`)的 server 启动指引。
202
+ > 2) 地址不对 —— 你可以重新告诉我正确的地址。
203
+ > 3) 网络不通(防火墙 / VPN / 内网)—— 你确认一下网络。
204
+ >
205
+ > 也可以选择"先把配置写下来",等服务起来就自动生效,要这么办吗?
206
+
207
+ > (EN) ❌ Cannot reach `BASE_URL`. Likely cause:
208
+ > 1) **Server isn't running** — please ask your OpenViking admin to start it. If you own the server, follow the OpenViking official docs (`https://github.com/volcengine/OpenViking`) to start it. **This skill does not install or run the server.**
209
+ > 2) **Wrong URL** — give me the correct URL.
210
+ > 3) **Network blocked** (firewall / VPN / private network) — please verify connectivity.
211
+ >
212
+ > Or I can save the config now (`--allow-offline`) so it will activate automatically once the server is up. Want me to do that?
213
+
214
+ If the user fixes the URL → back to STEP 4a.
215
+ If the user wants `--allow-offline` → remember `ALLOW_OFFLINE=true` and continue to STEP 6.
216
+ If the user gives up / cannot fix → stop here. Do NOT continue with a broken state.
217
+
218
+ ---
219
+
220
+ ## STEP 6: Install the Plugin
221
+
222
+ The plugin can be installed two ways. **Always try Path A first.** Use Path B only as a backup when Path A fails because ClawHub is unavailable, rate-limited, or authentication blocks anonymous install. For version conflicts, dependency errors, or other non-registry failures, stop and show the user the error instead of switching paths silently.
223
+
224
+ ### Path A — Primary: `openclaw plugins install` (uses ClawHub)
225
+
226
+ Tell the user:
227
+
228
+ > (CN) 现在开始装插件……
229
+ > (EN) Installing the plugin now...
230
+
231
+ Run:
232
+
233
+ ```bash
234
+ openclaw plugins install clawhub:@openviking/openclaw-plugin
235
+ ```
236
+
237
+ Trigger fallback to Path B only if the output contains any of these strings:
238
+
239
+ - `429`
240
+ - `rate limit` / `rate-limited` / `Too Many Requests`
241
+ - `not logged in` / `please log in` / `please login` / `unauthorized` / `401` / `403` together with `clawhub`
242
+ - `ETIMEDOUT` / `ECONNRESET` on a `clawhub`-related host
243
+ - generic message indicating the registry refused an anonymous client
244
+
245
+ Before falling back, also try the explicit registry prefix once:
246
+
247
+ ```bash
248
+ openclaw plugins install clawhub:@openviking/openclaw-plugin
249
+ ```
250
+
251
+ If the install **succeeds**, jump to STEP 7.
252
+
253
+ If both attempts fail with one of the fallback-eligible errors above, go to Path B. If the failure is a version conflict, missing dependency, package validation error, or another non-registry error, stop and show the last 30 lines to the user.
254
+
255
+ ### Path B — Backup: `ov-install` (bypasses ClawHub)
256
+
257
+ Tell the user:
258
+
259
+ > (CN) ClawHub 现在好像被限流、不可用,或者当前账号不能安装。我改用备用路径,通过 npm 下载并部署插件包。
260
+ > (EN) ClawHub looks rate-limited, unavailable, or blocked for this account. I'll use the backup path and install the plugin package from npm.
261
+
262
+ Run the installer with `npx` (no global install needed):
263
+
264
+ ```bash
265
+ npx -y openclaw-openviking-setup-helper@latest --base-url BASE_URL [--api-key API_KEY] [--agent-prefix AGENT_PREFIX] [--account-id ACCOUNT_ID] [--user-id USER_ID]
266
+ ```
267
+
268
+ Build the flag list according to what the user gave you:
269
+
270
+ - Always pass `--base-url BASE_URL`.
271
+ - Pass `--api-key API_KEY` only if `API_KEY` is non-empty.
272
+ - Pass `--agent-prefix AGENT_PREFIX` only if the user gave one.
273
+ - `--account-id` / `--user-id` only if the root-key path requires them.
274
+
275
+ `ov-install` will, in one shot:
276
+ 1. Download the `@openviking/openclaw-plugin` package from npm into a temporary staging dir.
277
+ 2. Copy the package into the OpenClaw `extensions/` dir and install plugin dependencies.
278
+ 3. Register the plugin in `openclaw.json` (via `openclaw plugins enable` or direct write).
279
+ 4. Run `openclaw openviking setup --json --base-url … [--api-key …]` for the user.
280
+ 5. Return a non-zero exit if setup needs explicit `--allow-offline` or `--force-slot` consent.
281
+
282
+ This means **STEP 7 is effectively done by `ov-install`**. After `ov-install` exits 0, jump straight to **STEP 9** (gateway restart) and **STEP 10** (verify).
283
+
284
+ If `ov-install` exits non-zero, capture the last 30 lines of its output, show them to the user, and stop. Don't retry blindly.
285
+
286
+ ---
287
+
288
+ ## STEP 7: Configure (only on Path A — Path B did this for you)
289
+
290
+ Run the setup wizard non-interactively. Build flags from collected values:
291
+
292
+ ```bash
293
+ openclaw openviking setup --base-url BASE_URL --json [--api-key API_KEY] [--agent-prefix AGENT_PREFIX] [--account-id ACCOUNT_ID] [--user-id USER_ID] [--allow-offline] [--force-slot]
294
+ ```
295
+
296
+ Rules:
297
+
298
+ - `--base-url BASE_URL` is **required** under `--json`. Without it, the wizard prints `--json requires --base-url for non-interactive mode`.
299
+ - `--api-key` only if `API_KEY` is non-empty.
300
+ - `--agent-prefix` only if the user gave one. Use **`--agent-prefix`**, not `--agent-id` (deprecated and removed).
301
+ - `--account-id` / `--user-id` only after STEP 7 root-key detection (see below).
302
+ - `--allow-offline` only if the user explicitly approved it in STEP 5.
303
+ - `--force-slot` **never** in the first attempt. Add only after the user confirms (see slot_blocked handling below).
304
+
305
+ ### Parse the JSON output
306
+
307
+ The wizard prints a single JSON object:
308
+
309
+ ```json
310
+ {
311
+ "success": true | false,
312
+ "action": "configured" | "existing" | "error" | "slot_blocked",
313
+ "config": { "mode": "remote", "baseUrl": "...", "apiKey": "...", "agent_prefix": "...", "accountId": "...", "userId": "..." },
314
+ "health": { "ok": true, "status": 200 },
315
+ "keyProbe": { "keyType": "user_key" | "root_key" | "none", "ok": true },
316
+ "slot": { "ok": true, "owner": "openviking" },
317
+ "error": "..."
318
+ }
319
+ ```
320
+
321
+ ### Decision matrix
322
+
323
+ | Condition | Action |
324
+ |---|---|
325
+ | `success: true` and `action: "configured"` or `"existing"` | Done. Proceed to STEP 9. |
326
+ | `success: false` and `action: "slot_blocked"` | **Slot conflict — see below.** |
327
+ | `success: false` and `error` contains `"Server unreachable"` | Connectivity broke between STEP 5 and STEP 7. Offer `--allow-offline`; if accepted, retry. Otherwise back to STEP 4a. |
328
+ | `success: false` and `error` contains `"Root API key detected"` and `"Missing: --account-id, --user-id"` | **Root-key path — see below.** |
329
+ | `success: false` and `error` contains `"Invalid API key"` / `keyProbe.keyType: "none"` with `ok: false` | API key wrong. Back to STEP 4b. |
330
+ | `success: false` and any other `action: "error"` | Show `error` to the user, stop. Do NOT pretend success. |
331
+
332
+ ### Slot conflict (`slot_blocked`)
333
+
334
+ The error text looks like:
335
+
336
+ > `contextEngine slot is owned by "<other-plugin>". Config was saved but slot was NOT changed. Use --force-slot to replace.`
337
+
338
+ **Do NOT silently use `--force-slot`.** Ask the user:
339
+
340
+ > (CN) 你的 OpenClaw 当前 contextEngine 槽被 `<other-plugin>` 占着。如果用 OpenViking 替换它,`<other-plugin>` 就不再生效。要替换吗?
341
+ > (EN) Your `contextEngine` slot is currently owned by `<other-plugin>`. Activating OpenViking will disable it. Replace?
342
+
343
+ If the user agrees, retry the same setup command with `--force-slot` appended. If they decline, tell them config has been saved but the slot is unchanged, and stop.
344
+
345
+ ### Root-key path
346
+
347
+ The error text looks like:
348
+
349
+ > `Root API key detected. Missing: --account-id, --user-id. Provide both to enable multi-tenant scoping.`
350
+
351
+ Ask the user:
352
+
353
+ > (CN) 你给的是 root 级 API Key,需要再补两个值才能用:账户 ID(accountId)和用户 ID(userId)。这两个一般是 OpenViking 服务管理员配的,不知道就问他们。
354
+ > (EN) Your API key is a root key, which needs two more values: `accountId` and `userId`. Both come from your OpenViking server admin — ask them if unsure.
355
+
356
+ After collecting, retry the setup command with `--account-id` and `--user-id` appended.
357
+
358
+ ---
359
+
360
+ ## STEP 8: (Reserved — done inside STEP 7 or by `ov-install`)
361
+
362
+ The setup wizard already wrote `plugins.entries.openviking.config.*` and (if successful) set `plugins.slots.contextEngine = "openviking"`. There is no separate STEP 8 — go to STEP 9.
363
+
364
+ ---
365
+
366
+ ## STEP 9: Restart the Gateway
367
+
368
+ ```bash
369
+ openclaw gateway restart
370
+ ```
371
+
372
+ If it fails, try once more with:
373
+
374
+ ```bash
375
+ openclaw gateway --force
376
+ ```
377
+
378
+ If both fail:
379
+
380
+ > (CN) Gateway 没能自动重启。请你手动跑一下 `openclaw gateway restart`。重启完告诉我,我来验证。
381
+ > (EN) Gateway didn't restart cleanly. Please run `openclaw gateway restart` manually, then tell me when it's done so I can verify.
382
+
383
+ Wait ~3 seconds before STEP 10.
384
+
385
+ ---
386
+
387
+ ## STEP 10: Verify
388
+
389
+ ```bash
390
+ openclaw openviking status --json
391
+ ```
392
+
393
+ Expected output:
394
+
395
+ ```json
396
+ {
397
+ "configured": true,
398
+ "slotActive": true,
399
+ "health": { "ok": true },
400
+ "config": { "baseUrl": "...", "agent_prefix": "..." }
401
+ }
402
+ ```
403
+
404
+ ### Decision
405
+
406
+ - `configured: true` **and** `slotActive: true` **and** `health.ok: true` → **success.** Send the success message below.
407
+ - `configured: true` but `slotActive: false` → if you previously skipped `--force-slot`, ask the user about replacing now and retry STEP 7 with `--force-slot`. Otherwise it's a gateway restart issue — back to STEP 9.
408
+ - `configured: true` but `health.ok: false` → server became unreachable. Tell the user; the config will start working as soon as the server is back.
409
+ - `configured: false` → setup didn't actually persist. Show full status JSON to the user and stop.
410
+
411
+ ### Success message
412
+
413
+ > (CN) 🎉 全部搞定!OpenViking 长期记忆已经接好了。
414
+ >
415
+ > 工作方式:
416
+ > - **每一轮**:你的对话会被自动归档到 OpenViking session 里
417
+ > - **`/compact` 时**:归档消息会被抽取成长期记忆,写到 `~/.openviking/data/` 下
418
+ > - **后续会话**:每次回复前我都会自动搜一下相关记忆并带进上下文
419
+ >
420
+ > 想验证一下吗?跟我聊几句包含可记忆事实的话(例如"我的邮箱是 test@example.com"),然后调一下 `/compact`,再开新对话问"我的邮箱是?",应该就能召回了。
421
+
422
+ > (EN) 🎉 All set! OpenViking long-term memory is connected.
423
+ >
424
+ > How it works:
425
+ > - **Every turn**: our messages are auto-archived into an OpenViking session
426
+ > - **On `/compact`**: archived messages are extracted into long-term memories under `~/.openviking/data/`
427
+ > - **Future sessions**: relevant memories are auto-retrieved and injected before my replies
428
+ >
429
+ > Want to verify? Tell me a few facts (e.g. "my email is test@example.com"), run `/compact`, then start a new chat and ask "what's my email?" — it should recall.
430
+
431
+ ---
432
+
433
+ # Part 2 — Reference
434
+
435
+ ## How It Works
436
+
437
+ The context-engine pipeline has three distinct stages — keep them apart, especially when telling users when memories actually appear in `~/.openviking/data/`:
438
+
439
+ - **Archive / capture (context-engine `afterTurn`)**: at the end of a user turn, the plugin commits user/assistant messages to the OpenViking session via `POST /api/v1/sessions/.../messages`. This is **archive only** — no memory extraction yet. You'll see session message counts grow on the server, but no new files under `viking://user/.../memories/`.
440
+ - **Memory extraction (on `/compact`)**: memory extraction runs when the user invokes OpenClaw's `/compact` command. The server-side extraction pipeline reads the archived session and writes new memories. The plugin's `after_compaction` hook is currently reserved; the extraction itself is driven by the server. **No `/compact`, no new memory files.**
441
+ - `captureMode: "semantic"` (default): server extraction pipeline filters all qualifying text.
442
+ - `captureMode: "keyword"`: only text matching trigger words (e.g. "remember", "preference") is considered.
443
+ - **Auto-Recall (context-engine `assemble()`)**: before prompt context is assembled, the plugin queries OpenViking for relevant memories and injects them into context. Recall works even when there are no extracted memories yet — you just won't see anything come back.
444
+
445
+ **Practical implication for testing**: if you write down a fact and immediately try to recall it without `/compact`, the plugin will only retrieve it as recent session context (archived messages), not as a long-term memory. To verify long-term memory cross-session, you must run `/compact` first.
446
+
447
+ ## Available Tools
448
+
449
+ These are the plugin tools the agent can call once installed.
450
+
451
+ ### `memory_recall` — Search Memories
452
+
453
+ | Parameter | Required | Description |
454
+ |---|---|---|
455
+ | `query` | Yes | Search query text |
456
+ | `limit` | No | Maximum number of results (defaults to plugin config) |
457
+ | `scoreThreshold` | No | Minimum relevance score 0–1 (defaults to plugin config) |
458
+ | `targetUri` | No | Search scope URI (defaults to plugin config) |
459
+
460
+ Example: user asks "What programming language did I say I like?"
461
+
462
+ ### `memory_store` — Manual Store
463
+
464
+ | Parameter | Required | Description |
465
+ |---|---|---|
466
+ | `text` | Yes | Information text to store |
467
+ | `role` | No | Session role (default `user`) |
468
+ | `sessionId` | No | Existing OpenViking session ID |
469
+
470
+ Example: user says "Remember my email is xxx@example.com".
471
+
472
+ ### `memory_forget` — Delete Memories
473
+
474
+ | Parameter | Required | Description |
475
+ |---|---|---|
476
+ | `uri` | No | Exact memory URI (direct delete) |
477
+ | `query` | No | Search query (find then delete) |
478
+ | `targetUri` | No | Search scope URI |
479
+ | `limit` | No | Search limit (default 5) |
480
+ | `scoreThreshold` | No | Minimum relevance score |
481
+
482
+ Example: user says "Forget my phone number".
483
+
484
+ ## Configuration Schema
485
+
486
+ These are the keys under `plugins.entries.openviking.config` in `openclaw.json`. The setup wizard / `ov-install` sets the first few; the rest are tunables.
487
+
488
+ | Field | Default | Description |
489
+ |---|---|---|
490
+ | `mode` | `"remote"` (forced by plugin) | Always remote in this skill. Don't set manually. |
491
+ | `baseUrl` | `http://127.0.0.1:1933` | OpenViking server URL. |
492
+ | `apiKey` | — | API key. Optional if server has no auth. |
493
+ | `agent_prefix` | `""` | Prefix for routing memories per agent. Letters / digits / `_` / `-`. |
494
+ | `accountId` | — | Required when `apiKey` is a root key. |
495
+ | `userId` | — | Required when `apiKey` is a root key. |
496
+ | `targetUri` | `viking://user/memories` | Default search scope URI. |
497
+ | `timeoutMs` | (plugin default) | HTTP timeout for OpenViking calls. |
498
+ | `autoCapture` | `true` | Auto-archive turn messages to OpenViking session at `afterTurn` (extraction itself runs on `/compact`, not here). |
499
+ | `captureMode` | `"semantic"` | Filter mode used by the server-side extraction pipeline: `semantic` or `keyword`. |
500
+ | `captureMaxLength` | `24000` | Max text length per archived turn. |
501
+ | `autoRecall` | `true` | Auto-recall and inject memories before reply. |
502
+ | `recallLimit` | `6` | Max memories injected per recall. |
503
+ | `recallScoreThreshold` | `0.15` | Min relevance score to inject. |
504
+ | `recallMaxInjectedChars` | (plugin default) | Hard cap on injected character count. |
505
+ | `recallPreferAbstract` | (plugin default) | Prefer abstract memories over raw. |
506
+ | `recallTokenBudget` | (plugin default) | Token budget for injected memories. |
507
+ | `isolateUserScopeByAgent` | (plugin default) | Multi-tenant scoping toggle. |
508
+ | `isolateAgentScopeByUser` | (plugin default) | Multi-tenant scoping toggle. |
509
+ | `agentScopeMode` | (plugin default) | Agent scope strategy. |
510
+ | `bypassSessionPatterns` | — | Glob patterns for sessions skipped by capture. |
511
+ | `ingestReplyAssist` | (plugin default) | Reply-assist ingestion toggle. |
512
+ | `emitStandardDiagnostics` | (plugin default) | Verbose diagnostic logs. |
513
+ | `logFindRequests` | (plugin default) | Log retrieval requests. |
514
+
515
+ To change a value:
516
+
517
+ ```bash
518
+ openclaw config set plugins.entries.openviking.config.<field> <value>
519
+ openclaw gateway restart
520
+ ```
521
+
522
+ ## Multi-Tenant (Root API Keys)
523
+
524
+ Some OpenViking deployments use a single **root** API key shared across tenants. In that case the plugin needs both `accountId` and `userId` so it can scope memories correctly. The setup wizard detects this automatically and returns:
525
+
526
+ ```
527
+ Root API key detected. Missing: --account-id, --user-id
528
+ ```
529
+
530
+ When you see this:
531
+
532
+ 1. Ask the user for both values (they come from the OpenViking admin).
533
+ 2. Retry STEP 7 with both flags:
534
+
535
+ ```bash
536
+ openclaw openviking setup --base-url BASE_URL --api-key API_KEY --account-id ACCOUNT_ID --user-id USER_ID --json
537
+ ```
538
+
539
+ A **user key** (issued per tenant) does not need these flags.
540
+
541
+ ## Multi-Instance (`--workdir` / `OPENCLAW_STATE_DIR`)
542
+
543
+ If the user runs multiple OpenClaw instances (e.g. testing several agents in parallel), each has its own state dir.
544
+
545
+ To target a non-default instance:
546
+
547
+ ```bash
548
+ npx -y openclaw-openviking-setup-helper@latest --workdir ~/.openclaw-second --base-url ... --api-key ...
549
+ ```
550
+
551
+ `ov-install` writes a helper env file when the state dir is non-default:
552
+
553
+ - Unix: `~/.openclaw/openviking.env` containing `export OPENCLAW_STATE_DIR='...'`
554
+ - Windows: `~/.openclaw/openviking.env.bat` and `.ps1` setting the same variable
555
+
556
+ Source it before running `openclaw` commands so they hit the correct state:
557
+
558
+ **Unix:**
559
+ ```bash
560
+ source ~/.openclaw/openviking.env
561
+ openclaw status
562
+ ```
563
+
564
+ **Windows (PowerShell):**
565
+ ```powershell
566
+ . "$HOME/.openclaw/openviking.env.ps1"
567
+ openclaw status
568
+ ```
569
+
570
+ Or pass `--workdir` directly to each `openclaw` invocation (note: not all `openclaw` subcommands honor `--workdir` consistently — when in doubt, prefer the env var).
571
+
572
+ ## Daily Operations
573
+
574
+ ```bash
575
+ # Start or restart OpenClaw gateway after config changes
576
+ openclaw gateway restart
577
+
578
+ # Check overall status
579
+ openclaw status
580
+ openclaw openviking status --json
581
+
582
+ # Read current OpenViking slot
583
+ openclaw config get plugins.slots.contextEngine
584
+
585
+ # Disable OpenViking memory (keep config, deactivate slot)
586
+ openclaw config set plugins.slots.contextEngine legacy
587
+ openclaw gateway restart
588
+
589
+ # Re-enable
590
+ openclaw config set plugins.slots.contextEngine openviking
591
+ openclaw gateway restart
592
+ ```
593
+
594
+ ## Uninstall
595
+
596
+ ### Preferred: via OpenClaw plugin manager
597
+
598
+ ```bash
599
+ openclaw plugins uninstall openviking
600
+ openclaw config set plugins.slots.contextEngine legacy
601
+ openclaw gateway restart
602
+ ```
603
+
604
+ ### If installed through backup `ov-install`
605
+
606
+ ```bash
607
+ npx -y openclaw-openviking-setup-helper@latest --uninstall
608
+ ```
609
+
610
+ This will:
611
+
612
+ 1. Stop the OpenClaw gateway.
613
+ 2. Back up `openclaw.json`.
614
+ 3. Remove all OpenViking plugin config from `openclaw.json` (`plugins.entries.openviking`, `plugins.allow`, `plugins.installs.openviking`, `plugins.slots.contextEngine`).
615
+ 4. Move the plugin directory to `disabled-extensions/` as backup.
616
+ 5. Remove the helper env files (`openviking.env`, `.bat`, `.ps1`).
617
+
618
+ Add `--base-url dummy` for fully non-interactive mode (skips the confirmation prompt).
619
+
620
+ ### Manual
621
+
622
+ ```bash
623
+ openclaw gateway stop
624
+ openclaw config set plugins.slots.contextEngine legacy
625
+ # Then edit ~/.openclaw/openclaw.json and remove openviking from
626
+ # plugins.entries
627
+ # plugins.allow
628
+ # plugins.installs
629
+ openclaw gateway restart
630
+ ```
631
+
632
+ ## Error Recovery Reference
633
+
634
+ Match against actual stderr / JSON `error` strings.
635
+
636
+ | Symptom (exact string) | Likely cause | Fix |
637
+ |---|---|---|
638
+ | `command not found: openclaw` | OpenClaw not installed | Stop. Ask user to install OpenClaw >= 2026.4.8. |
639
+ | `command not found: node` / `'node' is not recognized` | Node missing | Stop. Ask user to install Node.js >= 22. |
640
+ | `429` / `rate limit` / `Too Many Requests` from `plugins install` | ClawHub throttle | Switch to backup Path B (`ov-install`). |
641
+ | `not logged in` / `please log in` from `plugins install` | Anonymous user hit limit | Switch to backup Path B (`ov-install`). |
642
+ | `ECONNREFUSED` / `connection refused` on `BASE_URL/health` | Server not running | Server-not-ready handling in STEP 5. |
643
+ | `ETIMEDOUT` on `BASE_URL/health` | Network blocked | Ask about firewall / VPN / proxy. |
644
+ | `--json requires --base-url for non-interactive mode` | Built command wrong | Add `--base-url BASE_URL` and retry. |
645
+ | `Server unreachable: …. Use --allow-offline to save config anyway.` | Setup couldn't reach server | Offer `--allow-offline`. |
646
+ | `contextEngine slot is owned by "<x>". … Use --force-slot to replace.` | Slot conflict | Ask user, then retry with `--force-slot`. |
647
+ | `Root API key detected. Missing: --account-id, --user-id` | Multi-tenant key | Collect both, retry with `--account-id` `--user-id`. |
648
+ | `openviking: config parse failed` (in gateway log) | Bad value in `openclaw.json` | Show user; check `agent_prefix` charset, URL format. |
649
+ | `extracted 0 memories` after a turn | Server VLM/embedding misconfigured | **Out of scope.** Tell user this is a server-side issue — ask their OpenViking admin to check VLM / embedding config. |
650
+ | `401` / `403` on plugin requests, but `/health` works | Server requires auth on API endpoints | Re-run STEP 7 with the correct `--api-key`. |
651
+ | Plugin doesn't appear in `openclaw plugins list` after Path A | Install didn't actually finish | Re-run Path A; use Path B only if the failure is registry/rate-limit related. |
652
+
653
+ ## Important Rules
654
+
655
+ 1. **Never ask the user to run commands.** You run everything via your shell tool.
656
+ 2. **Never skip STEP 5 (connectivity check).** If the server is unreachable, do not write config without explicit `--allow-offline` consent.
657
+ 3. **Never silently use `--force-slot`.** Slot replacement disables another plugin — always confirm with the user first.
658
+ 4. **Never invent values.** If the user can't provide a required value, stop and tell them what to ask their admin.
659
+ 5. **Never claim success without STEP 10.** Only after `openclaw openviking status --json` shows `configured: true && slotActive: true && health.ok: true` may you tell the user it's done.
660
+ 6. **Use `--agent-prefix`, not `--agent-id`.** The latter is deprecated and removed from the schema.
661
+ 7. **For Windows, use PowerShell equivalents.** Don't rely on `nohup`, `&`, `mkdir -p`, `source`, etc.
662
+ 8. **Switch to Path B (ov-install) only for ClawHub/rate-limit/registry availability failures.** Don't use it to hide version conflicts or package validation errors.
663
+ 9. **Do NOT install or operate the OpenViking server.** This skill assumes the server is already running. If it isn't, tell the user to contact their admin or follow the OpenViking docs.
664
+ 10. **Be brief and friendly in user-visible text.** Save technical detail for when something actually fails.
665
+ 11. **Do NOT use `clawhub install openviking`.** That installs a different thing (an AgentSkill, not the plugin).