@remnic/plugin-openclaw 1.0.10 → 1.0.12
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/dist/{calibration-674TDQNV.js → calibration-WCHOK6DX.js} +12 -4
- package/dist/capsule-cli-GBM3WPAM.js +33 -0
- package/dist/capsule-crypto-K3IRTKRH.js +17 -0
- package/dist/capsule-export-IXVERCQG.js +17 -0
- package/dist/capsule-import-IA6VIOPQ.js +16 -0
- package/dist/capsule-merge-IWOQ34KL.js +189 -0
- package/dist/{causal-chain-OKDZSDEB.js → causal-chain-WYN5QOPS.js} +3 -2
- package/dist/{causal-consolidation-5BEXLQV5.js → causal-consolidation-YI53C2AO.js} +16 -12
- package/dist/{causal-retrieval-3BKBXVXD.js → causal-retrieval-NZHQOZOE.js} +6 -5
- package/dist/{causal-trajectory-graph-RQIT37DN.js → causal-trajectory-graph-VBPE2WPM.js} +1 -1
- package/dist/chunk-37NKFWSO.js +233 -0
- package/dist/chunk-3G7FAF6S.js +60 -0
- package/dist/{chunk-Z7GRLVK3.js → chunk-3GUF7RQI.js} +235 -19
- package/dist/chunk-4G2XCSD2.js +186 -0
- package/dist/chunk-4LYQ4ONL.js +185 -0
- package/dist/chunk-6F6EKSVP.js +453 -0
- package/dist/chunk-6IWEAUN6.js +148 -0
- package/dist/{chunk-LN5UZQVG.js → chunk-6UFI73TJ.js} +5 -3
- package/dist/chunk-7OQEPGQF.js +529 -0
- package/dist/{chunk-JJSNPSCD.js → chunk-7UZNLMW5.js} +652 -174
- package/dist/chunk-B52XADV3.js +244 -0
- package/dist/chunk-BU5KJVWF.js +78 -0
- package/dist/chunk-CDAZGIGT.js +720 -0
- package/dist/chunk-CXM7EBAO.js +289 -0
- package/dist/{chunk-HCFFXBLV.js → chunk-EXDYWXMB.js} +6 -1861
- package/dist/chunk-FGTYFLL5.js +274 -0
- package/dist/chunk-FQRSVYY4.js +110 -0
- package/dist/chunk-HRGFO6AW.js +349 -0
- package/dist/chunk-I6B2W2IY.js +47 -0
- package/dist/chunk-JZBOXOUC.js +259 -0
- package/dist/chunk-L6I4MQKO.js +227 -0
- package/dist/chunk-LLUROTZJ.js +328 -0
- package/dist/chunk-MBIFE6SA.js +250 -0
- package/dist/chunk-NKVIN6RD.js +118 -0
- package/dist/chunk-OAE7AQ6R.js +1832 -0
- package/dist/chunk-OEI7GLV2.js +17 -0
- package/dist/chunk-RKR6PTPA.js +308 -0
- package/dist/{chunk-7TENHBV2.js → chunk-RQCTMECT.js} +10 -48
- package/dist/chunk-SSFTU6LP.js +182 -0
- package/dist/{chunk-BXTMZDRT.js → chunk-SVSQAG6M.js} +7 -5
- package/dist/{chunk-S2ISS4AH.js → chunk-TILAJIJR.js} +10 -10
- package/dist/chunk-TLVIQLB4.js +874 -0
- package/dist/{chunk-YHH3SXKD.js → chunk-WPINX4MF.js} +1 -59
- package/dist/chunk-YGGGUTG3.js +125 -0
- package/dist/cipher-VHAFCG7Z.js +27 -0
- package/dist/dreams-ledger-3I52ISYR.js +285 -0
- package/dist/{engine-65C2J63X.js → engine-BIYI3P4J.js} +7 -2
- package/dist/{fallback-llm-LVK5PDIM.js → fallback-llm-WCWNGIQ3.js} +2 -1
- package/dist/first-start-migration-I24M2JEE.js +258 -0
- package/dist/forget-NI4RBDPB.js +68 -0
- package/dist/fs-utils-PZRI2HDZ.js +29 -0
- package/dist/graph-edge-decay-5CVKWBYH.js +203 -0
- package/dist/index.js +10654 -3067
- package/dist/kdf-H5B23ZM2.js +25 -0
- package/dist/memory-governance-SJ5DGRB3.js +25 -0
- package/dist/metadata-JAGIWHEA.js +20 -0
- package/dist/migrate-from-identity-anchor-N3354WMP.js +7 -0
- package/dist/path-5LCUBAAZ.js +8 -0
- package/dist/peers-JF2I6RCR.js +43 -0
- package/dist/purge-XN2VSPZ2.js +204 -0
- package/dist/secure-store-A4NGCNXV.js +155 -0
- package/dist/state-PVISYXRH.js +7 -0
- package/dist/state-store-LP5BO6SF.js +15 -0
- package/dist/{storage-DM4ZGOCN.js → storage-PTQ2H2YJ.js} +3 -1
- package/dist/tier-stats-IZNW66NC.js +147 -0
- package/dist/trace-NJESSGH7.js +289 -0
- package/dist/tui-MGK2LYJY.js +12 -0
- package/dist/types-R4DO7AKM.js +30 -0
- package/openclaw.plugin.json +519 -4
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_ARGON2ID_PARAMS,
|
|
3
|
+
DEFAULT_SCRYPT_PARAMS,
|
|
4
|
+
KDF_KEY_LENGTH,
|
|
5
|
+
KDF_SALT_LENGTH,
|
|
6
|
+
constantTimeEqual,
|
|
7
|
+
deriveKey,
|
|
8
|
+
deriveKeyArgon2id,
|
|
9
|
+
deriveKeyScrypt,
|
|
10
|
+
validateArgon2idParams,
|
|
11
|
+
validateScryptParams
|
|
12
|
+
} from "./chunk-6IWEAUN6.js";
|
|
13
|
+
import "./chunk-MLKGABMK.js";
|
|
14
|
+
export {
|
|
15
|
+
DEFAULT_ARGON2ID_PARAMS,
|
|
16
|
+
DEFAULT_SCRYPT_PARAMS,
|
|
17
|
+
KDF_KEY_LENGTH,
|
|
18
|
+
KDF_SALT_LENGTH,
|
|
19
|
+
constantTimeEqual,
|
|
20
|
+
deriveKey,
|
|
21
|
+
deriveKeyArgon2id,
|
|
22
|
+
deriveKeyScrypt,
|
|
23
|
+
validateArgon2idParams,
|
|
24
|
+
validateScryptParams
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildProposedActions,
|
|
3
|
+
buildQualityScore,
|
|
4
|
+
groupActionsByStatus,
|
|
5
|
+
listMemoryGovernanceRuns,
|
|
6
|
+
readMemoryGovernanceRunArtifact,
|
|
7
|
+
restoreMemoryGovernanceRun,
|
|
8
|
+
runMemoryGovernance
|
|
9
|
+
} from "./chunk-CDAZGIGT.js";
|
|
10
|
+
import "./chunk-4G2XCSD2.js";
|
|
11
|
+
import "./chunk-7UZNLMW5.js";
|
|
12
|
+
import "./chunk-6OJAU466.js";
|
|
13
|
+
import "./chunk-RKR6PTPA.js";
|
|
14
|
+
import "./chunk-UFU5GGGA.js";
|
|
15
|
+
import "./chunk-YGGGUTG3.js";
|
|
16
|
+
import "./chunk-MLKGABMK.js";
|
|
17
|
+
export {
|
|
18
|
+
buildProposedActions,
|
|
19
|
+
buildQualityScore,
|
|
20
|
+
groupActionsByStatus,
|
|
21
|
+
listMemoryGovernanceRuns,
|
|
22
|
+
readMemoryGovernanceRunArtifact,
|
|
23
|
+
restoreMemoryGovernanceRun,
|
|
24
|
+
runMemoryGovernance
|
|
25
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
METADATA_FORMAT,
|
|
3
|
+
METADATA_FORMAT_VERSION,
|
|
4
|
+
buildMetadata,
|
|
5
|
+
decodeMetadataSalt,
|
|
6
|
+
parseMetadata,
|
|
7
|
+
serializeMetadata,
|
|
8
|
+
validateMetadata
|
|
9
|
+
} from "./chunk-JZBOXOUC.js";
|
|
10
|
+
import "./chunk-6IWEAUN6.js";
|
|
11
|
+
import "./chunk-MLKGABMK.js";
|
|
12
|
+
export {
|
|
13
|
+
METADATA_FORMAT,
|
|
14
|
+
METADATA_FORMAT_VERSION,
|
|
15
|
+
buildMetadata,
|
|
16
|
+
decodeMetadataSalt,
|
|
17
|
+
parseMetadata,
|
|
18
|
+
serializeMetadata,
|
|
19
|
+
validateMetadata
|
|
20
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildPeerProfileReasonerPrompt,
|
|
3
|
+
parsePeerProfileReasonerResponse,
|
|
4
|
+
runPeerProfileReasoner
|
|
5
|
+
} from "./chunk-HRGFO6AW.js";
|
|
6
|
+
import {
|
|
7
|
+
PEERS_DIR_NAME,
|
|
8
|
+
PEER_ID_MAX_LENGTH,
|
|
9
|
+
PEER_ID_PATTERN,
|
|
10
|
+
appendInteractionLog,
|
|
11
|
+
assertValidPeerId,
|
|
12
|
+
deletePeer,
|
|
13
|
+
forgetPeer,
|
|
14
|
+
listPeers,
|
|
15
|
+
migrateFromIdentityAnchor,
|
|
16
|
+
readInteractionLogRaw,
|
|
17
|
+
readPeer,
|
|
18
|
+
readPeerInteractionLog,
|
|
19
|
+
readPeerProfile,
|
|
20
|
+
writePeer,
|
|
21
|
+
writePeerProfile
|
|
22
|
+
} from "./chunk-TLVIQLB4.js";
|
|
23
|
+
import "./chunk-MLKGABMK.js";
|
|
24
|
+
export {
|
|
25
|
+
PEERS_DIR_NAME,
|
|
26
|
+
PEER_ID_MAX_LENGTH,
|
|
27
|
+
PEER_ID_PATTERN,
|
|
28
|
+
appendInteractionLog,
|
|
29
|
+
assertValidPeerId,
|
|
30
|
+
buildPeerProfileReasonerPrompt,
|
|
31
|
+
deletePeer,
|
|
32
|
+
forgetPeer,
|
|
33
|
+
listPeers,
|
|
34
|
+
migrateFromIdentityAnchor,
|
|
35
|
+
parsePeerProfileReasonerResponse,
|
|
36
|
+
readInteractionLogRaw,
|
|
37
|
+
readPeer,
|
|
38
|
+
readPeerInteractionLog,
|
|
39
|
+
readPeerProfile,
|
|
40
|
+
runPeerProfileReasoner,
|
|
41
|
+
writePeer,
|
|
42
|
+
writePeerProfile
|
|
43
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import "./chunk-MLKGABMK.js";
|
|
2
|
+
|
|
3
|
+
// ../remnic-core/src/maintenance/purge.ts
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { appendFile, mkdir, unlink } from "fs/promises";
|
|
6
|
+
function hasErrorCode(err, code) {
|
|
7
|
+
return typeof err === "object" && err !== null && "code" in err && err.code === code;
|
|
8
|
+
}
|
|
9
|
+
function resolveTimestamp(memory) {
|
|
10
|
+
const fm = memory.frontmatter;
|
|
11
|
+
const updated = typeof fm.updated === "string" ? fm.updated : "";
|
|
12
|
+
const created = typeof fm.created === "string" ? fm.created : "";
|
|
13
|
+
return updated.length > 0 ? updated : created;
|
|
14
|
+
}
|
|
15
|
+
async function logPurgeAudit(storage, candidates, now, event = "PURGE_HARD_DELETE") {
|
|
16
|
+
if (candidates.length === 0) return;
|
|
17
|
+
const ledgerDir = path.join(storage.dir, "state", "observation-ledger");
|
|
18
|
+
await mkdir(ledgerDir, { recursive: true });
|
|
19
|
+
const ledgerPath = path.join(ledgerDir, "purge-audit.jsonl");
|
|
20
|
+
const entries = candidates.map(
|
|
21
|
+
(c) => JSON.stringify({
|
|
22
|
+
event,
|
|
23
|
+
timestamp: now.toISOString(),
|
|
24
|
+
memoryId: c.id,
|
|
25
|
+
path: c.path,
|
|
26
|
+
tier: c.tier,
|
|
27
|
+
status: c.status,
|
|
28
|
+
updatedOrCreated: c.updatedOrCreated
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
if (entries.length > 0) {
|
|
32
|
+
await appendFile(ledgerPath, `${entries.join("\n")}
|
|
33
|
+
`, "utf-8");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function purgeMemories(options) {
|
|
37
|
+
const {
|
|
38
|
+
storage,
|
|
39
|
+
olderThanMs,
|
|
40
|
+
tier = "cold",
|
|
41
|
+
forgottenOnly = false,
|
|
42
|
+
dryRun = true,
|
|
43
|
+
qmd,
|
|
44
|
+
hotCollection = "openclaw-engram",
|
|
45
|
+
coldCollection = "openclaw-engram-cold"
|
|
46
|
+
} = options;
|
|
47
|
+
if (!Number.isFinite(olderThanMs) || olderThanMs <= 0) {
|
|
48
|
+
throw new Error("olderThanMs must be a finite positive number");
|
|
49
|
+
}
|
|
50
|
+
const now = (options.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
51
|
+
const nowMs = now.getTime();
|
|
52
|
+
const [hotMemories, coldMemories, archivedMemories] = await Promise.all([
|
|
53
|
+
tier === "all" ? storage.readAllMemories() : Promise.resolve([]),
|
|
54
|
+
storage.readAllColdMemories(),
|
|
55
|
+
tier === "all" ? storage.readArchivedMemories() : Promise.resolve([])
|
|
56
|
+
]);
|
|
57
|
+
const poolEntries = [];
|
|
58
|
+
if (tier === "all") {
|
|
59
|
+
for (const m of hotMemories) {
|
|
60
|
+
poolEntries.push({ memory: m, resolvedTier: "hot" });
|
|
61
|
+
}
|
|
62
|
+
for (const m of archivedMemories) {
|
|
63
|
+
poolEntries.push({ memory: m, resolvedTier: "archive" });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const m of coldMemories) {
|
|
67
|
+
poolEntries.push({ memory: m, resolvedTier: "cold" });
|
|
68
|
+
}
|
|
69
|
+
const candidates = [];
|
|
70
|
+
const candidateMemoriesById = /* @__PURE__ */ new Map();
|
|
71
|
+
for (const { memory, resolvedTier } of poolEntries) {
|
|
72
|
+
const ts = resolveTimestamp(memory);
|
|
73
|
+
if (ts.length === 0) continue;
|
|
74
|
+
const tsMs = Date.parse(ts);
|
|
75
|
+
if (!Number.isFinite(tsMs)) continue;
|
|
76
|
+
const ageMs = nowMs - tsMs;
|
|
77
|
+
if (ageMs < olderThanMs) continue;
|
|
78
|
+
const fm = memory.frontmatter;
|
|
79
|
+
const status = typeof fm.status === "string" ? fm.status : "active";
|
|
80
|
+
if (forgottenOnly && status !== "forgotten") continue;
|
|
81
|
+
candidates.push({
|
|
82
|
+
id: memory.frontmatter.id,
|
|
83
|
+
path: memory.path,
|
|
84
|
+
tier: resolvedTier,
|
|
85
|
+
status,
|
|
86
|
+
updatedOrCreated: ts,
|
|
87
|
+
ageMs
|
|
88
|
+
});
|
|
89
|
+
candidateMemoriesById.set(memory.frontmatter.id, memory);
|
|
90
|
+
}
|
|
91
|
+
if (dryRun) {
|
|
92
|
+
return {
|
|
93
|
+
dryRun: true,
|
|
94
|
+
tier,
|
|
95
|
+
olderThanMs,
|
|
96
|
+
candidates,
|
|
97
|
+
purgedCount: 0,
|
|
98
|
+
alreadyAbsentCount: 0,
|
|
99
|
+
errorCount: 0,
|
|
100
|
+
errors: []
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const errors = [];
|
|
104
|
+
try {
|
|
105
|
+
await logPurgeAudit(storage, candidates, now, "PURGE_DELETE_INTENT");
|
|
106
|
+
} catch (auditErr) {
|
|
107
|
+
errors.push({
|
|
108
|
+
id: "(purge-audit)",
|
|
109
|
+
path: path.join(storage.dir, "state", "observation-ledger", "purge-audit.jsonl"),
|
|
110
|
+
error: auditErr instanceof Error ? auditErr.message : String(auditErr)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const actuallyPurged = [];
|
|
114
|
+
const alreadyAbsent = [];
|
|
115
|
+
const collectionsToUpdate = /* @__PURE__ */ new Set();
|
|
116
|
+
const addCollectionForCandidate = (candidate) => {
|
|
117
|
+
if (candidate.tier === "cold") {
|
|
118
|
+
collectionsToUpdate.add(coldCollection);
|
|
119
|
+
} else if (candidate.tier === "hot") {
|
|
120
|
+
collectionsToUpdate.add(hotCollection);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
for (const candidate of candidates) {
|
|
124
|
+
try {
|
|
125
|
+
await unlink(candidate.path);
|
|
126
|
+
actuallyPurged.push(candidate);
|
|
127
|
+
addCollectionForCandidate(candidate);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
130
|
+
if (hasErrorCode(err, "ENOENT")) {
|
|
131
|
+
alreadyAbsent.push(candidate);
|
|
132
|
+
addCollectionForCandidate(candidate);
|
|
133
|
+
} else {
|
|
134
|
+
errors.push({ id: candidate.id, path: candidate.path, error: message });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const recordPostDeleteAudit = async (purgedCandidates, event) => {
|
|
139
|
+
try {
|
|
140
|
+
await logPurgeAudit(storage, purgedCandidates, now, event);
|
|
141
|
+
} catch (auditErr) {
|
|
142
|
+
errors.push({
|
|
143
|
+
id: "(purge-audit)",
|
|
144
|
+
path: path.join(storage.dir, "state", "observation-ledger", "purge-audit.jsonl"),
|
|
145
|
+
error: auditErr instanceof Error ? auditErr.message : String(auditErr)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
await recordPostDeleteAudit(actuallyPurged, "PURGE_HARD_DELETE");
|
|
150
|
+
await recordPostDeleteAudit(alreadyAbsent, "PURGE_ALREADY_ABSENT");
|
|
151
|
+
const resolvedPurges = [...actuallyPurged, ...alreadyAbsent];
|
|
152
|
+
const invalidateTierCaches = storage.invalidateMemoryCachesForTiers;
|
|
153
|
+
if (typeof invalidateTierCaches === "function") {
|
|
154
|
+
invalidateTierCaches.call(storage, new Set(resolvedPurges.map((candidate) => candidate.tier)));
|
|
155
|
+
} else if (typeof storage.invalidateAllMemoriesCacheForDir === "function") {
|
|
156
|
+
storage.invalidateAllMemoriesCacheForDir();
|
|
157
|
+
}
|
|
158
|
+
if (qmd) {
|
|
159
|
+
for (const collection of collectionsToUpdate) {
|
|
160
|
+
try {
|
|
161
|
+
if (typeof qmd.updateCollectionStrict === "function") {
|
|
162
|
+
await qmd.updateCollectionStrict(collection, { signal: options.signal });
|
|
163
|
+
} else {
|
|
164
|
+
await qmd.updateCollection(collection, { signal: options.signal });
|
|
165
|
+
}
|
|
166
|
+
} catch (indexErr) {
|
|
167
|
+
errors.push({
|
|
168
|
+
id: "(qmd-update)",
|
|
169
|
+
path: collection,
|
|
170
|
+
error: indexErr instanceof Error ? indexErr.message : String(indexErr)
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const purgedFactMemories = resolvedPurges.map((candidate) => candidateMemoriesById.get(candidate.id)).filter((memory) => memory?.frontmatter.category === "fact");
|
|
176
|
+
if (purgedFactMemories.length > 0) {
|
|
177
|
+
const removeFactHashes = storage.removeFactContentHashesForMemories;
|
|
178
|
+
if (typeof removeFactHashes === "function") {
|
|
179
|
+
try {
|
|
180
|
+
await removeFactHashes.call(storage, purgedFactMemories);
|
|
181
|
+
await options.afterFactHashRemoval?.();
|
|
182
|
+
} catch (hashErr) {
|
|
183
|
+
errors.push({
|
|
184
|
+
id: "(fact-hash-index)",
|
|
185
|
+
path: path.join(storage.dir, "state", "fact-hashes.txt"),
|
|
186
|
+
error: hashErr instanceof Error ? hashErr.message : String(hashErr)
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
dryRun: false,
|
|
193
|
+
tier,
|
|
194
|
+
olderThanMs,
|
|
195
|
+
candidates,
|
|
196
|
+
purgedCount: actuallyPurged.length,
|
|
197
|
+
alreadyAbsentCount: alreadyAbsent.length,
|
|
198
|
+
errorCount: errors.length,
|
|
199
|
+
errors
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
purgeMemories
|
|
204
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MIN_PASSPHRASE_LENGTH,
|
|
3
|
+
createPassphraseReader,
|
|
4
|
+
renderDisableReport,
|
|
5
|
+
renderInitReport,
|
|
6
|
+
renderLockReport,
|
|
7
|
+
renderMigrateReport,
|
|
8
|
+
renderStatusReport,
|
|
9
|
+
renderUnlockReport,
|
|
10
|
+
runSecureStoreDisable,
|
|
11
|
+
runSecureStoreInit,
|
|
12
|
+
runSecureStoreLock,
|
|
13
|
+
runSecureStoreMigrate,
|
|
14
|
+
runSecureStoreStatus,
|
|
15
|
+
runSecureStoreUnlock
|
|
16
|
+
} from "./chunk-6F6EKSVP.js";
|
|
17
|
+
import {
|
|
18
|
+
HEADER_FILENAME,
|
|
19
|
+
HEADER_FORMAT,
|
|
20
|
+
HEADER_FORMAT_VERSION,
|
|
21
|
+
SECURE_STORE_DIR_NAME,
|
|
22
|
+
buildHeader,
|
|
23
|
+
buildHeaderFromPassphrase,
|
|
24
|
+
deriveKeyFromHeader,
|
|
25
|
+
headerPath,
|
|
26
|
+
keyring_exports,
|
|
27
|
+
parseHeader,
|
|
28
|
+
readHeader,
|
|
29
|
+
secureStoreDir,
|
|
30
|
+
serializeHeader,
|
|
31
|
+
validateHeader,
|
|
32
|
+
verifyKey,
|
|
33
|
+
writeHeader
|
|
34
|
+
} from "./chunk-CXM7EBAO.js";
|
|
35
|
+
import {
|
|
36
|
+
METADATA_FORMAT,
|
|
37
|
+
METADATA_FORMAT_VERSION,
|
|
38
|
+
buildMetadata,
|
|
39
|
+
decodeMetadataSalt,
|
|
40
|
+
parseMetadata,
|
|
41
|
+
serializeMetadata,
|
|
42
|
+
validateMetadata
|
|
43
|
+
} from "./chunk-JZBOXOUC.js";
|
|
44
|
+
import {
|
|
45
|
+
DEFAULT_ARGON2ID_PARAMS,
|
|
46
|
+
DEFAULT_SCRYPT_PARAMS,
|
|
47
|
+
KDF_KEY_LENGTH,
|
|
48
|
+
KDF_SALT_LENGTH,
|
|
49
|
+
constantTimeEqual,
|
|
50
|
+
deriveKey,
|
|
51
|
+
deriveKeyScrypt,
|
|
52
|
+
validateScryptParams
|
|
53
|
+
} from "./chunk-6IWEAUN6.js";
|
|
54
|
+
import {
|
|
55
|
+
FILE_FORMAT_FLAGS,
|
|
56
|
+
FILE_FORMAT_VERSION,
|
|
57
|
+
MAGIC_BYTES,
|
|
58
|
+
MAGIC_HEADER_SIZE,
|
|
59
|
+
SecureStoreDecryptError,
|
|
60
|
+
SecureStoreLockedError,
|
|
61
|
+
decryptFileBody,
|
|
62
|
+
decryptMemoryDirToPlaintext,
|
|
63
|
+
encryptFileBody,
|
|
64
|
+
filePathAad,
|
|
65
|
+
isEncryptedFile,
|
|
66
|
+
migrateMemoryDirToEncrypted,
|
|
67
|
+
readMaybeEncryptedFile,
|
|
68
|
+
writeMaybeEncryptedFile
|
|
69
|
+
} from "./chunk-RKR6PTPA.js";
|
|
70
|
+
import {
|
|
71
|
+
AES_KEY_LENGTH,
|
|
72
|
+
AUTH_TAG_LENGTH,
|
|
73
|
+
ENVELOPE_HEADER_SIZE,
|
|
74
|
+
ENVELOPE_LAYOUT,
|
|
75
|
+
ENVELOPE_SALT_LENGTH,
|
|
76
|
+
ENVELOPE_VERSION,
|
|
77
|
+
IV_LENGTH,
|
|
78
|
+
generateSalt,
|
|
79
|
+
open,
|
|
80
|
+
parseEnvelope,
|
|
81
|
+
seal
|
|
82
|
+
} from "./chunk-YGGGUTG3.js";
|
|
83
|
+
import "./chunk-MLKGABMK.js";
|
|
84
|
+
export {
|
|
85
|
+
AES_KEY_LENGTH,
|
|
86
|
+
AUTH_TAG_LENGTH,
|
|
87
|
+
DEFAULT_ARGON2ID_PARAMS,
|
|
88
|
+
DEFAULT_SCRYPT_PARAMS,
|
|
89
|
+
ENVELOPE_HEADER_SIZE,
|
|
90
|
+
ENVELOPE_LAYOUT,
|
|
91
|
+
ENVELOPE_SALT_LENGTH,
|
|
92
|
+
ENVELOPE_VERSION,
|
|
93
|
+
FILE_FORMAT_FLAGS,
|
|
94
|
+
FILE_FORMAT_VERSION,
|
|
95
|
+
HEADER_FILENAME,
|
|
96
|
+
HEADER_FORMAT,
|
|
97
|
+
HEADER_FORMAT_VERSION,
|
|
98
|
+
IV_LENGTH,
|
|
99
|
+
KDF_KEY_LENGTH,
|
|
100
|
+
KDF_SALT_LENGTH,
|
|
101
|
+
MAGIC_BYTES,
|
|
102
|
+
MAGIC_HEADER_SIZE,
|
|
103
|
+
METADATA_FORMAT,
|
|
104
|
+
METADATA_FORMAT_VERSION,
|
|
105
|
+
MIN_PASSPHRASE_LENGTH,
|
|
106
|
+
SECURE_STORE_DIR_NAME,
|
|
107
|
+
SecureStoreDecryptError,
|
|
108
|
+
SecureStoreLockedError,
|
|
109
|
+
buildHeader,
|
|
110
|
+
buildHeaderFromPassphrase,
|
|
111
|
+
buildMetadata,
|
|
112
|
+
constantTimeEqual,
|
|
113
|
+
createPassphraseReader,
|
|
114
|
+
decodeMetadataSalt,
|
|
115
|
+
decryptFileBody,
|
|
116
|
+
decryptMemoryDirToPlaintext,
|
|
117
|
+
deriveKey,
|
|
118
|
+
deriveKeyFromHeader,
|
|
119
|
+
deriveKeyScrypt,
|
|
120
|
+
encryptFileBody,
|
|
121
|
+
filePathAad,
|
|
122
|
+
generateSalt,
|
|
123
|
+
headerPath,
|
|
124
|
+
isEncryptedFile,
|
|
125
|
+
keyring_exports as keyring,
|
|
126
|
+
migrateMemoryDirToEncrypted,
|
|
127
|
+
open,
|
|
128
|
+
parseEnvelope,
|
|
129
|
+
parseHeader,
|
|
130
|
+
parseMetadata,
|
|
131
|
+
readHeader,
|
|
132
|
+
readMaybeEncryptedFile,
|
|
133
|
+
renderDisableReport,
|
|
134
|
+
renderInitReport,
|
|
135
|
+
renderLockReport,
|
|
136
|
+
renderMigrateReport,
|
|
137
|
+
renderStatusReport,
|
|
138
|
+
renderUnlockReport,
|
|
139
|
+
runSecureStoreDisable,
|
|
140
|
+
runSecureStoreInit,
|
|
141
|
+
runSecureStoreLock,
|
|
142
|
+
runSecureStoreMigrate,
|
|
143
|
+
runSecureStoreStatus,
|
|
144
|
+
runSecureStoreUnlock,
|
|
145
|
+
seal,
|
|
146
|
+
secureStoreDir,
|
|
147
|
+
serializeHeader,
|
|
148
|
+
serializeMetadata,
|
|
149
|
+
validateHeader,
|
|
150
|
+
validateMetadata,
|
|
151
|
+
validateScryptParams,
|
|
152
|
+
verifyKey,
|
|
153
|
+
writeHeader,
|
|
154
|
+
writeMaybeEncryptedFile
|
|
155
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_connectorStatePathForTest,
|
|
3
|
+
listConnectorStates,
|
|
4
|
+
readConnectorState,
|
|
5
|
+
writeConnectorState
|
|
6
|
+
} from "./chunk-37NKFWSO.js";
|
|
7
|
+
import "./chunk-OEI7GLV2.js";
|
|
8
|
+
import "./chunk-I6B2W2IY.js";
|
|
9
|
+
import "./chunk-MLKGABMK.js";
|
|
10
|
+
export {
|
|
11
|
+
_connectorStatePathForTest,
|
|
12
|
+
listConnectorStates,
|
|
13
|
+
readConnectorState,
|
|
14
|
+
writeConnectorState
|
|
15
|
+
};
|
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
normalizeEntityName,
|
|
9
9
|
parseEntityFile,
|
|
10
10
|
serializeEntityFile
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7UZNLMW5.js";
|
|
12
12
|
import "./chunk-6OJAU466.js";
|
|
13
|
+
import "./chunk-RKR6PTPA.js";
|
|
13
14
|
import "./chunk-UFU5GGGA.js";
|
|
15
|
+
import "./chunk-YGGGUTG3.js";
|
|
14
16
|
import "./chunk-MLKGABMK.js";
|
|
15
17
|
export {
|
|
16
18
|
ContentHashIndex,
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyUtilityPromotionRuntimePolicy,
|
|
3
|
+
computeTierValueScore,
|
|
4
|
+
decideTierTransition,
|
|
5
|
+
loadUtilityRuntimeValues
|
|
6
|
+
} from "./chunk-7OQEPGQF.js";
|
|
7
|
+
import {
|
|
8
|
+
computeLifecycleValueInputs
|
|
9
|
+
} from "./chunk-4G2XCSD2.js";
|
|
10
|
+
import "./chunk-3G7FAF6S.js";
|
|
11
|
+
import "./chunk-5LE4HTVL.js";
|
|
12
|
+
import "./chunk-MLKGABMK.js";
|
|
13
|
+
|
|
14
|
+
// ../remnic-core/src/maintenance/tier-stats.ts
|
|
15
|
+
async function readTierVisibleMemories(storage) {
|
|
16
|
+
const [hotMemories, coldMemories] = await Promise.all([
|
|
17
|
+
storage.readAllMemories(),
|
|
18
|
+
storage.readAllColdMemories()
|
|
19
|
+
]);
|
|
20
|
+
return [
|
|
21
|
+
...hotMemories.map((memory) => ({ memory, tier: "hot" })),
|
|
22
|
+
...coldMemories.map((memory) => ({ memory, tier: "cold" }))
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
async function tierRoutingPolicyFromConfig(config) {
|
|
26
|
+
const basePolicy = {
|
|
27
|
+
enabled: config.qmdTierMigrationEnabled,
|
|
28
|
+
demotionMinAgeDays: config.qmdTierDemotionMinAgeDays,
|
|
29
|
+
demotionValueThreshold: config.qmdTierDemotionValueThreshold,
|
|
30
|
+
promotionValueThreshold: config.qmdTierPromotionValueThreshold
|
|
31
|
+
};
|
|
32
|
+
const runtime = await loadUtilityRuntimeValues({
|
|
33
|
+
memoryDir: config.memoryDir,
|
|
34
|
+
memoryUtilityLearningEnabled: config.memoryUtilityLearningEnabled,
|
|
35
|
+
promotionByOutcomeEnabled: config.promotionByOutcomeEnabled
|
|
36
|
+
});
|
|
37
|
+
return applyUtilityPromotionRuntimePolicy(basePolicy, runtime);
|
|
38
|
+
}
|
|
39
|
+
async function summarizeTiers(storage) {
|
|
40
|
+
const all = await readTierVisibleMemories(storage);
|
|
41
|
+
const summary = {
|
|
42
|
+
total: all.length,
|
|
43
|
+
byTier: { hot: 0, cold: 0 },
|
|
44
|
+
byStatus: {},
|
|
45
|
+
forgottenCount: 0,
|
|
46
|
+
byCategory: {}
|
|
47
|
+
};
|
|
48
|
+
for (const { memory: m, tier } of all) {
|
|
49
|
+
summary.byTier[tier] += 1;
|
|
50
|
+
const status = m.frontmatter.status ?? "active";
|
|
51
|
+
summary.byStatus[status] = (summary.byStatus[status] ?? 0) + 1;
|
|
52
|
+
if (status === "forgotten") summary.forgottenCount += 1;
|
|
53
|
+
const cat = m.frontmatter.category ?? "(uncategorized)";
|
|
54
|
+
summary.byCategory[cat] = (summary.byCategory[cat] ?? 0) + 1;
|
|
55
|
+
}
|
|
56
|
+
return summary;
|
|
57
|
+
}
|
|
58
|
+
async function explainTierForMemory(storage, id, config) {
|
|
59
|
+
const trimmed = typeof id === "string" ? id.trim() : "";
|
|
60
|
+
if (trimmed.length === 0) {
|
|
61
|
+
throw new Error("tier explain: memory id is required and must be non-empty");
|
|
62
|
+
}
|
|
63
|
+
const all = await readTierVisibleMemories(storage);
|
|
64
|
+
const entry = all.find(({ memory: m }) => m.frontmatter.id === trimmed);
|
|
65
|
+
if (!entry) {
|
|
66
|
+
throw new Error(`tier explain: memory not found: ${trimmed}`);
|
|
67
|
+
}
|
|
68
|
+
const { memory, tier: currentTier } = entry;
|
|
69
|
+
const now = /* @__PURE__ */ new Date();
|
|
70
|
+
const valueInputs = computeLifecycleValueInputs(memory, now);
|
|
71
|
+
const valueScore = computeTierValueScore(memory, now);
|
|
72
|
+
const policy = await tierRoutingPolicyFromConfig(config);
|
|
73
|
+
const decision = decideTierTransition(memory, currentTier, policy, now);
|
|
74
|
+
const fm = memory.frontmatter;
|
|
75
|
+
return {
|
|
76
|
+
id: trimmed,
|
|
77
|
+
path: memory.path,
|
|
78
|
+
currentTier,
|
|
79
|
+
status: typeof fm.status === "string" ? fm.status : "active",
|
|
80
|
+
category: typeof fm.category === "string" ? fm.category : "",
|
|
81
|
+
valueScore,
|
|
82
|
+
decision,
|
|
83
|
+
signals: {
|
|
84
|
+
confidence: valueInputs.confidence,
|
|
85
|
+
accessCount: typeof fm.accessCount === "number" ? fm.accessCount : 0,
|
|
86
|
+
lastAccessed: typeof fm.lastAccessed === "string" ? fm.lastAccessed : null,
|
|
87
|
+
created: typeof fm.created === "string" ? fm.created : "",
|
|
88
|
+
updated: typeof fm.updated === "string" ? fm.updated : "",
|
|
89
|
+
importance: valueInputs.importance,
|
|
90
|
+
feedback: valueInputs.feedback
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function formatTierSummaryText(summary) {
|
|
95
|
+
const lines = [];
|
|
96
|
+
lines.push("=== Memory Tier Distribution ===");
|
|
97
|
+
lines.push(`Total memories: ${summary.total}`);
|
|
98
|
+
lines.push("");
|
|
99
|
+
lines.push("Tier:");
|
|
100
|
+
lines.push(` hot: ${summary.byTier.hot}`);
|
|
101
|
+
lines.push(` cold: ${summary.byTier.cold}`);
|
|
102
|
+
lines.push("");
|
|
103
|
+
lines.push("Status:");
|
|
104
|
+
const statusEntries = Object.entries(summary.byStatus).sort(
|
|
105
|
+
(a, b) => b[1] - a[1] || a[0].localeCompare(b[0])
|
|
106
|
+
);
|
|
107
|
+
for (const [status, count] of statusEntries) {
|
|
108
|
+
lines.push(` ${status}: ${count}`);
|
|
109
|
+
}
|
|
110
|
+
lines.push("");
|
|
111
|
+
lines.push("Top categories:");
|
|
112
|
+
const categoryEntries = Object.entries(summary.byCategory).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 8);
|
|
113
|
+
for (const [cat, count] of categoryEntries) {
|
|
114
|
+
lines.push(` ${cat}: ${count}`);
|
|
115
|
+
}
|
|
116
|
+
return lines.join("\n");
|
|
117
|
+
}
|
|
118
|
+
function formatTierExplainText(explain) {
|
|
119
|
+
const lines = [];
|
|
120
|
+
lines.push(`=== Tier Explain: ${explain.id} ===`);
|
|
121
|
+
lines.push(`path: ${explain.path}`);
|
|
122
|
+
lines.push(`current tier: ${explain.currentTier}`);
|
|
123
|
+
lines.push(`status: ${explain.status}`);
|
|
124
|
+
lines.push(`category: ${explain.category}`);
|
|
125
|
+
lines.push(`value score: ${explain.valueScore.toFixed(3)}`);
|
|
126
|
+
lines.push("");
|
|
127
|
+
lines.push("Tier-transition decision:");
|
|
128
|
+
lines.push(` next tier: ${explain.decision.nextTier}`);
|
|
129
|
+
lines.push(` changed: ${explain.decision.changed}`);
|
|
130
|
+
lines.push(` reason: ${explain.decision.reason}`);
|
|
131
|
+
lines.push("");
|
|
132
|
+
lines.push("Signals:");
|
|
133
|
+
lines.push(` confidence: ${explain.signals.confidence}`);
|
|
134
|
+
lines.push(` accessCount: ${explain.signals.accessCount}`);
|
|
135
|
+
lines.push(` lastAccessed: ${explain.signals.lastAccessed ?? "(never)"}`);
|
|
136
|
+
lines.push(` created: ${explain.signals.created}`);
|
|
137
|
+
lines.push(` updated: ${explain.signals.updated}`);
|
|
138
|
+
lines.push(` importance: ${explain.signals.importance}`);
|
|
139
|
+
lines.push(` feedback: ${explain.signals.feedback}`);
|
|
140
|
+
return lines.join("\n");
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
explainTierForMemory,
|
|
144
|
+
formatTierExplainText,
|
|
145
|
+
formatTierSummaryText,
|
|
146
|
+
summarizeTiers
|
|
147
|
+
};
|