@lotargo/memory_plugin 1.5.3 → 1.6.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/CHANGELOG.md +108 -0
- package/README.md +383 -352
- package/mcp-server/admin/auth.js +13 -4
- package/mcp-server/admin/snapshot.js +24 -7
- package/mcp-server/cli/direct_commands.js +334 -313
- package/mcp-server/cli/handlers/engine_actions.js +41 -0
- package/mcp-server/cli/handlers/storage_actions.js +58 -0
- package/mcp-server/cli/secret_input.js +44 -0
- package/mcp-server/cli/ui.js +564 -565
- package/mcp-server/cli.js +356 -324
- package/mcp-server/config/auth_store.js +74 -16
- package/mcp-server/config/config_manager.js +4 -0
- package/mcp-server/db/database.js +33 -14
- package/mcp-server/db/sync_queue.js +9 -19
- package/mcp-server/index.js +112 -42
- package/mcp-server/ingest/normalizer.js +116 -29
- package/mcp-server/ingest/pipeline.js +94 -6
- package/mcp-server/logger.js +49 -0
- package/mcp-server/memory.js +6 -9
- package/mcp-server/ml/gpu_monitor.js +169 -166
- package/mcp-server/ml/model_manager.js +17 -4
- package/mcp-server/retrieval/retriever.js +35 -15
- package/mcp-server/security/path_guard.js +67 -0
- package/mcp-server/setup.js +10 -2
- package/mcp-server/storage/blob_store.js +15 -2
- package/mcp-server/tools/core/memory_core.js +393 -0
- package/mcp-server/tools/helpers.js +59 -39
- package/mcp-server/tools/memory_tools.js +123 -516
- package/mcp-server/tools/rag_tools.js +49 -1
- package/opencode-plugin/index.js +94 -397
- package/package.json +7 -1
- package/skills/using-memory/SKILL.md +7 -2
|
@@ -1,39 +1,59 @@
|
|
|
1
|
-
import * as z from "zod/v4";
|
|
2
|
-
import { factMeta, factText } from "../fact_format.js";
|
|
3
|
-
|
|
4
|
-
// Optional string/number that tolerates null (some tool-call layers fill omitted
|
|
5
|
-
// optional args with null). Linking fields must NEVER be mandatory.
|
|
6
|
-
export const optStr = () => z.string().optional().nullable();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { factMeta, factText } from "../fact_format.js";
|
|
3
|
+
|
|
4
|
+
// Optional string/number that tolerates null (some tool-call layers fill omitted
|
|
5
|
+
// optional args with null). Linking fields must NEVER be mandatory.
|
|
6
|
+
export const optStr = () => z.string().optional().nullable();
|
|
7
|
+
// Tolerates "" and numeric strings: some tool-call layers send empty strings for
|
|
8
|
+
// omitted numeric args, which plain z.number() rejects with "Expected number".
|
|
9
|
+
export const optNum = () =>
|
|
10
|
+
z
|
|
11
|
+
.union([z.number(), z.string(), z.null()])
|
|
12
|
+
.optional()
|
|
13
|
+
.nullable()
|
|
14
|
+
.transform((v) => {
|
|
15
|
+
if (v === null || v === undefined || v === "") return undefined;
|
|
16
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
17
|
+
return Number.isFinite(n) ? n : undefined;
|
|
18
|
+
});
|
|
19
|
+
export const defStr = (fallback) =>
|
|
20
|
+
z
|
|
21
|
+
.string()
|
|
22
|
+
.nullish()
|
|
23
|
+
.transform((v) => (v === null || v === undefined || v === "" ? fallback : v));
|
|
24
|
+
export const defBool = (fallback) =>
|
|
25
|
+
z.boolean().nullish().transform((v) => (v === null || v === undefined ? fallback : v));
|
|
26
|
+
export const defNum = (fallback) =>
|
|
27
|
+
z
|
|
28
|
+
.union([z.number(), z.string(), z.null()])
|
|
29
|
+
.nullish()
|
|
30
|
+
.transform((v) => {
|
|
31
|
+
if (v === null || v === undefined || v === "") return fallback;
|
|
32
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
33
|
+
return Number.isFinite(n) ? n : fallback;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Project memory is git-based: outside a git repository there is no project key.
|
|
37
|
+
export function requireProjectKey(key) {
|
|
38
|
+
if (!key) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"No project memory available: this directory is not inside a git repository. " +
|
|
41
|
+
"Project memory is tied to a git repo; use scope: 'global' or open a git repository."
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return key;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Resolve a fact reference (1-based number, metadata id, or text) to an index.
|
|
48
|
+
export function resolveFactIndex(entries, ref) {
|
|
49
|
+
const trimmed = String(ref || "").trim();
|
|
50
|
+
if (!trimmed) return -1;
|
|
51
|
+
if (/^\d+$/.test(trimmed)) {
|
|
52
|
+
const num = parseInt(trimmed, 10);
|
|
53
|
+
if (num >= 1 && num <= entries.length) return num - 1;
|
|
54
|
+
}
|
|
55
|
+
const idIdx = entries.findIndex((e) => factMeta(e).id === trimmed);
|
|
56
|
+
if (idIdx !== -1) return idIdx;
|
|
57
|
+
const textIdx = entries.findIndex((e) => factText(e).toLowerCase().includes(trimmed.toLowerCase()));
|
|
58
|
+
return textIdx;
|
|
59
|
+
}
|