@openviking/openclaw-plugin 2026.10.21-2 → 2026.10.23
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/client.ts +10 -1
- package/commands/setup.ts +1 -0
- package/config.ts +23 -1
- package/dist/client.js +8 -1
- package/dist/commands/setup.js +1 -0
- package/dist/config.js +12 -0
- package/dist/plugin/openviking-client-runtime.js +1 -0
- package/dist/shared/redact.mjs +546 -0
- package/dist/shared/secret-rules.mjs +289 -0
- package/dist/shared/workspace-identity.mjs +339 -0
- package/install-manifest.json +1 -1
- package/openclaw.plugin.json +14 -0
- package/package.json +1 -1
- package/plugin/openviking-client-runtime.ts +3 -0
- package/shared/redact.d.mts +26 -0
- package/shared/redact.mjs +522 -0
- package/shared/secret-rules.mjs +294 -0
- package/shared/workspace-identity.mjs +334 -0
package/client.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
contextRequestTimeoutMs,
|
|
9
9
|
normalizeContextEntry,
|
|
10
10
|
} from "./shared/recall-core.mjs";
|
|
11
|
+
import { redactPayload } from "./shared/redact.mjs";
|
|
11
12
|
|
|
12
13
|
export type FindResultItem = {
|
|
13
14
|
uri: string;
|
|
@@ -68,6 +69,8 @@ function userSessionUri(sessionId: string): string {
|
|
|
68
69
|
|
|
69
70
|
export type OpenVikingClientOptions = {
|
|
70
71
|
transport?: HttpTransport;
|
|
72
|
+
/** Secret-redaction tier for session messages (`captureRedact`); default "standard". */
|
|
73
|
+
captureRedact?: string;
|
|
71
74
|
headers?: Record<string, string>;
|
|
72
75
|
resourcePackager?: ResourcePackager;
|
|
73
76
|
now?: () => number;
|
|
@@ -251,6 +254,7 @@ export class OpenVikingClient {
|
|
|
251
254
|
private readonly now: () => number;
|
|
252
255
|
private readonly sleep: (ms: number) => Promise<void>;
|
|
253
256
|
private readonly resourcePackager: ResourcePackager;
|
|
257
|
+
private readonly captureRedact: string | undefined;
|
|
254
258
|
|
|
255
259
|
constructor(
|
|
256
260
|
private readonly baseUrl: string,
|
|
@@ -275,6 +279,7 @@ export class OpenVikingClient {
|
|
|
275
279
|
this.now = options.now ?? Date.now;
|
|
276
280
|
this.sleep = options.sleep ?? sleep;
|
|
277
281
|
this.resourcePackager = options.resourcePackager ?? defaultResourcePackager;
|
|
282
|
+
this.captureRedact = options.captureRedact;
|
|
278
283
|
}
|
|
279
284
|
|
|
280
285
|
getDefaultAgentId(): string {
|
|
@@ -787,11 +792,15 @@ export class OpenVikingClient {
|
|
|
787
792
|
},
|
|
788
793
|
actorPeerId,
|
|
789
794
|
);
|
|
795
|
+
// Secrets in the captured text (a `cat .env`, a token in a tool result)
|
|
796
|
+
// are replaced before the message leaves the machine; ids, roles and
|
|
797
|
+
// URIs are left as they are. The caller's parts are not mutated.
|
|
798
|
+
const redacted = redactPayload(body, { tier: this.captureRedact });
|
|
790
799
|
await this.request<{ session_id: string }>(
|
|
791
800
|
`/api/v1/sessions/${encodeURIComponent(sessionId)}/messages`,
|
|
792
801
|
{
|
|
793
802
|
method: "POST",
|
|
794
|
-
body: JSON.stringify(
|
|
803
|
+
body: JSON.stringify(redacted),
|
|
795
804
|
},
|
|
796
805
|
undefined,
|
|
797
806
|
actorPeerId,
|
package/commands/setup.ts
CHANGED
package/config.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { homedir } from "node:os";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
|
|
4
4
|
import { getEnv } from "./runtime-utils.js";
|
|
5
|
+
import { normalizeRedactTier } from "./shared/redact.mjs";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Subset of OpenClaw's standard `SecretRef` shape supported by the OpenViking
|
|
@@ -46,6 +47,12 @@ export type MemoryOpenVikingConfig = {
|
|
|
46
47
|
autoCapture?: boolean;
|
|
47
48
|
captureMode?: "semantic" | "keyword";
|
|
48
49
|
captureMaxLength?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Secret redaction applied to every session message before it is sent:
|
|
52
|
+
* "off", "standard" (default) or "strict". `false` means "off"; an unknown
|
|
53
|
+
* tier name means "standard". OPENVIKING_CAPTURE_REDACT outranks this.
|
|
54
|
+
*/
|
|
55
|
+
captureRedact?: "off" | "standard" | "strict" | boolean;
|
|
49
56
|
autoRecall?: boolean;
|
|
50
57
|
/** Outer time budget for the whole server-assembled auto-recall flow. */
|
|
51
58
|
autoRecallTimeoutMs?: number;
|
|
@@ -133,8 +140,10 @@ export type MemoryOpenVikingConfig = {
|
|
|
133
140
|
|
|
134
141
|
/** Runtime config after memoryOpenVikingConfigSchema.parse() has applied defaults. */
|
|
135
142
|
export type ParsedMemoryOpenVikingConfig = Required<
|
|
136
|
-
Omit<MemoryOpenVikingConfig, "agentExperience" | "recallTargetTypes" | "apiKey" | "peer_role">
|
|
143
|
+
Omit<MemoryOpenVikingConfig, "agentExperience" | "recallTargetTypes" | "apiKey" | "peer_role" | "captureRedact">
|
|
137
144
|
> & {
|
|
145
|
+
/** Always a tier name after parse(). */
|
|
146
|
+
captureRedact: "off" | "standard" | "strict";
|
|
138
147
|
/** parse() resolves SecretRef values, so the runtime shape is always a plain string. */
|
|
139
148
|
apiKey: string;
|
|
140
149
|
/** Runtime uses the canonical name; legacy `person` input normalizes to `sender`. */
|
|
@@ -536,6 +545,7 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
536
545
|
"autoCapture",
|
|
537
546
|
"captureMode",
|
|
538
547
|
"captureMaxLength",
|
|
548
|
+
"captureRedact",
|
|
539
549
|
"autoRecall",
|
|
540
550
|
"autoRecallTimeoutMs",
|
|
541
551
|
"recallCompress",
|
|
@@ -667,6 +677,12 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
667
677
|
200,
|
|
668
678
|
Math.min(200_000, Math.floor(toNumber(cfg.captureMaxLength, DEFAULT_CAPTURE_MAX_LENGTH))),
|
|
669
679
|
),
|
|
680
|
+
// The env var outranks the file, as for every other harness. Never
|
|
681
|
+
// throws: an unknown tier redacts at the default rather than failing the
|
|
682
|
+
// plugin's config load.
|
|
683
|
+
captureRedact: normalizeRedactTier(
|
|
684
|
+
getEnv("OPENVIKING_CAPTURE_REDACT")?.trim() || cfg.captureRedact,
|
|
685
|
+
) as "off" | "standard" | "strict",
|
|
670
686
|
autoRecall: cfg.autoRecall !== false,
|
|
671
687
|
autoRecallTimeoutMs: Math.max(
|
|
672
688
|
1000,
|
|
@@ -878,6 +894,12 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
878
894
|
advanced: true,
|
|
879
895
|
help: "Maximum sanitized user text length allowed for auto-capture.",
|
|
880
896
|
},
|
|
897
|
+
captureRedact: {
|
|
898
|
+
label: "Capture Secret Redaction",
|
|
899
|
+
placeholder: "standard",
|
|
900
|
+
advanced: true,
|
|
901
|
+
help: 'Replace secrets (API keys, tokens, private keys) in captured messages with {{ov_redacted:<rule>:<tag>}} before they are sent. "standard" (default), "strict" (adds the generic key=value rule) or "off". Env: OPENVIKING_CAPTURE_REDACT.',
|
|
902
|
+
},
|
|
881
903
|
autoRecall: {
|
|
882
904
|
label: "Auto-Recall",
|
|
883
905
|
help: "Inject relevant OpenViking memories into agent context",
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defaultHttpTransport } from "./adapters/http-transport.js";
|
|
2
2
|
import { defaultResourcePackager, } from "./adapters/resource-packager.js";
|
|
3
3
|
import { buildContextSearchBody, contextRequestTimeoutMs, normalizeContextEntry, } from "./shared/recall-core.mjs";
|
|
4
|
+
import { redactPayload } from "./shared/redact.mjs";
|
|
4
5
|
function userSessionUri(sessionId) {
|
|
5
6
|
return `viking://~/sessions/${encodeURIComponent(sessionId)}`;
|
|
6
7
|
}
|
|
@@ -21,6 +22,7 @@ export class OpenVikingClient {
|
|
|
21
22
|
now;
|
|
22
23
|
sleep;
|
|
23
24
|
resourcePackager;
|
|
25
|
+
captureRedact;
|
|
24
26
|
constructor(baseUrl, apiKey, defaultAgentId, timeoutMs,
|
|
25
27
|
/** When set, sent so ROOT keys or trusted deployments can select tenant identity. */
|
|
26
28
|
accountId = "", userId = "",
|
|
@@ -41,6 +43,7 @@ export class OpenVikingClient {
|
|
|
41
43
|
this.now = options.now ?? Date.now;
|
|
42
44
|
this.sleep = options.sleep ?? sleep;
|
|
43
45
|
this.resourcePackager = options.resourcePackager ?? defaultResourcePackager;
|
|
46
|
+
this.captureRedact = options.captureRedact;
|
|
44
47
|
}
|
|
45
48
|
getDefaultAgentId() {
|
|
46
49
|
return this.defaultAgentId;
|
|
@@ -382,9 +385,13 @@ export class OpenVikingClient {
|
|
|
382
385
|
partCount: parts.length,
|
|
383
386
|
created_at: createdAt ?? null,
|
|
384
387
|
}, actorPeerId);
|
|
388
|
+
// Secrets in the captured text (a `cat .env`, a token in a tool result)
|
|
389
|
+
// are replaced before the message leaves the machine; ids, roles and
|
|
390
|
+
// URIs are left as they are. The caller's parts are not mutated.
|
|
391
|
+
const redacted = redactPayload(body, { tier: this.captureRedact });
|
|
385
392
|
await this.request(`/api/v1/sessions/${encodeURIComponent(sessionId)}/messages`, {
|
|
386
393
|
method: "POST",
|
|
387
|
-
body: JSON.stringify(
|
|
394
|
+
body: JSON.stringify(redacted),
|
|
388
395
|
}, undefined, actorPeerId);
|
|
389
396
|
}
|
|
390
397
|
/** GET session — server auto-creates if absent; returns session meta including message stats and token usage. */
|
package/dist/commands/setup.js
CHANGED
package/dist/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { getEnv } from "./runtime-utils.js";
|
|
4
|
+
import { normalizeRedactTier } from "./shared/redact.mjs";
|
|
4
5
|
const DEFAULT_BASE_URL = "http://127.0.0.1:1933";
|
|
5
6
|
const DEFAULT_TARGET_URI = "viking://~/memories";
|
|
6
7
|
const DEFAULT_TIMEOUT_MS = 15000;
|
|
@@ -347,6 +348,7 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
347
348
|
"autoCapture",
|
|
348
349
|
"captureMode",
|
|
349
350
|
"captureMaxLength",
|
|
351
|
+
"captureRedact",
|
|
350
352
|
"autoRecall",
|
|
351
353
|
"autoRecallTimeoutMs",
|
|
352
354
|
"recallCompress",
|
|
@@ -444,6 +446,10 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
444
446
|
autoCapture: cfg.autoCapture !== false,
|
|
445
447
|
captureMode: captureMode ?? DEFAULT_CAPTURE_MODE,
|
|
446
448
|
captureMaxLength: Math.max(200, Math.min(200_000, Math.floor(toNumber(cfg.captureMaxLength, DEFAULT_CAPTURE_MAX_LENGTH)))),
|
|
449
|
+
// The env var outranks the file, as for every other harness. Never
|
|
450
|
+
// throws: an unknown tier redacts at the default rather than failing the
|
|
451
|
+
// plugin's config load.
|
|
452
|
+
captureRedact: normalizeRedactTier(getEnv("OPENVIKING_CAPTURE_REDACT")?.trim() || cfg.captureRedact),
|
|
447
453
|
autoRecall: cfg.autoRecall !== false,
|
|
448
454
|
autoRecallTimeoutMs: Math.max(1000, Math.min(300_000, Math.floor(toNumber(cfg.autoRecallTimeoutMs, DEFAULT_AUTO_RECALL_TIMEOUT_MS)))),
|
|
449
455
|
recallResources,
|
|
@@ -567,6 +573,12 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
567
573
|
advanced: true,
|
|
568
574
|
help: "Maximum sanitized user text length allowed for auto-capture.",
|
|
569
575
|
},
|
|
576
|
+
captureRedact: {
|
|
577
|
+
label: "Capture Secret Redaction",
|
|
578
|
+
placeholder: "standard",
|
|
579
|
+
advanced: true,
|
|
580
|
+
help: 'Replace secrets (API keys, tokens, private keys) in captured messages with {{ov_redacted:<rule>:<tag>}} before they are sent. "standard" (default), "strict" (adds the generic key=value rule) or "off". Env: OPENVIKING_CAPTURE_REDACT.',
|
|
581
|
+
},
|
|
570
582
|
autoRecall: {
|
|
571
583
|
label: "Auto-Recall",
|
|
572
584
|
help: "Inject relevant OpenViking memories into agent context",
|
|
@@ -22,6 +22,7 @@ export function createOpenVikingClientRuntime(options) {
|
|
|
22
22
|
: undefined;
|
|
23
23
|
const clientPromise = Promise.resolve(new OpenVikingClient(cfg.baseUrl, cfg.apiKey, cfg.peer_prefix, cfg.timeoutMs, cfg.accountId, cfg.userId, routingDebugLog, {
|
|
24
24
|
transport: options.transport,
|
|
25
|
+
captureRedact: cfg.captureRedact,
|
|
25
26
|
headers: resolveOpenVikingRequestHeaders({
|
|
26
27
|
headers: cfg.headers,
|
|
27
28
|
}),
|