@openviking/openclaw-plugin 2026.9.4-2 → 2026.9.5
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/config.ts +1 -1
- package/context-engine.ts +5 -0
- package/dist/config.js +1 -1
- package/dist/context-engine.js +5 -0
- package/dist/plugin/openclaw-runtime-compaction.js +20 -0
- package/dist/services/context-lifecycle-service.js +13 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin/openclaw-runtime-compaction.ts +41 -0
- package/services/context-lifecycle-service.ts +15 -0
package/config.ts
CHANGED
|
@@ -907,7 +907,7 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
907
907
|
bypassSessionPatterns: {
|
|
908
908
|
label: "Bypass Session Patterns",
|
|
909
909
|
placeholder: "agent:*:cron:**",
|
|
910
|
-
help: "Completely bypass OpenViking for matching session keys. Use * within one segment and ** across segments.",
|
|
910
|
+
help: "Completely bypass OpenViking for matching session keys (no capture, recall, or commit; compaction falls back to OpenClaw's native compactor). Use * within one segment and ** across segments.",
|
|
911
911
|
advanced: true,
|
|
912
912
|
},
|
|
913
913
|
commitTokenThresholdRatio: {
|
package/context-engine.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
compactOpenVikingSession,
|
|
20
20
|
commitOpenVikingSession,
|
|
21
21
|
} from "./services/context-lifecycle-service.js";
|
|
22
|
+
import { loadRuntimeCompactionDelegate } from "./plugin/openclaw-runtime-compaction.js";
|
|
22
23
|
|
|
23
24
|
type ContextEngineInfo = {
|
|
24
25
|
id: string;
|
|
@@ -437,6 +438,10 @@ export function createMemoryOpenVikingContextEngine(params: {
|
|
|
437
438
|
logger,
|
|
438
439
|
resolveAgentId,
|
|
439
440
|
isBypassedSession,
|
|
441
|
+
runtimeCompact: async () => {
|
|
442
|
+
const delegate = await loadRuntimeCompactionDelegate();
|
|
443
|
+
return delegate ? delegate(compactParams) : undefined;
|
|
444
|
+
},
|
|
440
445
|
diag,
|
|
441
446
|
});
|
|
442
447
|
},
|
package/dist/config.js
CHANGED
|
@@ -603,7 +603,7 @@ export const memoryOpenVikingConfigSchema = {
|
|
|
603
603
|
bypassSessionPatterns: {
|
|
604
604
|
label: "Bypass Session Patterns",
|
|
605
605
|
placeholder: "agent:*:cron:**",
|
|
606
|
-
help: "Completely bypass OpenViking for matching session keys. Use * within one segment and ** across segments.",
|
|
606
|
+
help: "Completely bypass OpenViking for matching session keys (no capture, recall, or commit; compaction falls back to OpenClaw's native compactor). Use * within one segment and ** across segments.",
|
|
607
607
|
advanced: true,
|
|
608
608
|
},
|
|
609
609
|
commitTokenThresholdRatio: {
|
package/dist/context-engine.js
CHANGED
|
@@ -3,6 +3,7 @@ import { compileSessionPatterns, shouldBypassSession, } from "./text-utils.js";
|
|
|
3
3
|
import { estimateAgentMessageTokens, estimateAgentMessagesTokens } from "./token-estimator.js";
|
|
4
4
|
import { openClawSessionToOvStorageId } from "./routing/identity-routing.js";
|
|
5
5
|
import { assembleOpenVikingSession, afterTurnOpenVikingSession, compactOpenVikingSession, commitOpenVikingSession, } from "./services/context-lifecycle-service.js";
|
|
6
|
+
import { loadRuntimeCompactionDelegate } from "./plugin/openclaw-runtime-compaction.js";
|
|
6
7
|
function roughEstimate(messages) {
|
|
7
8
|
return estimateAgentMessagesTokens(messages);
|
|
8
9
|
}
|
|
@@ -255,6 +256,10 @@ export function createMemoryOpenVikingContextEngine(params) {
|
|
|
255
256
|
logger,
|
|
256
257
|
resolveAgentId,
|
|
257
258
|
isBypassedSession,
|
|
259
|
+
runtimeCompact: async () => {
|
|
260
|
+
const delegate = await loadRuntimeCompactionDelegate();
|
|
261
|
+
return delegate ? delegate(compactParams) : undefined;
|
|
262
|
+
},
|
|
258
263
|
diag,
|
|
259
264
|
});
|
|
260
265
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Bridge to OpenClaw's built-in compactor for sessions that bypass OpenViking.
|
|
2
|
+
// The host exports `delegateCompactionToRuntime` from `openclaw/plugin-sdk/core`
|
|
3
|
+
// (present since the earliest supported host); it is resolved lazily because the
|
|
4
|
+
// plugin builds without the host SDK installed.
|
|
5
|
+
const PLUGIN_SDK_CORE_SPECIFIER = "openclaw/plugin-sdk/core";
|
|
6
|
+
let cached;
|
|
7
|
+
export function loadRuntimeCompactionDelegate() {
|
|
8
|
+
cached ??= (async () => {
|
|
9
|
+
try {
|
|
10
|
+
const mod = (await import(PLUGIN_SDK_CORE_SPECIFIER));
|
|
11
|
+
return typeof mod?.delegateCompactionToRuntime === "function"
|
|
12
|
+
? mod.delegateCompactionToRuntime
|
|
13
|
+
: undefined;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
@@ -671,7 +671,7 @@ function compactFailureResult(reason, tokensBefore, details) {
|
|
|
671
671
|
},
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
|
-
export async function compactOpenVikingSession({ sessionId, sessionKey, tokenBudget, currentTokenCount, force, compactionTarget, customInstructions, getClient, logger, resolveAgentId, isBypassedSession, diag, }) {
|
|
674
|
+
export async function compactOpenVikingSession({ sessionId, sessionKey, tokenBudget, currentTokenCount, force, compactionTarget, customInstructions, getClient, logger, resolveAgentId, isBypassedSession, runtimeCompact, diag, }) {
|
|
675
675
|
const ovSessionId = openClawSessionToOvStorageId(sessionId, sessionKey);
|
|
676
676
|
diag("compact_entry", ovSessionId, {
|
|
677
677
|
tokenBudget,
|
|
@@ -682,6 +682,18 @@ export async function compactOpenVikingSession({ sessionId, sessionKey, tokenBud
|
|
|
682
682
|
customInstructions.trim().length > 0,
|
|
683
683
|
});
|
|
684
684
|
if (isBypassedSession({ sessionId, sessionKey })) {
|
|
685
|
+
// Bypassed sessions store nothing in OV, but the host still needs a real
|
|
686
|
+
// compaction (preflight hard-fails on an unknown skip reason), so hand the
|
|
687
|
+
// request to OpenClaw's native compactor.
|
|
688
|
+
const delegated = await runtimeCompact?.();
|
|
689
|
+
if (delegated) {
|
|
690
|
+
diag("compact_result", ovSessionId, {
|
|
691
|
+
ok: delegated.ok,
|
|
692
|
+
compacted: delegated.compacted,
|
|
693
|
+
reason: delegated.reason ?? "session_bypassed_runtime_compaction",
|
|
694
|
+
});
|
|
695
|
+
return delegated;
|
|
696
|
+
}
|
|
685
697
|
diag("compact_result", ovSessionId, {
|
|
686
698
|
ok: true,
|
|
687
699
|
compacted: false,
|
package/openclaw.plugin.json
CHANGED
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"bypassSessionPatterns": {
|
|
196
196
|
"label": "Bypass Session Patterns",
|
|
197
197
|
"placeholder": "agent:*:cron:**",
|
|
198
|
-
"help": "Completely bypass OpenViking for matching session keys. Use * within one segment and ** across segments.",
|
|
198
|
+
"help": "Completely bypass OpenViking for matching session keys (no capture, recall, or commit; compaction falls back to OpenClaw's native compactor). Use * within one segment and ** across segments.",
|
|
199
199
|
"advanced": true
|
|
200
200
|
},
|
|
201
201
|
"commitTokenThresholdRatio": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openviking/openclaw-plugin",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.5",
|
|
4
4
|
"displayName": "OpenViking",
|
|
5
5
|
"description": "OpenClaw context-engine plugin — OpenViking AI memory, long-term memory, knowledge base, semantic search, RAG, context engine. 长期记忆 · 知识库 · 语义检索 · 上下文引擎",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Bridge to OpenClaw's built-in compactor for sessions that bypass OpenViking.
|
|
2
|
+
// The host exports `delegateCompactionToRuntime` from `openclaw/plugin-sdk/core`
|
|
3
|
+
// (present since the earliest supported host); it is resolved lazily because the
|
|
4
|
+
// plugin builds without the host SDK installed.
|
|
5
|
+
|
|
6
|
+
export type RuntimeCompactionResult = {
|
|
7
|
+
ok: boolean;
|
|
8
|
+
compacted: boolean;
|
|
9
|
+
reason?: string;
|
|
10
|
+
result?: {
|
|
11
|
+
summary?: string;
|
|
12
|
+
firstKeptEntryId?: string;
|
|
13
|
+
tokensBefore: number;
|
|
14
|
+
tokensAfter?: number;
|
|
15
|
+
details?: unknown;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type RuntimeCompactionDelegate = (
|
|
20
|
+
params: Record<string, unknown>,
|
|
21
|
+
) => Promise<RuntimeCompactionResult>;
|
|
22
|
+
|
|
23
|
+
const PLUGIN_SDK_CORE_SPECIFIER = "openclaw/plugin-sdk/core";
|
|
24
|
+
|
|
25
|
+
let cached: Promise<RuntimeCompactionDelegate | undefined> | undefined;
|
|
26
|
+
|
|
27
|
+
export function loadRuntimeCompactionDelegate(): Promise<RuntimeCompactionDelegate | undefined> {
|
|
28
|
+
cached ??= (async () => {
|
|
29
|
+
try {
|
|
30
|
+
const mod = (await import(PLUGIN_SDK_CORE_SPECIFIER)) as {
|
|
31
|
+
delegateCompactionToRuntime?: unknown;
|
|
32
|
+
};
|
|
33
|
+
return typeof mod?.delegateCompactionToRuntime === "function"
|
|
34
|
+
? (mod.delegateCompactionToRuntime as RuntimeCompactionDelegate)
|
|
35
|
+
: undefined;
|
|
36
|
+
} catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
return cached;
|
|
41
|
+
}
|
|
@@ -117,6 +117,8 @@ export type CompactOpenVikingSessionParams = {
|
|
|
117
117
|
logger: ContextEngineLifecycleLogger;
|
|
118
118
|
resolveAgentId: (sessionId: string, sessionKey?: string, ovSessionId?: string) => string;
|
|
119
119
|
isBypassedSession: (params: { sessionId?: string; sessionKey?: string }) => boolean;
|
|
120
|
+
/** Host-native compaction for bypassed sessions; resolves undefined when unavailable. */
|
|
121
|
+
runtimeCompact?: () => Promise<CompactOpenVikingSessionResult | undefined>;
|
|
120
122
|
diag: (stage: string, sessionId: string, data: Record<string, unknown>) => void;
|
|
121
123
|
};
|
|
122
124
|
|
|
@@ -1014,6 +1016,7 @@ export async function compactOpenVikingSession({
|
|
|
1014
1016
|
logger,
|
|
1015
1017
|
resolveAgentId,
|
|
1016
1018
|
isBypassedSession,
|
|
1019
|
+
runtimeCompact,
|
|
1017
1020
|
diag,
|
|
1018
1021
|
}: CompactOpenVikingSessionParams): Promise<CompactOpenVikingSessionResult> {
|
|
1019
1022
|
const ovSessionId = openClawSessionToOvStorageId(sessionId, sessionKey);
|
|
@@ -1027,6 +1030,18 @@ export async function compactOpenVikingSession({
|
|
|
1027
1030
|
});
|
|
1028
1031
|
|
|
1029
1032
|
if (isBypassedSession({ sessionId, sessionKey })) {
|
|
1033
|
+
// Bypassed sessions store nothing in OV, but the host still needs a real
|
|
1034
|
+
// compaction (preflight hard-fails on an unknown skip reason), so hand the
|
|
1035
|
+
// request to OpenClaw's native compactor.
|
|
1036
|
+
const delegated = await runtimeCompact?.();
|
|
1037
|
+
if (delegated) {
|
|
1038
|
+
diag("compact_result", ovSessionId, {
|
|
1039
|
+
ok: delegated.ok,
|
|
1040
|
+
compacted: delegated.compacted,
|
|
1041
|
+
reason: delegated.reason ?? "session_bypassed_runtime_compaction",
|
|
1042
|
+
});
|
|
1043
|
+
return delegated;
|
|
1044
|
+
}
|
|
1030
1045
|
diag("compact_result", ovSessionId, {
|
|
1031
1046
|
ok: true,
|
|
1032
1047
|
compacted: false,
|