@xdarkicex/openclaw-memory-libravdb 1.4.44 → 1.4.46
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/dist/cli.js +16 -10
- package/dist/dream-promotion.js +1 -6
- package/dist/format-error.d.ts +9 -0
- package/dist/format-error.js +14 -0
- package/dist/identity.d.ts +3 -0
- package/dist/identity.js +3 -0
- package/dist/index.js +144 -156
- package/dist/lifecycle-hooks.js +1 -6
- package/dist/markdown-ingest.js +1 -6
- package/dist/plugin-runtime.js +1 -6
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,8 @@ import { createInterface } from "node:readline/promises";
|
|
|
2
2
|
import { stdin, stdout } from "node:process";
|
|
3
3
|
import { MEMORY_CLI_DESCRIPTOR, isMemorySlotSelected } from "./cli-descriptors.js";
|
|
4
4
|
import { resolveDurableNamespace } from "./memory-scopes.js";
|
|
5
|
+
import { resolveIdentity } from "./identity.js";
|
|
6
|
+
import { formatError } from "./format-error.js";
|
|
5
7
|
import { promoteDreamDiaryFile } from "./dream-promotion.js";
|
|
6
8
|
import { buildMemoryRuntimeBridge } from "./memory-runtime.js";
|
|
7
9
|
export function registerMemoryCli(api, runtime, cfg, logger = console) {
|
|
@@ -143,7 +145,7 @@ async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
|
143
145
|
try {
|
|
144
146
|
const rpc = await runtime.getRpc();
|
|
145
147
|
const status = await rpc.call("status", {});
|
|
146
|
-
const deep = opts.deep ? await runDeepStatusProbe(rpc) : undefined;
|
|
148
|
+
const deep = opts.deep ? await runDeepStatusProbe(rpc, cfg) : undefined;
|
|
147
149
|
if (opts.json) {
|
|
148
150
|
console.log(JSON.stringify({ status, ...(deep ? { deep } : {}) }, null, 2));
|
|
149
151
|
if (deep && !deep.ok) {
|
|
@@ -192,10 +194,20 @@ async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
|
192
194
|
process.exitCode = 1;
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
const
|
|
196
|
-
async function runDeepStatusProbe(rpc) {
|
|
197
|
+
const AUTHORED_STATUS_COLLECTIONS = ["authored:hard", "authored:soft", "authored:variant"];
|
|
198
|
+
async function runDeepStatusProbe(rpc, cfg) {
|
|
199
|
+
// Resolve userId without triggering auto-derive file writes.
|
|
200
|
+
// status --deep should be read-only; if no userId is configured and no
|
|
201
|
+
// identity file exists, fall back to "default" rather than creating one.
|
|
202
|
+
const { userId } = resolveIdentity({
|
|
203
|
+
configUserId: cfg.userId,
|
|
204
|
+
identityPath: cfg.identityPath,
|
|
205
|
+
noAutoPersist: true,
|
|
206
|
+
});
|
|
207
|
+
const durableCollections = [`user:${userId}`, "global"];
|
|
208
|
+
const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
|
|
197
209
|
const probes = [];
|
|
198
|
-
for (const collection of
|
|
210
|
+
for (const collection of allCollections) {
|
|
199
211
|
try {
|
|
200
212
|
const result = await rpc.call("search_text", {
|
|
201
213
|
collection,
|
|
@@ -418,12 +430,6 @@ async function confirm(prompt) {
|
|
|
418
430
|
rl.close();
|
|
419
431
|
}
|
|
420
432
|
}
|
|
421
|
-
function formatError(error) {
|
|
422
|
-
if (error instanceof Error && error.message.trim()) {
|
|
423
|
-
return error.message;
|
|
424
|
-
}
|
|
425
|
-
return String(error);
|
|
426
|
-
}
|
|
427
433
|
function normalizeCliLimit(limit, optionName) {
|
|
428
434
|
if (limit === undefined)
|
|
429
435
|
return undefined;
|
package/dist/dream-promotion.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import fsp from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { getHashBackendName, hashBytes } from "./markdown-hash.js";
|
|
5
|
+
import { formatError } from "./format-error.js";
|
|
5
6
|
const DEFAULT_DEBOUNCE_MS = 150;
|
|
6
7
|
const DEFAULT_MIN_SCORE = 0.6;
|
|
7
8
|
const DEFAULT_MIN_RECALL_COUNT = 2;
|
|
@@ -354,10 +355,4 @@ function createRealFsApi() {
|
|
|
354
355
|
watch: (dir, onChange) => fs.watch(dir, onChange),
|
|
355
356
|
};
|
|
356
357
|
}
|
|
357
|
-
function formatError(error) {
|
|
358
|
-
if (error instanceof Error) {
|
|
359
|
-
return error.message;
|
|
360
|
-
}
|
|
361
|
-
return String(error);
|
|
362
|
-
}
|
|
363
358
|
const textDecoder = new TextDecoder();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format an unknown thrown value as a human-readable string.
|
|
3
|
+
*
|
|
4
|
+
* If the value is an Error with a non-blank message, returns the trimmed
|
|
5
|
+
* message. Otherwise falls back to `String(error)`, which produces
|
|
6
|
+
* `"Error"` for `new Error("")` and preserves the original string for
|
|
7
|
+
* non-Error throws.
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatError(error: unknown): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format an unknown thrown value as a human-readable string.
|
|
3
|
+
*
|
|
4
|
+
* If the value is an Error with a non-blank message, returns the trimmed
|
|
5
|
+
* message. Otherwise falls back to `String(error)`, which produces
|
|
6
|
+
* `"Error"` for `new Error("")` and preserves the original string for
|
|
7
|
+
* non-Error throws.
|
|
8
|
+
*/
|
|
9
|
+
export function formatError(error) {
|
|
10
|
+
if (error instanceof Error && error.message.trim()) {
|
|
11
|
+
return error.message.trim();
|
|
12
|
+
}
|
|
13
|
+
return String(error);
|
|
14
|
+
}
|
package/dist/identity.d.ts
CHANGED
|
@@ -9,4 +9,7 @@ export declare function resolveIdentity(params: {
|
|
|
9
9
|
identityPath?: string;
|
|
10
10
|
sessionKey?: string;
|
|
11
11
|
logger?: LoggerLike;
|
|
12
|
+
/** When true, skip writing the auto-derived identity file. Useful for
|
|
13
|
+
* read-only commands (e.g. status --deep) that should not mutate disk. */
|
|
14
|
+
noAutoPersist?: boolean;
|
|
12
15
|
}): ResolvedIdentity;
|
package/dist/identity.js
CHANGED
|
@@ -96,6 +96,9 @@ export function resolveIdentity(params) {
|
|
|
96
96
|
return { userId: "default", source: "default" };
|
|
97
97
|
}
|
|
98
98
|
const autoId = deriveAutoId(parts);
|
|
99
|
+
if (params.noAutoPersist) {
|
|
100
|
+
return { userId: autoId, source: "auto" };
|
|
101
|
+
}
|
|
99
102
|
try {
|
|
100
103
|
writeIdentityFile(filePath, autoId, parts);
|
|
101
104
|
params.logger?.info?.(`LibraVDB: auto-derived identity "${autoId}" written to ${filePath}`);
|
package/dist/index.js
CHANGED
|
@@ -32179,6 +32179,116 @@ function firstNonEmpty(value) {
|
|
|
32179
32179
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
32180
32180
|
}
|
|
32181
32181
|
|
|
32182
|
+
// src/identity.ts
|
|
32183
|
+
import { userInfo, hostname } from "node:os";
|
|
32184
|
+
import { createHash } from "node:crypto";
|
|
32185
|
+
import {
|
|
32186
|
+
existsSync,
|
|
32187
|
+
readFileSync,
|
|
32188
|
+
writeFileSync,
|
|
32189
|
+
renameSync,
|
|
32190
|
+
mkdirSync
|
|
32191
|
+
} from "node:fs";
|
|
32192
|
+
import { join, dirname } from "node:path";
|
|
32193
|
+
function resolveIdentityPath(configuredPath) {
|
|
32194
|
+
if (configuredPath) return configuredPath;
|
|
32195
|
+
const stateDir = process.env.OPENCLAW_STATE_DIR?.trim();
|
|
32196
|
+
if (stateDir) return join(stateDir, "libravdb-identity.json");
|
|
32197
|
+
const home = userInfo().homedir;
|
|
32198
|
+
return join(home, ".openclaw", "libravdb-identity.json");
|
|
32199
|
+
}
|
|
32200
|
+
function deriveIdentityParts() {
|
|
32201
|
+
let username;
|
|
32202
|
+
let home;
|
|
32203
|
+
try {
|
|
32204
|
+
const info = userInfo();
|
|
32205
|
+
username = info.username;
|
|
32206
|
+
home = info.homedir;
|
|
32207
|
+
} catch {
|
|
32208
|
+
username = process.env.USER || process.env.USERNAME || process.env.LOGNAME || "anon";
|
|
32209
|
+
home = process.env.HOME || process.env.USERPROFILE || "unknown";
|
|
32210
|
+
}
|
|
32211
|
+
const host = hostname();
|
|
32212
|
+
const homeHash = createHash("sha256").update(home.replace(/\\/g, "/").toLowerCase()).digest("hex").slice(0, 8);
|
|
32213
|
+
return { username, host, home, homeHash };
|
|
32214
|
+
}
|
|
32215
|
+
function deriveAutoId(parts) {
|
|
32216
|
+
return `${parts.username}@${parts.host}#${parts.homeHash}`;
|
|
32217
|
+
}
|
|
32218
|
+
function writeIdentityFile(path5, userId, parts) {
|
|
32219
|
+
const identity = {
|
|
32220
|
+
userId,
|
|
32221
|
+
derivedFrom: {
|
|
32222
|
+
username: parts.username,
|
|
32223
|
+
hostname: parts.host,
|
|
32224
|
+
homeHash: parts.homeHash,
|
|
32225
|
+
platform: process.platform
|
|
32226
|
+
},
|
|
32227
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
32228
|
+
};
|
|
32229
|
+
const dir = dirname(path5);
|
|
32230
|
+
mkdirSync(dir, { recursive: true });
|
|
32231
|
+
const tmp = `${path5}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
|
|
32232
|
+
writeFileSync(tmp, JSON.stringify(identity, null, 2) + "\n");
|
|
32233
|
+
renameSync(tmp, path5);
|
|
32234
|
+
}
|
|
32235
|
+
function resolveIdentity(params) {
|
|
32236
|
+
const configUserId = params.configUserId?.trim();
|
|
32237
|
+
if (configUserId) {
|
|
32238
|
+
return { userId: configUserId, source: "config" };
|
|
32239
|
+
}
|
|
32240
|
+
const filePath = resolveIdentityPath(params.identityPath);
|
|
32241
|
+
if (existsSync(filePath)) {
|
|
32242
|
+
try {
|
|
32243
|
+
const raw = readFileSync(filePath, "utf8");
|
|
32244
|
+
const parsed = JSON.parse(raw);
|
|
32245
|
+
if (parsed.userId && typeof parsed.userId === "string") {
|
|
32246
|
+
const trimmed = parsed.userId.trim();
|
|
32247
|
+
if (trimmed.length > 0) {
|
|
32248
|
+
return { userId: trimmed, source: "file" };
|
|
32249
|
+
}
|
|
32250
|
+
}
|
|
32251
|
+
} catch (error) {
|
|
32252
|
+
params.logger?.warn?.(
|
|
32253
|
+
`LibraVDB: failed to read identity file at ${filePath}: ${error instanceof Error ? error.message : String(error)}`
|
|
32254
|
+
);
|
|
32255
|
+
}
|
|
32256
|
+
}
|
|
32257
|
+
let parts;
|
|
32258
|
+
try {
|
|
32259
|
+
parts = deriveIdentityParts();
|
|
32260
|
+
} catch {
|
|
32261
|
+
const fallback = params.sessionKey?.trim();
|
|
32262
|
+
if (fallback) {
|
|
32263
|
+
return { userId: `session-key:${fallback}`, source: "session-key" };
|
|
32264
|
+
}
|
|
32265
|
+
return { userId: "default", source: "default" };
|
|
32266
|
+
}
|
|
32267
|
+
const autoId = deriveAutoId(parts);
|
|
32268
|
+
if (params.noAutoPersist) {
|
|
32269
|
+
return { userId: autoId, source: "auto" };
|
|
32270
|
+
}
|
|
32271
|
+
try {
|
|
32272
|
+
writeIdentityFile(filePath, autoId, parts);
|
|
32273
|
+
params.logger?.info?.(
|
|
32274
|
+
`LibraVDB: auto-derived identity "${autoId}" written to ${filePath}`
|
|
32275
|
+
);
|
|
32276
|
+
} catch (error) {
|
|
32277
|
+
params.logger?.warn?.(
|
|
32278
|
+
`LibraVDB: failed to persist identity file at ${filePath}: ${error instanceof Error ? error.message : String(error)}`
|
|
32279
|
+
);
|
|
32280
|
+
}
|
|
32281
|
+
return { userId: autoId, source: "auto" };
|
|
32282
|
+
}
|
|
32283
|
+
|
|
32284
|
+
// src/format-error.ts
|
|
32285
|
+
function formatError(error) {
|
|
32286
|
+
if (error instanceof Error && error.message.trim()) {
|
|
32287
|
+
return error.message.trim();
|
|
32288
|
+
}
|
|
32289
|
+
return String(error);
|
|
32290
|
+
}
|
|
32291
|
+
|
|
32182
32292
|
// src/dream-promotion.ts
|
|
32183
32293
|
import fs from "node:fs";
|
|
32184
32294
|
import fsp from "node:fs/promises";
|
|
@@ -32740,113 +32850,8 @@ function createRealFsApi() {
|
|
|
32740
32850
|
watch: (dir, onChange) => fs.watch(dir, onChange)
|
|
32741
32851
|
};
|
|
32742
32852
|
}
|
|
32743
|
-
function formatError(error) {
|
|
32744
|
-
if (error instanceof Error) {
|
|
32745
|
-
return error.message;
|
|
32746
|
-
}
|
|
32747
|
-
return String(error);
|
|
32748
|
-
}
|
|
32749
32853
|
var textDecoder = new TextDecoder();
|
|
32750
32854
|
|
|
32751
|
-
// src/identity.ts
|
|
32752
|
-
import { userInfo, hostname } from "node:os";
|
|
32753
|
-
import { createHash } from "node:crypto";
|
|
32754
|
-
import {
|
|
32755
|
-
existsSync,
|
|
32756
|
-
readFileSync,
|
|
32757
|
-
writeFileSync,
|
|
32758
|
-
renameSync,
|
|
32759
|
-
mkdirSync
|
|
32760
|
-
} from "node:fs";
|
|
32761
|
-
import { join, dirname } from "node:path";
|
|
32762
|
-
function resolveIdentityPath(configuredPath) {
|
|
32763
|
-
if (configuredPath) return configuredPath;
|
|
32764
|
-
const stateDir = process.env.OPENCLAW_STATE_DIR?.trim();
|
|
32765
|
-
if (stateDir) return join(stateDir, "libravdb-identity.json");
|
|
32766
|
-
const home = userInfo().homedir;
|
|
32767
|
-
return join(home, ".openclaw", "libravdb-identity.json");
|
|
32768
|
-
}
|
|
32769
|
-
function deriveIdentityParts() {
|
|
32770
|
-
let username;
|
|
32771
|
-
let home;
|
|
32772
|
-
try {
|
|
32773
|
-
const info = userInfo();
|
|
32774
|
-
username = info.username;
|
|
32775
|
-
home = info.homedir;
|
|
32776
|
-
} catch {
|
|
32777
|
-
username = process.env.USER || process.env.USERNAME || process.env.LOGNAME || "anon";
|
|
32778
|
-
home = process.env.HOME || process.env.USERPROFILE || "unknown";
|
|
32779
|
-
}
|
|
32780
|
-
const host = hostname();
|
|
32781
|
-
const homeHash = createHash("sha256").update(home.replace(/\\/g, "/").toLowerCase()).digest("hex").slice(0, 8);
|
|
32782
|
-
return { username, host, home, homeHash };
|
|
32783
|
-
}
|
|
32784
|
-
function deriveAutoId(parts) {
|
|
32785
|
-
return `${parts.username}@${parts.host}#${parts.homeHash}`;
|
|
32786
|
-
}
|
|
32787
|
-
function writeIdentityFile(path5, userId, parts) {
|
|
32788
|
-
const identity = {
|
|
32789
|
-
userId,
|
|
32790
|
-
derivedFrom: {
|
|
32791
|
-
username: parts.username,
|
|
32792
|
-
hostname: parts.host,
|
|
32793
|
-
homeHash: parts.homeHash,
|
|
32794
|
-
platform: process.platform
|
|
32795
|
-
},
|
|
32796
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
32797
|
-
};
|
|
32798
|
-
const dir = dirname(path5);
|
|
32799
|
-
mkdirSync(dir, { recursive: true });
|
|
32800
|
-
const tmp = `${path5}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
|
|
32801
|
-
writeFileSync(tmp, JSON.stringify(identity, null, 2) + "\n");
|
|
32802
|
-
renameSync(tmp, path5);
|
|
32803
|
-
}
|
|
32804
|
-
function resolveIdentity(params) {
|
|
32805
|
-
const configUserId = params.configUserId?.trim();
|
|
32806
|
-
if (configUserId) {
|
|
32807
|
-
return { userId: configUserId, source: "config" };
|
|
32808
|
-
}
|
|
32809
|
-
const filePath = resolveIdentityPath(params.identityPath);
|
|
32810
|
-
if (existsSync(filePath)) {
|
|
32811
|
-
try {
|
|
32812
|
-
const raw = readFileSync(filePath, "utf8");
|
|
32813
|
-
const parsed = JSON.parse(raw);
|
|
32814
|
-
if (parsed.userId && typeof parsed.userId === "string") {
|
|
32815
|
-
const trimmed = parsed.userId.trim();
|
|
32816
|
-
if (trimmed.length > 0) {
|
|
32817
|
-
return { userId: trimmed, source: "file" };
|
|
32818
|
-
}
|
|
32819
|
-
}
|
|
32820
|
-
} catch (error) {
|
|
32821
|
-
params.logger?.warn?.(
|
|
32822
|
-
`LibraVDB: failed to read identity file at ${filePath}: ${error instanceof Error ? error.message : String(error)}`
|
|
32823
|
-
);
|
|
32824
|
-
}
|
|
32825
|
-
}
|
|
32826
|
-
let parts;
|
|
32827
|
-
try {
|
|
32828
|
-
parts = deriveIdentityParts();
|
|
32829
|
-
} catch {
|
|
32830
|
-
const fallback = params.sessionKey?.trim();
|
|
32831
|
-
if (fallback) {
|
|
32832
|
-
return { userId: `session-key:${fallback}`, source: "session-key" };
|
|
32833
|
-
}
|
|
32834
|
-
return { userId: "default", source: "default" };
|
|
32835
|
-
}
|
|
32836
|
-
const autoId = deriveAutoId(parts);
|
|
32837
|
-
try {
|
|
32838
|
-
writeIdentityFile(filePath, autoId, parts);
|
|
32839
|
-
params.logger?.info?.(
|
|
32840
|
-
`LibraVDB: auto-derived identity "${autoId}" written to ${filePath}`
|
|
32841
|
-
);
|
|
32842
|
-
} catch (error) {
|
|
32843
|
-
params.logger?.warn?.(
|
|
32844
|
-
`LibraVDB: failed to persist identity file at ${filePath}: ${error instanceof Error ? error.message : String(error)}`
|
|
32845
|
-
);
|
|
32846
|
-
}
|
|
32847
|
-
return { userId: autoId, source: "auto" };
|
|
32848
|
-
}
|
|
32849
|
-
|
|
32850
32855
|
// src/dream-routing.ts
|
|
32851
32856
|
var DREAM_COLLECTION_PREFIX = "dream:";
|
|
32852
32857
|
var DREAM_PATTERN_RULES = [
|
|
@@ -33234,7 +33239,7 @@ async function runCliCommand(runtime, logger, action) {
|
|
|
33234
33239
|
try {
|
|
33235
33240
|
await runtime.shutdown();
|
|
33236
33241
|
} catch (error) {
|
|
33237
|
-
logger.warn?.(`LibraVDB CLI shutdown failed: ${
|
|
33242
|
+
logger.warn?.(`LibraVDB CLI shutdown failed: ${formatError(error)}`);
|
|
33238
33243
|
}
|
|
33239
33244
|
}
|
|
33240
33245
|
}
|
|
@@ -33242,7 +33247,7 @@ async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
|
33242
33247
|
try {
|
|
33243
33248
|
const rpc = await runtime.getRpc();
|
|
33244
33249
|
const status = await rpc.call("status", {});
|
|
33245
|
-
const deep = opts.deep ? await runDeepStatusProbe(rpc) : void 0;
|
|
33250
|
+
const deep = opts.deep ? await runDeepStatusProbe(rpc, cfg) : void 0;
|
|
33246
33251
|
if (opts.json) {
|
|
33247
33252
|
console.log(JSON.stringify({ status, ...deep ? { deep } : {} }, null, 2));
|
|
33248
33253
|
if (deep && !deep.ok) {
|
|
@@ -33265,14 +33270,14 @@ async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
|
33265
33270
|
process.exitCode = 1;
|
|
33266
33271
|
}
|
|
33267
33272
|
} catch (error) {
|
|
33268
|
-
logger.error(`LibraVDB status unavailable: ${
|
|
33273
|
+
logger.error(`LibraVDB status unavailable: ${formatError(error)}`);
|
|
33269
33274
|
if (opts.json) {
|
|
33270
33275
|
console.log(
|
|
33271
33276
|
JSON.stringify(
|
|
33272
33277
|
{
|
|
33273
33278
|
status: {
|
|
33274
33279
|
ok: false,
|
|
33275
|
-
message:
|
|
33280
|
+
message: formatError(error),
|
|
33276
33281
|
gatingThreshold: cfg.ingestionGateThreshold ?? 0.35
|
|
33277
33282
|
}
|
|
33278
33283
|
},
|
|
@@ -33291,15 +33296,22 @@ async function runStatus(runtime, cfg, logger, opts = {}) {
|
|
|
33291
33296
|
"Gate threshold": cfg.ingestionGateThreshold ?? 0.35,
|
|
33292
33297
|
"Abstractive model": "unknown",
|
|
33293
33298
|
"Embedding profile": "unknown",
|
|
33294
|
-
Message:
|
|
33299
|
+
Message: formatError(error)
|
|
33295
33300
|
});
|
|
33296
33301
|
process.exitCode = 1;
|
|
33297
33302
|
}
|
|
33298
33303
|
}
|
|
33299
|
-
var
|
|
33300
|
-
async function runDeepStatusProbe(rpc) {
|
|
33304
|
+
var AUTHORED_STATUS_COLLECTIONS = ["authored:hard", "authored:soft", "authored:variant"];
|
|
33305
|
+
async function runDeepStatusProbe(rpc, cfg) {
|
|
33306
|
+
const { userId } = resolveIdentity({
|
|
33307
|
+
configUserId: cfg.userId,
|
|
33308
|
+
identityPath: cfg.identityPath,
|
|
33309
|
+
noAutoPersist: true
|
|
33310
|
+
});
|
|
33311
|
+
const durableCollections = [`user:${userId}`, "global"];
|
|
33312
|
+
const allCollections = [...AUTHORED_STATUS_COLLECTIONS, ...durableCollections];
|
|
33301
33313
|
const probes = [];
|
|
33302
|
-
for (const collection of
|
|
33314
|
+
for (const collection of allCollections) {
|
|
33303
33315
|
try {
|
|
33304
33316
|
const result = await rpc.call("search_text", {
|
|
33305
33317
|
collection,
|
|
@@ -33315,7 +33327,7 @@ async function runDeepStatusProbe(rpc) {
|
|
|
33315
33327
|
probes.push({
|
|
33316
33328
|
ok: false,
|
|
33317
33329
|
collection,
|
|
33318
|
-
error:
|
|
33330
|
+
error: formatError(error)
|
|
33319
33331
|
});
|
|
33320
33332
|
}
|
|
33321
33333
|
}
|
|
@@ -33362,7 +33374,7 @@ async function runIndex(runtime, _cfg, opts, logger, params = {}) {
|
|
|
33362
33374
|
process.exitCode = 1;
|
|
33363
33375
|
}
|
|
33364
33376
|
} catch (error) {
|
|
33365
|
-
logger.error(`LibraVDB index rebuild failed: ${
|
|
33377
|
+
logger.error(`LibraVDB index rebuild failed: ${formatError(error)}`);
|
|
33366
33378
|
process.exitCode = 1;
|
|
33367
33379
|
}
|
|
33368
33380
|
}
|
|
@@ -33379,7 +33391,7 @@ async function runSearch(runtime, cfg, queryArg, opts, logger) {
|
|
|
33379
33391
|
maxResults = normalizeCliLimit(opts?.maxResults ?? opts?.limit, "--max-results");
|
|
33380
33392
|
explicitMinScore = normalizeCliScore(opts?.minScore, "--min-score");
|
|
33381
33393
|
} catch (validationError) {
|
|
33382
|
-
logger.error(
|
|
33394
|
+
logger.error(formatError(validationError));
|
|
33383
33395
|
process.exitCode = 1;
|
|
33384
33396
|
return;
|
|
33385
33397
|
}
|
|
@@ -33410,7 +33422,7 @@ async function runSearch(runtime, cfg, queryArg, opts, logger) {
|
|
|
33410
33422
|
console.log("");
|
|
33411
33423
|
}
|
|
33412
33424
|
} catch (error) {
|
|
33413
|
-
logger.error(`LibraVDB search failed: ${
|
|
33425
|
+
logger.error(`LibraVDB search failed: ${formatError(error)}`);
|
|
33414
33426
|
process.exitCode = 1;
|
|
33415
33427
|
}
|
|
33416
33428
|
}
|
|
@@ -33436,7 +33448,7 @@ async function runFlush(runtime, opts, logger) {
|
|
|
33436
33448
|
await rpc.call("flush_namespace", { namespace });
|
|
33437
33449
|
console.log(`Deleted durable memory namespace ${namespace}.`);
|
|
33438
33450
|
} catch (error) {
|
|
33439
|
-
logger.error(`LibraVDB flush failed: ${
|
|
33451
|
+
logger.error(`LibraVDB flush failed: ${formatError(error)}`);
|
|
33440
33452
|
process.exitCode = 1;
|
|
33441
33453
|
}
|
|
33442
33454
|
}
|
|
@@ -33457,7 +33469,7 @@ async function runExport(runtime, opts, logger) {
|
|
|
33457
33469
|
`);
|
|
33458
33470
|
}
|
|
33459
33471
|
} catch (error) {
|
|
33460
|
-
logger.error(`LibraVDB export failed: ${
|
|
33472
|
+
logger.error(`LibraVDB export failed: ${formatError(error)}`);
|
|
33461
33473
|
process.exitCode = 1;
|
|
33462
33474
|
}
|
|
33463
33475
|
}
|
|
@@ -33466,7 +33478,7 @@ async function runJournal(runtime, opts, logger) {
|
|
|
33466
33478
|
try {
|
|
33467
33479
|
limit = normalizeCliLimit(opts?.limit, "--limit");
|
|
33468
33480
|
} catch (validationError) {
|
|
33469
|
-
logger.error(
|
|
33481
|
+
logger.error(formatError(validationError));
|
|
33470
33482
|
process.exitCode = 1;
|
|
33471
33483
|
return;
|
|
33472
33484
|
}
|
|
@@ -33481,7 +33493,7 @@ async function runJournal(runtime, opts, logger) {
|
|
|
33481
33493
|
`);
|
|
33482
33494
|
}
|
|
33483
33495
|
} catch (error) {
|
|
33484
|
-
logger.error(`LibraVDB journal lookup failed: ${
|
|
33496
|
+
logger.error(`LibraVDB journal lookup failed: ${formatError(error)}`);
|
|
33485
33497
|
process.exitCode = 1;
|
|
33486
33498
|
}
|
|
33487
33499
|
}
|
|
@@ -33500,7 +33512,7 @@ async function runDreamPromote(runtime, opts, logger) {
|
|
|
33500
33512
|
`Promoted ${result.promoted ?? 0} dream entr${(result.promoted ?? 0) === 1 ? "y" : "ies"}; rejected ${result.rejected ?? 0}.`
|
|
33501
33513
|
);
|
|
33502
33514
|
} catch (error) {
|
|
33503
|
-
logger.error(`LibraVDB dream promotion failed: ${
|
|
33515
|
+
logger.error(`LibraVDB dream promotion failed: ${formatError(error)}`);
|
|
33504
33516
|
process.exitCode = 1;
|
|
33505
33517
|
}
|
|
33506
33518
|
}
|
|
@@ -33513,12 +33525,6 @@ async function confirm(prompt) {
|
|
|
33513
33525
|
rl.close();
|
|
33514
33526
|
}
|
|
33515
33527
|
}
|
|
33516
|
-
function formatError2(error) {
|
|
33517
|
-
if (error instanceof Error && error.message.trim()) {
|
|
33518
|
-
return error.message;
|
|
33519
|
-
}
|
|
33520
|
-
return String(error);
|
|
33521
|
-
}
|
|
33522
33528
|
function normalizeCliLimit(limit, optionName) {
|
|
33523
33529
|
if (limit === void 0) return void 0;
|
|
33524
33530
|
const parsed = parseStrictNumber(limit);
|
|
@@ -34368,7 +34374,7 @@ function createBeforeResetHook(runtime, logger = console) {
|
|
|
34368
34374
|
messageCount: Array.isArray(typedEvent.messages) ? typedEvent.messages.length : void 0
|
|
34369
34375
|
});
|
|
34370
34376
|
} catch (error) {
|
|
34371
|
-
logger.warn?.(`LibraVDB before_reset hint failed: ${
|
|
34377
|
+
logger.warn?.(`LibraVDB before_reset hint failed: ${formatError(error)}`);
|
|
34372
34378
|
}
|
|
34373
34379
|
};
|
|
34374
34380
|
}
|
|
@@ -34392,7 +34398,7 @@ function createSessionEndHook(runtime, logger = console) {
|
|
|
34392
34398
|
nextSessionKey: typedEvent.nextSessionKey
|
|
34393
34399
|
});
|
|
34394
34400
|
} catch (error) {
|
|
34395
|
-
logger.warn?.(`LibraVDB session_end hint failed: ${
|
|
34401
|
+
logger.warn?.(`LibraVDB session_end hint failed: ${formatError(error)}`);
|
|
34396
34402
|
}
|
|
34397
34403
|
};
|
|
34398
34404
|
}
|
|
@@ -34408,12 +34414,6 @@ function asSessionEndEvent(value) {
|
|
|
34408
34414
|
function isRecord(value) {
|
|
34409
34415
|
return typeof value === "object" && value !== null;
|
|
34410
34416
|
}
|
|
34411
|
-
function formatError3(error) {
|
|
34412
|
-
if (error instanceof Error && error.message.trim()) {
|
|
34413
|
-
return error.message;
|
|
34414
|
-
}
|
|
34415
|
-
return String(error);
|
|
34416
|
-
}
|
|
34417
34417
|
|
|
34418
34418
|
// src/markdown-ingest.ts
|
|
34419
34419
|
import fs2 from "node:fs";
|
|
@@ -34629,7 +34629,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
34629
34629
|
rootState.scanState.timer = setTimeout(() => {
|
|
34630
34630
|
rootState.scanState.timer = null;
|
|
34631
34631
|
void this.scanRoot(rootState.root).catch((error) => {
|
|
34632
|
-
this.logger.warn?.(`[markdown-ingest] root scan failed for ${rootState.root}: ${
|
|
34632
|
+
this.logger.warn?.(`[markdown-ingest] root scan failed for ${rootState.root}: ${formatError(error)}`);
|
|
34633
34633
|
});
|
|
34634
34634
|
}, this.debounceMs);
|
|
34635
34635
|
}
|
|
@@ -34639,7 +34639,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
34639
34639
|
try {
|
|
34640
34640
|
entries = await this.fsApi.readdir(dir);
|
|
34641
34641
|
} catch (error) {
|
|
34642
|
-
const message =
|
|
34642
|
+
const message = formatError(error);
|
|
34643
34643
|
if (!message.includes("ENOENT")) {
|
|
34644
34644
|
this.logger.warn?.(`[markdown-ingest] readdir failed for ${dir}: ${message}`);
|
|
34645
34645
|
}
|
|
@@ -34665,7 +34665,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
34665
34665
|
await this.syncMarkdownFile(rootState, child);
|
|
34666
34666
|
} catch (error) {
|
|
34667
34667
|
if (!this.stopping) {
|
|
34668
|
-
this.logger.warn?.(`[markdown-ingest] sync failed for ${child}: ${
|
|
34668
|
+
this.logger.warn?.(`[markdown-ingest] sync failed for ${child}: ${formatError(error)}`);
|
|
34669
34669
|
}
|
|
34670
34670
|
}
|
|
34671
34671
|
}
|
|
@@ -34681,11 +34681,11 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
34681
34681
|
}
|
|
34682
34682
|
});
|
|
34683
34683
|
watcher.on("error", (error) => {
|
|
34684
|
-
this.logger.warn?.(`[markdown-ingest] watch error for ${dir}: ${
|
|
34684
|
+
this.logger.warn?.(`[markdown-ingest] watch error for ${dir}: ${formatError(error)}`);
|
|
34685
34685
|
});
|
|
34686
34686
|
rootState.directoryWatchers.set(dir, watcher);
|
|
34687
34687
|
} catch (error) {
|
|
34688
|
-
this.logger.warn?.(`[markdown-ingest] watch unavailable for ${dir}: ${
|
|
34688
|
+
this.logger.warn?.(`[markdown-ingest] watch unavailable for ${dir}: ${formatError(error)}`);
|
|
34689
34689
|
}
|
|
34690
34690
|
}
|
|
34691
34691
|
shouldIncludeFile(root, filePath) {
|
|
@@ -34855,12 +34855,6 @@ function matchesGlob(value, pattern) {
|
|
|
34855
34855
|
const escaped = pattern.split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
34856
34856
|
return new RegExp(`^${escaped}$`).test(value);
|
|
34857
34857
|
}
|
|
34858
|
-
function formatError4(error) {
|
|
34859
|
-
if (error instanceof Error) {
|
|
34860
|
-
return error.message;
|
|
34861
|
-
}
|
|
34862
|
-
return String(error);
|
|
34863
|
-
}
|
|
34864
34858
|
function looksLikeObsidianNote(filePath, text) {
|
|
34865
34859
|
if (!text.startsWith("---\n")) {
|
|
34866
34860
|
return hasInlineObsidianTag(text);
|
|
@@ -39542,7 +39536,7 @@ function createPluginRuntime(cfg, logger = console) {
|
|
|
39542
39536
|
timeoutMs: cfg.rpcTimeoutMs ?? DEFAULT_RPC_TIMEOUT_MS
|
|
39543
39537
|
});
|
|
39544
39538
|
} catch (error) {
|
|
39545
|
-
logger.warn?.(`LibraVDB: failed to initialize gRPC kernel client: ${
|
|
39539
|
+
logger.warn?.(`LibraVDB: failed to initialize gRPC kernel client: ${formatError(error)}`);
|
|
39546
39540
|
}
|
|
39547
39541
|
}
|
|
39548
39542
|
return { rpc, sidecar, kernel };
|
|
@@ -39565,7 +39559,7 @@ function createPluginRuntime(cfg, logger = console) {
|
|
|
39565
39559
|
const active = await ensureStarted();
|
|
39566
39560
|
await active.rpc.call("session_lifecycle_hint", hint);
|
|
39567
39561
|
} catch (error) {
|
|
39568
|
-
logger.warn?.(`LibraVDB lifecycle hint dropped: ${
|
|
39562
|
+
logger.warn?.(`LibraVDB lifecycle hint dropped: ${formatError(error)}`);
|
|
39569
39563
|
}
|
|
39570
39564
|
},
|
|
39571
39565
|
onShutdown(task) {
|
|
@@ -39583,7 +39577,7 @@ function createPluginRuntime(cfg, logger = console) {
|
|
|
39583
39577
|
try {
|
|
39584
39578
|
await task();
|
|
39585
39579
|
} catch (error) {
|
|
39586
|
-
logger.warn?.(`LibraVDB shutdown task failed: ${
|
|
39580
|
+
logger.warn?.(`LibraVDB shutdown task failed: ${formatError(error)}`);
|
|
39587
39581
|
}
|
|
39588
39582
|
}
|
|
39589
39583
|
stopped = true;
|
|
@@ -39615,12 +39609,6 @@ function loadSecretFromEnv() {
|
|
|
39615
39609
|
}
|
|
39616
39610
|
return void 0;
|
|
39617
39611
|
}
|
|
39618
|
-
function formatError5(error) {
|
|
39619
|
-
if (error instanceof Error && error.message.trim()) {
|
|
39620
|
-
return error.message;
|
|
39621
|
-
}
|
|
39622
|
-
return String(error);
|
|
39623
|
-
}
|
|
39624
39612
|
function enrichStartupError(error, healthMessage) {
|
|
39625
39613
|
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
39626
39614
|
const message = rawMessage.trim() || "LibraVDB daemon startup failed";
|
package/dist/lifecycle-hooks.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatError } from "./format-error.js";
|
|
1
2
|
export function createBeforeResetHook(runtime, logger = console) {
|
|
2
3
|
return async (event, ctx) => {
|
|
3
4
|
const typedEvent = asBeforeResetEvent(event);
|
|
@@ -56,9 +57,3 @@ function asSessionEndEvent(value) {
|
|
|
56
57
|
function isRecord(value) {
|
|
57
58
|
return typeof value === "object" && value !== null;
|
|
58
59
|
}
|
|
59
|
-
function formatError(error) {
|
|
60
|
-
if (error instanceof Error && error.message.trim()) {
|
|
61
|
-
return error.message;
|
|
62
|
-
}
|
|
63
|
-
return String(error);
|
|
64
|
-
}
|
package/dist/markdown-ingest.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import fsp from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { hashBytes } from "./markdown-hash.js";
|
|
5
|
+
import { formatError } from "./format-error.js";
|
|
5
6
|
const DEFAULT_DEBOUNCE_MS = 150;
|
|
6
7
|
const DEFAULT_TOKENIZER_ID = "markdown-ingest:v1";
|
|
7
8
|
const MARKDOWN_INGEST_VERSION = 3;
|
|
@@ -429,12 +430,6 @@ function matchesGlob(value, pattern) {
|
|
|
429
430
|
.join(".*");
|
|
430
431
|
return new RegExp(`^${escaped}$`).test(value);
|
|
431
432
|
}
|
|
432
|
-
function formatError(error) {
|
|
433
|
-
if (error instanceof Error) {
|
|
434
|
-
return error.message;
|
|
435
|
-
}
|
|
436
|
-
return String(error);
|
|
437
|
-
}
|
|
438
433
|
function looksLikeObsidianNote(filePath, text) {
|
|
439
434
|
if (!text.startsWith("---\n")) {
|
|
440
435
|
return hasInlineObsidianTag(text);
|
package/dist/plugin-runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RpcClient } from "./rpc.js";
|
|
2
2
|
import { GrpcKernelClient } from "./grpc-client.js";
|
|
3
3
|
import { daemonProvisioningHint, startSidecar } from "./sidecar.js";
|
|
4
|
+
import { formatError } from "./format-error.js";
|
|
4
5
|
import { readFileSync } from "node:fs";
|
|
5
6
|
export const DEFAULT_RPC_TIMEOUT_MS = 30000;
|
|
6
7
|
export const STARTUP_HEALTH_TIMEOUT_MS = 2000;
|
|
@@ -124,12 +125,6 @@ function loadSecretFromEnv() {
|
|
|
124
125
|
}
|
|
125
126
|
return undefined;
|
|
126
127
|
}
|
|
127
|
-
function formatError(error) {
|
|
128
|
-
if (error instanceof Error && error.message.trim()) {
|
|
129
|
-
return error.message;
|
|
130
|
-
}
|
|
131
|
-
return String(error);
|
|
132
|
-
}
|
|
133
128
|
export function enrichStartupError(error, healthMessage) {
|
|
134
129
|
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
135
130
|
const message = rawMessage.trim() || "LibraVDB daemon startup failed";
|
package/openclaw.plugin.json
CHANGED