@gakr-gakr/memory-lancedb 0.1.0
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/api.ts +2 -0
- package/autobot.plugin.json +147 -0
- package/cli-metadata.ts +18 -0
- package/config.ts +283 -0
- package/index.ts +1162 -0
- package/lancedb-runtime.ts +77 -0
- package/package.json +39 -0
- package/test-helpers.ts +25 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
type LanceDbModule = typeof import("@lancedb/lancedb");
|
|
2
|
+
|
|
3
|
+
export type LanceDbRuntimeLogger = {
|
|
4
|
+
info?: (message: string) => void;
|
|
5
|
+
warn?: (message: string) => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type LanceDbRuntimeLoaderDeps = {
|
|
9
|
+
platform: NodeJS.Platform;
|
|
10
|
+
arch: NodeJS.Architecture;
|
|
11
|
+
importBundled: () => Promise<LanceDbModule>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function buildLoadFailureMessage(error: unknown): string {
|
|
15
|
+
return [
|
|
16
|
+
"memory-lancedb: bundled @lancedb/lancedb dependency is unavailable.",
|
|
17
|
+
"Install or repair the memory-lancedb plugin package dependencies, then restart AutoBot.",
|
|
18
|
+
String(error),
|
|
19
|
+
].join(" ");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isUnsupportedNativePlatform(params: {
|
|
23
|
+
platform: NodeJS.Platform;
|
|
24
|
+
arch: NodeJS.Architecture;
|
|
25
|
+
}): boolean {
|
|
26
|
+
return params.platform === "darwin" && params.arch === "x64";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function buildUnsupportedNativePlatformMessage(params: {
|
|
30
|
+
platform: NodeJS.Platform;
|
|
31
|
+
arch: NodeJS.Architecture;
|
|
32
|
+
}): string {
|
|
33
|
+
return [
|
|
34
|
+
`memory-lancedb: LanceDB runtime is unavailable on ${params.platform}-${params.arch}.`,
|
|
35
|
+
"The bundled @lancedb/lancedb dependency does not publish a native package for this platform.",
|
|
36
|
+
"Disable memory-lancedb or switch to a supported memory backend/platform.",
|
|
37
|
+
].join(" ");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function createLanceDbRuntimeLoader(overrides: Partial<LanceDbRuntimeLoaderDeps> = {}): {
|
|
41
|
+
load: (loggerInstance?: LanceDbRuntimeLogger) => Promise<LanceDbModule>;
|
|
42
|
+
} {
|
|
43
|
+
const deps: LanceDbRuntimeLoaderDeps = {
|
|
44
|
+
platform: overrides.platform ?? process.platform,
|
|
45
|
+
arch: overrides.arch ?? process.arch,
|
|
46
|
+
importBundled: overrides.importBundled ?? (() => import("@lancedb/lancedb")),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
let loadPromise: Promise<LanceDbModule> | null = null;
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
async load(_logger?: LanceDbRuntimeLogger): Promise<LanceDbModule> {
|
|
53
|
+
if (!loadPromise) {
|
|
54
|
+
loadPromise = deps.importBundled().catch((error) => {
|
|
55
|
+
loadPromise = null;
|
|
56
|
+
if (isUnsupportedNativePlatform({ platform: deps.platform, arch: deps.arch })) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
buildUnsupportedNativePlatformMessage({
|
|
59
|
+
platform: deps.platform,
|
|
60
|
+
arch: deps.arch,
|
|
61
|
+
}),
|
|
62
|
+
{ cause: error },
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
throw new Error(buildLoadFailureMessage(error), { cause: error });
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return await loadPromise;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const defaultLoader = createLanceDbRuntimeLoader();
|
|
74
|
+
|
|
75
|
+
export async function loadLanceDbModule(logger?: LanceDbRuntimeLogger): Promise<LanceDbModule> {
|
|
76
|
+
return await defaultLoader.load(logger);
|
|
77
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gakr-gakr/memory-lancedb",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AutoBot LanceDB-backed long-term memory plugin with auto-recall/capture",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/autobot/autobot"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@lancedb/lancedb": "0.27.2",
|
|
12
|
+
"apache-arrow": "18.1.0",
|
|
13
|
+
"openai": "6.37.0",
|
|
14
|
+
"typebox": "1.1.38"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@gakr-gakr/plugin-sdk": "workspace:*"
|
|
18
|
+
},
|
|
19
|
+
"autobot": {
|
|
20
|
+
"extensions": [
|
|
21
|
+
"./index.ts"
|
|
22
|
+
],
|
|
23
|
+
"install": {
|
|
24
|
+
"npmSpec": "@gakr-gakr/memory-lancedb",
|
|
25
|
+
"defaultChoice": "npm",
|
|
26
|
+
"minHostVersion": ">=2026.4.10"
|
|
27
|
+
},
|
|
28
|
+
"compat": {
|
|
29
|
+
"pluginApi": ">=2026.5.19"
|
|
30
|
+
},
|
|
31
|
+
"build": {
|
|
32
|
+
"autobotVersion": "2026.5.19"
|
|
33
|
+
},
|
|
34
|
+
"release": {
|
|
35
|
+
"publishToClawHub": true,
|
|
36
|
+
"publishToNpm": true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/test-helpers.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolvePreferredAutoBotTmpDir } from "autobot/plugin-sdk/temp-path";
|
|
4
|
+
import { afterEach, beforeEach } from "vitest";
|
|
5
|
+
|
|
6
|
+
export function installTmpDirHarness(params: { prefix: string }) {
|
|
7
|
+
let tmpDir = "";
|
|
8
|
+
let dbPath = "";
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
tmpDir = await fs.mkdtemp(path.join(resolvePreferredAutoBotTmpDir(), params.prefix));
|
|
12
|
+
dbPath = path.join(tmpDir, "lancedb");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(async () => {
|
|
16
|
+
if (tmpDir) {
|
|
17
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
getTmpDir: () => tmpDir,
|
|
23
|
+
getDbPath: () => dbPath,
|
|
24
|
+
};
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.package-boundary.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "."
|
|
5
|
+
},
|
|
6
|
+
"include": ["./*.ts", "./src/**/*.ts"],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"./**/*.test.ts",
|
|
9
|
+
"./dist/**",
|
|
10
|
+
"./node_modules/**",
|
|
11
|
+
"./src/test-support/**",
|
|
12
|
+
"./src/**/*test-helpers.ts",
|
|
13
|
+
"./src/**/*test-harness.ts",
|
|
14
|
+
"./src/**/*test-support.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|