@openviking/openclaw-plugin 2026.6.2 → 2026.6.17-dev.2
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/INSTALL-AGENT.md +4 -4
- package/INSTALL-ZH.md +68 -8
- package/INSTALL.md +12 -8
- package/README.md +45 -35
- package/adapters/http-transport.ts +3 -0
- package/adapters/resource-packager.ts +141 -0
- package/auto-recall.ts +258 -27
- package/client.ts +201 -177
- package/commands/setup.ts +200 -33
- package/config/feature-gates.json +10 -0
- package/config.ts +428 -85
- package/context-engine.ts +71 -1402
- package/dist/adapters/http-transport.js +1 -0
- package/dist/adapters/resource-packager.js +114 -0
- package/dist/auto-recall.js +201 -25
- package/dist/client.js +125 -161
- package/dist/commands/setup.js +170 -32
- package/dist/config.js +285 -64
- package/dist/context-engine.js +62 -1173
- package/dist/index.js +209 -1489
- package/dist/memory-ranking.js +35 -12
- package/dist/plugin/command-registration.js +5 -0
- package/dist/plugin/openviking-archive-tools.js +210 -0
- package/dist/plugin/openviking-bypass-runtime.js +8 -0
- package/dist/plugin/openviking-client-runtime.js +28 -0
- package/dist/plugin/openviking-command-args.js +146 -0
- package/dist/plugin/openviking-command-definitions.js +206 -0
- package/dist/plugin/openviking-context-engine-ref.js +11 -0
- package/dist/plugin/openviking-context-engine-registration.js +23 -0
- package/dist/plugin/openviking-feature-gates.js +250 -0
- package/dist/plugin/openviking-import-runtime.js +50 -0
- package/dist/plugin/openviking-import-tools.js +86 -0
- package/dist/plugin/openviking-lifecycle-hooks.js +33 -0
- package/dist/plugin/openviking-memory-recall-tools.js +233 -0
- package/dist/plugin/openviking-memory-tools.js +199 -0
- package/dist/plugin/openviking-query-config-command.js +203 -0
- package/dist/plugin/openviking-query-runtime.js +367 -0
- package/dist/plugin/openviking-query-tools.js +91 -0
- package/dist/plugin/openviking-recall-trace-runtime.js +387 -0
- package/dist/plugin/openviking-recall-trace-tools.js +38 -0
- package/dist/plugin/openviking-runtime-state.js +26 -0
- package/dist/plugin/openviking-runtime-utils.js +62 -0
- package/dist/plugin/openviking-services.js +20 -0
- package/dist/plugin/openviking-session-routing-runtime.js +61 -0
- package/dist/plugin/openviking-tool-result-tools.js +268 -0
- package/dist/plugin/recall-trace-routes.js +77 -0
- package/dist/plugin/tool-registration.js +23 -0
- package/dist/process-manager.js +1 -1
- package/dist/query-config.js +336 -0
- package/dist/recall-trace.js +309 -0
- package/dist/registries/recall-resource-types.js +58 -0
- package/dist/routing/identity-routing.js +152 -0
- package/dist/routing/memory-uri.js +7 -0
- package/dist/services/context-lifecycle-service.js +847 -0
- package/dist/services/context-message-adapter.js +340 -0
- package/dist/session-transcript-repair.js +0 -1
- package/dist/text-utils.js +14 -31
- package/index.ts +271 -1873
- package/install-manifest.json +10 -1
- package/memory-ranking.ts +46 -10
- package/openclaw.plugin.json +198 -36
- package/package.json +14 -4
- package/plugin/command-registration.ts +34 -0
- package/plugin/openviking-archive-tools.ts +301 -0
- package/plugin/openviking-bypass-runtime.ts +26 -0
- package/plugin/openviking-client-runtime.ts +74 -0
- package/plugin/openviking-command-args.ts +187 -0
- package/plugin/openviking-command-definitions.ts +294 -0
- package/plugin/openviking-context-engine-ref.ts +16 -0
- package/plugin/openviking-context-engine-registration.ts +97 -0
- package/plugin/openviking-feature-gates.ts +335 -0
- package/plugin/openviking-import-runtime.ts +105 -0
- package/plugin/openviking-import-tools.ts +133 -0
- package/plugin/openviking-lifecycle-hooks.ts +65 -0
- package/plugin/openviking-memory-recall-tools.ts +368 -0
- package/plugin/openviking-memory-tools.ts +299 -0
- package/plugin/openviking-query-config-command.ts +230 -0
- package/plugin/openviking-query-formatters.ts +108 -0
- package/plugin/openviking-query-runtime.ts +476 -0
- package/plugin/openviking-query-tools.ts +161 -0
- package/plugin/openviking-recall-trace-runtime.ts +482 -0
- package/plugin/openviking-recall-trace-tools.ts +99 -0
- package/plugin/openviking-runtime-state.ts +52 -0
- package/plugin/openviking-runtime-utils.ts +67 -0
- package/plugin/openviking-services.ts +49 -0
- package/plugin/openviking-session-routing-runtime.ts +105 -0
- package/plugin/openviking-tool-result-tools.ts +397 -0
- package/plugin/recall-trace-routes.ts +133 -0
- package/plugin/tool-registration.ts +51 -0
- package/process-manager.ts +1 -1
- package/query-config.ts +400 -0
- package/recall-trace.ts +442 -0
- package/registries/openviking-tools.ts +84 -0
- package/registries/recall-resource-types.ts +74 -0
- package/routing/identity-routing.ts +210 -0
- package/routing/memory-uri.ts +8 -0
- package/services/context-lifecycle-service.ts +1209 -0
- package/services/context-message-adapter.ts +375 -0
- package/services/setup/config-writer.ts +125 -0
- package/services/setup/exit-utils.ts +5 -0
- package/services/setup/package-metadata.ts +56 -0
- package/services/setup/probe-service.ts +143 -0
- package/services/setup/setup-flow.ts +306 -0
- package/services/setup/version-compatibility.ts +41 -0
- package/session-transcript-repair.ts +0 -2
- package/skills/install-openviking-memory/SKILL.md +123 -50
- package/skills/openviking-context-database/SKILL.md +286 -0
- package/text-utils.ts +15 -34
package/dist/config.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
1
2
|
import { getEnv } from "./runtime-utils.js";
|
|
2
3
|
const DEFAULT_BASE_URL = "http://127.0.0.1:1933";
|
|
3
4
|
const DEFAULT_TARGET_URI = "viking://user/memories";
|
|
4
5
|
const DEFAULT_TIMEOUT_MS = 15000;
|
|
5
6
|
const DEFAULT_CAPTURE_MODE = "semantic";
|
|
6
7
|
const DEFAULT_CAPTURE_MAX_LENGTH = 24000;
|
|
8
|
+
const DEFAULT_AUTO_RECALL_TIMEOUT_MS = 5000;
|
|
7
9
|
const DEFAULT_RECALL_LIMIT = 6;
|
|
8
10
|
const DEFAULT_RECALL_SCORE_THRESHOLD = 0.15;
|
|
9
11
|
const DEFAULT_RECALL_MAX_CONTENT_CHARS = 5000;
|
|
@@ -13,13 +15,79 @@ const DEFAULT_COMMIT_TOKEN_THRESHOLD = 20000;
|
|
|
13
15
|
const DEFAULT_COMMIT_KEEP_RECENT_COUNT = 10;
|
|
14
16
|
const DEFAULT_BYPASS_SESSION_PATTERNS = [];
|
|
15
17
|
const DEFAULT_EMIT_STANDARD_DIAGNOSTICS = false;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
+
const DEFAULT_PEER_ROLE = "assistant";
|
|
19
|
+
const DEFAULT_PEER_PREFIX = "";
|
|
20
|
+
const DEFAULT_TRACE_RECALL_DIR = "~/.openclaw/openviking/recall-traces";
|
|
21
|
+
const DEFAULT_TRACE_RECALL_RETENTION_DAYS = 14;
|
|
22
|
+
const DEFAULT_TRACE_RECALL_LOAD_RECENT_DAYS = 2;
|
|
23
|
+
const DEFAULT_TRACE_RECALL_MAX_ENTRIES = 1000;
|
|
24
|
+
const DEFAULT_TRACE_RECALL_MAX_RESULTS_PER_SEARCH = 20;
|
|
25
|
+
const DEFAULT_TRACE_RECALL_PREVIEW_CHARS = 240;
|
|
26
|
+
const DEFAULT_TRACE_RECALL_QUERY_MAX_CHARS = 4000;
|
|
27
|
+
const DEFAULT_TRACE_RECALL_QUERY_MAX_DAYS = 14;
|
|
28
|
+
const ALLOWED_RECALL_TARGET_TYPES = ["resource", "user", "agent"];
|
|
29
|
+
const DEFAULT_RECALL_TARGET_TYPES = ["user", "agent"];
|
|
30
|
+
export const OPENVIKING_ADD_RESOURCE_TOOL_NAME = "add_resource";
|
|
31
|
+
export const OPENVIKING_DEFAULT_ENABLED_TOOL_NAMES = [
|
|
32
|
+
"add_skill",
|
|
33
|
+
"ov_search",
|
|
34
|
+
"ov_read",
|
|
35
|
+
"ov_multi_read",
|
|
36
|
+
"ov_list",
|
|
37
|
+
"memory_recall",
|
|
38
|
+
"ov_recall_trace",
|
|
39
|
+
"memory_store",
|
|
40
|
+
"memory_forget",
|
|
41
|
+
"ov_archive_search",
|
|
42
|
+
"ov_archive_expand",
|
|
43
|
+
"openviking_tool_result_read",
|
|
44
|
+
"openviking_tool_result_search",
|
|
45
|
+
"openviking_tool_result_list",
|
|
46
|
+
];
|
|
47
|
+
export const OPENVIKING_ALL_TOOL_NAMES = [
|
|
48
|
+
OPENVIKING_ADD_RESOURCE_TOOL_NAME,
|
|
49
|
+
...OPENVIKING_DEFAULT_ENABLED_TOOL_NAMES,
|
|
50
|
+
];
|
|
51
|
+
export const OPENVIKING_TOOL_GROUPS = {
|
|
52
|
+
all: OPENVIKING_ALL_TOOL_NAMES,
|
|
53
|
+
default: OPENVIKING_DEFAULT_ENABLED_TOOL_NAMES,
|
|
54
|
+
memory: ["memory_recall", "memory_store", "memory_forget"],
|
|
55
|
+
resource_query: ["ov_search", "ov_read", "ov_multi_read", "ov_list"],
|
|
56
|
+
import: ["add_resource", "add_skill"],
|
|
57
|
+
recall_trace: ["ov_recall_trace"],
|
|
58
|
+
archive: ["ov_archive_search", "ov_archive_expand"],
|
|
59
|
+
tool_result: [
|
|
60
|
+
"openviking_tool_result_read",
|
|
61
|
+
"openviking_tool_result_search",
|
|
62
|
+
"openviking_tool_result_list",
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
const DEFAULT_AGENT_EXPERIENCE = {
|
|
66
|
+
enabled: false,
|
|
67
|
+
recallLimit: 3,
|
|
68
|
+
scoreThreshold: 0.35,
|
|
69
|
+
maxInjectedChars: 6000,
|
|
70
|
+
minQueryChars: 12,
|
|
71
|
+
};
|
|
72
|
+
function resolvePeerPrefix(configured) {
|
|
18
73
|
if (typeof configured === "string" && configured.trim()) {
|
|
19
74
|
const trimmed = configured.trim();
|
|
20
|
-
return trimmed === "default" ?
|
|
75
|
+
return trimmed === "default" ? DEFAULT_PEER_PREFIX : trimmed;
|
|
76
|
+
}
|
|
77
|
+
return DEFAULT_PEER_PREFIX;
|
|
78
|
+
}
|
|
79
|
+
function resolvePeerRole(configured) {
|
|
80
|
+
if (typeof configured === "string") {
|
|
81
|
+
const role = configured.trim().toLowerCase();
|
|
82
|
+
if (role === "none" || role === "assistant" || role === "person") {
|
|
83
|
+
return role;
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`openviking peer_role must be "none", "assistant", or "person"`);
|
|
86
|
+
}
|
|
87
|
+
if (configured !== undefined) {
|
|
88
|
+
throw new Error(`openviking peer_role must be "none", "assistant", or "person"`);
|
|
21
89
|
}
|
|
22
|
-
return
|
|
90
|
+
return DEFAULT_PEER_ROLE;
|
|
23
91
|
}
|
|
24
92
|
function resolveEnvVars(value) {
|
|
25
93
|
return value.replace(/\$\{([^}]+)\}/g, (_, envVar) => {
|
|
@@ -30,6 +98,15 @@ function resolveEnvVars(value) {
|
|
|
30
98
|
return envValue;
|
|
31
99
|
});
|
|
32
100
|
}
|
|
101
|
+
function expandHomeDir(value) {
|
|
102
|
+
if (value === "~") {
|
|
103
|
+
return homedir();
|
|
104
|
+
}
|
|
105
|
+
if (value.startsWith("~/")) {
|
|
106
|
+
return `${homedir()}${value.slice(1)}`;
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
33
110
|
function toNumber(value, fallback) {
|
|
34
111
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
35
112
|
return value;
|
|
@@ -57,6 +134,86 @@ function toStringArray(value, fallback) {
|
|
|
57
134
|
}
|
|
58
135
|
return fallback;
|
|
59
136
|
}
|
|
137
|
+
function toIntegerInRange(value, fallback, min, max) {
|
|
138
|
+
return Math.max(min, Math.min(max, Math.floor(toNumber(value, fallback))));
|
|
139
|
+
}
|
|
140
|
+
function normalizeRecallTargetTypes(value, includeResources = false) {
|
|
141
|
+
const entries = toStringArray(value, [...DEFAULT_RECALL_TARGET_TYPES]);
|
|
142
|
+
const seen = new Set();
|
|
143
|
+
const normalized = [];
|
|
144
|
+
const unknown = [];
|
|
145
|
+
for (const entry of entries) {
|
|
146
|
+
if (ALLOWED_RECALL_TARGET_TYPES.includes(entry)) {
|
|
147
|
+
const typed = entry;
|
|
148
|
+
if (!seen.has(typed)) {
|
|
149
|
+
seen.add(typed);
|
|
150
|
+
normalized.push(typed);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
unknown.push(entry);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (unknown.length > 0) {
|
|
158
|
+
throw new Error(`openviking recallTargetTypes contains unknown resource types: ${unknown.join(", ")}`);
|
|
159
|
+
}
|
|
160
|
+
const result = normalized.length > 0 ? normalized : [...DEFAULT_RECALL_TARGET_TYPES];
|
|
161
|
+
if (includeResources && !seen.has("resource")) {
|
|
162
|
+
result.push("resource");
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
function toRecord(value) {
|
|
167
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
168
|
+
? value
|
|
169
|
+
: {};
|
|
170
|
+
}
|
|
171
|
+
function expandToolSelectors(value, fallback, label) {
|
|
172
|
+
const entries = toStringArray(value, fallback);
|
|
173
|
+
const seen = new Set();
|
|
174
|
+
const normalized = [];
|
|
175
|
+
const unknown = [];
|
|
176
|
+
for (const rawEntry of entries) {
|
|
177
|
+
const entry = rawEntry.trim();
|
|
178
|
+
const group = OPENVIKING_TOOL_GROUPS[entry];
|
|
179
|
+
const tools = group ??
|
|
180
|
+
(OPENVIKING_ALL_TOOL_NAMES.includes(entry)
|
|
181
|
+
? [entry]
|
|
182
|
+
: undefined);
|
|
183
|
+
if (!tools) {
|
|
184
|
+
unknown.push(entry);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
for (const tool of tools) {
|
|
188
|
+
if (!seen.has(tool)) {
|
|
189
|
+
seen.add(tool);
|
|
190
|
+
normalized.push(tool);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (unknown.length > 0) {
|
|
195
|
+
throw new Error(`openviking ${label} contains unknown tool selectors: ${unknown.join(", ")}`);
|
|
196
|
+
}
|
|
197
|
+
return normalized;
|
|
198
|
+
}
|
|
199
|
+
function normalizeEnabledTools(cfg) {
|
|
200
|
+
const enableAddResourceTool = cfg.enableAddResourceTool === true;
|
|
201
|
+
const defaultTools = enableAddResourceTool
|
|
202
|
+
? [OPENVIKING_ADD_RESOURCE_TOOL_NAME, ...OPENVIKING_DEFAULT_ENABLED_TOOL_NAMES]
|
|
203
|
+
: [...OPENVIKING_DEFAULT_ENABLED_TOOL_NAMES];
|
|
204
|
+
const selected = expandToolSelectors(cfg.enabledTools, defaultTools, "enabledTools");
|
|
205
|
+
const disabled = expandToolSelectors(cfg.disabledTools, [], "disabledTools");
|
|
206
|
+
const disabledSet = new Set(disabled);
|
|
207
|
+
if (!enableAddResourceTool) {
|
|
208
|
+
disabledSet.add(OPENVIKING_ADD_RESOURCE_TOOL_NAME);
|
|
209
|
+
}
|
|
210
|
+
const enabledTools = selected.filter((tool) => !disabledSet.has(tool) &&
|
|
211
|
+
(tool !== OPENVIKING_ADD_RESOURCE_TOOL_NAME || enableAddResourceTool));
|
|
212
|
+
return {
|
|
213
|
+
enabledTools,
|
|
214
|
+
disabledTools: Array.from(disabledSet),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
60
217
|
/** True when env is 1 / true / yes (case-insensitive). Used for debug flags without editing plugin JSON. */
|
|
61
218
|
function envFlag(name) {
|
|
62
219
|
const v = getEnv(name);
|
|
@@ -86,30 +243,22 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
86
243
|
value = {};
|
|
87
244
|
}
|
|
88
245
|
const cfg = value;
|
|
89
|
-
if ("agentId" in cfg) {
|
|
90
|
-
if (!("agent_prefix" in cfg)) {
|
|
91
|
-
cfg.agent_prefix = cfg.agentId;
|
|
92
|
-
}
|
|
93
|
-
delete cfg.agentId;
|
|
94
|
-
}
|
|
95
246
|
assertAllowedKeys(cfg, [
|
|
96
247
|
"mode",
|
|
97
248
|
"baseUrl",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
249
|
+
"peer_role",
|
|
250
|
+
"peer_prefix",
|
|
100
251
|
"serverAuthMode",
|
|
101
252
|
"apiKey",
|
|
102
253
|
"accountId",
|
|
103
254
|
"userId",
|
|
104
|
-
"isolateUserScopeByAgent",
|
|
105
|
-
"isolateAgentScopeByUser",
|
|
106
|
-
"agentScopeMode",
|
|
107
255
|
"targetUri",
|
|
108
256
|
"timeoutMs",
|
|
109
257
|
"autoCapture",
|
|
110
258
|
"captureMode",
|
|
111
259
|
"captureMaxLength",
|
|
112
260
|
"autoRecall",
|
|
261
|
+
"autoRecallTimeoutMs",
|
|
113
262
|
"recallResources",
|
|
114
263
|
"recallLimit",
|
|
115
264
|
"recallScoreThreshold",
|
|
@@ -126,8 +275,30 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
126
275
|
"ingestReplyAssistIgnoreSessionPatterns",
|
|
127
276
|
"emitStandardDiagnostics",
|
|
128
277
|
"logFindRequests",
|
|
278
|
+
"traceRecall",
|
|
279
|
+
"traceRecallPersist",
|
|
280
|
+
"traceRecallDir",
|
|
281
|
+
"traceRecallRetentionDays",
|
|
282
|
+
"traceRecallLoadRecentDays",
|
|
283
|
+
"traceRecallMaxEntries",
|
|
284
|
+
"traceRecallMaxResultsPerSearch",
|
|
285
|
+
"traceRecallPreviewChars",
|
|
286
|
+
"traceRecallQueryMaxChars",
|
|
287
|
+
"traceRecallQueryMaxDays",
|
|
288
|
+
"traceRecallIncludeContentByDefault",
|
|
289
|
+
"traceRecallIncludeRawUserPreview",
|
|
290
|
+
"recallTargetTypes",
|
|
291
|
+
"enableAddResourceTool",
|
|
292
|
+
"enabledTools",
|
|
293
|
+
"disabledTools",
|
|
294
|
+
"runtimeQueryConfigPath",
|
|
295
|
+
"agentExperience",
|
|
129
296
|
], "openviking config");
|
|
297
|
+
const agentExperienceRaw = toRecord(cfg.agentExperience);
|
|
298
|
+
assertAllowedKeys(agentExperienceRaw, ["enabled", "recallLimit", "scoreThreshold", "maxInjectedChars", "minQueryChars"], "openviking config agentExperience");
|
|
130
299
|
const mode = "remote";
|
|
300
|
+
const peerRole = resolvePeerRole(cfg.peer_role);
|
|
301
|
+
const peerPrefix = resolvePeerPrefix(cfg.peer_prefix);
|
|
131
302
|
const rawBaseUrl = typeof cfg.baseUrl === "string" ? cfg.baseUrl : resolveDefaultBaseUrl();
|
|
132
303
|
const resolvedBaseUrl = resolveEnvVars(rawBaseUrl).replace(/\/+$/, "");
|
|
133
304
|
const rawApiKey = typeof cfg.apiKey === "string" ? cfg.apiKey : getEnv("OPENVIKING_API_KEY");
|
|
@@ -143,47 +314,26 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
143
314
|
const userId = typeof cfg.userId === "string" && cfg.userId.trim()
|
|
144
315
|
? cfg.userId.trim()
|
|
145
316
|
: (getEnv("OPENVIKING_USER_ID")?.trim() || "");
|
|
146
|
-
const hasExplicitAgentScopeMode = typeof cfg.agentScopeMode === "string" || getEnv("OPENVIKING_AGENT_SCOPE_MODE") !== undefined;
|
|
147
|
-
const rawAgentScope = cfg.agentScopeMode ?? getEnv("OPENVIKING_AGENT_SCOPE_MODE");
|
|
148
|
-
const agentScopeMode = rawAgentScope === "user_agent" ? "user_agent" : "agent";
|
|
149
|
-
const explicitIsolateUserScopeByAgent = typeof cfg.isolateUserScopeByAgent === "boolean"
|
|
150
|
-
? cfg.isolateUserScopeByAgent
|
|
151
|
-
: undefined;
|
|
152
|
-
const explicitIsolateAgentScopeByUser = typeof cfg.isolateAgentScopeByUser === "boolean"
|
|
153
|
-
? cfg.isolateAgentScopeByUser
|
|
154
|
-
: undefined;
|
|
155
|
-
const envIsolateUserScopeByAgent = explicitIsolateUserScopeByAgent === undefined &&
|
|
156
|
-
getEnv("OPENVIKING_ISOLATE_USER_SCOPE_BY_AGENT") !== undefined
|
|
157
|
-
? envFlag("OPENVIKING_ISOLATE_USER_SCOPE_BY_AGENT")
|
|
158
|
-
: undefined;
|
|
159
|
-
const envIsolateAgentScopeByUser = explicitIsolateAgentScopeByUser === undefined &&
|
|
160
|
-
getEnv("OPENVIKING_ISOLATE_AGENT_SCOPE_BY_USER") !== undefined
|
|
161
|
-
? envFlag("OPENVIKING_ISOLATE_AGENT_SCOPE_BY_USER")
|
|
162
|
-
: undefined;
|
|
163
|
-
const isolateUserScopeByAgent = explicitIsolateUserScopeByAgent ??
|
|
164
|
-
envIsolateUserScopeByAgent ??
|
|
165
|
-
false;
|
|
166
|
-
const isolateAgentScopeByUser = explicitIsolateAgentScopeByUser ??
|
|
167
|
-
envIsolateAgentScopeByUser ??
|
|
168
|
-
(hasExplicitAgentScopeMode && agentScopeMode === "user_agent" ? true : false);
|
|
169
317
|
const recallMaxInjectedChars = Math.max(100, Math.min(50000, Math.floor(toNumber(cfg.recallMaxInjectedChars, toNumber(cfg.recallTokenBudget, DEFAULT_RECALL_MAX_INJECTED_CHARS)))));
|
|
318
|
+
const recallResources = cfg.recallResources === true || envFlag("OPENVIKING_RECALL_RESOURCES");
|
|
319
|
+
const recallTargetTypes = normalizeRecallTargetTypes(cfg.recallTargetTypes, !("recallTargetTypes" in cfg) && recallResources);
|
|
320
|
+
const { enabledTools, disabledTools } = normalizeEnabledTools(cfg);
|
|
170
321
|
return {
|
|
171
322
|
mode,
|
|
172
323
|
baseUrl: resolvedBaseUrl,
|
|
173
|
-
|
|
324
|
+
peer_role: peerRole,
|
|
325
|
+
peer_prefix: peerPrefix,
|
|
174
326
|
apiKey: rawApiKey ? resolveEnvVars(rawApiKey) : "",
|
|
175
327
|
accountId,
|
|
176
328
|
userId,
|
|
177
|
-
isolateUserScopeByAgent,
|
|
178
|
-
isolateAgentScopeByUser,
|
|
179
|
-
agentScopeMode,
|
|
180
329
|
targetUri: typeof cfg.targetUri === "string" ? cfg.targetUri : DEFAULT_TARGET_URI,
|
|
181
330
|
timeoutMs: Math.max(1000, Math.floor(toNumber(cfg.timeoutMs, DEFAULT_TIMEOUT_MS))),
|
|
182
331
|
autoCapture: cfg.autoCapture !== false,
|
|
183
332
|
captureMode: captureMode ?? DEFAULT_CAPTURE_MODE,
|
|
184
333
|
captureMaxLength: Math.max(200, Math.min(200_000, Math.floor(toNumber(cfg.captureMaxLength, DEFAULT_CAPTURE_MAX_LENGTH)))),
|
|
185
334
|
autoRecall: cfg.autoRecall !== false,
|
|
186
|
-
|
|
335
|
+
autoRecallTimeoutMs: Math.max(1000, Math.min(300_000, Math.floor(toNumber(cfg.autoRecallTimeoutMs, DEFAULT_AUTO_RECALL_TIMEOUT_MS)))),
|
|
336
|
+
recallResources,
|
|
187
337
|
recallLimit: Math.max(1, Math.floor(toNumber(cfg.recallLimit, DEFAULT_RECALL_LIMIT))),
|
|
188
338
|
recallScoreThreshold: Math.min(1, Math.max(0, toNumber(cfg.recallScoreThreshold, DEFAULT_RECALL_SCORE_THRESHOLD))),
|
|
189
339
|
recallMaxContentChars: Math.max(50, Math.min(10000, Math.floor(toNumber(cfg.recallMaxContentChars, DEFAULT_RECALL_MAX_CONTENT_CHARS)))),
|
|
@@ -201,6 +351,36 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
201
351
|
logFindRequests: cfg.logFindRequests === true ||
|
|
202
352
|
envFlag("OPENVIKING_LOG_ROUTING") ||
|
|
203
353
|
envFlag("OPENVIKING_DEBUG"),
|
|
354
|
+
traceRecall: cfg.traceRecall === true,
|
|
355
|
+
traceRecallPersist: cfg.traceRecallPersist === true,
|
|
356
|
+
traceRecallDir: typeof cfg.traceRecallDir === "string" && cfg.traceRecallDir.trim()
|
|
357
|
+
? expandHomeDir(cfg.traceRecallDir.trim())
|
|
358
|
+
: expandHomeDir(DEFAULT_TRACE_RECALL_DIR),
|
|
359
|
+
traceRecallRetentionDays: toIntegerInRange(cfg.traceRecallRetentionDays, DEFAULT_TRACE_RECALL_RETENTION_DAYS, 1, 3650),
|
|
360
|
+
traceRecallLoadRecentDays: toIntegerInRange(cfg.traceRecallLoadRecentDays, DEFAULT_TRACE_RECALL_LOAD_RECENT_DAYS, 0, 3650),
|
|
361
|
+
traceRecallMaxEntries: toIntegerInRange(cfg.traceRecallMaxEntries, DEFAULT_TRACE_RECALL_MAX_ENTRIES, 1, 1_000_000),
|
|
362
|
+
traceRecallMaxResultsPerSearch: toIntegerInRange(cfg.traceRecallMaxResultsPerSearch, DEFAULT_TRACE_RECALL_MAX_RESULTS_PER_SEARCH, 1, 1_000),
|
|
363
|
+
traceRecallPreviewChars: toIntegerInRange(cfg.traceRecallPreviewChars, DEFAULT_TRACE_RECALL_PREVIEW_CHARS, 20, 10_000),
|
|
364
|
+
traceRecallQueryMaxChars: toIntegerInRange(cfg.traceRecallQueryMaxChars, DEFAULT_TRACE_RECALL_QUERY_MAX_CHARS, 200, 200_000),
|
|
365
|
+
traceRecallQueryMaxDays: toIntegerInRange(cfg.traceRecallQueryMaxDays, DEFAULT_TRACE_RECALL_QUERY_MAX_DAYS, 1, 3650),
|
|
366
|
+
traceRecallIncludeContentByDefault: cfg.traceRecallIncludeContentByDefault === true,
|
|
367
|
+
traceRecallIncludeRawUserPreview: cfg.traceRecallIncludeRawUserPreview === true,
|
|
368
|
+
recallTargetTypes,
|
|
369
|
+
enableAddResourceTool: cfg.enableAddResourceTool === true,
|
|
370
|
+
enabledTools,
|
|
371
|
+
disabledTools,
|
|
372
|
+
runtimeQueryConfigPath: typeof cfg.runtimeQueryConfigPath === "string" && cfg.runtimeQueryConfigPath.trim()
|
|
373
|
+
? expandHomeDir(cfg.runtimeQueryConfigPath.trim())
|
|
374
|
+
: "",
|
|
375
|
+
agentExperience: {
|
|
376
|
+
enabled: typeof agentExperienceRaw.enabled === "boolean"
|
|
377
|
+
? agentExperienceRaw.enabled
|
|
378
|
+
: DEFAULT_AGENT_EXPERIENCE.enabled,
|
|
379
|
+
recallLimit: Math.max(1, Math.min(10, Math.floor(toNumber(agentExperienceRaw.recallLimit, DEFAULT_AGENT_EXPERIENCE.recallLimit)))),
|
|
380
|
+
scoreThreshold: Math.min(1, Math.max(0, toNumber(agentExperienceRaw.scoreThreshold, DEFAULT_AGENT_EXPERIENCE.scoreThreshold))),
|
|
381
|
+
maxInjectedChars: Math.max(500, Math.min(50_000, Math.floor(toNumber(agentExperienceRaw.maxInjectedChars, DEFAULT_AGENT_EXPERIENCE.maxInjectedChars)))),
|
|
382
|
+
minQueryChars: Math.max(1, Math.min(500, Math.floor(toNumber(agentExperienceRaw.minQueryChars, DEFAULT_AGENT_EXPERIENCE.minQueryChars)))),
|
|
383
|
+
},
|
|
204
384
|
};
|
|
205
385
|
},
|
|
206
386
|
uiHints: {
|
|
@@ -209,10 +389,15 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
209
389
|
placeholder: DEFAULT_BASE_URL,
|
|
210
390
|
help: "HTTP URL when mode is remote (or use ${OPENVIKING_BASE_URL})",
|
|
211
391
|
},
|
|
212
|
-
|
|
213
|
-
label: "
|
|
392
|
+
peer_role: {
|
|
393
|
+
label: "Peer Role",
|
|
394
|
+
placeholder: DEFAULT_PEER_ROLE,
|
|
395
|
+
help: 'Controls which session messages get peer_id: "none", "assistant", or "person".',
|
|
396
|
+
},
|
|
397
|
+
peer_prefix: {
|
|
398
|
+
label: "Peer Prefix",
|
|
214
399
|
placeholder: "optional-prefix",
|
|
215
|
-
help:
|
|
400
|
+
help: "Optional prefix applied to assistant peer_id values derived from OpenClaw runtime agent IDs.",
|
|
216
401
|
},
|
|
217
402
|
apiKey: {
|
|
218
403
|
label: "OpenViking API Key",
|
|
@@ -232,24 +417,6 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
232
417
|
help: "Advanced option. Tenant user ID. Only needed when explicitly sending identity headers.",
|
|
233
418
|
advanced: true,
|
|
234
419
|
},
|
|
235
|
-
isolateUserScopeByAgent: {
|
|
236
|
-
label: "Isolate User Scope By Agent",
|
|
237
|
-
placeholder: "false",
|
|
238
|
-
help: "Canonical namespace policy. false (default): user alias expands to viking://user/<user_id>/... . true: expands to viking://user/<user_id>/agent/<agent_id>/... . Must match the server-side account namespace policy.",
|
|
239
|
-
advanced: true,
|
|
240
|
-
},
|
|
241
|
-
isolateAgentScopeByUser: {
|
|
242
|
-
label: "Isolate Agent Scope By User",
|
|
243
|
-
placeholder: "false",
|
|
244
|
-
help: "Canonical namespace policy. false (default): agent alias expands to viking://agent/<agent_id>/... . true: expands to viking://agent/<agent_id>/user/<user_id>/... . Must match the server-side account namespace policy.",
|
|
245
|
-
advanced: true,
|
|
246
|
-
},
|
|
247
|
-
agentScopeMode: {
|
|
248
|
-
label: "Deprecated Agent Scope Mode",
|
|
249
|
-
placeholder: "agent",
|
|
250
|
-
help: 'Deprecated compatibility alias for older routing behavior. Prefer isolateUserScopeByAgent / isolateAgentScopeByUser. Mapping: explicit "user_agent" => false/true, explicit "agent" => false/false. When fully unset, the plugin defaults to false/false to match the current server-side default policy.',
|
|
251
|
-
advanced: true,
|
|
252
|
-
},
|
|
253
420
|
targetUri: {
|
|
254
421
|
label: "Search Target URI",
|
|
255
422
|
placeholder: DEFAULT_TARGET_URI,
|
|
@@ -280,11 +447,23 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
280
447
|
label: "Auto-Recall",
|
|
281
448
|
help: "Inject relevant OpenViking memories into agent context",
|
|
282
449
|
},
|
|
450
|
+
autoRecallTimeoutMs: {
|
|
451
|
+
label: "Auto-Recall Timeout (ms)",
|
|
452
|
+
placeholder: String(DEFAULT_AUTO_RECALL_TIMEOUT_MS),
|
|
453
|
+
advanced: true,
|
|
454
|
+
help: "Outer time budget for the whole auto-recall flow, including search, ranking, and memory reads.",
|
|
455
|
+
},
|
|
283
456
|
recallResources: {
|
|
284
457
|
label: "Recall Resources",
|
|
285
458
|
help: "Include resources (viking://resources) in auto-recall and default memory_recall search. Enables account-level shared knowledge retrieval.",
|
|
286
459
|
advanced: true,
|
|
287
460
|
},
|
|
461
|
+
recallTargetTypes: {
|
|
462
|
+
label: "Recall Target Types",
|
|
463
|
+
placeholder: "user,agent",
|
|
464
|
+
help: "Comma-separated auto-recall and default memory_recall targets: user, agent, resource. Session history is available through ov_archive_search and ov_archive_expand.",
|
|
465
|
+
advanced: true,
|
|
466
|
+
},
|
|
288
467
|
recallLimit: {
|
|
289
468
|
label: "Recall Limit",
|
|
290
469
|
placeholder: String(DEFAULT_RECALL_LIMIT),
|
|
@@ -348,5 +527,47 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
348
527
|
"Or set env OPENVIKING_LOG_ROUTING=1 or OPENVIKING_DEBUG=1 (no JSON edit).",
|
|
349
528
|
advanced: true,
|
|
350
529
|
},
|
|
530
|
+
traceRecall: {
|
|
531
|
+
label: "Trace Recall",
|
|
532
|
+
placeholder: "false",
|
|
533
|
+
help: "Enable best-effort recall trace recording for debugging recall and search decisions.",
|
|
534
|
+
advanced: true,
|
|
535
|
+
},
|
|
536
|
+
traceRecallPersist: {
|
|
537
|
+
label: "Persist Recall Trace",
|
|
538
|
+
placeholder: "false",
|
|
539
|
+
help: "Persist recall traces to local JSONL files. Disabled by default.",
|
|
540
|
+
advanced: true,
|
|
541
|
+
},
|
|
542
|
+
traceRecallDir: {
|
|
543
|
+
label: "Recall Trace Directory",
|
|
544
|
+
placeholder: DEFAULT_TRACE_RECALL_DIR,
|
|
545
|
+
help: "Directory for persisted recall trace JSONL files.",
|
|
546
|
+
advanced: true,
|
|
547
|
+
},
|
|
548
|
+
enableAddResourceTool: {
|
|
549
|
+
label: "Enable Add Resource Tool",
|
|
550
|
+
placeholder: "false",
|
|
551
|
+
help: "Disabled by default so search and read flows cannot call add_resource. Set true only when agents should import resources; manual /add-resource remains available.",
|
|
552
|
+
advanced: true,
|
|
553
|
+
},
|
|
554
|
+
enabledTools: {
|
|
555
|
+
label: "Enabled Tools",
|
|
556
|
+
placeholder: "default",
|
|
557
|
+
help: "Agent-visible tool allowlist. Accepts tool names or groups: default, all, memory, resource_query, import, recall_trace, archive, tool_result. add_resource also requires enableAddResourceTool=true.",
|
|
558
|
+
advanced: true,
|
|
559
|
+
},
|
|
560
|
+
disabledTools: {
|
|
561
|
+
label: "Disabled Tools",
|
|
562
|
+
placeholder: "memory",
|
|
563
|
+
help: "Agent-visible tool blocklist applied after enabledTools. Accepts the same tool names or groups.",
|
|
564
|
+
advanced: true,
|
|
565
|
+
},
|
|
566
|
+
runtimeQueryConfigPath: {
|
|
567
|
+
label: "Runtime Query Config Path",
|
|
568
|
+
placeholder: "~/.openclaw/openviking/runtime-query-config.json",
|
|
569
|
+
help: "Optional JSON file for /ov-query-config runtime overrides. Empty keeps overrides in memory only.",
|
|
570
|
+
advanced: true,
|
|
571
|
+
},
|
|
351
572
|
},
|
|
352
573
|
};
|