@openviking/openclaw-plugin 2026.9.8-1 → 2026.9.8-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.
@@ -1,63 +1,5 @@
1
1
  import { appendFile, mkdir, readFile, readdir, unlink } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- const ALLOWED_RESOURCE_TYPES = ["resource", "user", "agent"];
4
- const DEFAULT_RESOURCE_TYPES = ["user", "agent"];
5
- function toResourceTypeEntries(value) {
6
- if (Array.isArray(value)) {
7
- return value
8
- .filter((entry) => typeof entry === "string")
9
- .map((entry) => entry.trim())
10
- .filter(Boolean);
11
- }
12
- if (typeof value === "string") {
13
- return value
14
- .split(/[,\n]/)
15
- .map((entry) => entry.trim())
16
- .filter(Boolean);
17
- }
18
- return [];
19
- }
20
- export function normalizeResourceTypes(value) {
21
- const entries = toResourceTypeEntries(value);
22
- if (entries.length === 0) {
23
- return [...DEFAULT_RESOURCE_TYPES];
24
- }
25
- const seen = new Set();
26
- const normalized = [];
27
- const invalid = [];
28
- for (const entry of entries) {
29
- if (ALLOWED_RESOURCE_TYPES.includes(entry)) {
30
- const typed = entry;
31
- if (!seen.has(typed)) {
32
- seen.add(typed);
33
- normalized.push(typed);
34
- }
35
- }
36
- else {
37
- invalid.push(entry);
38
- }
39
- }
40
- if (invalid.length > 0) {
41
- throw new Error(`invalid resourceTypes: ${invalid.join(", ")}`);
42
- }
43
- return normalized.length > 0 ? normalized : [...DEFAULT_RESOURCE_TYPES];
44
- }
45
- export function resolveRecallSearchPlan(resourceTypes, _ctx) {
46
- const normalized = normalizeResourceTypes(resourceTypes);
47
- const searches = [];
48
- const skipped = [];
49
- let addedMemorySearch = false;
50
- for (const resourceType of normalized) {
51
- if (resourceType === "resource") {
52
- searches.push({ resourceType, contextType: "resource" });
53
- }
54
- else if ((resourceType === "user" || resourceType === "agent") && !addedMemorySearch) {
55
- searches.push({ resourceType: "user", contextType: "memory" });
56
- addedMemorySearch = true;
57
- }
58
- }
59
- return { resourceTypes: normalized, searches, skipped };
60
- }
61
3
  export class RecallTraceMemoryStore {
62
4
  maxEntries;
63
5
  entries = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openviking/openclaw-plugin",
3
- "version": "2026.9.8-1",
3
+ "version": "2026.9.8-2",
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",
package/recall-trace.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { appendFile, mkdir, readFile, readdir, unlink } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
 
4
- export type RecallResourceType = "resource" | "session" | "user" | "agent";
4
+ import type { RecallResourceType } from "./registries/recall-resource-types.js";
5
5
 
6
6
  export type RecallTraceSource = "auto_recall" | "memory_recall" | "ov_search" | "ov_archive_search";
7
7
 
@@ -27,7 +27,9 @@ export type RecallTraceEntry = {
27
27
  agentId?: string;
28
28
  source: RecallTraceSource;
29
29
  operationType: RecallTraceOperationType;
30
- resourceTypes: RecallResourceType[];
30
+ // "session" labels archive-grep traces over session history; recall targets
31
+ // stay in the registry's narrower union and never include it.
32
+ resourceTypes: Array<RecallResourceType | "session">;
31
33
  trigger: {
32
34
  rawUserTextPreview?: string;
33
35
  query: string;
@@ -92,78 +94,6 @@ export type RecallTraceFlushResult = {
92
94
  warnings: string[];
93
95
  };
94
96
 
95
- const ALLOWED_RESOURCE_TYPES: RecallResourceType[] = ["resource", "user", "agent"];
96
- const DEFAULT_RESOURCE_TYPES: RecallResourceType[] = ["user", "agent"];
97
-
98
- function toResourceTypeEntries(value: unknown): string[] {
99
- if (Array.isArray(value)) {
100
- return value
101
- .filter((entry): entry is string => typeof entry === "string")
102
- .map((entry) => entry.trim())
103
- .filter(Boolean);
104
- }
105
- if (typeof value === "string") {
106
- return value
107
- .split(/[,\n]/)
108
- .map((entry) => entry.trim())
109
- .filter(Boolean);
110
- }
111
- return [];
112
- }
113
-
114
- export function normalizeResourceTypes(value: unknown): RecallResourceType[] {
115
- const entries = toResourceTypeEntries(value);
116
- if (entries.length === 0) {
117
- return [...DEFAULT_RESOURCE_TYPES];
118
- }
119
-
120
- const seen = new Set<RecallResourceType>();
121
- const normalized: RecallResourceType[] = [];
122
- const invalid: string[] = [];
123
- for (const entry of entries) {
124
- if ((ALLOWED_RESOURCE_TYPES as string[]).includes(entry)) {
125
- const typed = entry as RecallResourceType;
126
- if (!seen.has(typed)) {
127
- seen.add(typed);
128
- normalized.push(typed);
129
- }
130
- } else {
131
- invalid.push(entry);
132
- }
133
- }
134
-
135
- if (invalid.length > 0) {
136
- throw new Error(`invalid resourceTypes: ${invalid.join(", ")}`);
137
- }
138
-
139
- return normalized.length > 0 ? normalized : [...DEFAULT_RESOURCE_TYPES];
140
- }
141
-
142
- export function resolveRecallSearchPlan(
143
- resourceTypes: unknown,
144
- _ctx: { ovSessionId?: string; agentId?: string },
145
- ): {
146
- resourceTypes: RecallResourceType[];
147
- searches: Array<{ resourceType: RecallResourceType; targetUri?: string; contextType: "memory" | "resource" }>;
148
- skipped: Array<{ resourceType: RecallResourceType; reason: "missing_session" }>;
149
- } {
150
- const normalized = normalizeResourceTypes(resourceTypes);
151
- const searches: Array<{ resourceType: RecallResourceType; targetUri?: string; contextType: "memory" | "resource" }> = [];
152
- const skipped: Array<{ resourceType: RecallResourceType; reason: "missing_session" }> = [];
153
- let addedMemorySearch = false;
154
-
155
- for (const resourceType of normalized) {
156
- if (resourceType === "resource") {
157
- searches.push({ resourceType, contextType: "resource" });
158
- } else if ((resourceType === "user" || resourceType === "agent") && !addedMemorySearch) {
159
- searches.push({ resourceType: "user", contextType: "memory" });
160
- addedMemorySearch = true;
161
- }
162
- }
163
-
164
- return { resourceTypes: normalized, searches, skipped };
165
- }
166
-
167
97
  export class RecallTraceMemoryStore {
168
98
  private readonly maxEntries: number;
169
99
  private readonly entries: RecallTraceEntry[] = [];
@@ -183,7 +113,7 @@ export class RecallTraceMemoryStore {
183
113
  const limit = Math.max(1, Math.floor(query.limit ?? 20));
184
114
  const turn = query.turn ?? "latest";
185
115
  const resourceTypes = query.resourceTypes && query.resourceTypes.length > 0
186
- ? new Set(query.resourceTypes)
116
+ ? new Set<string>(query.resourceTypes)
187
117
  : undefined;
188
118
 
189
119
  const filtered = this.entries