@openviking/openclaw-plugin 2026.5.26 → 2026.6.17-dev.1
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 +355 -355
- package/INSTALL-ZH.md +405 -345
- package/INSTALL.md +366 -362
- package/README.md +364 -338
- package/adapters/http-transport.ts +3 -0
- package/adapters/resource-packager.ts +141 -0
- package/auto-recall.ts +518 -257
- package/client.ts +963 -939
- package/commands/setup.ts +1169 -1002
- package/config/feature-gates.json +10 -0
- package/config.ts +819 -476
- package/context-engine.ts +408 -1737
- package/dist/adapters/http-transport.js +1 -0
- package/dist/adapters/resource-packager.js +114 -0
- package/dist/auto-recall.js +228 -32
- package/dist/client.js +125 -161
- package/dist/commands/setup.js +170 -32
- package/dist/config.js +285 -64
- package/dist/context-engine.js +64 -1179
- package/dist/index.js +209 -1470
- 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 +5 -17
- 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/dist/token-estimator.js +51 -0
- package/index.ts +408 -1985
- package/install-manifest.json +57 -47
- package/memory-ranking.ts +303 -267
- package/openclaw.plugin.json +497 -335
- package/package.json +86 -76
- 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 +41 -45
- 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/runtime-utils.ts +5 -5
- 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 +528 -530
- package/skills/install-openviking-memory/SKILL.md +752 -665
- package/skills/openviking-context-database/SKILL.md +286 -0
- package/text-utils.ts +488 -507
- package/token-estimator.ts +65 -0
- package/tool-call-id.ts +331 -331
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { once } from "node:events";
|
|
3
|
+
import { createWriteStream } from "node:fs";
|
|
4
|
+
import { mkdtemp, readdir, readFile, rm, stat } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { basename, dirname, join, relative } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { Zip, ZipDeflate } from "fflate";
|
|
9
|
+
|
|
10
|
+
const REMOTE_RESOURCE_PREFIXES = ["http://", "https://", "git@", "ssh://", "git://"];
|
|
11
|
+
|
|
12
|
+
export type PackagedResourceSource =
|
|
13
|
+
| { kind: "remote"; path: string }
|
|
14
|
+
| { kind: "upload"; uploadPath: string; sourceName?: string; cleanupPath?: string };
|
|
15
|
+
|
|
16
|
+
export type ResourcePackager = {
|
|
17
|
+
prepareResourceSource(pathOrUrl: string): Promise<PackagedResourceSource>;
|
|
18
|
+
prepareLocalUploadSource(path: string): Promise<PackagedResourceSource>;
|
|
19
|
+
createTempUploadBody(uploadPath: string): Promise<BodyInit>;
|
|
20
|
+
cleanup(source?: PackagedResourceSource): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function toBlobPart(value: Buffer): ArrayBuffer {
|
|
24
|
+
return value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength) as ArrayBuffer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isRemoteResourceSource(source: string): boolean {
|
|
28
|
+
return REMOTE_RESOURCE_PREFIXES.some((prefix) => source.startsWith(prefix));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function cleanupUploadTempPath(path?: string): Promise<void> {
|
|
32
|
+
if (!path) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await rm(path, { force: true }).catch(() => undefined);
|
|
36
|
+
await rm(dirname(path), { recursive: true, force: true }).catch(() => undefined);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function zipDirectoryForUpload(dirPath: string): Promise<string> {
|
|
40
|
+
const rootStats = await stat(dirPath);
|
|
41
|
+
if (!rootStats.isDirectory()) {
|
|
42
|
+
throw new Error(`Not a directory: ${dirPath}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const zipDir = await mkdtemp(join(tmpdir(), "openviking-openclaw-upload-"));
|
|
46
|
+
const zipPath = join(zipDir, `${basename(dirPath).replace(/[^a-zA-Z0-9._-]/g, "_")}-${randomUUID()}.zip`);
|
|
47
|
+
const output = createWriteStream(zipPath);
|
|
48
|
+
const outputClosed = once(output, "close");
|
|
49
|
+
const outputErrored = once(output, "error").then(([err]) => Promise.reject(err));
|
|
50
|
+
const zip = new Zip((err, chunk, final) => {
|
|
51
|
+
if (err) {
|
|
52
|
+
output.destroy(err);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (chunk?.length) {
|
|
56
|
+
output.write(Buffer.from(chunk));
|
|
57
|
+
}
|
|
58
|
+
if (final) {
|
|
59
|
+
output.end();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const walk = async (currentDir: string) => {
|
|
64
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
65
|
+
for (const entry of entries) {
|
|
66
|
+
const fullPath = join(currentDir, entry.name);
|
|
67
|
+
if (entry.isDirectory()) {
|
|
68
|
+
await walk(fullPath);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (!entry.isFile()) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const relPath = relative(dirPath, fullPath).split("\\").join("/");
|
|
75
|
+
if (!relPath || relPath.startsWith("../") || relPath.includes("/../")) {
|
|
76
|
+
throw new Error(`Unsafe relative path while zipping: ${relPath}`);
|
|
77
|
+
}
|
|
78
|
+
const file = new ZipDeflate(relPath);
|
|
79
|
+
zip.add(file);
|
|
80
|
+
file.push(new Uint8Array(await readFile(fullPath)), true);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
await walk(dirPath);
|
|
85
|
+
zip.end();
|
|
86
|
+
await Promise.race([outputClosed, outputErrored]);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
zip.terminate();
|
|
89
|
+
output.destroy(err as Error);
|
|
90
|
+
await cleanupUploadTempPath(zipPath);
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
return zipPath;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function prepareLocalUploadSource(path: string, includeSourceName = false): Promise<PackagedResourceSource> {
|
|
97
|
+
const localStats = await stat(path);
|
|
98
|
+
if (localStats.isDirectory()) {
|
|
99
|
+
const uploadPath = await zipDirectoryForUpload(path);
|
|
100
|
+
return {
|
|
101
|
+
kind: "upload",
|
|
102
|
+
uploadPath,
|
|
103
|
+
cleanupPath: uploadPath,
|
|
104
|
+
...(includeSourceName ? { sourceName: basename(path) } : {}),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (!localStats.isFile()) {
|
|
108
|
+
throw new Error(`Path is not a file or directory: ${path}`);
|
|
109
|
+
}
|
|
110
|
+
return { kind: "upload", uploadPath: path };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const defaultResourcePackager: ResourcePackager = {
|
|
114
|
+
async prepareResourceSource(pathOrUrl: string): Promise<PackagedResourceSource> {
|
|
115
|
+
if (isRemoteResourceSource(pathOrUrl)) {
|
|
116
|
+
return { kind: "remote", path: pathOrUrl };
|
|
117
|
+
}
|
|
118
|
+
return prepareLocalUploadSource(pathOrUrl, true);
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
async prepareLocalUploadSource(path: string): Promise<PackagedResourceSource> {
|
|
122
|
+
return prepareLocalUploadSource(path, false);
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
async createTempUploadBody(uploadPath: string): Promise<BodyInit> {
|
|
126
|
+
const fileBytes = await readFile(uploadPath);
|
|
127
|
+
const form = new FormData();
|
|
128
|
+
form.append(
|
|
129
|
+
"file",
|
|
130
|
+
new Blob([toBlobPart(fileBytes)], { type: "application/octet-stream" }),
|
|
131
|
+
basename(uploadPath),
|
|
132
|
+
);
|
|
133
|
+
return form;
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
async cleanup(source?: PackagedResourceSource): Promise<void> {
|
|
137
|
+
if (source?.kind === "upload") {
|
|
138
|
+
await cleanupUploadTempPath(source.cleanupPath);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
};
|