@remnic/plugin-openclaw 1.0.10 → 1.0.11

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.
Files changed (69) hide show
  1. package/dist/{calibration-674TDQNV.js → calibration-WCHOK6DX.js} +12 -4
  2. package/dist/capsule-cli-TFKLAG3S.js +329 -0
  3. package/dist/capsule-crypto-K3IRTKRH.js +17 -0
  4. package/dist/capsule-export-CVA3CKUQ.js +265 -0
  5. package/dist/capsule-import-CFX7BY5W.js +16 -0
  6. package/dist/capsule-merge-7RVOHJK3.js +189 -0
  7. package/dist/{causal-chain-OKDZSDEB.js → causal-chain-WYN5QOPS.js} +3 -2
  8. package/dist/{causal-consolidation-5BEXLQV5.js → causal-consolidation-JD6KJJH6.js} +16 -12
  9. package/dist/{causal-retrieval-3BKBXVXD.js → causal-retrieval-NZHQOZOE.js} +6 -5
  10. package/dist/{causal-trajectory-graph-RQIT37DN.js → causal-trajectory-graph-VBPE2WPM.js} +1 -1
  11. package/dist/chunk-37NKFWSO.js +233 -0
  12. package/dist/chunk-3G7FAF6S.js +60 -0
  13. package/dist/{chunk-Z7GRLVK3.js → chunk-3GUF7RQI.js} +235 -19
  14. package/dist/chunk-3I7RHWYT.js +214 -0
  15. package/dist/chunk-4G2XCSD2.js +186 -0
  16. package/dist/chunk-6IWEAUN6.js +148 -0
  17. package/dist/{chunk-LN5UZQVG.js → chunk-6UFI73TJ.js} +5 -3
  18. package/dist/chunk-7OQEPGQF.js +529 -0
  19. package/dist/chunk-B52XADV3.js +244 -0
  20. package/dist/chunk-BU5KJVWF.js +78 -0
  21. package/dist/chunk-CXM7EBAO.js +289 -0
  22. package/dist/chunk-ETJZRIAM.js +227 -0
  23. package/dist/chunk-FQRSVYY4.js +110 -0
  24. package/dist/chunk-HRGFO6AW.js +349 -0
  25. package/dist/chunk-I6B2W2IY.js +47 -0
  26. package/dist/chunk-JZBOXOUC.js +259 -0
  27. package/dist/chunk-K7EUBNDD.js +185 -0
  28. package/dist/chunk-L4PRBB2A.js +1860 -0
  29. package/dist/chunk-MBIFE6SA.js +250 -0
  30. package/dist/chunk-N7EOZY6F.js +400 -0
  31. package/dist/chunk-NKVIN6RD.js +118 -0
  32. package/dist/chunk-OEI7GLV2.js +17 -0
  33. package/dist/{chunk-S2ISS4AH.js → chunk-P3DIW2SD.js} +10 -10
  34. package/dist/{chunk-7TENHBV2.js → chunk-RQCTMECT.js} +10 -48
  35. package/dist/chunk-SSFTU6LP.js +182 -0
  36. package/dist/{chunk-BXTMZDRT.js → chunk-SVSQAG6M.js} +7 -5
  37. package/dist/chunk-TLVIQLB4.js +874 -0
  38. package/dist/{chunk-JJSNPSCD.js → chunk-TNH24SF6.js} +352 -50
  39. package/dist/chunk-TVKKIS53.js +720 -0
  40. package/dist/{chunk-YHH3SXKD.js → chunk-WPINX4MF.js} +1 -59
  41. package/dist/{chunk-HCFFXBLV.js → chunk-XMSDA5WA.js} +5 -1861
  42. package/dist/chunk-YGGGUTG3.js +125 -0
  43. package/dist/chunk-YGXXBRV7.js +10 -0
  44. package/dist/cipher-VHAFCG7Z.js +27 -0
  45. package/dist/dreams-ledger-3I52ISYR.js +285 -0
  46. package/dist/{engine-65C2J63X.js → engine-VMTFKFGO.js} +5 -2
  47. package/dist/{fallback-llm-LVK5PDIM.js → fallback-llm-WCWNGIQ3.js} +2 -1
  48. package/dist/first-start-migration-I24M2JEE.js +258 -0
  49. package/dist/forget-NI4RBDPB.js +68 -0
  50. package/dist/fs-utils-PZRI2HDZ.js +29 -0
  51. package/dist/graph-edge-decay-5CVKWBYH.js +203 -0
  52. package/dist/index.js +9775 -2900
  53. package/dist/kdf-H5B23ZM2.js +25 -0
  54. package/dist/memory-governance-DWGFV4FX.js +25 -0
  55. package/dist/metadata-JAGIWHEA.js +20 -0
  56. package/dist/migrate-from-identity-anchor-N3354WMP.js +7 -0
  57. package/dist/path-5LCUBAAZ.js +8 -0
  58. package/dist/peers-JF2I6RCR.js +43 -0
  59. package/dist/purge-XN2VSPZ2.js +204 -0
  60. package/dist/secure-store-FWJ7LBPH.js +149 -0
  61. package/dist/state-PVISYXRH.js +7 -0
  62. package/dist/state-store-LP5BO6SF.js +15 -0
  63. package/dist/{storage-DM4ZGOCN.js → storage-T2OGFUF4.js} +3 -1
  64. package/dist/tier-stats-IZNW66NC.js +147 -0
  65. package/dist/trace-NJESSGH7.js +289 -0
  66. package/dist/tui-MGK2LYJY.js +12 -0
  67. package/dist/types-H5R5D3WF.js +30 -0
  68. package/openclaw.plugin.json +519 -4
  69. package/package.json +1 -1
