@xdarkicex/openclaw-memory-libravdb 1.6.25 → 1.6.28
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/README.md +218 -37
- package/dist/context-engine.d.ts +10 -2
- package/dist/context-engine.js +261 -22
- package/dist/identity.d.ts +10 -1
- package/dist/identity.js +20 -0
- package/dist/index.js +974 -149
- package/dist/libravdb-client.d.ts +3 -0
- package/dist/libravdb-client.js +12 -1
- package/dist/manifest.d.ts +46 -0
- package/dist/manifest.js +127 -0
- package/dist/memory-runtime.js +12 -7
- package/dist/plugin-runtime.d.ts +1 -1
- package/dist/plugin-runtime.js +10 -3
- package/dist/types.d.ts +5 -0
- package/docs/configuration.md +2 -2
- package/docs/embedding-profiles.md +5 -3
- package/docs/installation.md +14 -6
- package/openclaw.plugin.json +7 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5162,7 +5162,7 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5162
5162
|
return `enum ${this.typeName}`;
|
|
5163
5163
|
},
|
|
5164
5164
|
getComments() {
|
|
5165
|
-
const
|
|
5165
|
+
const path6 = this.parent ? [
|
|
5166
5166
|
...this.parent.getComments().sourcePath,
|
|
5167
5167
|
FieldNumber.DescriptorProto_EnumType,
|
|
5168
5168
|
this.parent.proto.enumType.indexOf(this.proto)
|
|
@@ -5170,7 +5170,7 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5170
5170
|
FieldNumber.FileDescriptorProto_EnumType,
|
|
5171
5171
|
this.file.proto.enumType.indexOf(this.proto)
|
|
5172
5172
|
];
|
|
5173
|
-
return findComments(file.proto.sourceCodeInfo,
|
|
5173
|
+
return findComments(file.proto.sourceCodeInfo, path6);
|
|
5174
5174
|
},
|
|
5175
5175
|
getFeatures() {
|
|
5176
5176
|
var _a2, _b2;
|
|
@@ -5201,12 +5201,12 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5201
5201
|
return str;
|
|
5202
5202
|
},
|
|
5203
5203
|
getComments() {
|
|
5204
|
-
const
|
|
5204
|
+
const path6 = [
|
|
5205
5205
|
...this.parent.getComments().sourcePath,
|
|
5206
5206
|
FieldNumber.EnumDescriptorProto_Value,
|
|
5207
5207
|
this.parent.proto.value.indexOf(this.proto)
|
|
5208
5208
|
];
|
|
5209
|
-
return findComments(file.proto.sourceCodeInfo,
|
|
5209
|
+
return findComments(file.proto.sourceCodeInfo, path6);
|
|
5210
5210
|
},
|
|
5211
5211
|
getFeatures() {
|
|
5212
5212
|
var _a3;
|
|
@@ -5237,7 +5237,7 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5237
5237
|
return `message ${this.typeName}`;
|
|
5238
5238
|
},
|
|
5239
5239
|
getComments() {
|
|
5240
|
-
const
|
|
5240
|
+
const path6 = this.parent ? [
|
|
5241
5241
|
...this.parent.getComments().sourcePath,
|
|
5242
5242
|
FieldNumber.DescriptorProto_NestedType,
|
|
5243
5243
|
this.parent.proto.nestedType.indexOf(this.proto)
|
|
@@ -5245,7 +5245,7 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5245
5245
|
FieldNumber.FileDescriptorProto_MessageType,
|
|
5246
5246
|
this.file.proto.messageType.indexOf(this.proto)
|
|
5247
5247
|
];
|
|
5248
|
-
return findComments(file.proto.sourceCodeInfo,
|
|
5248
|
+
return findComments(file.proto.sourceCodeInfo, path6);
|
|
5249
5249
|
},
|
|
5250
5250
|
getFeatures() {
|
|
5251
5251
|
var _a2, _b2;
|
|
@@ -5280,11 +5280,11 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5280
5280
|
return `service ${this.typeName}`;
|
|
5281
5281
|
},
|
|
5282
5282
|
getComments() {
|
|
5283
|
-
const
|
|
5283
|
+
const path6 = [
|
|
5284
5284
|
FieldNumber.FileDescriptorProto_Service,
|
|
5285
5285
|
this.file.proto.service.indexOf(this.proto)
|
|
5286
5286
|
];
|
|
5287
|
-
return findComments(file.proto.sourceCodeInfo,
|
|
5287
|
+
return findComments(file.proto.sourceCodeInfo, path6);
|
|
5288
5288
|
},
|
|
5289
5289
|
getFeatures() {
|
|
5290
5290
|
var _a2;
|
|
@@ -5344,12 +5344,12 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5344
5344
|
return `rpc ${parent.typeName}.${name}`;
|
|
5345
5345
|
},
|
|
5346
5346
|
getComments() {
|
|
5347
|
-
const
|
|
5347
|
+
const path6 = [
|
|
5348
5348
|
...this.parent.getComments().sourcePath,
|
|
5349
5349
|
FieldNumber.ServiceDescriptorProto_Method,
|
|
5350
5350
|
this.parent.proto.method.indexOf(this.proto)
|
|
5351
5351
|
];
|
|
5352
|
-
return findComments(parent.file.proto.sourceCodeInfo,
|
|
5352
|
+
return findComments(parent.file.proto.sourceCodeInfo, path6);
|
|
5353
5353
|
},
|
|
5354
5354
|
getFeatures() {
|
|
5355
5355
|
var _a2;
|
|
@@ -5370,12 +5370,12 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5370
5370
|
return `oneof ${parent.typeName}.${this.name}`;
|
|
5371
5371
|
},
|
|
5372
5372
|
getComments() {
|
|
5373
|
-
const
|
|
5373
|
+
const path6 = [
|
|
5374
5374
|
...this.parent.getComments().sourcePath,
|
|
5375
5375
|
FieldNumber.DescriptorProto_OneofDecl,
|
|
5376
5376
|
this.parent.proto.oneofDecl.indexOf(this.proto)
|
|
5377
5377
|
];
|
|
5378
|
-
return findComments(parent.file.proto.sourceCodeInfo,
|
|
5378
|
+
return findComments(parent.file.proto.sourceCodeInfo, path6);
|
|
5379
5379
|
},
|
|
5380
5380
|
getFeatures() {
|
|
5381
5381
|
var _a;
|
|
@@ -5411,12 +5411,12 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5411
5411
|
return `field ${this.parent.typeName}.${this.name}`;
|
|
5412
5412
|
},
|
|
5413
5413
|
getComments() {
|
|
5414
|
-
const
|
|
5414
|
+
const path6 = [
|
|
5415
5415
|
...this.parent.getComments().sourcePath,
|
|
5416
5416
|
FieldNumber.DescriptorProto_Field,
|
|
5417
5417
|
this.parent.proto.field.indexOf(this.proto)
|
|
5418
5418
|
];
|
|
5419
|
-
return findComments(file.proto.sourceCodeInfo,
|
|
5419
|
+
return findComments(file.proto.sourceCodeInfo, path6);
|
|
5420
5420
|
},
|
|
5421
5421
|
getFeatures() {
|
|
5422
5422
|
var _a2;
|
|
@@ -5493,7 +5493,7 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5493
5493
|
return `extension ${this.typeName}`;
|
|
5494
5494
|
},
|
|
5495
5495
|
getComments() {
|
|
5496
|
-
const
|
|
5496
|
+
const path6 = this.parent ? [
|
|
5497
5497
|
...this.parent.getComments().sourcePath,
|
|
5498
5498
|
FieldNumber.DescriptorProto_Extension,
|
|
5499
5499
|
this.parent.proto.extension.indexOf(proto)
|
|
@@ -5501,7 +5501,7 @@ var require_create_descriptor_set = __commonJS({
|
|
|
5501
5501
|
FieldNumber.FileDescriptorProto_Extension,
|
|
5502
5502
|
this.file.proto.extension.indexOf(proto)
|
|
5503
5503
|
];
|
|
5504
|
-
return findComments(file.proto.sourceCodeInfo,
|
|
5504
|
+
return findComments(file.proto.sourceCodeInfo, path6);
|
|
5505
5505
|
},
|
|
5506
5506
|
getFeatures() {
|
|
5507
5507
|
var _a;
|
|
@@ -8624,14 +8624,14 @@ var require_util = __commonJS({
|
|
|
8624
8624
|
}
|
|
8625
8625
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
8626
8626
|
let origin = url.origin != null ? url.origin : `${url.protocol}//${url.hostname}:${port}`;
|
|
8627
|
-
let
|
|
8627
|
+
let path6 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
8628
8628
|
if (origin.endsWith("/")) {
|
|
8629
8629
|
origin = origin.substring(0, origin.length - 1);
|
|
8630
8630
|
}
|
|
8631
|
-
if (
|
|
8632
|
-
|
|
8631
|
+
if (path6 && !path6.startsWith("/")) {
|
|
8632
|
+
path6 = `/${path6}`;
|
|
8633
8633
|
}
|
|
8634
|
-
url = new URL(origin +
|
|
8634
|
+
url = new URL(origin + path6);
|
|
8635
8635
|
}
|
|
8636
8636
|
return url;
|
|
8637
8637
|
}
|
|
@@ -10245,20 +10245,20 @@ var require_parseParams = __commonJS({
|
|
|
10245
10245
|
var require_basename = __commonJS({
|
|
10246
10246
|
"node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports, module) {
|
|
10247
10247
|
"use strict";
|
|
10248
|
-
module.exports = function basename(
|
|
10249
|
-
if (typeof
|
|
10248
|
+
module.exports = function basename(path6) {
|
|
10249
|
+
if (typeof path6 !== "string") {
|
|
10250
10250
|
return "";
|
|
10251
10251
|
}
|
|
10252
|
-
for (var i =
|
|
10253
|
-
switch (
|
|
10252
|
+
for (var i = path6.length - 1; i >= 0; --i) {
|
|
10253
|
+
switch (path6.charCodeAt(i)) {
|
|
10254
10254
|
case 47:
|
|
10255
10255
|
// '/'
|
|
10256
10256
|
case 92:
|
|
10257
|
-
|
|
10258
|
-
return
|
|
10257
|
+
path6 = path6.slice(i + 1);
|
|
10258
|
+
return path6 === ".." || path6 === "." ? "" : path6;
|
|
10259
10259
|
}
|
|
10260
10260
|
}
|
|
10261
|
-
return
|
|
10261
|
+
return path6 === ".." || path6 === "." ? "" : path6;
|
|
10262
10262
|
};
|
|
10263
10263
|
}
|
|
10264
10264
|
});
|
|
@@ -11262,11 +11262,11 @@ var require_util2 = __commonJS({
|
|
|
11262
11262
|
var assert = __require("assert");
|
|
11263
11263
|
var { isUint8Array } = __require("util/types");
|
|
11264
11264
|
var supportedHashes = [];
|
|
11265
|
-
var
|
|
11265
|
+
var crypto2;
|
|
11266
11266
|
try {
|
|
11267
|
-
|
|
11267
|
+
crypto2 = __require("crypto");
|
|
11268
11268
|
const possibleRelevantHashes = ["sha256", "sha384", "sha512"];
|
|
11269
|
-
supportedHashes =
|
|
11269
|
+
supportedHashes = crypto2.getHashes().filter((hash) => possibleRelevantHashes.includes(hash));
|
|
11270
11270
|
} catch {
|
|
11271
11271
|
}
|
|
11272
11272
|
function responseURL(response) {
|
|
@@ -11543,7 +11543,7 @@ var require_util2 = __commonJS({
|
|
|
11543
11543
|
}
|
|
11544
11544
|
}
|
|
11545
11545
|
function bytesMatch(bytes, metadataList) {
|
|
11546
|
-
if (
|
|
11546
|
+
if (crypto2 === void 0) {
|
|
11547
11547
|
return true;
|
|
11548
11548
|
}
|
|
11549
11549
|
const parsedMetadata = parseMetadata(metadataList);
|
|
@@ -11558,7 +11558,7 @@ var require_util2 = __commonJS({
|
|
|
11558
11558
|
for (const item of metadata) {
|
|
11559
11559
|
const algorithm = item.algo;
|
|
11560
11560
|
const expectedValue = item.hash;
|
|
11561
|
-
let actualValue =
|
|
11561
|
+
let actualValue = crypto2.createHash(algorithm).update(bytes).digest("base64");
|
|
11562
11562
|
if (actualValue[actualValue.length - 1] === "=") {
|
|
11563
11563
|
if (actualValue[actualValue.length - 2] === "=") {
|
|
11564
11564
|
actualValue = actualValue.slice(0, -2);
|
|
@@ -12904,8 +12904,8 @@ var require_body = __commonJS({
|
|
|
12904
12904
|
var { parseMIMEType, serializeAMimeType } = require_dataURL();
|
|
12905
12905
|
var random;
|
|
12906
12906
|
try {
|
|
12907
|
-
const
|
|
12908
|
-
random = (max) =>
|
|
12907
|
+
const crypto2 = __require("node:crypto");
|
|
12908
|
+
random = (max) => crypto2.randomInt(0, max);
|
|
12909
12909
|
} catch {
|
|
12910
12910
|
random = (max) => Math.floor(Math.random(max));
|
|
12911
12911
|
}
|
|
@@ -13288,7 +13288,7 @@ var require_request = __commonJS({
|
|
|
13288
13288
|
}
|
|
13289
13289
|
var Request = class _Request {
|
|
13290
13290
|
constructor(origin, {
|
|
13291
|
-
path:
|
|
13291
|
+
path: path6,
|
|
13292
13292
|
method,
|
|
13293
13293
|
body,
|
|
13294
13294
|
headers,
|
|
@@ -13302,11 +13302,11 @@ var require_request = __commonJS({
|
|
|
13302
13302
|
throwOnError,
|
|
13303
13303
|
expectContinue
|
|
13304
13304
|
}, handler) {
|
|
13305
|
-
if (typeof
|
|
13305
|
+
if (typeof path6 !== "string") {
|
|
13306
13306
|
throw new InvalidArgumentError("path must be a string");
|
|
13307
|
-
} else if (
|
|
13307
|
+
} else if (path6[0] !== "/" && !(path6.startsWith("http://") || path6.startsWith("https://")) && method !== "CONNECT") {
|
|
13308
13308
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
13309
|
-
} else if (invalidPathRegex.exec(
|
|
13309
|
+
} else if (invalidPathRegex.exec(path6) !== null) {
|
|
13310
13310
|
throw new InvalidArgumentError("invalid request path");
|
|
13311
13311
|
}
|
|
13312
13312
|
if (typeof method !== "string") {
|
|
@@ -13369,7 +13369,7 @@ var require_request = __commonJS({
|
|
|
13369
13369
|
this.completed = false;
|
|
13370
13370
|
this.aborted = false;
|
|
13371
13371
|
this.upgrade = upgrade || null;
|
|
13372
|
-
this.path = query ? util.buildURL(
|
|
13372
|
+
this.path = query ? util.buildURL(path6, query) : path6;
|
|
13373
13373
|
this.origin = origin;
|
|
13374
13374
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
13375
13375
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -14377,9 +14377,9 @@ var require_RedirectHandler = __commonJS({
|
|
|
14377
14377
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
14378
14378
|
}
|
|
14379
14379
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
14380
|
-
const
|
|
14380
|
+
const path6 = search ? `${pathname}${search}` : pathname;
|
|
14381
14381
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
14382
|
-
this.opts.path =
|
|
14382
|
+
this.opts.path = path6;
|
|
14383
14383
|
this.opts.origin = origin;
|
|
14384
14384
|
this.opts.maxRedirections = 0;
|
|
14385
14385
|
this.opts.query = null;
|
|
@@ -15619,7 +15619,7 @@ var require_client = __commonJS({
|
|
|
15619
15619
|
writeH2(client, client[kHTTP2Session], request3);
|
|
15620
15620
|
return;
|
|
15621
15621
|
}
|
|
15622
|
-
const { body, method, path:
|
|
15622
|
+
const { body, method, path: path6, host, upgrade, headers, blocking, reset } = request3;
|
|
15623
15623
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
15624
15624
|
if (body && typeof body.read === "function") {
|
|
15625
15625
|
body.read(0);
|
|
@@ -15669,7 +15669,7 @@ var require_client = __commonJS({
|
|
|
15669
15669
|
if (blocking) {
|
|
15670
15670
|
socket[kBlocking] = true;
|
|
15671
15671
|
}
|
|
15672
|
-
let header = `${method} ${
|
|
15672
|
+
let header = `${method} ${path6} HTTP/1.1\r
|
|
15673
15673
|
`;
|
|
15674
15674
|
if (typeof host === "string") {
|
|
15675
15675
|
header += `host: ${host}\r
|
|
@@ -15732,7 +15732,7 @@ upgrade: ${upgrade}\r
|
|
|
15732
15732
|
return true;
|
|
15733
15733
|
}
|
|
15734
15734
|
function writeH2(client, session, request3) {
|
|
15735
|
-
const { body, method, path:
|
|
15735
|
+
const { body, method, path: path6, host, upgrade, expectContinue, signal, headers: reqHeaders } = request3;
|
|
15736
15736
|
let headers;
|
|
15737
15737
|
if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
|
|
15738
15738
|
else headers = reqHeaders;
|
|
@@ -15775,7 +15775,7 @@ upgrade: ${upgrade}\r
|
|
|
15775
15775
|
});
|
|
15776
15776
|
return true;
|
|
15777
15777
|
}
|
|
15778
|
-
headers[HTTP2_HEADER_PATH] =
|
|
15778
|
+
headers[HTTP2_HEADER_PATH] = path6;
|
|
15779
15779
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
15780
15780
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
15781
15781
|
if (body && typeof body.read === "function") {
|
|
@@ -18015,20 +18015,20 @@ var require_mock_utils = __commonJS({
|
|
|
18015
18015
|
}
|
|
18016
18016
|
return true;
|
|
18017
18017
|
}
|
|
18018
|
-
function safeUrl(
|
|
18019
|
-
if (typeof
|
|
18020
|
-
return
|
|
18018
|
+
function safeUrl(path6) {
|
|
18019
|
+
if (typeof path6 !== "string") {
|
|
18020
|
+
return path6;
|
|
18021
18021
|
}
|
|
18022
|
-
const pathSegments =
|
|
18022
|
+
const pathSegments = path6.split("?");
|
|
18023
18023
|
if (pathSegments.length !== 2) {
|
|
18024
|
-
return
|
|
18024
|
+
return path6;
|
|
18025
18025
|
}
|
|
18026
18026
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
18027
18027
|
qp.sort();
|
|
18028
18028
|
return [...pathSegments, qp.toString()].join("?");
|
|
18029
18029
|
}
|
|
18030
|
-
function matchKey(mockDispatch2, { path:
|
|
18031
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
18030
|
+
function matchKey(mockDispatch2, { path: path6, method, body, headers }) {
|
|
18031
|
+
const pathMatch = matchValue(mockDispatch2.path, path6);
|
|
18032
18032
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
18033
18033
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
18034
18034
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -18046,7 +18046,7 @@ var require_mock_utils = __commonJS({
|
|
|
18046
18046
|
function getMockDispatch(mockDispatches, key) {
|
|
18047
18047
|
const basePath = key.query ? buildURL(key.path, key.query) : key.path;
|
|
18048
18048
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
18049
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
18049
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path6 }) => matchValue(safeUrl(path6), resolvedPath));
|
|
18050
18050
|
if (matchedMockDispatches.length === 0) {
|
|
18051
18051
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
18052
18052
|
}
|
|
@@ -18083,9 +18083,9 @@ var require_mock_utils = __commonJS({
|
|
|
18083
18083
|
}
|
|
18084
18084
|
}
|
|
18085
18085
|
function buildKey(opts) {
|
|
18086
|
-
const { path:
|
|
18086
|
+
const { path: path6, method, body, headers, query } = opts;
|
|
18087
18087
|
return {
|
|
18088
|
-
path:
|
|
18088
|
+
path: path6,
|
|
18089
18089
|
method,
|
|
18090
18090
|
body,
|
|
18091
18091
|
headers,
|
|
@@ -18534,10 +18534,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
18534
18534
|
}
|
|
18535
18535
|
format(pendingInterceptors) {
|
|
18536
18536
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
18537
|
-
({ method, path:
|
|
18537
|
+
({ method, path: path6, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
18538
18538
|
Method: method,
|
|
18539
18539
|
Origin: origin,
|
|
18540
|
-
Path:
|
|
18540
|
+
Path: path6,
|
|
18541
18541
|
"Status code": statusCode,
|
|
18542
18542
|
Persistent: persist ? "\u2705" : "\u274C",
|
|
18543
18543
|
Invocations: timesInvoked,
|
|
@@ -23157,8 +23157,8 @@ var require_util6 = __commonJS({
|
|
|
23157
23157
|
}
|
|
23158
23158
|
}
|
|
23159
23159
|
}
|
|
23160
|
-
function validateCookiePath(
|
|
23161
|
-
for (const char of
|
|
23160
|
+
function validateCookiePath(path6) {
|
|
23161
|
+
for (const char of path6) {
|
|
23162
23162
|
const code = char.charCodeAt(0);
|
|
23163
23163
|
if (code < 33 || char === ";") {
|
|
23164
23164
|
throw new Error("Invalid cookie path");
|
|
@@ -23955,9 +23955,9 @@ var require_connection = __commonJS({
|
|
|
23955
23955
|
channels.open = diagnosticsChannel.channel("undici:websocket:open");
|
|
23956
23956
|
channels.close = diagnosticsChannel.channel("undici:websocket:close");
|
|
23957
23957
|
channels.socketError = diagnosticsChannel.channel("undici:websocket:socket_error");
|
|
23958
|
-
var
|
|
23958
|
+
var crypto2;
|
|
23959
23959
|
try {
|
|
23960
|
-
|
|
23960
|
+
crypto2 = __require("crypto");
|
|
23961
23961
|
} catch {
|
|
23962
23962
|
}
|
|
23963
23963
|
function establishWebSocketConnection(url, protocols, ws, onEstablish, options) {
|
|
@@ -23976,7 +23976,7 @@ var require_connection = __commonJS({
|
|
|
23976
23976
|
const headersList = new Headers2(options.headers)[kHeadersList];
|
|
23977
23977
|
request3.headersList = headersList;
|
|
23978
23978
|
}
|
|
23979
|
-
const keyValue =
|
|
23979
|
+
const keyValue = crypto2.randomBytes(16).toString("base64");
|
|
23980
23980
|
request3.headersList.append("sec-websocket-key", keyValue);
|
|
23981
23981
|
request3.headersList.append("sec-websocket-version", "13");
|
|
23982
23982
|
for (const protocol of protocols) {
|
|
@@ -24005,7 +24005,7 @@ var require_connection = __commonJS({
|
|
|
24005
24005
|
return;
|
|
24006
24006
|
}
|
|
24007
24007
|
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
24008
|
-
const digest =
|
|
24008
|
+
const digest = crypto2.createHash("sha1").update(keyValue + uid).digest("base64");
|
|
24009
24009
|
if (secWSAccept !== digest) {
|
|
24010
24010
|
failWebsocketConnection(ws, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
24011
24011
|
return;
|
|
@@ -24085,9 +24085,9 @@ var require_frame = __commonJS({
|
|
|
24085
24085
|
"node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/frame.js"(exports, module) {
|
|
24086
24086
|
"use strict";
|
|
24087
24087
|
var { maxUnsigned16Bit } = require_constants5();
|
|
24088
|
-
var
|
|
24088
|
+
var crypto2;
|
|
24089
24089
|
try {
|
|
24090
|
-
|
|
24090
|
+
crypto2 = __require("crypto");
|
|
24091
24091
|
} catch {
|
|
24092
24092
|
}
|
|
24093
24093
|
var WebsocketFrameSend = class {
|
|
@@ -24096,7 +24096,7 @@ var require_frame = __commonJS({
|
|
|
24096
24096
|
*/
|
|
24097
24097
|
constructor(data) {
|
|
24098
24098
|
this.frameData = data;
|
|
24099
|
-
this.maskKey =
|
|
24099
|
+
this.maskKey = crypto2.randomBytes(4);
|
|
24100
24100
|
}
|
|
24101
24101
|
createFrame(opcode) {
|
|
24102
24102
|
const bodyLength = this.frameData?.byteLength ?? 0;
|
|
@@ -24838,11 +24838,11 @@ var require_undici = __commonJS({
|
|
|
24838
24838
|
if (typeof opts.path !== "string") {
|
|
24839
24839
|
throw new InvalidArgumentError("invalid opts.path");
|
|
24840
24840
|
}
|
|
24841
|
-
let
|
|
24841
|
+
let path6 = opts.path;
|
|
24842
24842
|
if (!opts.path.startsWith("/")) {
|
|
24843
|
-
|
|
24843
|
+
path6 = `/${path6}`;
|
|
24844
24844
|
}
|
|
24845
|
-
url = new URL(util.parseOrigin(url).origin +
|
|
24845
|
+
url = new URL(util.parseOrigin(url).origin + path6);
|
|
24846
24846
|
} else {
|
|
24847
24847
|
if (!opts) {
|
|
24848
24848
|
opts = typeof url === "object" ? url : {};
|
|
@@ -25030,7 +25030,7 @@ function deriveIdentityParts() {
|
|
|
25030
25030
|
function deriveAutoId(parts) {
|
|
25031
25031
|
return `${parts.username}@${parts.host}#${parts.homeHash}`;
|
|
25032
25032
|
}
|
|
25033
|
-
function writeIdentityFile(
|
|
25033
|
+
function writeIdentityFile(path6, userId, parts) {
|
|
25034
25034
|
const identity = {
|
|
25035
25035
|
userId,
|
|
25036
25036
|
derivedFrom: {
|
|
@@ -25041,15 +25041,15 @@ function writeIdentityFile(path5, userId, parts) {
|
|
|
25041
25041
|
},
|
|
25042
25042
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
25043
25043
|
};
|
|
25044
|
-
const dir = dirname(
|
|
25044
|
+
const dir = dirname(path6);
|
|
25045
25045
|
mkdirSync(dir, { recursive: true });
|
|
25046
|
-
const tmp = `${
|
|
25046
|
+
const tmp = `${path6}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
|
|
25047
25047
|
writeFileSync(tmp, JSON.stringify(identity, null, 2) + "\n", { mode: 384 });
|
|
25048
|
-
renameSync(tmp,
|
|
25048
|
+
renameSync(tmp, path6);
|
|
25049
25049
|
if (process.platform === "win32") {
|
|
25050
25050
|
try {
|
|
25051
25051
|
execSync(
|
|
25052
|
-
`icacls "${
|
|
25052
|
+
`icacls "${path6}" /inheritance:r /grant:r "%USERNAME%:(R,W)"`,
|
|
25053
25053
|
{ stdio: "ignore", timeout: 5e3 }
|
|
25054
25054
|
);
|
|
25055
25055
|
} catch {
|
|
@@ -25104,6 +25104,16 @@ function resolveIdentity(params) {
|
|
|
25104
25104
|
}
|
|
25105
25105
|
return { userId: autoId, source: "auto" };
|
|
25106
25106
|
}
|
|
25107
|
+
function resolveTenantKey(cfg) {
|
|
25108
|
+
const explicit = cfg.tenantId?.trim();
|
|
25109
|
+
if (explicit) return explicit;
|
|
25110
|
+
const envId = process.env.LIBRAVDB_AGENT_ID?.trim();
|
|
25111
|
+
if (envId) return envId;
|
|
25112
|
+
return resolveIdentity({
|
|
25113
|
+
configUserId: cfg.userId,
|
|
25114
|
+
identityPath: cfg.identityPath
|
|
25115
|
+
}).userId;
|
|
25116
|
+
}
|
|
25107
25117
|
|
|
25108
25118
|
// src/format-error.ts
|
|
25109
25119
|
function formatError(error2) {
|
|
@@ -25849,18 +25859,22 @@ function createMemorySearchManager(getClient, cfg, defaults, initialStatus) {
|
|
|
25849
25859
|
k
|
|
25850
25860
|
}) : await searchResolvedCollections(client, cfg, userId, sessionId, queryText, k);
|
|
25851
25861
|
const filteredResults = minScore === void 0 ? result.results : result.results.filter((item) => item.score >= minScore);
|
|
25852
|
-
const legacyResults = filteredResults.map((item) =>
|
|
25853
|
-
|
|
25854
|
-
|
|
25855
|
-
|
|
25862
|
+
const legacyResults = filteredResults.map((item) => {
|
|
25863
|
+
const meta = parseMetadataJson(item);
|
|
25864
|
+
return {
|
|
25865
|
+
...item,
|
|
25866
|
+
content: item.text || (typeof meta.text === "string" ? meta.text : "")
|
|
25867
|
+
};
|
|
25868
|
+
});
|
|
25856
25869
|
if (legacyCall) {
|
|
25857
25870
|
return { results: legacyResults };
|
|
25858
25871
|
}
|
|
25859
25872
|
const memoryResults = filteredResults.map((item) => {
|
|
25860
25873
|
const meta = parseMetadataJson(item);
|
|
25861
25874
|
const collection = typeof meta.collection === "string" ? meta.collection : "memory";
|
|
25875
|
+
const effectiveText = item.text || (typeof meta.text === "string" ? meta.text : "") || "";
|
|
25862
25876
|
const relPath = encodeSearchResultPath(collection, item.id);
|
|
25863
|
-
returnedSearchPaths.set(relPath,
|
|
25877
|
+
returnedSearchPaths.set(relPath, effectiveText);
|
|
25864
25878
|
return toMemorySearchResult(item);
|
|
25865
25879
|
});
|
|
25866
25880
|
return memoryResults;
|
|
@@ -25962,12 +25976,13 @@ function parseMetadataJson(item) {
|
|
|
25962
25976
|
function toMemorySearchResult(item) {
|
|
25963
25977
|
const meta = parseMetadataJson(item);
|
|
25964
25978
|
const collection = typeof meta.collection === "string" ? meta.collection : "memory";
|
|
25979
|
+
const effectiveText = item.text || (typeof meta.text === "string" ? meta.text : "") || "";
|
|
25965
25980
|
return {
|
|
25966
25981
|
path: encodeSearchResultPath(collection, item.id),
|
|
25967
25982
|
startLine: 1,
|
|
25968
|
-
endLine: Math.max(1,
|
|
25983
|
+
endLine: Math.max(1, effectiveText.split("\n").length),
|
|
25969
25984
|
score: item.score,
|
|
25970
|
-
snippet:
|
|
25985
|
+
snippet: effectiveText,
|
|
25971
25986
|
source: collection.startsWith("session:") || collection.startsWith("session_") ? "sessions" : "memory",
|
|
25972
25987
|
citation: `${collection}:${item.id}`
|
|
25973
25988
|
};
|
|
@@ -26514,6 +26529,131 @@ function resolveCliMemoryOperationScope(opts) {
|
|
|
26514
26529
|
};
|
|
26515
26530
|
}
|
|
26516
26531
|
|
|
26532
|
+
// src/context-engine.ts
|
|
26533
|
+
import { randomUUID } from "node:crypto";
|
|
26534
|
+
|
|
26535
|
+
// src/manifest.ts
|
|
26536
|
+
import * as fs2 from "fs";
|
|
26537
|
+
import * as path2 from "path";
|
|
26538
|
+
import * as crypto from "crypto";
|
|
26539
|
+
import * as os2 from "os";
|
|
26540
|
+
var TurnManifestStore = class {
|
|
26541
|
+
manifestDir;
|
|
26542
|
+
constructor() {
|
|
26543
|
+
this.manifestDir = path2.join(os2.homedir(), ".openclaw", "libravdb-manifests");
|
|
26544
|
+
if (!fs2.existsSync(this.manifestDir)) {
|
|
26545
|
+
fs2.mkdirSync(this.manifestDir, { recursive: true });
|
|
26546
|
+
}
|
|
26547
|
+
}
|
|
26548
|
+
getManifestPath(sessionId) {
|
|
26549
|
+
const safe = sessionId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
26550
|
+
return path2.join(this.manifestDir, `${safe}.manifest.json`);
|
|
26551
|
+
}
|
|
26552
|
+
hashString(data) {
|
|
26553
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
26554
|
+
}
|
|
26555
|
+
createEmpty(sessionId) {
|
|
26556
|
+
return {
|
|
26557
|
+
sessionId,
|
|
26558
|
+
version: 0,
|
|
26559
|
+
turns: [],
|
|
26560
|
+
tailHash: "0000000000000000000000000000000000000000000000000000000000000000"
|
|
26561
|
+
};
|
|
26562
|
+
}
|
|
26563
|
+
load(sessionId, logger) {
|
|
26564
|
+
const filePath = this.getManifestPath(sessionId);
|
|
26565
|
+
if (!fs2.existsSync(filePath)) {
|
|
26566
|
+
return this.createEmpty(sessionId);
|
|
26567
|
+
}
|
|
26568
|
+
try {
|
|
26569
|
+
const raw = fs2.readFileSync(filePath, "utf8");
|
|
26570
|
+
const manifest = JSON.parse(raw);
|
|
26571
|
+
if (!this.verifyChain(manifest)) {
|
|
26572
|
+
logger?.warn?.(`[LibraVDB] Manifest chain broken for session ${sessionId}. Forcing re-sync.`);
|
|
26573
|
+
return this.createEmpty(sessionId);
|
|
26574
|
+
}
|
|
26575
|
+
return manifest;
|
|
26576
|
+
} catch (e) {
|
|
26577
|
+
logger?.error?.(`[LibraVDB] Failed to read manifest for ${sessionId}:`, e);
|
|
26578
|
+
return this.createEmpty(sessionId);
|
|
26579
|
+
}
|
|
26580
|
+
}
|
|
26581
|
+
save(manifest) {
|
|
26582
|
+
const filePath = this.getManifestPath(manifest.sessionId);
|
|
26583
|
+
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
26584
|
+
fs2.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
|
|
26585
|
+
fs2.renameSync(tempPath, filePath);
|
|
26586
|
+
}
|
|
26587
|
+
verifyChain(manifest) {
|
|
26588
|
+
let currentHash = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
26589
|
+
for (const turn of manifest.turns) {
|
|
26590
|
+
const expectedHash = this.hashString(`${turn.index}${turn.role}${turn.contentHash}${currentHash}`);
|
|
26591
|
+
if (turn.turnHash !== expectedHash) {
|
|
26592
|
+
return false;
|
|
26593
|
+
}
|
|
26594
|
+
currentHash = expectedHash;
|
|
26595
|
+
}
|
|
26596
|
+
return manifest.tailHash === currentHash;
|
|
26597
|
+
}
|
|
26598
|
+
/**
|
|
26599
|
+
* Finds the overlap point between incoming messages and our stored history.
|
|
26600
|
+
* Returns the index into incomingMessages where new (un-ACKed) messages begin.
|
|
26601
|
+
* Returns 0 if no overlap (full re-sync).
|
|
26602
|
+
*/
|
|
26603
|
+
findOverlapIndex(manifest, incomingMessages) {
|
|
26604
|
+
if (manifest.turns.length === 0) {
|
|
26605
|
+
return 0;
|
|
26606
|
+
}
|
|
26607
|
+
const known = /* @__PURE__ */ new Map();
|
|
26608
|
+
for (const turn of manifest.turns) {
|
|
26609
|
+
known.set(turn.contentHash, turn.index);
|
|
26610
|
+
}
|
|
26611
|
+
for (let i = incomingMessages.length - 1; i >= 0; i--) {
|
|
26612
|
+
const contentHash = this.hashString(incomingMessages[i].content);
|
|
26613
|
+
if (known.has(contentHash)) {
|
|
26614
|
+
return i + 1;
|
|
26615
|
+
}
|
|
26616
|
+
}
|
|
26617
|
+
return 0;
|
|
26618
|
+
}
|
|
26619
|
+
appendACKedMessages(manifest, newMessages, startingIndex) {
|
|
26620
|
+
let currentHash = manifest.tailHash;
|
|
26621
|
+
const newTurns = [];
|
|
26622
|
+
for (let i = 0; i < newMessages.length; i++) {
|
|
26623
|
+
const msg = newMessages[i];
|
|
26624
|
+
const absoluteIndex = startingIndex + i;
|
|
26625
|
+
const contentHash = this.hashString(msg.content);
|
|
26626
|
+
currentHash = this.hashString(`${absoluteIndex}${msg.role}${contentHash}${currentHash}`);
|
|
26627
|
+
newTurns.push({
|
|
26628
|
+
index: absoluteIndex,
|
|
26629
|
+
role: msg.role,
|
|
26630
|
+
contentHash,
|
|
26631
|
+
turnHash: currentHash,
|
|
26632
|
+
ingestedAt: Date.now()
|
|
26633
|
+
});
|
|
26634
|
+
}
|
|
26635
|
+
return {
|
|
26636
|
+
sessionId: manifest.sessionId,
|
|
26637
|
+
version: manifest.version + 1,
|
|
26638
|
+
turns: [...manifest.turns, ...newTurns],
|
|
26639
|
+
tailHash: currentHash
|
|
26640
|
+
};
|
|
26641
|
+
}
|
|
26642
|
+
/**
|
|
26643
|
+
* Determines the absolute starting index for a set of new messages.
|
|
26644
|
+
* If we have stored turns, the next message's index is last_turn.index + 1.
|
|
26645
|
+
* If the manifest is empty, we infer from OpenClaw's prePromptMessageCount signal
|
|
26646
|
+
* (caller must provide this as a hint when available).
|
|
26647
|
+
*/
|
|
26648
|
+
deriveStartingIndex(manifest, prePromptMessageCountHint) {
|
|
26649
|
+
if (manifest.turns.length > 0) {
|
|
26650
|
+
return manifest.turns[manifest.turns.length - 1].index + 1;
|
|
26651
|
+
}
|
|
26652
|
+
return typeof prePromptMessageCountHint === "number" && prePromptMessageCountHint >= 0 ? prePromptMessageCountHint : 0;
|
|
26653
|
+
}
|
|
26654
|
+
};
|
|
26655
|
+
var manifestStore = new TurnManifestStore();
|
|
26656
|
+
|
|
26517
26657
|
// src/context-engine.ts
|
|
26518
26658
|
var APPROX_CHARS_PER_TOKEN = 4;
|
|
26519
26659
|
var PROMPT_AUTHORITY_PREASSEMBLY_MAY_OVERFLOW = "preassembly_may_overflow";
|
|
@@ -26527,6 +26667,15 @@ var EXACT_RECALL_SEARCH_K = 32;
|
|
|
26527
26667
|
var EXACT_RECALL_MAX_TOKENS = 4;
|
|
26528
26668
|
var RESERVED_CURRENT_TURN_TOKENS = 150;
|
|
26529
26669
|
var AFTER_TURN_INGEST_MAX_TOKENS = 2048;
|
|
26670
|
+
var OPENCLAW_LEADING_TIMESTAMP_PREFIX_RE = /^\[[A-Za-z]{3} \d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\] */;
|
|
26671
|
+
var OPENCLAW_METADATA_HEADERS = [
|
|
26672
|
+
"Conversation info (untrusted metadata):",
|
|
26673
|
+
"Sender (untrusted metadata):",
|
|
26674
|
+
"Thread starter (untrusted, for context):",
|
|
26675
|
+
"Reply target of current user message (untrusted, for context):",
|
|
26676
|
+
"Forwarded message context (untrusted metadata):",
|
|
26677
|
+
"Chat history since last reply (untrusted, for context):"
|
|
26678
|
+
];
|
|
26530
26679
|
var COMMON_QUERY_WORDS = /* @__PURE__ */ new Set([
|
|
26531
26680
|
"what",
|
|
26532
26681
|
"does",
|
|
@@ -26617,14 +26766,160 @@ function stringifyKernelBlock(block) {
|
|
|
26617
26766
|
return typeof record.text === "string" ? record.text : "";
|
|
26618
26767
|
}
|
|
26619
26768
|
}
|
|
26620
|
-
function normalizeKernelContent(content) {
|
|
26621
|
-
|
|
26622
|
-
|
|
26769
|
+
function normalizeKernelContent(content, options = {}) {
|
|
26770
|
+
const text = typeof content === "string" ? content : Array.isArray(content) ? content.map(stringifyKernelBlock).filter((part) => part.length > 0).join("\n") : "";
|
|
26771
|
+
return stripOpenClawUntrustedMetadataEnvelope(text, {
|
|
26772
|
+
retainContext: options.retainOpenClawContext === true
|
|
26773
|
+
});
|
|
26774
|
+
}
|
|
26775
|
+
function stripOpenClawUntrustedMetadataEnvelope(text, options = {}) {
|
|
26776
|
+
let remaining = text.replace(OPENCLAW_LEADING_TIMESTAMP_PREFIX_RE, "").replace(/\r\n/g, "\n");
|
|
26777
|
+
const preambleEnd = findFirstHeaderPosition(remaining);
|
|
26778
|
+
let preamble = "";
|
|
26779
|
+
if (preambleEnd > 0) {
|
|
26780
|
+
const newlineIndex = remaining.lastIndexOf("\n", preambleEnd);
|
|
26781
|
+
preamble = newlineIndex >= 0 ? remaining.slice(0, newlineIndex + 1) : remaining.slice(0, preambleEnd);
|
|
26782
|
+
remaining = remaining.slice(preamble.length);
|
|
26783
|
+
}
|
|
26784
|
+
const retainedContext = [];
|
|
26785
|
+
let stripped = false;
|
|
26786
|
+
while (true) {
|
|
26787
|
+
const next = stripOneOpenClawMetadataBlock(remaining);
|
|
26788
|
+
if (next.text === remaining) {
|
|
26789
|
+
break;
|
|
26790
|
+
}
|
|
26791
|
+
stripped = true;
|
|
26792
|
+
if (next.context.length > 0) {
|
|
26793
|
+
retainedContext.push(...next.context);
|
|
26794
|
+
}
|
|
26795
|
+
remaining = next.text;
|
|
26623
26796
|
}
|
|
26624
|
-
if (!
|
|
26625
|
-
return
|
|
26797
|
+
if (!stripped) {
|
|
26798
|
+
return text;
|
|
26799
|
+
}
|
|
26800
|
+
const contextLine = options.retainContext === true ? formatRetainedOpenClawContext(retainedContext) : "";
|
|
26801
|
+
const strippedText = remaining.trimStart();
|
|
26802
|
+
const result = contextLine ? `${contextLine}
|
|
26803
|
+
${strippedText}` : strippedText;
|
|
26804
|
+
return preamble ? `${preamble}${result}` : result;
|
|
26805
|
+
}
|
|
26806
|
+
function findFirstHeaderPosition(text) {
|
|
26807
|
+
let pos = -1;
|
|
26808
|
+
for (const header of OPENCLAW_METADATA_HEADERS) {
|
|
26809
|
+
const p = text.indexOf(header);
|
|
26810
|
+
if (p >= 0 && (pos < 0 || p < pos)) {
|
|
26811
|
+
pos = p;
|
|
26812
|
+
}
|
|
26626
26813
|
}
|
|
26627
|
-
return
|
|
26814
|
+
return pos;
|
|
26815
|
+
}
|
|
26816
|
+
function stripOneOpenClawMetadataBlock(text) {
|
|
26817
|
+
const leadingWhitespaceLength = text.length - text.trimStart().length;
|
|
26818
|
+
const offsetText = text.slice(leadingWhitespaceLength);
|
|
26819
|
+
const header = OPENCLAW_METADATA_HEADERS.find((candidate) => offsetText.startsWith(candidate)) ?? null;
|
|
26820
|
+
if (!header) {
|
|
26821
|
+
return { text, context: [] };
|
|
26822
|
+
}
|
|
26823
|
+
const afterHeader = offsetText.slice(header.length);
|
|
26824
|
+
const fenceStartMatch = afterHeader.match(/^\n```(?:json)?\n/i);
|
|
26825
|
+
if (!fenceStartMatch) {
|
|
26826
|
+
const afterHeaderLines = afterHeader.replace(/^\n?/, "").split("\n");
|
|
26827
|
+
const firstBlankIndex = afterHeaderLines.findIndex((line) => line.trim() === "");
|
|
26828
|
+
if (firstBlankIndex < 0) {
|
|
26829
|
+
return { text, context: [] };
|
|
26830
|
+
}
|
|
26831
|
+
return { text: afterHeaderLines.slice(firstBlankIndex + 1).join("\n"), context: [] };
|
|
26832
|
+
}
|
|
26833
|
+
const bodyStart = header.length + fenceStartMatch[0].length;
|
|
26834
|
+
const fenceEnd = offsetText.indexOf("\n```", bodyStart);
|
|
26835
|
+
if (fenceEnd < 0) {
|
|
26836
|
+
return { text, context: [] };
|
|
26837
|
+
}
|
|
26838
|
+
const jsonText = offsetText.slice(bodyStart, fenceEnd);
|
|
26839
|
+
const afterFence = fenceEnd + "\n```".length;
|
|
26840
|
+
const trailingNewlineLength = offsetText.slice(afterFence).startsWith("\n") ? 1 : 0;
|
|
26841
|
+
return {
|
|
26842
|
+
text: offsetText.slice(afterFence + trailingNewlineLength),
|
|
26843
|
+
context: summarizeOpenClawMetadataBlock(header, jsonText)
|
|
26844
|
+
};
|
|
26845
|
+
}
|
|
26846
|
+
function summarizeOpenClawMetadataBlock(header, jsonText) {
|
|
26847
|
+
const parsed = parseJsonRecord(jsonText);
|
|
26848
|
+
if (!parsed) {
|
|
26849
|
+
return [];
|
|
26850
|
+
}
|
|
26851
|
+
if (header === "Conversation info (untrusted metadata):") {
|
|
26852
|
+
const hasIMessageContext = firstString2(
|
|
26853
|
+
parsed.chat_guid,
|
|
26854
|
+
parsed.chatGuid,
|
|
26855
|
+
parsed.chat_identifier,
|
|
26856
|
+
parsed.chatIdentifier,
|
|
26857
|
+
parsed.chat_name,
|
|
26858
|
+
parsed.chatName,
|
|
26859
|
+
parsed.service
|
|
26860
|
+
) != null;
|
|
26861
|
+
return [
|
|
26862
|
+
labelValue("channel", firstString2(parsed.group_channel, parsed.channel, parsed.group_subject)),
|
|
26863
|
+
labelValue("channel_id", firstString2(parsed.chat_id, parsed.channel_id)),
|
|
26864
|
+
labelValue("account_id", firstString2(parsed.account_id, parsed.accountId)),
|
|
26865
|
+
labelValue("provider", firstString2(parsed.provider, parsed.surface)),
|
|
26866
|
+
labelValue("chat_id", hasIMessageContext ? firstString2(parsed.chat_id, parsed.chatId) : void 0),
|
|
26867
|
+
labelValue("chat_guid", firstString2(parsed.chat_guid, parsed.chatGuid)),
|
|
26868
|
+
labelValue("chat_identifier", firstString2(parsed.chat_identifier, parsed.chatIdentifier)),
|
|
26869
|
+
labelValue("chat_name", firstString2(parsed.chat_name, parsed.chatName)),
|
|
26870
|
+
labelValue("is_group", firstString2(parsed.is_group, parsed.isGroup, parsed.is_group_chat)),
|
|
26871
|
+
labelValue("chat_type", firstString2(parsed.chat_type, parsed.chatType)),
|
|
26872
|
+
labelValue("service", firstString2(parsed.service)),
|
|
26873
|
+
labelValue("server_id", firstString2(parsed.group_space, parsed.guild_id, parsed.server_id)),
|
|
26874
|
+
labelValue("sender_id", firstString2(parsed.sender_id, parsed.user_id)),
|
|
26875
|
+
labelValue("sender", firstString2(parsed.sender)),
|
|
26876
|
+
labelValue("emoji_id", firstString2(parsed.emoji_id, parsed.server_emoji_id, parsed.guild_emoji_id)),
|
|
26877
|
+
labelValue("emoji", firstString2(parsed.emoji_name, parsed.emoji))
|
|
26878
|
+
].filter(isNonEmptyString);
|
|
26879
|
+
}
|
|
26880
|
+
if (header === "Sender (untrusted metadata):") {
|
|
26881
|
+
return [
|
|
26882
|
+
labelValue("username", firstString2(parsed.username, parsed.tag, parsed.name, parsed.label)),
|
|
26883
|
+
labelValue("user_id", firstString2(parsed.id, parsed.user_id, parsed.sender_id)),
|
|
26884
|
+
labelValue("sender", firstString2(parsed.sender, parsed.e164))
|
|
26885
|
+
].filter(isNonEmptyString);
|
|
26886
|
+
}
|
|
26887
|
+
return [];
|
|
26888
|
+
}
|
|
26889
|
+
function parseJsonRecord(jsonText) {
|
|
26890
|
+
try {
|
|
26891
|
+
const parsed = JSON.parse(jsonText);
|
|
26892
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
26893
|
+
} catch {
|
|
26894
|
+
return null;
|
|
26895
|
+
}
|
|
26896
|
+
}
|
|
26897
|
+
function labelValue(label, value) {
|
|
26898
|
+
return value ? `${label}=${sanitizeOpenClawContextValue(value)}` : "";
|
|
26899
|
+
}
|
|
26900
|
+
function firstString2(...values) {
|
|
26901
|
+
for (const value of values) {
|
|
26902
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
26903
|
+
return value.trim();
|
|
26904
|
+
}
|
|
26905
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
26906
|
+
return String(value);
|
|
26907
|
+
}
|
|
26908
|
+
if (typeof value === "boolean") {
|
|
26909
|
+
return String(value);
|
|
26910
|
+
}
|
|
26911
|
+
}
|
|
26912
|
+
return void 0;
|
|
26913
|
+
}
|
|
26914
|
+
function sanitizeOpenClawContextValue(value) {
|
|
26915
|
+
return value.replace(/[\r\n;]+/g, " ").trim().slice(0, 120);
|
|
26916
|
+
}
|
|
26917
|
+
function formatRetainedOpenClawContext(values) {
|
|
26918
|
+
const uniqueValues = [...new Set(values.filter(isNonEmptyString))];
|
|
26919
|
+
return uniqueValues.length > 0 ? `[OpenClaw context: ${uniqueValues.join("; ")}]` : "";
|
|
26920
|
+
}
|
|
26921
|
+
function isNonEmptyString(value) {
|
|
26922
|
+
return value.trim().length > 0;
|
|
26628
26923
|
}
|
|
26629
26924
|
function approximateTokenCount(text) {
|
|
26630
26925
|
if (typeof text === "string") {
|
|
@@ -26839,15 +27134,15 @@ function resolveAfterTurnPredictiveCompactionTokenCount(args) {
|
|
|
26839
27134
|
}
|
|
26840
27135
|
return Math.max(currentTokenCount, forwardedMessageTokens);
|
|
26841
27136
|
}
|
|
26842
|
-
function normalizeKernelMessage(message) {
|
|
27137
|
+
function normalizeKernelMessage(message, options = {}) {
|
|
26843
27138
|
return {
|
|
26844
27139
|
role: message.role,
|
|
26845
|
-
content: normalizeKernelContent(message.content),
|
|
26846
|
-
|
|
27140
|
+
content: normalizeKernelContent(message.content, options),
|
|
27141
|
+
id: typeof message.id === "string" ? message.id : randomUUID()
|
|
26847
27142
|
};
|
|
26848
27143
|
}
|
|
26849
|
-
function normalizeKernelMessages(messages) {
|
|
26850
|
-
return messages.map((message) => normalizeKernelMessage(message));
|
|
27144
|
+
function normalizeKernelMessages(messages, options = {}) {
|
|
27145
|
+
return messages.map((message) => normalizeKernelMessage(message, options)).filter((message) => message.role === "user" || message.content.trim().length > 0);
|
|
26851
27146
|
}
|
|
26852
27147
|
function extractExactRecallTokens(text) {
|
|
26853
27148
|
const tokens = /* @__PURE__ */ new Set();
|
|
@@ -26897,9 +27192,9 @@ function extractExactRecallFactText(text, token) {
|
|
|
26897
27192
|
function escapeMemoryFactText(text) {
|
|
26898
27193
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'").replaceAll("\r", " ").replaceAll("\n", " ").replaceAll(" ", "	");
|
|
26899
27194
|
}
|
|
26900
|
-
var TOOL_CALL_BRACKET_RE = /\[tool:([^\]]+)\]
|
|
26901
|
-
var TOOL_CALL_JSON_RE = /\{\s*"name"\s*:\s*"([^"]+)"[
|
|
26902
|
-
var TOOL_RESULT_ANNOTATION_RE = /\[tool:[^\]]+\]
|
|
27195
|
+
var TOOL_CALL_BRACKET_RE = /\[tool:([^\]]+)\](?:\s*(?:\{[\s\S]*?\}|\[[\s\S]*?\]|".*?"))?/gi;
|
|
27196
|
+
var TOOL_CALL_JSON_RE = /\{\s*"name"\s*:\s*"([^"]+)"[\s\S]*?\}/g;
|
|
27197
|
+
var TOOL_RESULT_ANNOTATION_RE = /\[tool:[^\]]+\][^\n]*/g;
|
|
26903
27198
|
function sanitizeToolCallPatterns(text) {
|
|
26904
27199
|
let sanitized = text;
|
|
26905
27200
|
sanitized = sanitized.replace(TOOL_CALL_BRACKET_RE, (_match, toolName) => {
|
|
@@ -27094,7 +27389,7 @@ function normalizeAssembleResult(result, sourceMessages) {
|
|
|
27094
27389
|
if (isRealTranscript) {
|
|
27095
27390
|
messages.push({
|
|
27096
27391
|
role: message.role === "user" ? "user" : "assistant",
|
|
27097
|
-
content,
|
|
27392
|
+
content: sanitizeToolCallPatterns(content),
|
|
27098
27393
|
...typeof message.id === "string" ? { id: message.id } : {}
|
|
27099
27394
|
});
|
|
27100
27395
|
} else {
|
|
@@ -27121,6 +27416,18 @@ ${extractedMemoryItems.join("\n")}
|
|
|
27121
27416
|
...result.debug != null ? { debug: result.debug } : {}
|
|
27122
27417
|
};
|
|
27123
27418
|
}
|
|
27419
|
+
function extractCursorFromResult(result) {
|
|
27420
|
+
if (result && typeof result === "object" && "cursor" in result) {
|
|
27421
|
+
const cursor = result.cursor;
|
|
27422
|
+
if (cursor && typeof cursor === "object") {
|
|
27423
|
+
const c = cursor;
|
|
27424
|
+
if (typeof c.lastProcessedIndex === "number" && typeof c.sessionVersion === "number" && typeof c.manifestTailHash === "string") {
|
|
27425
|
+
return c;
|
|
27426
|
+
}
|
|
27427
|
+
}
|
|
27428
|
+
}
|
|
27429
|
+
return void 0;
|
|
27430
|
+
}
|
|
27124
27431
|
function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
27125
27432
|
const predictiveContextCache = /* @__PURE__ */ new Map();
|
|
27126
27433
|
const PREDICTIVE_CACHE_MAX_SIZE = 100;
|
|
@@ -27381,12 +27688,13 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
27381
27688
|
sessionKey: args.sessionKey
|
|
27382
27689
|
});
|
|
27383
27690
|
const messages = normalizeKernelMessages(args.messages);
|
|
27691
|
+
const strippedPrompt = args.prompt ? normalizeKernelContent(args.prompt, { retainOpenClawContext: false }) : "";
|
|
27384
27692
|
const lastUserMessage = findLastReplaySafeUserMessage(messages);
|
|
27385
27693
|
const reservedCurrentTurnTokens = lastUserMessage ? approximateMessageTokens(lastUserMessage) : RESERVED_CURRENT_TURN_TOKENS;
|
|
27386
27694
|
const currentContextTokens = resolvePredictiveCompactionTokenCount({
|
|
27387
27695
|
currentTokenCount: args.currentTokenCount,
|
|
27388
27696
|
messages,
|
|
27389
|
-
prompt:
|
|
27697
|
+
prompt: strippedPrompt
|
|
27390
27698
|
});
|
|
27391
27699
|
const dynamicCompactThreshold = getDynamicCompactThreshold(args.tokenBudget);
|
|
27392
27700
|
const predictiveTargetSize = resolvePredictiveCompactionTarget({
|
|
@@ -27434,7 +27742,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
27434
27742
|
sessionId,
|
|
27435
27743
|
sessionKey: args.sessionKey,
|
|
27436
27744
|
userId,
|
|
27437
|
-
prompt:
|
|
27745
|
+
prompt: strippedPrompt,
|
|
27438
27746
|
messages,
|
|
27439
27747
|
tokenBudget: args.tokenBudget,
|
|
27440
27748
|
config: buildAssemblyConfig(args.tokenBudget),
|
|
@@ -27443,7 +27751,7 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
27443
27751
|
const assembled = normalizeAssembleResult(resp, args.messages);
|
|
27444
27752
|
let enforced = enforceTokenBudgetInvariant(
|
|
27445
27753
|
await augmentWithExactRecall(assembled, {
|
|
27446
|
-
queryText:
|
|
27754
|
+
queryText: strippedPrompt || (messages[messages.length - 1]?.content ?? ""),
|
|
27447
27755
|
userId,
|
|
27448
27756
|
sessionId,
|
|
27449
27757
|
tokenBudget: args.tokenBudget,
|
|
@@ -27526,12 +27834,20 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
27526
27834
|
userIdOverride: args.userId,
|
|
27527
27835
|
sessionKey: args.sessionKey
|
|
27528
27836
|
});
|
|
27837
|
+
const manifest = manifestStore.load(sessionId, logger);
|
|
27529
27838
|
const afterTurnMessages = selectAfterTurnMessages(args.messages, args.prePromptMessageCount, logger);
|
|
27530
|
-
const messages = normalizeKernelMessages(afterTurnMessages);
|
|
27531
|
-
const
|
|
27532
|
-
const
|
|
27839
|
+
const messages = normalizeKernelMessages(afterTurnMessages, { retainOpenClawContext: true });
|
|
27840
|
+
const overlapIndex = manifestStore.findOverlapIndex(manifest, messages);
|
|
27841
|
+
const newMessages = messages.slice(overlapIndex);
|
|
27842
|
+
const ingestMessages = boundAfterTurnMessagesForIngest(newMessages, logger, sessionId);
|
|
27843
|
+
const startIndex = manifestStore.deriveStartingIndex(manifest, args.prePromptMessageCount);
|
|
27844
|
+
const cursor = {
|
|
27845
|
+
lastProcessedIndex: startIndex > 0 ? startIndex - 1 : 0,
|
|
27846
|
+
sessionVersion: manifest.version,
|
|
27847
|
+
manifestTailHash: manifest.tailHash
|
|
27848
|
+
};
|
|
27533
27849
|
logger.info?.(
|
|
27534
|
-
`LibraVDB afterTurn sessionId=${sessionId} userId=${userId} messageCount=${
|
|
27850
|
+
`LibraVDB afterTurn sessionId=${sessionId} userId=${userId} messageCount=${messages.length} newMessages=${newMessages.length} overlapIndex=${overlapIndex} startIndex=${startIndex} prePromptMessageCount=${args.prePromptMessageCount ?? "unknown"} heartbeat=${args.isHeartbeat ?? false}`
|
|
27535
27851
|
);
|
|
27536
27852
|
try {
|
|
27537
27853
|
const client = await runtime.getClient();
|
|
@@ -27543,8 +27859,38 @@ function buildContextEngineFactory(runtime, cfg, logger = console) {
|
|
|
27543
27859
|
sessionKey: args.sessionKey,
|
|
27544
27860
|
userId,
|
|
27545
27861
|
messages: ingestMessages,
|
|
27546
|
-
|
|
27862
|
+
prePromptMessageCount: args.prePromptMessageCount,
|
|
27863
|
+
isHeartbeat: args.isHeartbeat,
|
|
27864
|
+
cursor
|
|
27547
27865
|
});
|
|
27866
|
+
const daemonCursor = extractCursorFromResult(result);
|
|
27867
|
+
if (daemonCursor) {
|
|
27868
|
+
if (!daemonCursor.manifestTailHash) {
|
|
27869
|
+
logger.warn?.(
|
|
27870
|
+
`[LibraVDB] Daemon reported cursor gap for session ${sessionId}. Resetting manifest for full re-sync next turn.`
|
|
27871
|
+
);
|
|
27872
|
+
manifestStore.save(manifestStore.createEmpty(sessionId));
|
|
27873
|
+
} else if (ingestMessages.length > 0) {
|
|
27874
|
+
const confirmedIndex = daemonCursor.lastProcessedIndex;
|
|
27875
|
+
const ackCount = Math.max(0, confirmedIndex - startIndex + 1);
|
|
27876
|
+
if (ackCount > 0) {
|
|
27877
|
+
const ackedMessages = ingestMessages.slice(0, ackCount);
|
|
27878
|
+
const updatedManifest = manifestStore.appendACKedMessages(
|
|
27879
|
+
manifest,
|
|
27880
|
+
ackedMessages,
|
|
27881
|
+
startIndex
|
|
27882
|
+
);
|
|
27883
|
+
manifestStore.save(updatedManifest);
|
|
27884
|
+
}
|
|
27885
|
+
}
|
|
27886
|
+
} else if (ingestMessages.length > 0) {
|
|
27887
|
+
const updatedManifest = manifestStore.appendACKedMessages(
|
|
27888
|
+
manifest,
|
|
27889
|
+
ingestMessages,
|
|
27890
|
+
startIndex
|
|
27891
|
+
);
|
|
27892
|
+
manifestStore.save(updatedManifest);
|
|
27893
|
+
}
|
|
27548
27894
|
await performAfterTurnPredictiveCompaction({
|
|
27549
27895
|
sessionId,
|
|
27550
27896
|
messages,
|
|
@@ -27637,16 +27983,16 @@ function isRecord(value) {
|
|
|
27637
27983
|
}
|
|
27638
27984
|
|
|
27639
27985
|
// src/markdown-ingest.ts
|
|
27640
|
-
import
|
|
27986
|
+
import fs3 from "node:fs";
|
|
27641
27987
|
import fsp2 from "node:fs/promises";
|
|
27642
|
-
import
|
|
27643
|
-
import
|
|
27988
|
+
import os3 from "node:os";
|
|
27989
|
+
import path3 from "node:path";
|
|
27644
27990
|
|
|
27645
27991
|
// node_modules/.pnpm/@bufbuild+protobuf@1.7.2/node_modules/@bufbuild/protobuf/dist/proxy/index.js
|
|
27646
27992
|
var proxy_exports = {};
|
|
27647
27993
|
__reExport(proxy_exports, __toESM(require_cjs(), 1));
|
|
27648
27994
|
|
|
27649
|
-
// node_modules/.pnpm/@xdarkicex+libravdb-contracts@2.0.
|
|
27995
|
+
// node_modules/.pnpm/@xdarkicex+libravdb-contracts@2.0.12/node_modules/@xdarkicex/libravdb-contracts/gen/js/libravdb/ipc/v1/rpc_pb.js
|
|
27650
27996
|
var IngestMode;
|
|
27651
27997
|
(function(IngestMode2) {
|
|
27652
27998
|
IngestMode2[IngestMode2["REPLACE"] = 0] = "REPLACE";
|
|
@@ -28415,6 +28761,61 @@ var KernelMessage = class _KernelMessage extends proxy_exports.Message {
|
|
|
28415
28761
|
return proxy_exports.proto3.util.equals(_KernelMessage, a, b);
|
|
28416
28762
|
}
|
|
28417
28763
|
};
|
|
28764
|
+
var SessionSyncCursor = class _SessionSyncCursor extends proxy_exports.Message {
|
|
28765
|
+
/**
|
|
28766
|
+
* @generated from field: int64 last_processed_index = 1;
|
|
28767
|
+
*/
|
|
28768
|
+
lastProcessedIndex = proxy_exports.protoInt64.zero;
|
|
28769
|
+
/**
|
|
28770
|
+
* @generated from field: int64 session_version = 2;
|
|
28771
|
+
*/
|
|
28772
|
+
sessionVersion = proxy_exports.protoInt64.zero;
|
|
28773
|
+
/**
|
|
28774
|
+
* @generated from field: string manifest_tail_hash = 3;
|
|
28775
|
+
*/
|
|
28776
|
+
manifestTailHash = "";
|
|
28777
|
+
constructor(data) {
|
|
28778
|
+
super();
|
|
28779
|
+
proxy_exports.proto3.util.initPartial(data, this);
|
|
28780
|
+
}
|
|
28781
|
+
static runtime = proxy_exports.proto3;
|
|
28782
|
+
static typeName = "libravdb.ipc.v1.SessionSyncCursor";
|
|
28783
|
+
static fields = proxy_exports.proto3.util.newFieldList(() => [
|
|
28784
|
+
{
|
|
28785
|
+
no: 1,
|
|
28786
|
+
name: "last_processed_index",
|
|
28787
|
+
kind: "scalar",
|
|
28788
|
+
T: 3
|
|
28789
|
+
/* ScalarType.INT64 */
|
|
28790
|
+
},
|
|
28791
|
+
{
|
|
28792
|
+
no: 2,
|
|
28793
|
+
name: "session_version",
|
|
28794
|
+
kind: "scalar",
|
|
28795
|
+
T: 3
|
|
28796
|
+
/* ScalarType.INT64 */
|
|
28797
|
+
},
|
|
28798
|
+
{
|
|
28799
|
+
no: 3,
|
|
28800
|
+
name: "manifest_tail_hash",
|
|
28801
|
+
kind: "scalar",
|
|
28802
|
+
T: 9
|
|
28803
|
+
/* ScalarType.STRING */
|
|
28804
|
+
}
|
|
28805
|
+
]);
|
|
28806
|
+
static fromBinary(bytes, options) {
|
|
28807
|
+
return new _SessionSyncCursor().fromBinary(bytes, options);
|
|
28808
|
+
}
|
|
28809
|
+
static fromJson(jsonValue, options) {
|
|
28810
|
+
return new _SessionSyncCursor().fromJson(jsonValue, options);
|
|
28811
|
+
}
|
|
28812
|
+
static fromJsonString(jsonString, options) {
|
|
28813
|
+
return new _SessionSyncCursor().fromJsonString(jsonString, options);
|
|
28814
|
+
}
|
|
28815
|
+
static equals(a, b) {
|
|
28816
|
+
return proxy_exports.proto3.util.equals(_SessionSyncCursor, a, b);
|
|
28817
|
+
}
|
|
28818
|
+
};
|
|
28418
28819
|
var AssembleContextInternalResponse = class _AssembleContextInternalResponse extends proxy_exports.Message {
|
|
28419
28820
|
/**
|
|
28420
28821
|
* @generated from field: repeated libravdb.ipc.v1.KernelMessage messages = 1;
|
|
@@ -30976,6 +31377,10 @@ var MemoryStatusResponse = class _MemoryStatusResponse extends proxy_exports.Mes
|
|
|
30976
31377
|
* @generated from field: string embedding_profile = 8;
|
|
30977
31378
|
*/
|
|
30978
31379
|
embeddingProfile = "";
|
|
31380
|
+
/**
|
|
31381
|
+
* @generated from field: string embedding_backend = 9;
|
|
31382
|
+
*/
|
|
31383
|
+
embeddingBackend = "";
|
|
30979
31384
|
constructor(data) {
|
|
30980
31385
|
super();
|
|
30981
31386
|
proxy_exports.proto3.util.initPartial(data, this);
|
|
@@ -31038,6 +31443,13 @@ var MemoryStatusResponse = class _MemoryStatusResponse extends proxy_exports.Mes
|
|
|
31038
31443
|
kind: "scalar",
|
|
31039
31444
|
T: 9
|
|
31040
31445
|
/* ScalarType.STRING */
|
|
31446
|
+
},
|
|
31447
|
+
{
|
|
31448
|
+
no: 9,
|
|
31449
|
+
name: "embedding_backend",
|
|
31450
|
+
kind: "scalar",
|
|
31451
|
+
T: 9
|
|
31452
|
+
/* ScalarType.STRING */
|
|
31041
31453
|
}
|
|
31042
31454
|
]);
|
|
31043
31455
|
static fromBinary(bytes, options) {
|
|
@@ -31418,6 +31830,10 @@ var AfterTurnKernelRequest = class _AfterTurnKernelRequest extends proxy_exports
|
|
|
31418
31830
|
* @generated from field: bool is_heartbeat = 6;
|
|
31419
31831
|
*/
|
|
31420
31832
|
isHeartbeat = false;
|
|
31833
|
+
/**
|
|
31834
|
+
* @generated from field: libravdb.ipc.v1.SessionSyncCursor cursor = 7;
|
|
31835
|
+
*/
|
|
31836
|
+
cursor;
|
|
31421
31837
|
constructor(data) {
|
|
31422
31838
|
super();
|
|
31423
31839
|
proxy_exports.proto3.util.initPartial(data, this);
|
|
@@ -31460,7 +31876,8 @@ var AfterTurnKernelRequest = class _AfterTurnKernelRequest extends proxy_exports
|
|
|
31460
31876
|
kind: "scalar",
|
|
31461
31877
|
T: 8
|
|
31462
31878
|
/* ScalarType.BOOL */
|
|
31463
|
-
}
|
|
31879
|
+
},
|
|
31880
|
+
{ no: 7, name: "cursor", kind: "message", T: SessionSyncCursor }
|
|
31464
31881
|
]);
|
|
31465
31882
|
static fromBinary(bytes, options) {
|
|
31466
31883
|
return new _AfterTurnKernelRequest().fromBinary(bytes, options);
|
|
@@ -31484,6 +31901,10 @@ var AfterTurnKernelResponse = class _AfterTurnKernelResponse extends proxy_expor
|
|
|
31484
31901
|
* @generated from field: repeated libravdb.ipc.v1.PredictedContext predictions = 2;
|
|
31485
31902
|
*/
|
|
31486
31903
|
predictions = [];
|
|
31904
|
+
/**
|
|
31905
|
+
* @generated from field: libravdb.ipc.v1.SessionSyncCursor cursor = 3;
|
|
31906
|
+
*/
|
|
31907
|
+
cursor;
|
|
31487
31908
|
constructor(data) {
|
|
31488
31909
|
super();
|
|
31489
31910
|
proxy_exports.proto3.util.initPartial(data, this);
|
|
@@ -31498,7 +31919,8 @@ var AfterTurnKernelResponse = class _AfterTurnKernelResponse extends proxy_expor
|
|
|
31498
31919
|
T: 8
|
|
31499
31920
|
/* ScalarType.BOOL */
|
|
31500
31921
|
},
|
|
31501
|
-
{ no: 2, name: "predictions", kind: "message", T: PredictedContext, repeated: true }
|
|
31922
|
+
{ no: 2, name: "predictions", kind: "message", T: PredictedContext, repeated: true },
|
|
31923
|
+
{ no: 3, name: "cursor", kind: "message", T: SessionSyncCursor }
|
|
31502
31924
|
]);
|
|
31503
31925
|
static fromBinary(bytes, options) {
|
|
31504
31926
|
return new _AfterTurnKernelResponse().fromBinary(bytes, options);
|
|
@@ -31839,6 +32261,375 @@ var CognitiveMetricsRequest = class _CognitiveMetricsRequest extends proxy_expor
|
|
|
31839
32261
|
return proxy_exports.proto3.util.equals(_CognitiveMetricsRequest, a, b);
|
|
31840
32262
|
}
|
|
31841
32263
|
};
|
|
32264
|
+
var TenantStatus = class _TenantStatus extends proxy_exports.Message {
|
|
32265
|
+
/**
|
|
32266
|
+
* @generated from field: string tenant_key = 1;
|
|
32267
|
+
*/
|
|
32268
|
+
tenantKey = "";
|
|
32269
|
+
/**
|
|
32270
|
+
* "active", "idle"
|
|
32271
|
+
*
|
|
32272
|
+
* @generated from field: string status = 2;
|
|
32273
|
+
*/
|
|
32274
|
+
status = "";
|
|
32275
|
+
/**
|
|
32276
|
+
* @generated from field: int64 size_bytes = 3;
|
|
32277
|
+
*/
|
|
32278
|
+
sizeBytes = proxy_exports.protoInt64.zero;
|
|
32279
|
+
/**
|
|
32280
|
+
* @generated from field: int64 last_active_ms = 4;
|
|
32281
|
+
*/
|
|
32282
|
+
lastActiveMs = proxy_exports.protoInt64.zero;
|
|
32283
|
+
/**
|
|
32284
|
+
* @generated from field: int32 open_sessions = 5;
|
|
32285
|
+
*/
|
|
32286
|
+
openSessions = 0;
|
|
32287
|
+
/**
|
|
32288
|
+
* @generated from field: bool unregistered = 6;
|
|
32289
|
+
*/
|
|
32290
|
+
unregistered = false;
|
|
32291
|
+
constructor(data) {
|
|
32292
|
+
super();
|
|
32293
|
+
proxy_exports.proto3.util.initPartial(data, this);
|
|
32294
|
+
}
|
|
32295
|
+
static runtime = proxy_exports.proto3;
|
|
32296
|
+
static typeName = "libravdb.ipc.v1.TenantStatus";
|
|
32297
|
+
static fields = proxy_exports.proto3.util.newFieldList(() => [
|
|
32298
|
+
{
|
|
32299
|
+
no: 1,
|
|
32300
|
+
name: "tenant_key",
|
|
32301
|
+
kind: "scalar",
|
|
32302
|
+
T: 9
|
|
32303
|
+
/* ScalarType.STRING */
|
|
32304
|
+
},
|
|
32305
|
+
{
|
|
32306
|
+
no: 2,
|
|
32307
|
+
name: "status",
|
|
32308
|
+
kind: "scalar",
|
|
32309
|
+
T: 9
|
|
32310
|
+
/* ScalarType.STRING */
|
|
32311
|
+
},
|
|
32312
|
+
{
|
|
32313
|
+
no: 3,
|
|
32314
|
+
name: "size_bytes",
|
|
32315
|
+
kind: "scalar",
|
|
32316
|
+
T: 3
|
|
32317
|
+
/* ScalarType.INT64 */
|
|
32318
|
+
},
|
|
32319
|
+
{
|
|
32320
|
+
no: 4,
|
|
32321
|
+
name: "last_active_ms",
|
|
32322
|
+
kind: "scalar",
|
|
32323
|
+
T: 3
|
|
32324
|
+
/* ScalarType.INT64 */
|
|
32325
|
+
},
|
|
32326
|
+
{
|
|
32327
|
+
no: 5,
|
|
32328
|
+
name: "open_sessions",
|
|
32329
|
+
kind: "scalar",
|
|
32330
|
+
T: 5
|
|
32331
|
+
/* ScalarType.INT32 */
|
|
32332
|
+
},
|
|
32333
|
+
{
|
|
32334
|
+
no: 6,
|
|
32335
|
+
name: "unregistered",
|
|
32336
|
+
kind: "scalar",
|
|
32337
|
+
T: 8
|
|
32338
|
+
/* ScalarType.BOOL */
|
|
32339
|
+
}
|
|
32340
|
+
]);
|
|
32341
|
+
static fromBinary(bytes, options) {
|
|
32342
|
+
return new _TenantStatus().fromBinary(bytes, options);
|
|
32343
|
+
}
|
|
32344
|
+
static fromJson(jsonValue, options) {
|
|
32345
|
+
return new _TenantStatus().fromJson(jsonValue, options);
|
|
32346
|
+
}
|
|
32347
|
+
static fromJsonString(jsonString, options) {
|
|
32348
|
+
return new _TenantStatus().fromJsonString(jsonString, options);
|
|
32349
|
+
}
|
|
32350
|
+
static equals(a, b) {
|
|
32351
|
+
return proxy_exports.proto3.util.equals(_TenantStatus, a, b);
|
|
32352
|
+
}
|
|
32353
|
+
};
|
|
32354
|
+
var DaemonStatusRequest = class _DaemonStatusRequest extends proxy_exports.Message {
|
|
32355
|
+
constructor(data) {
|
|
32356
|
+
super();
|
|
32357
|
+
proxy_exports.proto3.util.initPartial(data, this);
|
|
32358
|
+
}
|
|
32359
|
+
static runtime = proxy_exports.proto3;
|
|
32360
|
+
static typeName = "libravdb.ipc.v1.DaemonStatusRequest";
|
|
32361
|
+
static fields = proxy_exports.proto3.util.newFieldList(() => []);
|
|
32362
|
+
static fromBinary(bytes, options) {
|
|
32363
|
+
return new _DaemonStatusRequest().fromBinary(bytes, options);
|
|
32364
|
+
}
|
|
32365
|
+
static fromJson(jsonValue, options) {
|
|
32366
|
+
return new _DaemonStatusRequest().fromJson(jsonValue, options);
|
|
32367
|
+
}
|
|
32368
|
+
static fromJsonString(jsonString, options) {
|
|
32369
|
+
return new _DaemonStatusRequest().fromJsonString(jsonString, options);
|
|
32370
|
+
}
|
|
32371
|
+
static equals(a, b) {
|
|
32372
|
+
return proxy_exports.proto3.util.equals(_DaemonStatusRequest, a, b);
|
|
32373
|
+
}
|
|
32374
|
+
};
|
|
32375
|
+
var DaemonStatusResponse = class _DaemonStatusResponse extends proxy_exports.Message {
|
|
32376
|
+
/**
|
|
32377
|
+
* @generated from field: bool ok = 1;
|
|
32378
|
+
*/
|
|
32379
|
+
ok = false;
|
|
32380
|
+
/**
|
|
32381
|
+
* @generated from field: string version = 2;
|
|
32382
|
+
*/
|
|
32383
|
+
version = "";
|
|
32384
|
+
/**
|
|
32385
|
+
* @generated from field: string uptime = 3;
|
|
32386
|
+
*/
|
|
32387
|
+
uptime = "";
|
|
32388
|
+
/**
|
|
32389
|
+
* @generated from field: string backend = 4;
|
|
32390
|
+
*/
|
|
32391
|
+
backend = "";
|
|
32392
|
+
/**
|
|
32393
|
+
* @generated from field: int64 global_db_size = 5;
|
|
32394
|
+
*/
|
|
32395
|
+
globalDbSize = proxy_exports.protoInt64.zero;
|
|
32396
|
+
/**
|
|
32397
|
+
* @generated from field: bool global_db_healthy = 6;
|
|
32398
|
+
*/
|
|
32399
|
+
globalDbHealthy = false;
|
|
32400
|
+
/**
|
|
32401
|
+
* @generated from field: repeated libravdb.ipc.v1.TenantStatus tenants = 7;
|
|
32402
|
+
*/
|
|
32403
|
+
tenants = [];
|
|
32404
|
+
/**
|
|
32405
|
+
* @generated from field: int64 cache_size = 8;
|
|
32406
|
+
*/
|
|
32407
|
+
cacheSize = proxy_exports.protoInt64.zero;
|
|
32408
|
+
/**
|
|
32409
|
+
* @generated from field: int64 cache_max_size = 9;
|
|
32410
|
+
*/
|
|
32411
|
+
cacheMaxSize = proxy_exports.protoInt64.zero;
|
|
32412
|
+
/**
|
|
32413
|
+
* @generated from field: int32 cache_entries = 10;
|
|
32414
|
+
*/
|
|
32415
|
+
cacheEntries = 0;
|
|
32416
|
+
/**
|
|
32417
|
+
* @generated from field: double cache_hit_rate = 11;
|
|
32418
|
+
*/
|
|
32419
|
+
cacheHitRate = 0;
|
|
32420
|
+
/**
|
|
32421
|
+
* @generated from field: int64 cache_savings = 12;
|
|
32422
|
+
*/
|
|
32423
|
+
cacheSavings = proxy_exports.protoInt64.zero;
|
|
32424
|
+
/**
|
|
32425
|
+
* @generated from field: string tenant_mode = 13;
|
|
32426
|
+
*/
|
|
32427
|
+
tenantMode = "";
|
|
32428
|
+
/**
|
|
32429
|
+
* @generated from field: int32 max_open_tenants = 14;
|
|
32430
|
+
*/
|
|
32431
|
+
maxOpenTenants = 0;
|
|
32432
|
+
/**
|
|
32433
|
+
* @generated from field: int32 current_open_tenants = 15;
|
|
32434
|
+
*/
|
|
32435
|
+
currentOpenTenants = 0;
|
|
32436
|
+
constructor(data) {
|
|
32437
|
+
super();
|
|
32438
|
+
proxy_exports.proto3.util.initPartial(data, this);
|
|
32439
|
+
}
|
|
32440
|
+
static runtime = proxy_exports.proto3;
|
|
32441
|
+
static typeName = "libravdb.ipc.v1.DaemonStatusResponse";
|
|
32442
|
+
static fields = proxy_exports.proto3.util.newFieldList(() => [
|
|
32443
|
+
{
|
|
32444
|
+
no: 1,
|
|
32445
|
+
name: "ok",
|
|
32446
|
+
kind: "scalar",
|
|
32447
|
+
T: 8
|
|
32448
|
+
/* ScalarType.BOOL */
|
|
32449
|
+
},
|
|
32450
|
+
{
|
|
32451
|
+
no: 2,
|
|
32452
|
+
name: "version",
|
|
32453
|
+
kind: "scalar",
|
|
32454
|
+
T: 9
|
|
32455
|
+
/* ScalarType.STRING */
|
|
32456
|
+
},
|
|
32457
|
+
{
|
|
32458
|
+
no: 3,
|
|
32459
|
+
name: "uptime",
|
|
32460
|
+
kind: "scalar",
|
|
32461
|
+
T: 9
|
|
32462
|
+
/* ScalarType.STRING */
|
|
32463
|
+
},
|
|
32464
|
+
{
|
|
32465
|
+
no: 4,
|
|
32466
|
+
name: "backend",
|
|
32467
|
+
kind: "scalar",
|
|
32468
|
+
T: 9
|
|
32469
|
+
/* ScalarType.STRING */
|
|
32470
|
+
},
|
|
32471
|
+
{
|
|
32472
|
+
no: 5,
|
|
32473
|
+
name: "global_db_size",
|
|
32474
|
+
kind: "scalar",
|
|
32475
|
+
T: 3
|
|
32476
|
+
/* ScalarType.INT64 */
|
|
32477
|
+
},
|
|
32478
|
+
{
|
|
32479
|
+
no: 6,
|
|
32480
|
+
name: "global_db_healthy",
|
|
32481
|
+
kind: "scalar",
|
|
32482
|
+
T: 8
|
|
32483
|
+
/* ScalarType.BOOL */
|
|
32484
|
+
},
|
|
32485
|
+
{ no: 7, name: "tenants", kind: "message", T: TenantStatus, repeated: true },
|
|
32486
|
+
{
|
|
32487
|
+
no: 8,
|
|
32488
|
+
name: "cache_size",
|
|
32489
|
+
kind: "scalar",
|
|
32490
|
+
T: 3
|
|
32491
|
+
/* ScalarType.INT64 */
|
|
32492
|
+
},
|
|
32493
|
+
{
|
|
32494
|
+
no: 9,
|
|
32495
|
+
name: "cache_max_size",
|
|
32496
|
+
kind: "scalar",
|
|
32497
|
+
T: 3
|
|
32498
|
+
/* ScalarType.INT64 */
|
|
32499
|
+
},
|
|
32500
|
+
{
|
|
32501
|
+
no: 10,
|
|
32502
|
+
name: "cache_entries",
|
|
32503
|
+
kind: "scalar",
|
|
32504
|
+
T: 5
|
|
32505
|
+
/* ScalarType.INT32 */
|
|
32506
|
+
},
|
|
32507
|
+
{
|
|
32508
|
+
no: 11,
|
|
32509
|
+
name: "cache_hit_rate",
|
|
32510
|
+
kind: "scalar",
|
|
32511
|
+
T: 1
|
|
32512
|
+
/* ScalarType.DOUBLE */
|
|
32513
|
+
},
|
|
32514
|
+
{
|
|
32515
|
+
no: 12,
|
|
32516
|
+
name: "cache_savings",
|
|
32517
|
+
kind: "scalar",
|
|
32518
|
+
T: 3
|
|
32519
|
+
/* ScalarType.INT64 */
|
|
32520
|
+
},
|
|
32521
|
+
{
|
|
32522
|
+
no: 13,
|
|
32523
|
+
name: "tenant_mode",
|
|
32524
|
+
kind: "scalar",
|
|
32525
|
+
T: 9
|
|
32526
|
+
/* ScalarType.STRING */
|
|
32527
|
+
},
|
|
32528
|
+
{
|
|
32529
|
+
no: 14,
|
|
32530
|
+
name: "max_open_tenants",
|
|
32531
|
+
kind: "scalar",
|
|
32532
|
+
T: 5
|
|
32533
|
+
/* ScalarType.INT32 */
|
|
32534
|
+
},
|
|
32535
|
+
{
|
|
32536
|
+
no: 15,
|
|
32537
|
+
name: "current_open_tenants",
|
|
32538
|
+
kind: "scalar",
|
|
32539
|
+
T: 5
|
|
32540
|
+
/* ScalarType.INT32 */
|
|
32541
|
+
}
|
|
32542
|
+
]);
|
|
32543
|
+
static fromBinary(bytes, options) {
|
|
32544
|
+
return new _DaemonStatusResponse().fromBinary(bytes, options);
|
|
32545
|
+
}
|
|
32546
|
+
static fromJson(jsonValue, options) {
|
|
32547
|
+
return new _DaemonStatusResponse().fromJson(jsonValue, options);
|
|
32548
|
+
}
|
|
32549
|
+
static fromJsonString(jsonString, options) {
|
|
32550
|
+
return new _DaemonStatusResponse().fromJsonString(jsonString, options);
|
|
32551
|
+
}
|
|
32552
|
+
static equals(a, b) {
|
|
32553
|
+
return proxy_exports.proto3.util.equals(_DaemonStatusResponse, a, b);
|
|
32554
|
+
}
|
|
32555
|
+
};
|
|
32556
|
+
var EvictTenantRequest = class _EvictTenantRequest extends proxy_exports.Message {
|
|
32557
|
+
/**
|
|
32558
|
+
* @generated from field: string tenant_key = 1;
|
|
32559
|
+
*/
|
|
32560
|
+
tenantKey = "";
|
|
32561
|
+
constructor(data) {
|
|
32562
|
+
super();
|
|
32563
|
+
proxy_exports.proto3.util.initPartial(data, this);
|
|
32564
|
+
}
|
|
32565
|
+
static runtime = proxy_exports.proto3;
|
|
32566
|
+
static typeName = "libravdb.ipc.v1.EvictTenantRequest";
|
|
32567
|
+
static fields = proxy_exports.proto3.util.newFieldList(() => [
|
|
32568
|
+
{
|
|
32569
|
+
no: 1,
|
|
32570
|
+
name: "tenant_key",
|
|
32571
|
+
kind: "scalar",
|
|
32572
|
+
T: 9
|
|
32573
|
+
/* ScalarType.STRING */
|
|
32574
|
+
}
|
|
32575
|
+
]);
|
|
32576
|
+
static fromBinary(bytes, options) {
|
|
32577
|
+
return new _EvictTenantRequest().fromBinary(bytes, options);
|
|
32578
|
+
}
|
|
32579
|
+
static fromJson(jsonValue, options) {
|
|
32580
|
+
return new _EvictTenantRequest().fromJson(jsonValue, options);
|
|
32581
|
+
}
|
|
32582
|
+
static fromJsonString(jsonString, options) {
|
|
32583
|
+
return new _EvictTenantRequest().fromJsonString(jsonString, options);
|
|
32584
|
+
}
|
|
32585
|
+
static equals(a, b) {
|
|
32586
|
+
return proxy_exports.proto3.util.equals(_EvictTenantRequest, a, b);
|
|
32587
|
+
}
|
|
32588
|
+
};
|
|
32589
|
+
var EvictTenantResponse = class _EvictTenantResponse extends proxy_exports.Message {
|
|
32590
|
+
/**
|
|
32591
|
+
* @generated from field: bool ok = 1;
|
|
32592
|
+
*/
|
|
32593
|
+
ok = false;
|
|
32594
|
+
/**
|
|
32595
|
+
* @generated from field: string message = 2;
|
|
32596
|
+
*/
|
|
32597
|
+
message = "";
|
|
32598
|
+
constructor(data) {
|
|
32599
|
+
super();
|
|
32600
|
+
proxy_exports.proto3.util.initPartial(data, this);
|
|
32601
|
+
}
|
|
32602
|
+
static runtime = proxy_exports.proto3;
|
|
32603
|
+
static typeName = "libravdb.ipc.v1.EvictTenantResponse";
|
|
32604
|
+
static fields = proxy_exports.proto3.util.newFieldList(() => [
|
|
32605
|
+
{
|
|
32606
|
+
no: 1,
|
|
32607
|
+
name: "ok",
|
|
32608
|
+
kind: "scalar",
|
|
32609
|
+
T: 8
|
|
32610
|
+
/* ScalarType.BOOL */
|
|
32611
|
+
},
|
|
32612
|
+
{
|
|
32613
|
+
no: 2,
|
|
32614
|
+
name: "message",
|
|
32615
|
+
kind: "scalar",
|
|
32616
|
+
T: 9
|
|
32617
|
+
/* ScalarType.STRING */
|
|
32618
|
+
}
|
|
32619
|
+
]);
|
|
32620
|
+
static fromBinary(bytes, options) {
|
|
32621
|
+
return new _EvictTenantResponse().fromBinary(bytes, options);
|
|
32622
|
+
}
|
|
32623
|
+
static fromJson(jsonValue, options) {
|
|
32624
|
+
return new _EvictTenantResponse().fromJson(jsonValue, options);
|
|
32625
|
+
}
|
|
32626
|
+
static fromJsonString(jsonString, options) {
|
|
32627
|
+
return new _EvictTenantResponse().fromJsonString(jsonString, options);
|
|
32628
|
+
}
|
|
32629
|
+
static equals(a, b) {
|
|
32630
|
+
return proxy_exports.proto3.util.equals(_EvictTenantResponse, a, b);
|
|
32631
|
+
}
|
|
32632
|
+
};
|
|
31842
32633
|
var CognitiveMetricsResponse = class _CognitiveMetricsResponse extends proxy_exports.Message {
|
|
31843
32634
|
/**
|
|
31844
32635
|
* @generated from field: int64 total_nodes = 1;
|
|
@@ -33130,7 +33921,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33130
33921
|
this.started = false;
|
|
33131
33922
|
}
|
|
33132
33923
|
getRootState(root) {
|
|
33133
|
-
const resolved =
|
|
33924
|
+
const resolved = path3.resolve(root);
|
|
33134
33925
|
const existing = this.states.get(resolved);
|
|
33135
33926
|
if (existing) {
|
|
33136
33927
|
return existing;
|
|
@@ -33231,7 +34022,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33231
34022
|
if (this.stopping) {
|
|
33232
34023
|
return;
|
|
33233
34024
|
}
|
|
33234
|
-
const child =
|
|
34025
|
+
const child = path3.join(dir, entry.name);
|
|
33235
34026
|
if (entry.isDirectory()) {
|
|
33236
34027
|
await this.walkDirectory(rootState, child, currentFiles, stats, candidates);
|
|
33237
34028
|
continue;
|
|
@@ -33315,7 +34106,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33315
34106
|
rootState.scanState.resumeFromPath = null;
|
|
33316
34107
|
}
|
|
33317
34108
|
shouldPruneDirectory(root, dir) {
|
|
33318
|
-
const relative = toPosixPath(
|
|
34109
|
+
const relative = toPosixPath(path3.relative(root, dir));
|
|
33319
34110
|
if (!relative || relative === "." || relative.startsWith("..")) {
|
|
33320
34111
|
return false;
|
|
33321
34112
|
}
|
|
@@ -33353,7 +34144,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33353
34144
|
if (isOpenClawMemoryFile(filePath)) {
|
|
33354
34145
|
return true;
|
|
33355
34146
|
}
|
|
33356
|
-
const relative = toPosixPath(
|
|
34147
|
+
const relative = toPosixPath(path3.relative(root, filePath));
|
|
33357
34148
|
if (this.excludePatterns.length > 0) {
|
|
33358
34149
|
for (const pattern of this.excludePatterns) {
|
|
33359
34150
|
if (matchesGlob(relative, pattern)) {
|
|
@@ -33390,7 +34181,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33390
34181
|
}
|
|
33391
34182
|
async syncMarkdownFile(rootState, filePath, initialStat) {
|
|
33392
34183
|
const sourceDoc = filePath;
|
|
33393
|
-
const relativePath = toPosixPath(
|
|
34184
|
+
const relativePath = toPosixPath(path3.relative(rootState.root, filePath));
|
|
33394
34185
|
const stat = initialStat ?? await this.safeStatWithCtime(filePath);
|
|
33395
34186
|
if (!stat) {
|
|
33396
34187
|
await this.deleteSourceDocument(sourceDoc);
|
|
@@ -33628,9 +34419,9 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33628
34419
|
if (parsed.ingestVersion !== MARKDOWN_INGEST_VERSION || parsed.hashBackend !== HASH_BACKEND || !parsed.files) {
|
|
33629
34420
|
return;
|
|
33630
34421
|
}
|
|
33631
|
-
const configuredRoots = new Set(this.roots.map((root) =>
|
|
34422
|
+
const configuredRoots = new Set(this.roots.map((root) => path3.resolve(root)));
|
|
33632
34423
|
for (const [sourceDoc, state] of Object.entries(parsed.files)) {
|
|
33633
|
-
if (isValidSnapshotState(sourceDoc, state) && configuredRoots.has(
|
|
34424
|
+
if (isValidSnapshotState(sourceDoc, state) && configuredRoots.has(path3.resolve(state.root))) {
|
|
33634
34425
|
this.fileStates.set(sourceDoc, state);
|
|
33635
34426
|
}
|
|
33636
34427
|
}
|
|
@@ -33650,7 +34441,7 @@ var DirectoryMarkdownSourceAdapter = class {
|
|
|
33650
34441
|
files: Object.fromEntries([...this.fileStates.entries()].sort(([left], [right]) => left.localeCompare(right)))
|
|
33651
34442
|
};
|
|
33652
34443
|
try {
|
|
33653
|
-
await fsp2.mkdir(
|
|
34444
|
+
await fsp2.mkdir(path3.dirname(this.snapshotPath), { recursive: true });
|
|
33654
34445
|
const tmp = `${this.snapshotPath}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
|
|
33655
34446
|
await fsp2.writeFile(tmp, `${JSON.stringify(payload, null, 2)}
|
|
33656
34447
|
`);
|
|
@@ -33709,7 +34500,7 @@ function recordSyncResult(stats, result) {
|
|
|
33709
34500
|
}
|
|
33710
34501
|
}
|
|
33711
34502
|
function toPosixPath(value) {
|
|
33712
|
-
return value.split(
|
|
34503
|
+
return value.split(path3.sep).join("/");
|
|
33713
34504
|
}
|
|
33714
34505
|
function normalizeMarkdownRoots(roots) {
|
|
33715
34506
|
if (!roots?.length) {
|
|
@@ -33721,7 +34512,7 @@ function normalizeMarkdownRoots(roots) {
|
|
|
33721
34512
|
if (!trimmed) {
|
|
33722
34513
|
continue;
|
|
33723
34514
|
}
|
|
33724
|
-
resolved.add(
|
|
34515
|
+
resolved.add(path3.resolve(trimmed));
|
|
33725
34516
|
}
|
|
33726
34517
|
return [...resolved];
|
|
33727
34518
|
}
|
|
@@ -33737,10 +34528,10 @@ function updateFnv1a64(seed, bytes) {
|
|
|
33737
34528
|
function resolveMarkdownSnapshotPath(kind, configuredPath) {
|
|
33738
34529
|
const trimmed = configuredPath?.trim();
|
|
33739
34530
|
if (trimmed) {
|
|
33740
|
-
return
|
|
34531
|
+
return path3.resolve(trimmed);
|
|
33741
34532
|
}
|
|
33742
|
-
const stateDir = process.env.OPENCLAW_STATE_DIR?.trim() ||
|
|
33743
|
-
return
|
|
34533
|
+
const stateDir = process.env.OPENCLAW_STATE_DIR?.trim() || path3.join(os3.homedir(), ".openclaw");
|
|
34534
|
+
return path3.join(stateDir, `libravdb-markdown-ingest-${kind}.json`);
|
|
33744
34535
|
}
|
|
33745
34536
|
function isMarkdownIngestionEnabled(cfg, roots) {
|
|
33746
34537
|
return cfg.markdownIngestionEnabled === true && roots.length > 0;
|
|
@@ -33753,7 +34544,7 @@ function createRealFsApi2() {
|
|
|
33753
34544
|
const s = await fsp2.stat(file);
|
|
33754
34545
|
return { size: s.size, mtimeMs: s.mtimeMs, ctimeMs: s.ctimeMs };
|
|
33755
34546
|
},
|
|
33756
|
-
watch: (dir, onChange) =>
|
|
34547
|
+
watch: (dir, onChange) => fs3.watch(dir, onChange),
|
|
33757
34548
|
openReadStream: async (file) => {
|
|
33758
34549
|
const handle = await fsp2.open(file, "r");
|
|
33759
34550
|
return {
|
|
@@ -33921,7 +34712,7 @@ function hasInlineObsidianTag(text) {
|
|
|
33921
34712
|
return false;
|
|
33922
34713
|
}
|
|
33923
34714
|
function isOpenClawMemoryFile(filePath) {
|
|
33924
|
-
return
|
|
34715
|
+
return path3.basename(filePath).toLowerCase() === "memory.md";
|
|
33925
34716
|
}
|
|
33926
34717
|
|
|
33927
34718
|
// src/memory-provider.ts
|
|
@@ -35731,11 +36522,11 @@ var Http2SessionManager = class {
|
|
|
35731
36522
|
* Clients must call notifyResponseByteRead() whenever they successfully read
|
|
35732
36523
|
* data from the http2.ClientHttp2Stream.
|
|
35733
36524
|
*/
|
|
35734
|
-
async request(method,
|
|
36525
|
+
async request(method, path6, headers, options) {
|
|
35735
36526
|
for (; ; ) {
|
|
35736
36527
|
const ready2 = await this.gotoReady();
|
|
35737
36528
|
try {
|
|
35738
|
-
const stream = ready2.conn.request(Object.assign(Object.assign({}, headers), { ":method": method, ":path":
|
|
36529
|
+
const stream = ready2.conn.request(Object.assign(Object.assign({}, headers), { ":method": method, ":path": path6 }), options);
|
|
35739
36530
|
ready2.registerRequest(stream);
|
|
35740
36531
|
return stream;
|
|
35741
36532
|
} catch (e) {
|
|
@@ -36373,7 +37164,7 @@ function createGrpcTransport(options) {
|
|
|
36373
37164
|
return createTransport(validateNodeTransportOptions(options));
|
|
36374
37165
|
}
|
|
36375
37166
|
|
|
36376
|
-
// node_modules/.pnpm/@xdarkicex+libravdb-contracts@2.0.
|
|
37167
|
+
// node_modules/.pnpm/@xdarkicex+libravdb-contracts@2.0.12/node_modules/@xdarkicex/libravdb-contracts/gen/js/libravdb/ipc/v1/rpc_connect.js
|
|
36377
37168
|
var LibravDB = {
|
|
36378
37169
|
typeName: "libravdb.ipc.v1.LibravDB",
|
|
36379
37170
|
methods: {
|
|
@@ -36397,6 +37188,24 @@ var LibravDB = {
|
|
|
36397
37188
|
O: MemoryStatusResponse,
|
|
36398
37189
|
kind: proxy_exports.MethodKind.Unary
|
|
36399
37190
|
},
|
|
37191
|
+
/**
|
|
37192
|
+
* @generated from rpc libravdb.ipc.v1.LibravDB.DaemonStatus
|
|
37193
|
+
*/
|
|
37194
|
+
daemonStatus: {
|
|
37195
|
+
name: "DaemonStatus",
|
|
37196
|
+
I: DaemonStatusRequest,
|
|
37197
|
+
O: DaemonStatusResponse,
|
|
37198
|
+
kind: proxy_exports.MethodKind.Unary
|
|
37199
|
+
},
|
|
37200
|
+
/**
|
|
37201
|
+
* @generated from rpc libravdb.ipc.v1.LibravDB.EvictTenant
|
|
37202
|
+
*/
|
|
37203
|
+
evictTenant: {
|
|
37204
|
+
name: "EvictTenant",
|
|
37205
|
+
I: EvictTenantRequest,
|
|
37206
|
+
O: EvictTenantResponse,
|
|
37207
|
+
kind: proxy_exports.MethodKind.Unary
|
|
37208
|
+
},
|
|
36400
37209
|
/**
|
|
36401
37210
|
* @generated from rpc libravdb.ipc.v1.LibravDB.Flush
|
|
36402
37211
|
*/
|
|
@@ -36705,25 +37514,27 @@ var LibravDB = {
|
|
|
36705
37514
|
|
|
36706
37515
|
// src/libravdb-client.ts
|
|
36707
37516
|
import { createHmac } from "node:crypto";
|
|
36708
|
-
import
|
|
37517
|
+
import fs4 from "node:fs";
|
|
36709
37518
|
import net from "node:net";
|
|
36710
|
-
import
|
|
36711
|
-
import
|
|
37519
|
+
import os4 from "node:os";
|
|
37520
|
+
import path4 from "node:path";
|
|
36712
37521
|
function resolveClientEndpoint(configuredEndpoint) {
|
|
36713
37522
|
if (configuredEndpoint && configuredEndpoint !== "auto") return configuredEndpoint;
|
|
36714
37523
|
if (process.env.LIBRAVDB_GRPC_ENDPOINT) return process.env.LIBRAVDB_GRPC_ENDPOINT;
|
|
36715
37524
|
if (process.platform === "win32") return "tcp:127.0.0.1:37421";
|
|
36716
37525
|
const sockName = "libravdb.sock";
|
|
36717
37526
|
const candidateDirs = [
|
|
36718
|
-
|
|
37527
|
+
path4.join(os4.homedir(), ".libravdbd", "run"),
|
|
36719
37528
|
"/opt/homebrew/var/libravdbd/run",
|
|
36720
|
-
"/usr/local/var/libravdbd/run"
|
|
37529
|
+
"/usr/local/var/libravdbd/run",
|
|
37530
|
+
"/var/run/libravdbd",
|
|
37531
|
+
"/run/libravdbd"
|
|
36721
37532
|
];
|
|
36722
37533
|
for (const dir of candidateDirs) {
|
|
36723
|
-
const fullPath =
|
|
36724
|
-
if (
|
|
37534
|
+
const fullPath = path4.join(dir, sockName);
|
|
37535
|
+
if (fs4.existsSync(fullPath)) return `unix:${fullPath}`;
|
|
36725
37536
|
}
|
|
36726
|
-
return `unix:${
|
|
37537
|
+
return `unix:${path4.join(os4.homedir(), ".libravdbd", "run", sockName)}`;
|
|
36727
37538
|
}
|
|
36728
37539
|
function isLegacyJsonRpcHealthResponse(payload) {
|
|
36729
37540
|
try {
|
|
@@ -36850,11 +37661,11 @@ var LibravDBClient = class {
|
|
|
36850
37661
|
let clientKey = null;
|
|
36851
37662
|
let clientCert = null;
|
|
36852
37663
|
if (!isInsecure && options.tlsCaPath) {
|
|
36853
|
-
rootCerts =
|
|
37664
|
+
rootCerts = fs4.readFileSync(options.tlsCaPath);
|
|
36854
37665
|
}
|
|
36855
37666
|
if (options.tlsClientCertPath && options.tlsClientKeyPath) {
|
|
36856
|
-
clientCert =
|
|
36857
|
-
clientKey =
|
|
37667
|
+
clientCert = fs4.readFileSync(options.tlsClientCertPath);
|
|
37668
|
+
clientKey = fs4.readFileSync(options.tlsClientKeyPath);
|
|
36858
37669
|
}
|
|
36859
37670
|
const rpcMutex = createRpcMutex();
|
|
36860
37671
|
const self = this;
|
|
@@ -36869,6 +37680,15 @@ var LibravDBClient = class {
|
|
|
36869
37680
|
bootstrap: () => self.bootstrapHandshake(),
|
|
36870
37681
|
rpcMutex
|
|
36871
37682
|
});
|
|
37683
|
+
const interceptors = [];
|
|
37684
|
+
if (options.tenantKey) {
|
|
37685
|
+
const tenantKey = options.tenantKey;
|
|
37686
|
+
interceptors.push((next) => async (req) => {
|
|
37687
|
+
req.header.set("libravdb-tenant-key", tenantKey);
|
|
37688
|
+
return next(req);
|
|
37689
|
+
});
|
|
37690
|
+
}
|
|
37691
|
+
interceptors.push(authInterceptor);
|
|
36872
37692
|
const transport = createGrpcTransport({
|
|
36873
37693
|
baseUrl: targetUrl,
|
|
36874
37694
|
httpVersion: "2",
|
|
@@ -36879,7 +37699,7 @@ var LibravDBClient = class {
|
|
|
36879
37699
|
...isInsecure ? { rejectUnauthorized: false } : {}
|
|
36880
37700
|
},
|
|
36881
37701
|
defaultTimeoutMs: options.timeoutMs ?? 3e4,
|
|
36882
|
-
interceptors
|
|
37702
|
+
interceptors
|
|
36883
37703
|
});
|
|
36884
37704
|
this.client = createPromiseClient(LibravDB, transport);
|
|
36885
37705
|
}
|
|
@@ -37034,7 +37854,7 @@ function loadSecretFromEnv(logger) {
|
|
|
37034
37854
|
const secretPath = process.env.LIBRAVDB_AUTH_SECRET_FILE;
|
|
37035
37855
|
if (secretPath) {
|
|
37036
37856
|
try {
|
|
37037
|
-
return
|
|
37857
|
+
return fs4.readFileSync(secretPath, "utf8").trim() || void 0;
|
|
37038
37858
|
} catch (error2) {
|
|
37039
37859
|
logger?.warn?.(`LibraVDB: failed to read auth secret file "${secretPath}": ${formatError(error2)}`);
|
|
37040
37860
|
return void 0;
|
|
@@ -37044,9 +37864,13 @@ function loadSecretFromEnv(logger) {
|
|
|
37044
37864
|
}
|
|
37045
37865
|
|
|
37046
37866
|
// src/plugin-runtime.ts
|
|
37047
|
-
import { existsSync as
|
|
37048
|
-
import
|
|
37049
|
-
var DEFAULT_RPC_TIMEOUT_MS =
|
|
37867
|
+
import { existsSync as existsSync3, statSync } from "node:fs";
|
|
37868
|
+
import path5 from "node:path";
|
|
37869
|
+
var DEFAULT_RPC_TIMEOUT_MS = 12e4;
|
|
37870
|
+
var ENV_RPC_TIMEOUT_MS = (() => {
|
|
37871
|
+
const raw = Number(process.env.LIBRAVDB_RPC_TIMEOUT_MS);
|
|
37872
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 0;
|
|
37873
|
+
})();
|
|
37050
37874
|
var VALID_TLS_MODES = ["auto", "tls", "insecure"];
|
|
37051
37875
|
var isTlsModeValid = (m) => VALID_TLS_MODES.includes(m);
|
|
37052
37876
|
function daemonProvisioningHint() {
|
|
@@ -37071,7 +37895,7 @@ function validateEmbeddingConfig(cfg) {
|
|
|
37071
37895
|
`LibraVDB: embeddingRuntimePath must point to a readable ONNX Runtime library: ${runtimePath}`
|
|
37072
37896
|
);
|
|
37073
37897
|
}
|
|
37074
|
-
if (!pathExistsAsDirectory(modelPath) || !pathExistsAsFile(
|
|
37898
|
+
if (!pathExistsAsDirectory(modelPath) || !pathExistsAsFile(path5.join(modelPath, "embedding.json"))) {
|
|
37075
37899
|
throw new Error(
|
|
37076
37900
|
`LibraVDB: embeddingModelPath must point to a directory containing embedding.json: ${modelPath}`
|
|
37077
37901
|
);
|
|
@@ -37093,11 +37917,12 @@ function createPluginRuntime(cfg, logger = console) {
|
|
|
37093
37917
|
validateTlsConfig(cfg, logger);
|
|
37094
37918
|
client = new LibravDBClient({
|
|
37095
37919
|
endpoint: cfg.grpcEndpoint || cfg.sidecarPath,
|
|
37096
|
-
timeoutMs: cfg.rpcTimeoutMs ?? DEFAULT_RPC_TIMEOUT_MS,
|
|
37920
|
+
timeoutMs: cfg.rpcTimeoutMs ?? (ENV_RPC_TIMEOUT_MS || DEFAULT_RPC_TIMEOUT_MS),
|
|
37097
37921
|
tlsCaPath: cfg.grpcEndpointTlsCa,
|
|
37098
37922
|
tlsMode: cfg.grpcEndpointTlsMode,
|
|
37099
37923
|
tlsClientCertPath: cfg.grpcEndpointTlsClientCert,
|
|
37100
|
-
tlsClientKeyPath: cfg.grpcEndpointTlsClientKey
|
|
37924
|
+
tlsClientKeyPath: cfg.grpcEndpointTlsClientKey,
|
|
37925
|
+
tenantKey: resolveTenantKey(cfg)
|
|
37101
37926
|
});
|
|
37102
37927
|
await client.bootstrapHandshake();
|
|
37103
37928
|
return client;
|
|
@@ -37173,14 +37998,14 @@ function shouldValidateLocalEmbeddingPaths(cfg) {
|
|
|
37173
37998
|
}
|
|
37174
37999
|
function pathExistsAsFile(filePath) {
|
|
37175
38000
|
try {
|
|
37176
|
-
return
|
|
38001
|
+
return existsSync3(filePath) && statSync(filePath).isFile();
|
|
37177
38002
|
} catch {
|
|
37178
38003
|
return false;
|
|
37179
38004
|
}
|
|
37180
38005
|
}
|
|
37181
38006
|
function pathExistsAsDirectory(dirPath) {
|
|
37182
38007
|
try {
|
|
37183
|
-
return
|
|
38008
|
+
return existsSync3(dirPath) && statSync(dirPath).isDirectory();
|
|
37184
38009
|
} catch {
|
|
37185
38010
|
return false;
|
|
37186
38011
|
}
|