memory-lancedb-pro 1.0.21 → 1.0.22
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/CHANGELOG.md +12 -0
- package/README.md +34 -0
- package/README_CN.md +34 -0
- package/index.ts +13 -1
- package/package.json +1 -1
- package/src/store.ts +90 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## 1.0.22
|
|
5
|
+
|
|
6
|
+
**Storage Path Validation & Better Error Messages**
|
|
7
|
+
|
|
8
|
+
- **Fix**: Validate `dbPath` at startup — resolve symlinks, auto-create missing directories, check write permissions (#26, #27)
|
|
9
|
+
- **Fix**: Write/connection failures now include `errno`, resolved path, and actionable fix suggestions instead of generic errors (#28)
|
|
10
|
+
- **New**: Exported `validateStoragePath()` utility for external tooling and diagnostics
|
|
11
|
+
|
|
12
|
+
Breaking changes: None. Backward compatible.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
4
16
|
## 1.0.21
|
|
5
17
|
|
|
6
18
|
**Long Context Chunking**
|
package/README.md
CHANGED
|
@@ -720,6 +720,40 @@ upgrade to **memory-lancedb-pro >= 1.0.14**. This plugin now coerces these value
|
|
|
720
720
|
|
|
721
721
|
---
|
|
722
722
|
|
|
723
|
+
## ⭐ Star History
|
|
724
|
+
|
|
725
|
+
<a href="https://star-history.com/#win4r/memory-lancedb-pro&Date">
|
|
726
|
+
<picture>
|
|
727
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=win4r/memory-lancedb-pro&type=Date&theme=dark&transparent=true" />
|
|
728
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=win4r/memory-lancedb-pro&type=Date&transparent=true" />
|
|
729
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=win4r/memory-lancedb-pro&type=Date&transparent=true" />
|
|
730
|
+
</picture>
|
|
731
|
+
</a>
|
|
732
|
+
|
|
733
|
+
## Contributors
|
|
734
|
+
|
|
735
|
+
Top contributors (from GitHub’s contributors list, sorted by commit contributions; bots excluded):
|
|
736
|
+
|
|
737
|
+
<p>
|
|
738
|
+
<a href="https://github.com/win4r"><img src="https://avatars.githubusercontent.com/u/42172631?v=4" width="48" height="48" alt="@win4r" /></a>
|
|
739
|
+
<a href="https://github.com/kctony"><img src="https://avatars.githubusercontent.com/u/1731141?v=4" width="48" height="48" alt="@kctony" /></a>
|
|
740
|
+
<a href="https://github.com/Akatsuki-Ryu"><img src="https://avatars.githubusercontent.com/u/8062209?v=4" width="48" height="48" alt="@Akatsuki-Ryu" /></a>
|
|
741
|
+
<a href="https://github.com/JasonSuz"><img src="https://avatars.githubusercontent.com/u/612256?v=4" width="48" height="48" alt="@JasonSuz" /></a>
|
|
742
|
+
<a href="https://github.com/Minidoracat"><img src="https://avatars.githubusercontent.com/u/11269639?v=4" width="48" height="48" alt="@Minidoracat" /></a>
|
|
743
|
+
<a href="https://github.com/furedericca-lab"><img src="https://avatars.githubusercontent.com/u/263020793?v=4" width="48" height="48" alt="@furedericca-lab" /></a>
|
|
744
|
+
<a href="https://github.com/joe2643"><img src="https://avatars.githubusercontent.com/u/19421931?v=4" width="48" height="48" alt="@joe2643" /></a>
|
|
745
|
+
</p>
|
|
746
|
+
|
|
747
|
+
- [@win4r](https://github.com/win4r) (3 commits)
|
|
748
|
+
- [@kctony](https://github.com/kctony) (2 commits)
|
|
749
|
+
- [@Akatsuki-Ryu](https://github.com/Akatsuki-Ryu) (1 commit)
|
|
750
|
+
- [@JasonSuz](https://github.com/JasonSuz) (1 commit)
|
|
751
|
+
- [@Minidoracat](https://github.com/Minidoracat) (1 commit)
|
|
752
|
+
- [@furedericca-lab](https://github.com/furedericca-lab) (1 commit)
|
|
753
|
+
- [@joe2643](https://github.com/joe2643) (1 commit)
|
|
754
|
+
|
|
755
|
+
Full list: https://github.com/win4r/memory-lancedb-pro/graphs/contributors
|
|
756
|
+
|
|
723
757
|
## License
|
|
724
758
|
|
|
725
759
|
MIT
|
package/README_CN.md
CHANGED
|
@@ -594,6 +594,40 @@ LanceDB 表 `memories`:
|
|
|
594
594
|
|
|
595
595
|
---
|
|
596
596
|
|
|
597
|
+
## ⭐ Star 趋势
|
|
598
|
+
|
|
599
|
+
<a href="https://star-history.com/#win4r/memory-lancedb-pro&Date">
|
|
600
|
+
<picture>
|
|
601
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=win4r/memory-lancedb-pro&type=Date&theme=dark&transparent=true" />
|
|
602
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=win4r/memory-lancedb-pro&type=Date&transparent=true" />
|
|
603
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=win4r/memory-lancedb-pro&type=Date&transparent=true" />
|
|
604
|
+
</picture>
|
|
605
|
+
</a>
|
|
606
|
+
|
|
607
|
+
## 主要贡献者
|
|
608
|
+
|
|
609
|
+
按 GitHub Contributors 列表自动生成(按 commit 贡献数排序,已排除 bot):
|
|
610
|
+
|
|
611
|
+
<p>
|
|
612
|
+
<a href="https://github.com/win4r"><img src="https://avatars.githubusercontent.com/u/42172631?v=4" width="48" height="48" alt="@win4r" /></a>
|
|
613
|
+
<a href="https://github.com/kctony"><img src="https://avatars.githubusercontent.com/u/1731141?v=4" width="48" height="48" alt="@kctony" /></a>
|
|
614
|
+
<a href="https://github.com/Akatsuki-Ryu"><img src="https://avatars.githubusercontent.com/u/8062209?v=4" width="48" height="48" alt="@Akatsuki-Ryu" /></a>
|
|
615
|
+
<a href="https://github.com/JasonSuz"><img src="https://avatars.githubusercontent.com/u/612256?v=4" width="48" height="48" alt="@JasonSuz" /></a>
|
|
616
|
+
<a href="https://github.com/Minidoracat"><img src="https://avatars.githubusercontent.com/u/11269639?v=4" width="48" height="48" alt="@Minidoracat" /></a>
|
|
617
|
+
<a href="https://github.com/furedericca-lab"><img src="https://avatars.githubusercontent.com/u/263020793?v=4" width="48" height="48" alt="@furedericca-lab" /></a>
|
|
618
|
+
<a href="https://github.com/joe2643"><img src="https://avatars.githubusercontent.com/u/19421931?v=4" width="48" height="48" alt="@joe2643" /></a>
|
|
619
|
+
</p>
|
|
620
|
+
|
|
621
|
+
- [@win4r](https://github.com/win4r)(3 次提交)
|
|
622
|
+
- [@kctony](https://github.com/kctony)(2 次提交)
|
|
623
|
+
- [@Akatsuki-Ryu](https://github.com/Akatsuki-Ryu)(1 次提交)
|
|
624
|
+
- [@JasonSuz](https://github.com/JasonSuz)(1 次提交)
|
|
625
|
+
- [@Minidoracat](https://github.com/Minidoracat)(1 次提交)
|
|
626
|
+
- [@furedericca-lab](https://github.com/furedericca-lab)(1 次提交)
|
|
627
|
+
- [@joe2643](https://github.com/joe2643)(1 次提交)
|
|
628
|
+
|
|
629
|
+
完整列表:https://github.com/win4r/memory-lancedb-pro/graphs/contributors
|
|
630
|
+
|
|
597
631
|
## License
|
|
598
632
|
|
|
599
633
|
MIT
|
package/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { readFile, readdir, writeFile, mkdir } from "node:fs/promises";
|
|
|
10
10
|
import { readFileSync } from "node:fs";
|
|
11
11
|
|
|
12
12
|
// Import core components
|
|
13
|
-
import { MemoryStore } from "./src/store.js";
|
|
13
|
+
import { MemoryStore, validateStoragePath } from "./src/store.js";
|
|
14
14
|
import { createEmbedder, getVectorDimensions } from "./src/embedder.js";
|
|
15
15
|
import { createRetriever, DEFAULT_RETRIEVAL_CONFIG } from "./src/retriever.js";
|
|
16
16
|
import { createScopeManager } from "./src/scopes.js";
|
|
@@ -315,6 +315,18 @@ const memoryLanceDBProPlugin = {
|
|
|
315
315
|
const config = parsePluginConfig(api.pluginConfig);
|
|
316
316
|
|
|
317
317
|
const resolvedDbPath = api.resolvePath(config.dbPath || getDefaultDbPath());
|
|
318
|
+
|
|
319
|
+
// Pre-flight: validate storage path (symlink resolution, mkdir, write check).
|
|
320
|
+
// Runs synchronously and logs warnings; does NOT block gateway startup.
|
|
321
|
+
try {
|
|
322
|
+
validateStoragePath(resolvedDbPath);
|
|
323
|
+
} catch (err) {
|
|
324
|
+
api.logger.warn(
|
|
325
|
+
`memory-lancedb-pro: storage path issue — ${String(err)}\n` +
|
|
326
|
+
` The plugin will still attempt to start, but writes may fail.`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
318
330
|
const vectorDim = getVectorDimensions(
|
|
319
331
|
config.embedding.model || "text-embedding-3-small",
|
|
320
332
|
config.embedding.dimensions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memory-lancedb-pro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "OpenClaw enhanced LanceDB memory plugin with hybrid retrieval (Vector + BM25), cross-encoder rerank, multi-scope isolation, long-context chunking, and management CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
package/src/store.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as LanceDB from "@lancedb/lancedb";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { existsSync, accessSync, constants, mkdirSync, realpathSync, lstatSync } from "node:fs";
|
|
8
|
+
import { dirname } from "node:path";
|
|
7
9
|
|
|
8
10
|
// ============================================================================
|
|
9
11
|
// Types
|
|
@@ -60,6 +62,72 @@ function escapeSqlLiteral(value: string): string {
|
|
|
60
62
|
return value.replace(/'/g, "''");
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Storage Path Validation
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Validate and prepare the storage directory before LanceDB connection.
|
|
71
|
+
* Resolves symlinks, creates missing directories, and checks write permissions.
|
|
72
|
+
* Returns the resolved absolute path on success, or throws a descriptive error.
|
|
73
|
+
*/
|
|
74
|
+
export function validateStoragePath(dbPath: string): string {
|
|
75
|
+
let resolvedPath = dbPath;
|
|
76
|
+
|
|
77
|
+
// Resolve symlinks (including dangling symlinks)
|
|
78
|
+
try {
|
|
79
|
+
const stats = lstatSync(dbPath);
|
|
80
|
+
if (stats.isSymbolicLink()) {
|
|
81
|
+
try {
|
|
82
|
+
resolvedPath = realpathSync(dbPath);
|
|
83
|
+
} catch (err: any) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`dbPath "${dbPath}" is a symlink whose target does not exist.\n` +
|
|
86
|
+
` Fix: Create the target directory, or update the symlink to point to a valid path.\n` +
|
|
87
|
+
` Details: ${err.code || ""} ${err.message}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} catch (err: any) {
|
|
92
|
+
// Missing path is OK (it will be created below)
|
|
93
|
+
if (err?.code === "ENOENT") {
|
|
94
|
+
// no-op
|
|
95
|
+
} else if (typeof err?.message === "string" && err.message.includes("symlink whose target does not exist")) {
|
|
96
|
+
throw err;
|
|
97
|
+
} else {
|
|
98
|
+
// Other lstat failures — continue with original path
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Create directory if it doesn't exist
|
|
103
|
+
if (!existsSync(resolvedPath)) {
|
|
104
|
+
try {
|
|
105
|
+
mkdirSync(resolvedPath, { recursive: true });
|
|
106
|
+
} catch (err: any) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Failed to create dbPath directory "${resolvedPath}".\n` +
|
|
109
|
+
` Fix: Ensure the parent directory "${dirname(resolvedPath)}" exists and is writable,\n` +
|
|
110
|
+
` or create it manually: mkdir -p "${resolvedPath}"\n` +
|
|
111
|
+
` Details: ${err.code || ""} ${err.message}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Check write permissions
|
|
117
|
+
try {
|
|
118
|
+
accessSync(resolvedPath, constants.W_OK);
|
|
119
|
+
} catch (err: any) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`dbPath directory "${resolvedPath}" is not writable.\n` +
|
|
122
|
+
` Fix: Check permissions with: ls -la "${dirname(resolvedPath)}"\n` +
|
|
123
|
+
` Or grant write access: chmod u+w "${resolvedPath}"\n` +
|
|
124
|
+
` Details: ${err.code || ""} ${err.message}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return resolvedPath;
|
|
129
|
+
}
|
|
130
|
+
|
|
63
131
|
// ============================================================================
|
|
64
132
|
// Memory Store
|
|
65
133
|
// ============================================================================
|
|
@@ -95,7 +163,19 @@ export class MemoryStore {
|
|
|
95
163
|
|
|
96
164
|
private async doInitialize(): Promise<void> {
|
|
97
165
|
const lancedb = await loadLanceDB();
|
|
98
|
-
|
|
166
|
+
|
|
167
|
+
let db: LanceDB.Connection;
|
|
168
|
+
try {
|
|
169
|
+
db = await lancedb.connect(this.config.dbPath);
|
|
170
|
+
} catch (err: any) {
|
|
171
|
+
const code = err.code || "";
|
|
172
|
+
const message = err.message || String(err);
|
|
173
|
+
throw new Error(
|
|
174
|
+
`Failed to open LanceDB at "${this.config.dbPath}": ${code} ${message}\n` +
|
|
175
|
+
` Fix: Verify the path exists and is writable. Check parent directory permissions.`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
99
179
|
let table: LanceDB.Table;
|
|
100
180
|
|
|
101
181
|
// Idempotent table init: try openTable first, create only if missing,
|
|
@@ -196,7 +276,15 @@ export class MemoryStore {
|
|
|
196
276
|
metadata: entry.metadata || "{}",
|
|
197
277
|
};
|
|
198
278
|
|
|
199
|
-
|
|
279
|
+
try {
|
|
280
|
+
await this.table!.add([fullEntry]);
|
|
281
|
+
} catch (err: any) {
|
|
282
|
+
const code = err.code || "";
|
|
283
|
+
const message = err.message || String(err);
|
|
284
|
+
throw new Error(
|
|
285
|
+
`Failed to store memory in "${this.config.dbPath}": ${code} ${message}`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
200
288
|
return fullEntry;
|
|
201
289
|
}
|
|
202
290
|
|