@@ -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-TVKKIS53.js";
10
+ import "./chunk-4G2XCSD2.js";
11
+ import "./chunk-TNH24SF6.js";
12
+ import "./chunk-6OJAU466.js";
13
+ import "./chunk-3I7RHWYT.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,7 @@
1
+ import {
2
+ migrateFromIdentityAnchor
3
+ } from "./chunk-TLVIQLB4.js";
4
+ import "./chunk-MLKGABMK.js";
5
+ export {
6
+ migrateFromIdentityAnchor
7
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ expandTildePath
3
+ } from "./chunk-OEI7GLV2.js";
4
+ import "./chunk-I6B2W2IY.js";
5
+ import "./chunk-MLKGABMK.js";
6
+ export {
7
+ expandTildePath
8
+ };
@@ -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,149 @@
1
+ import {
2
+ MIN_PASSPHRASE_LENGTH,
3
+ createPassphraseReader,
4
+ renderInitReport,
5
+ renderLockReport,
6
+ renderMigrateReport,
7
+ renderStatusReport,
8
+ renderUnlockReport,
9
+ runSecureStoreInit,
10
+ runSecureStoreLock,
11
+ runSecureStoreMigrate,
12
+ runSecureStoreStatus,
13
+ runSecureStoreUnlock
14
+ } from "./chunk-N7EOZY6F.js";
15
+ import {
16
+ HEADER_FILENAME,
17
+ HEADER_FORMAT,
18
+ HEADER_FORMAT_VERSION,
19
+ SECURE_STORE_DIR_NAME,
20
+ buildHeader,
21
+ buildHeaderFromPassphrase,
22
+ deriveKeyFromHeader,
23
+ headerPath,
24
+ keyring_exports,
25
+ parseHeader,
26
+ readHeader,
27
+ secureStoreDir,
28
+ serializeHeader,
29
+ validateHeader,
30
+ verifyKey,
31
+ writeHeader
32
+ } from "./chunk-CXM7EBAO.js";
33
+ import {
34
+ METADATA_FORMAT,
35
+ METADATA_FORMAT_VERSION,
36
+ buildMetadata,
37
+ decodeMetadataSalt,
38
+ parseMetadata,
39
+ serializeMetadata,
40
+ validateMetadata
41
+ } from "./chunk-JZBOXOUC.js";
42
+ import {
43
+ DEFAULT_ARGON2ID_PARAMS,
44
+ DEFAULT_SCRYPT_PARAMS,
45
+ KDF_KEY_LENGTH,
46
+ KDF_SALT_LENGTH,
47
+ constantTimeEqual,
48
+ deriveKey,
49
+ deriveKeyScrypt,
50
+ validateScryptParams
51
+ } from "./chunk-6IWEAUN6.js";
52
+ import {
53
+ FILE_FORMAT_FLAGS,
54
+ FILE_FORMAT_VERSION,
55
+ MAGIC_BYTES,
56
+ MAGIC_HEADER_SIZE,
57
+ SecureStoreDecryptError,
58
+ SecureStoreLockedError,
59
+ decryptFileBody,
60
+ encryptFileBody,
61
+ filePathAad,
62
+ isEncryptedFile,
63
+ migrateMemoryDirToEncrypted,
64
+ readMaybeEncryptedFile,
65
+ writeMaybeEncryptedFile
66
+ } from "./chunk-3I7RHWYT.js";
67
+ import {
68
+ AES_KEY_LENGTH,
69
+ AUTH_TAG_LENGTH,
70
+ ENVELOPE_HEADER_SIZE,
71
+ ENVELOPE_LAYOUT,
72
+ ENVELOPE_SALT_LENGTH,
73
+ ENVELOPE_VERSION,
74
+ IV_LENGTH,
75
+ generateSalt,
76
+ open,
77
+ parseEnvelope,
78
+ seal
79
+ } from "./chunk-YGGGUTG3.js";
80
+ import "./chunk-MLKGABMK.js";
81
+ export {
82
+ AES_KEY_LENGTH,
83
+ AUTH_TAG_LENGTH,
84
+ DEFAULT_ARGON2ID_PARAMS,
85
+ DEFAULT_SCRYPT_PARAMS,
86
+ ENVELOPE_HEADER_SIZE,
87
+ ENVELOPE_LAYOUT,
88
+ ENVELOPE_SALT_LENGTH,
89
+ ENVELOPE_VERSION,
90
+ FILE_FORMAT_FLAGS,
91
+ FILE_FORMAT_VERSION,
92
+ HEADER_FILENAME,
93
+ HEADER_FORMAT,
94
+ HEADER_FORMAT_VERSION,
95
+ IV_LENGTH,
96
+ KDF_KEY_LENGTH,
97
+ KDF_SALT_LENGTH,
98
+ MAGIC_BYTES,
99
+ MAGIC_HEADER_SIZE,
100
+ METADATA_FORMAT,
101
+ METADATA_FORMAT_VERSION,
102
+ MIN_PASSPHRASE_LENGTH,
103
+ SECURE_STORE_DIR_NAME,
104
+ SecureStoreDecryptError,
105
+ SecureStoreLockedError,
106
+ buildHeader,
107
+ buildHeaderFromPassphrase,
108
+ buildMetadata,
109
+ constantTimeEqual,
110
+ createPassphraseReader,
111
+ decodeMetadataSalt,
112
+ decryptFileBody,
113
+ deriveKey,
114
+ deriveKeyFromHeader,
115
+ deriveKeyScrypt,
116
+ encryptFileBody,
117
+ filePathAad,
118
+ generateSalt,
119
+ headerPath,
120
+ isEncryptedFile,
121
+ keyring_exports as keyring,
122
+ migrateMemoryDirToEncrypted,
123
+ open,
124
+ parseEnvelope,
125
+ parseHeader,
126
+ parseMetadata,
127
+ readHeader,
128
+ readMaybeEncryptedFile,
129
+ renderInitReport,
130
+ renderLockReport,
131
+ renderMigrateReport,
132
+ renderStatusReport,
133
+ renderUnlockReport,
134
+ runSecureStoreInit,
135
+ runSecureStoreLock,
136
+ runSecureStoreMigrate,
137
+ runSecureStoreStatus,
138
+ runSecureStoreUnlock,
139
+ seal,
140
+ secureStoreDir,
141
+ serializeHeader,
142
+ serializeMetadata,
143
+ validateHeader,
144
+ validateMetadata,
145
+ validateScryptParams,
146
+ verifyKey,
147
+ writeHeader,
148
+ writeMaybeEncryptedFile
149
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ gatherConsoleState
3
+ } from "./chunk-MBIFE6SA.js";
4
+ import "./chunk-MLKGABMK.js";
5
+ export {
6
+ gatherConsoleState
7
+ };
@@ -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-JJSNPSCD.js";
11
+ } from "./chunk-TNH24SF6.js";
12
12
  import "./chunk-6OJAU466.js";
13
+ import "./chunk-3I7RHWYT.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
+ };