@openviking/openclaw-plugin 2026.5.8 → 2026.5.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openviking/openclaw-plugin",
3
- "version": "2026.5.8",
3
+ "version": "2026.5.21",
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",
@@ -30,6 +30,7 @@
30
30
  "INSTALL.md",
31
31
  "INSTALL-ZH.md",
32
32
  "INSTALL-AGENT.md",
33
+ "images/",
33
34
  "skills/"
34
35
  ],
35
36
  "scripts": {
@@ -1,169 +1,45 @@
1
- import { Socket } from "node:net";
2
-
3
- type ChildLike = {
4
- killed?: boolean;
5
- exitCode?: number | null;
6
- signalCode?: string | null;
7
- off?: (event: string, listener: (...args: any[]) => void) => void;
8
- once: (event: string, listener: (...args: any[]) => void) => void;
9
- };
10
-
11
- export function waitForHealth(baseUrl: string, timeoutMs: number, intervalMs: number): Promise<void> {
12
- const deadline = Date.now() + timeoutMs;
13
- return new Promise((resolve, reject) => {
14
- const tick = () => {
15
- if (Date.now() > deadline) {
16
- reject(new Error(`OpenViking health check timeout at ${baseUrl}`));
17
- return;
18
- }
19
- fetch(`${baseUrl}/health`)
20
- .then((r) => r.json())
21
- .then((body: { status?: string }) => {
22
- if (body?.status === "ok") {
23
- resolve();
24
- return;
25
- }
26
- setTimeout(tick, intervalMs);
27
- })
28
- .catch(() => setTimeout(tick, intervalMs));
29
- };
30
- tick();
31
- });
32
- }
33
-
34
- export function waitForHealthOrExit(
35
- baseUrl: string,
36
- timeoutMs: number,
37
- intervalMs: number,
38
- child: ChildLike,
39
- ): Promise<void> {
40
- const exited =
41
- child.killed || child.exitCode !== null || child.signalCode !== null;
42
- if (exited) {
43
- return Promise.reject(
44
- new Error(
45
- `OpenViking subprocess exited before health check ` +
46
- `(code=${child.exitCode}, signal=${child.signalCode})`,
47
- ),
48
- );
49
- }
50
-
51
- return new Promise((resolve, reject) => {
52
- let settled = false;
53
-
54
- const cleanup = () => {
55
- child.off?.("error", onError);
56
- child.off?.("exit", onExit);
57
- };
58
-
59
- const finishResolve = () => {
60
- if (settled) {
61
- return;
62
- }
63
- settled = true;
64
- cleanup();
65
- resolve();
66
- };
67
-
68
- const finishReject = (err: unknown) => {
69
- if (settled) {
70
- return;
71
- }
72
- settled = true;
73
- cleanup();
74
- reject(err instanceof Error ? err : new Error(String(err)));
75
- };
76
-
77
- const onError = (err: Error) => {
78
- finishReject(err);
79
- };
80
-
81
- const onExit = (code: number | null, signal: string | null) => {
82
- finishReject(
83
- new Error(
84
- `OpenViking subprocess exited before health check ` +
85
- `(code=${code}, signal=${signal})`,
86
- ),
87
- );
88
- };
89
-
90
- child.once("error", onError);
91
- child.once("exit", onExit);
92
- waitForHealth(baseUrl, timeoutMs, intervalMs).then(finishResolve, finishReject);
93
- });
94
- }
95
-
96
- export function withTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutMessage: string): Promise<T> {
97
- return new Promise((resolve, reject) => {
98
- const timer = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs);
99
- promise.then(
100
- (value) => {
101
- clearTimeout(timer);
102
- resolve(value);
103
- },
104
- (err) => {
105
- clearTimeout(timer);
106
- reject(err);
107
- },
108
- );
109
- });
110
- }
111
-
112
- export function quickTcpProbe(host: string, port: number, timeoutMs: number): Promise<boolean> {
113
- return new Promise((resolve) => {
114
- const socket = new Socket();
115
- let done = false;
116
- const finish = (ok: boolean) => {
117
- if (done) {
118
- return;
119
- }
120
- done = true;
121
- socket.destroy();
122
- resolve(ok);
123
- };
124
- socket.setTimeout(timeoutMs);
125
- socket.once("connect", () => finish(true));
126
- socket.once("timeout", () => finish(false));
127
- socket.once("error", () => finish(false));
128
- try {
129
- socket.connect(port, host);
130
- } catch {
131
- finish(false);
132
- }
133
- });
134
- }
135
-
136
- export async function quickHealthCheck(baseUrl: string, timeoutMs: number): Promise<boolean> {
137
- const controller = new AbortController();
138
- const timer = setTimeout(() => controller.abort(), timeoutMs);
139
- try {
140
- const response = await fetch(`${baseUrl}/health`, {
141
- method: "GET",
142
- signal: controller.signal,
143
- });
144
- if (!response.ok) {
145
- return false;
146
- }
147
- const body = (await response.json().catch(() => ({}))) as { status?: string };
148
- return body.status === "ok";
149
- } catch {
150
- return false;
151
- } finally {
152
- clearTimeout(timer);
153
- }
154
- }
155
-
156
- export async function quickRecallPrecheck(
157
- baseUrl: string,
158
- ): Promise<{ ok: true } | { ok: false; reason: string }> {
159
- const healthOk = await quickHealthCheck(baseUrl, 500);
160
- if (healthOk) {
161
- return { ok: true };
162
- }
163
- return { ok: false, reason: "health check failed" };
164
- }
165
-
166
- export interface ProcessLogger {
167
- info?: (msg: string) => void;
168
- warn?: (msg: string) => void;
169
- }
1
+ export function withTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutMessage: string): Promise<T> {
2
+ return new Promise((resolve, reject) => {
3
+ const timer = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs);
4
+ promise.then(
5
+ (value) => {
6
+ clearTimeout(timer);
7
+ resolve(value);
8
+ },
9
+ (err) => {
10
+ clearTimeout(timer);
11
+ reject(err);
12
+ },
13
+ );
14
+ });
15
+ }
16
+
17
+ export async function quickHealthCheck(baseUrl: string, timeoutMs: number): Promise<boolean> {
18
+ const controller = new AbortController();
19
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
20
+ try {
21
+ const response = await fetch(`${baseUrl}/health`, {
22
+ method: "GET",
23
+ signal: controller.signal,
24
+ });
25
+ if (!response.ok) {
26
+ return false;
27
+ }
28
+ const body = (await response.json().catch(() => ({}))) as { status?: string };
29
+ return body.status === "ok";
30
+ } catch {
31
+ return false;
32
+ } finally {
33
+ clearTimeout(timer);
34
+ }
35
+ }
36
+
37
+ export async function quickRecallPrecheck(
38
+ baseUrl: string,
39
+ ): Promise<{ ok: true } | { ok: false; reason: string }> {
40
+ const healthOk = await quickHealthCheck(baseUrl, 500);
41
+ if (healthOk) {
42
+ return { ok: true };
43
+ }
44
+ return { ok: false, reason: "health check failed" };
45
+ }
package/runtime-utils.ts CHANGED
@@ -1,8 +1,5 @@
1
- const _env = globalThis["process"];
2
- export function sysEnv(): NodeJS.ProcessEnv {
3
- return _env.env;
4
- }
5
-
6
- export function getEnv(key: string): string | undefined {
7
- return _env.env[key];
8
- }
1
+ const _env = globalThis["process"];
2
+
3
+ export function getEnv(key: string): string | undefined {
4
+ return _env.env[key];
5
+ }