@xdarkicex/openclaw-memory-libravdb 1.3.12 → 1.3.17
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 +247 -48
- package/docs/README.md +3 -0
- package/docs/ast-v2.md +47 -5
- package/docs/continuity.md +220 -0
- package/docs/contributing.md +1 -0
- package/docs/elevated-guidance.md +258 -0
- package/docs/implementation.md +60 -2
- package/docs/install.md +181 -0
- package/docs/installation.md +13 -16
- package/docs/mathematics-v2.md +161 -1
- package/docs/uninstall.md +100 -0
- package/openclaw.plugin.json +5 -0
- package/package.json +5 -1
- package/packaging/README.md +36 -0
- package/packaging/homebrew/libravdbd.rb.tmpl +176 -2
- package/packaging/launchd/com.xdarkicex.libravdbd.plist +6 -0
- package/src/cli.ts +47 -0
- package/src/context-engine.ts +596 -157
- package/src/index.ts +6 -1
- package/src/lifecycle-hooks.ts +96 -0
- package/src/memory-provider.ts +80 -17
- package/src/memory-runtime.ts +150 -0
- package/src/openclaw-plugin-sdk.d.ts +1 -0
- package/src/plugin-runtime.ts +53 -4
- package/src/recall-utils.ts +20 -3
- package/src/scoring.ts +130 -0
- package/src/sidecar.ts +45 -1
- package/src/types.ts +28 -0
|
@@ -23,15 +23,189 @@ class Libravdbd < Formula
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
if OS.mac?
|
|
27
|
+
resource "onnxruntime" do
|
|
28
|
+
url "https://github.com/microsoft/onnxruntime/releases/download/v1.23.0/onnxruntime-osx-universal2-1.23.0.tgz"
|
|
29
|
+
sha256 :no_check
|
|
30
|
+
end
|
|
31
|
+
elsif OS.linux?
|
|
32
|
+
if Hardware::CPU.arm?
|
|
33
|
+
resource "onnxruntime" do
|
|
34
|
+
url "https://github.com/microsoft/onnxruntime/releases/download/v1.23.0/onnxruntime-linux-aarch64-1.23.0.tgz"
|
|
35
|
+
sha256 :no_check
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
resource "onnxruntime" do
|
|
39
|
+
url "https://github.com/microsoft/onnxruntime/releases/download/v1.23.0/onnxruntime-linux-x64-1.23.0.tgz"
|
|
40
|
+
sha256 :no_check
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
resource "nomic-embed-text-v1.5-model" do
|
|
46
|
+
url "https://huggingface.co/nomic-ai/nomic-embed-text-v1.5/resolve/main/onnx/model.onnx"
|
|
47
|
+
sha256 "147d5aa88c2101237358e17796cf3a227cead1ec304ec34b465bb08e9d952965"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
resource "nomic-embed-text-v1.5-tokenizer" do
|
|
51
|
+
url "https://huggingface.co/nomic-ai/nomic-embed-text-v1.5/resolve/main/tokenizer.json"
|
|
52
|
+
sha256 "d241a60d5e8f04cc1b2b3e9ef7a4921b27bf526d9f6050ab90f9267a1f9e5c66"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
resource "all-minilm-l6-v2-model" do
|
|
56
|
+
url "https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/main/onnx/model.onnx"
|
|
57
|
+
sha256 "759c3cd2b7fe7e93933ad23c4c9181b7396442a2ed746ec7c1d46192c469c46e"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
resource "all-minilm-l6-v2-tokenizer" do
|
|
61
|
+
url "https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer.json"
|
|
62
|
+
sha256 "da0e79933b9ed51798a3ae27893d3c5fa4a201126cef75586296df9b4d2c62a0"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
resource "t5-small-encoder" do
|
|
66
|
+
url "https://huggingface.co/optimum/t5-small/resolve/main/encoder_model.onnx"
|
|
67
|
+
sha256 "41d326633f1b85f526508cc0db78a5d40877c292c1b6dccae2eacd7d2a53480d"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
resource "t5-small-decoder" do
|
|
71
|
+
url "https://huggingface.co/optimum/t5-small/resolve/main/decoder_model.onnx"
|
|
72
|
+
sha256 "0a1451011d61bcc796a87b7306c503562e910f110f884d0cc08532972c2cc584"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
resource "t5-small-tokenizer" do
|
|
76
|
+
url "https://huggingface.co/optimum/t5-small/resolve/main/tokenizer.json"
|
|
77
|
+
sha256 "5f0ed8ab5b8cfa9812bb73752f1d80c292e52bcf5a87a144dc9ab2d251056cbb"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
resource "t5-small-tokenizer-config" do
|
|
81
|
+
url "https://huggingface.co/optimum/t5-small/resolve/main/tokenizer_config.json"
|
|
82
|
+
sha256 "4969f8d76ef05a16553bd2b07b3501673ae8d36972aea88a0f78ad31a3ff2de9"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
resource "t5-small-config" do
|
|
86
|
+
url "https://huggingface.co/optimum/t5-small/resolve/main/config.json"
|
|
87
|
+
sha256 "d112428e703aa7ea0d6b17a77e9739fcc15b87653779d9b7942d5ecbc61c00ed"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
resource "provision" do
|
|
91
|
+
url "https://github.com/xDarkicex/openclaw-memory-libravdb/releases/download/v#{version}/provision.sh"
|
|
92
|
+
sha256 "__SHA256_PROVISION__"
|
|
93
|
+
end
|
|
94
|
+
|
|
26
95
|
def install
|
|
27
96
|
bin.install Dir["libravdbd*"].first => "libravdbd"
|
|
97
|
+
|
|
98
|
+
models_dir = prefix/"models"
|
|
99
|
+
runtime_dir = models_dir/"onnxruntime"
|
|
100
|
+
nomic_dir = models_dir/"nomic-embed-text-v1.5"
|
|
101
|
+
minilm_dir = models_dir/"all-minilm-l6-v2"
|
|
102
|
+
t5_dir = models_dir/"t5-small"
|
|
103
|
+
|
|
104
|
+
runtime_dir.mkpath
|
|
105
|
+
nomic_dir.mkpath
|
|
106
|
+
minilm_dir.mkpath
|
|
107
|
+
t5_dir.mkpath
|
|
108
|
+
|
|
109
|
+
resource("onnxruntime").stage do
|
|
110
|
+
cp_r Dir["onnxruntime-*"].first, runtime_dir
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
resource("nomic-embed-text-v1.5-model").stage do
|
|
114
|
+
cp "model.onnx", nomic_dir/"model.onnx"
|
|
115
|
+
end
|
|
116
|
+
resource("nomic-embed-text-v1.5-tokenizer").stage do
|
|
117
|
+
cp "tokenizer.json", nomic_dir/"tokenizer.json"
|
|
118
|
+
end
|
|
119
|
+
write_embedding_manifest(nomic_dir, "nomic-embed-text-v1.5", 768)
|
|
120
|
+
|
|
121
|
+
resource("all-minilm-l6-v2-model").stage do
|
|
122
|
+
cp "model.onnx", minilm_dir/"model.onnx"
|
|
123
|
+
end
|
|
124
|
+
resource("all-minilm-l6-v2-tokenizer").stage do
|
|
125
|
+
cp "tokenizer.json", minilm_dir/"tokenizer.json"
|
|
126
|
+
end
|
|
127
|
+
write_embedding_manifest(minilm_dir, "all-minilm-l6-v2", 384)
|
|
128
|
+
|
|
129
|
+
resource("t5-small-encoder").stage do
|
|
130
|
+
cp "encoder_model.onnx", t5_dir/"encoder_model.onnx"
|
|
131
|
+
end
|
|
132
|
+
resource("t5-small-decoder").stage do
|
|
133
|
+
cp "decoder_model.onnx", t5_dir/"decoder_model.onnx"
|
|
134
|
+
end
|
|
135
|
+
resource("t5-small-tokenizer").stage do
|
|
136
|
+
cp "tokenizer.json", t5_dir/"tokenizer.json"
|
|
137
|
+
end
|
|
138
|
+
resource("t5-small-tokenizer-config").stage do
|
|
139
|
+
cp "tokenizer_config.json", t5_dir/"tokenizer_config.json"
|
|
140
|
+
end
|
|
141
|
+
resource("t5-small-config").stage do
|
|
142
|
+
cp "config.json", t5_dir/"config.json"
|
|
143
|
+
end
|
|
144
|
+
write_summarizer_manifest(t5_dir, "t5-small")
|
|
145
|
+
|
|
146
|
+
libexec.install resource("provision")
|
|
147
|
+
chmod 0755, libexec/"provision.sh"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def post_install
|
|
151
|
+
(var/"clawdb/data").mkpath
|
|
152
|
+
(var/"clawdb/run").mkpath
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def caveats
|
|
156
|
+
<<~EOS
|
|
157
|
+
libravdbd requires ONNX embedding models to function. Models are
|
|
158
|
+
automatically provisioned during `brew install`. To re-provision
|
|
159
|
+
or repair assets manually:
|
|
160
|
+
|
|
161
|
+
#{libexec}/provision.sh --target #{prefix}/models
|
|
162
|
+
|
|
163
|
+
Data directory: #{var}/clawdb/data
|
|
164
|
+
Socket directory: #{var}/clawdb/run
|
|
165
|
+
EOS
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
private
|
|
169
|
+
|
|
170
|
+
def write_embedding_manifest(dir, profile, dimensions)
|
|
171
|
+
File.write(dir/"embedding.json", <<~JSON)
|
|
172
|
+
{
|
|
173
|
+
"backend": "onnx-local",
|
|
174
|
+
"profile": "#{profile}",
|
|
175
|
+
"family": "#{profile}",
|
|
176
|
+
"model": "model.onnx",
|
|
177
|
+
"tokenizer": "tokenizer.json",
|
|
178
|
+
"dimensions": #{dimensions},
|
|
179
|
+
"normalize": true,
|
|
180
|
+
"inputNames": ["input_ids", "attention_mask", "token_type_ids"],
|
|
181
|
+
"outputName": "last_hidden_state",
|
|
182
|
+
"pooling": "mean",
|
|
183
|
+
"addSpecialTokens": true
|
|
184
|
+
}
|
|
185
|
+
JSON
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def write_summarizer_manifest(dir, profile)
|
|
189
|
+
File.write(dir/"summarizer.json", <<~JSON)
|
|
190
|
+
{
|
|
191
|
+
"backend": "onnx-local",
|
|
192
|
+
"profile": "#{profile}",
|
|
193
|
+
"family": "#{profile}",
|
|
194
|
+
"encoder": "encoder_model.onnx",
|
|
195
|
+
"decoder": "decoder_model.onnx",
|
|
196
|
+
"tokenizer": "tokenizer.json",
|
|
197
|
+
"maxContextTokens": 512
|
|
198
|
+
}
|
|
199
|
+
JSON
|
|
28
200
|
end
|
|
29
201
|
|
|
30
202
|
service do
|
|
31
203
|
run [opt_bin/"libravdbd", "serve"]
|
|
32
|
-
environment_variables LIBRAVDB_RPC_ENDPOINT: "unix:#{
|
|
204
|
+
environment_variables LIBRAVDB_RPC_ENDPOINT: "unix:#{var}/clawdb/run/libravdb.sock",
|
|
205
|
+
LIBRAVDB_DB_PATH: "#{var}/clawdb/data",
|
|
206
|
+
LIBRAVDB_SUMMARIZER_BACKEND: "bundled"
|
|
33
207
|
keep_alive true
|
|
34
|
-
working_dir
|
|
208
|
+
working_dir var/"clawdb"
|
|
35
209
|
end
|
|
36
210
|
|
|
37
211
|
test do
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
<dict>
|
|
14
14
|
<key>LIBRAVDB_RPC_ENDPOINT</key>
|
|
15
15
|
<string>unix:__HOME__/.clawdb/run/libravdb.sock</string>
|
|
16
|
+
<key>LIBRAVDB_DB_PATH</key>
|
|
17
|
+
<string>__HOME__/.clawdb/data</string>
|
|
18
|
+
<key>LIBRAVDB_ONNX_RUNTIME</key>
|
|
19
|
+
<string>__ONNX_RUNTIME_LIB__</string>
|
|
20
|
+
<key>LIBRAVDB_SUMMARIZER_BACKEND</key>
|
|
21
|
+
<string>bundled</string>
|
|
16
22
|
</dict>
|
|
17
23
|
<key>RunAtLoad</key>
|
|
18
24
|
<true/>
|
package/src/cli.ts
CHANGED
|
@@ -9,6 +9,7 @@ type StatusResult = {
|
|
|
9
9
|
message?: string;
|
|
10
10
|
turnCount?: number;
|
|
11
11
|
memoryCount?: number;
|
|
12
|
+
lifecycleHintCount?: number;
|
|
12
13
|
gatingThreshold?: number;
|
|
13
14
|
abstractiveReady?: boolean;
|
|
14
15
|
embeddingProfile?: string;
|
|
@@ -25,9 +26,18 @@ type ExportResult = {
|
|
|
25
26
|
|
|
26
27
|
type CliOptionBag = {
|
|
27
28
|
userId?: string;
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
limit?: string | number;
|
|
28
31
|
yes?: boolean;
|
|
29
32
|
};
|
|
30
33
|
|
|
34
|
+
type JournalResult = {
|
|
35
|
+
results?: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
metadata: Record<string, unknown>;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
|
|
31
41
|
type CliCommand = {
|
|
32
42
|
commands?: CliCommand[];
|
|
33
43
|
command(name: string): CliCommand;
|
|
@@ -74,6 +84,12 @@ export function registerMemoryCli(
|
|
|
74
84
|
.description("Stream stored memories as newline-delimited JSON");
|
|
75
85
|
exportCmd.option("--user-id <userId>", "Restrict export to a single user namespace");
|
|
76
86
|
exportCmd.action((opts) => void runExport(runtime, opts, logger));
|
|
87
|
+
|
|
88
|
+
const journal = ensureCommand(root, "journal")
|
|
89
|
+
.description("Inspect internal lifecycle journal hints");
|
|
90
|
+
journal.option("--session-id <sessionId>", "Restrict journal entries to one session id");
|
|
91
|
+
journal.option("--limit <limit>", "Maximum journal entries to show");
|
|
92
|
+
journal.action((opts) => void runJournal(runtime, opts, logger));
|
|
77
93
|
},
|
|
78
94
|
{
|
|
79
95
|
descriptors: [
|
|
@@ -108,6 +124,7 @@ async function runStatus(runtime: PluginRuntime, cfg: PluginConfig, logger: Logg
|
|
|
108
124
|
Sidecar: status.ok ? "running" : "down",
|
|
109
125
|
"Turns stored": status.turnCount ?? 0,
|
|
110
126
|
"Memories stored": status.memoryCount ?? 0,
|
|
127
|
+
"Lifecycle hints": status.lifecycleHintCount ?? 0,
|
|
111
128
|
"Gate threshold": status.gatingThreshold ?? cfg.ingestionGateThreshold ?? 0.35,
|
|
112
129
|
"Abstractive model": status.abstractiveReady ? "ready" : "not provisioned",
|
|
113
130
|
"Embedding profile": status.embeddingProfile ?? "unknown",
|
|
@@ -119,6 +136,7 @@ async function runStatus(runtime: PluginRuntime, cfg: PluginConfig, logger: Logg
|
|
|
119
136
|
Sidecar: "down",
|
|
120
137
|
"Turns stored": "n/a",
|
|
121
138
|
"Memories stored": "n/a",
|
|
139
|
+
"Lifecycle hints": "n/a",
|
|
122
140
|
"Gate threshold": cfg.ingestionGateThreshold ?? 0.35,
|
|
123
141
|
"Abstractive model": "unknown",
|
|
124
142
|
"Embedding profile": "unknown",
|
|
@@ -169,6 +187,22 @@ async function runExport(runtime: PluginRuntime, opts: CliOptionBag | undefined,
|
|
|
169
187
|
}
|
|
170
188
|
}
|
|
171
189
|
|
|
190
|
+
async function runJournal(runtime: PluginRuntime, opts: CliOptionBag | undefined, logger: LoggerLike): Promise<void> {
|
|
191
|
+
try {
|
|
192
|
+
const rpc = await runtime.getRpc();
|
|
193
|
+
const result = await rpc.call<JournalResult>("list_lifecycle_journal", {
|
|
194
|
+
sessionId: opts?.sessionId?.trim() || undefined,
|
|
195
|
+
limit: normalizeLimit(opts?.limit),
|
|
196
|
+
});
|
|
197
|
+
for (const record of result.results ?? []) {
|
|
198
|
+
stdout.write(`${JSON.stringify(record)}\n`);
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
logger.error(`LibraVDB journal lookup failed: ${formatError(error)}`);
|
|
202
|
+
process.exitCode = 1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
172
206
|
async function confirm(prompt: string): Promise<boolean> {
|
|
173
207
|
const rl = createInterface({ input: stdin, output: stdout });
|
|
174
208
|
try {
|
|
@@ -186,6 +220,19 @@ function formatError(error: unknown): string {
|
|
|
186
220
|
return String(error);
|
|
187
221
|
}
|
|
188
222
|
|
|
223
|
+
function normalizeLimit(limit: string | number | undefined): number | undefined {
|
|
224
|
+
if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) {
|
|
225
|
+
return Math.floor(limit);
|
|
226
|
+
}
|
|
227
|
+
if (typeof limit === "string") {
|
|
228
|
+
const parsed = Number.parseInt(limit, 10);
|
|
229
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
230
|
+
return parsed;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
189
236
|
type CliRegistrar = {
|
|
190
237
|
registerCli?(
|
|
191
238
|
builder: (ctx: { program: CliProgram }) => void,
|