@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.
Files changed (70) hide show
  1. package/dist/{calibration-674TDQNV.js → calibration-WCHOK6DX.js} +12 -4
  2. package/dist/capsule-cli-GBM3WPAM.js +33 -0
  3. package/dist/capsule-crypto-K3IRTKRH.js +17 -0
  4. package/dist/capsule-export-IXVERCQG.js +17 -0
  5. package/dist/capsule-import-IA6VIOPQ.js +16 -0
  6. package/dist/capsule-merge-IWOQ34KL.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-YI53C2AO.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-4G2XCSD2.js +186 -0
  15. package/dist/chunk-4LYQ4ONL.js +185 -0
  16. package/dist/chunk-6F6EKSVP.js +453 -0
  17. package/dist/chunk-6IWEAUN6.js +148 -0
  18. package/dist/{chunk-LN5UZQVG.js → chunk-6UFI73TJ.js} +5 -3
  19. package/dist/chunk-7OQEPGQF.js +529 -0
  20. package/dist/{chunk-JJSNPSCD.js → chunk-7UZNLMW5.js} +652 -174
  21. package/dist/chunk-B52XADV3.js +244 -0
  22. package/dist/chunk-BU5KJVWF.js +78 -0
  23. package/dist/chunk-CDAZGIGT.js +720 -0
  24. package/dist/chunk-CXM7EBAO.js +289 -0
  25. package/dist/{chunk-HCFFXBLV.js → chunk-EXDYWXMB.js} +6 -1861
  26. package/dist/chunk-FGTYFLL5.js +274 -0
  27. package/dist/chunk-FQRSVYY4.js +110 -0
  28. package/dist/chunk-HRGFO6AW.js +349 -0
  29. package/dist/chunk-I6B2W2IY.js +47 -0
  30. package/dist/chunk-JZBOXOUC.js +259 -0
  31. package/dist/chunk-L6I4MQKO.js +227 -0
  32. package/dist/chunk-LLUROTZJ.js +328 -0
  33. package/dist/chunk-MBIFE6SA.js +250 -0
  34. package/dist/chunk-NKVIN6RD.js +118 -0
  35. package/dist/chunk-OAE7AQ6R.js +1832 -0
  36. package/dist/chunk-OEI7GLV2.js +17 -0
  37. package/dist/chunk-RKR6PTPA.js +308 -0
  38. package/dist/{chunk-7TENHBV2.js → chunk-RQCTMECT.js} +10 -48
  39. package/dist/chunk-SSFTU6LP.js +182 -0
  40. package/dist/{chunk-BXTMZDRT.js → chunk-SVSQAG6M.js} +7 -5
  41. package/dist/{chunk-S2ISS4AH.js → chunk-TILAJIJR.js} +10 -10
  42. package/dist/chunk-TLVIQLB4.js +874 -0
  43. package/dist/{chunk-YHH3SXKD.js → chunk-WPINX4MF.js} +1 -59
  44. package/dist/chunk-YGGGUTG3.js +125 -0
  45. package/dist/cipher-VHAFCG7Z.js +27 -0
  46. package/dist/dreams-ledger-3I52ISYR.js +285 -0
  47. package/dist/{engine-65C2J63X.js → engine-BIYI3P4J.js} +7 -2
  48. package/dist/{fallback-llm-LVK5PDIM.js → fallback-llm-WCWNGIQ3.js} +2 -1
  49. package/dist/first-start-migration-I24M2JEE.js +258 -0
  50. package/dist/forget-NI4RBDPB.js +68 -0
  51. package/dist/fs-utils-PZRI2HDZ.js +29 -0
  52. package/dist/graph-edge-decay-5CVKWBYH.js +203 -0
  53. package/dist/index.js +10654 -3067
  54. package/dist/kdf-H5B23ZM2.js +25 -0
  55. package/dist/memory-governance-SJ5DGRB3.js +25 -0
  56. package/dist/metadata-JAGIWHEA.js +20 -0
  57. package/dist/migrate-from-identity-anchor-N3354WMP.js +7 -0
  58. package/dist/path-5LCUBAAZ.js +8 -0
  59. package/dist/peers-JF2I6RCR.js +43 -0
  60. package/dist/purge-XN2VSPZ2.js +204 -0
  61. package/dist/secure-store-A4NGCNXV.js +155 -0
  62. package/dist/state-PVISYXRH.js +7 -0
  63. package/dist/state-store-LP5BO6SF.js +15 -0
  64. package/dist/{storage-DM4ZGOCN.js → storage-PTQ2H2YJ.js} +3 -1
  65. package/dist/tier-stats-IZNW66NC.js +147 -0
  66. package/dist/trace-NJESSGH7.js +289 -0
  67. package/dist/tui-MGK2LYJY.js +12 -0
  68. package/dist/types-R4DO7AKM.js +30 -0
  69. package/openclaw.plugin.json +519 -4
  70. package/package.json +2 -2
@@ -0,0 +1,244 @@
1
+ import {
2
+ gatherConsoleState
3
+ } from "./chunk-MBIFE6SA.js";
4
+
5
+ // ../remnic-core/src/console/tui.ts
6
+ var ANSI_CLEAR_HOME = "\x1B[2J\x1B[H";
7
+ var ANSI_HIDE_CURSOR = "\x1B[?25l";
8
+ var ANSI_SHOW_CURSOR = "\x1B[?25h";
9
+ var FRAME_INNER_WIDTH = 70;
10
+ var DEFAULT_REFRESH_INTERVAL_MS = 2e3;
11
+ function runConsoleTui(orchestrator, options = {}) {
12
+ const refreshIntervalMs = Math.max(
13
+ 50,
14
+ options.refreshIntervalMs ?? DEFAULT_REFRESH_INTERVAL_MS
15
+ );
16
+ const output = options.output ?? process.stdout;
17
+ const now = options.now ?? (() => Date.now());
18
+ const installSigintHandler = options.installSigintHandler ?? true;
19
+ let stopped = false;
20
+ let inFlight = false;
21
+ let inFlightTickPromise = null;
22
+ let traceWritePending = false;
23
+ let traceFramesDropped = 0;
24
+ let resolveDone;
25
+ const done = new Promise((resolve) => {
26
+ resolveDone = resolve;
27
+ });
28
+ safeWrite(output, ANSI_HIDE_CURSOR);
29
+ const tick = async () => {
30
+ if (stopped || inFlight) return;
31
+ inFlight = true;
32
+ try {
33
+ let snapshot = null;
34
+ let renderError = null;
35
+ try {
36
+ snapshot = await gatherConsoleState(orchestrator);
37
+ } catch (err) {
38
+ renderError = describeError(err);
39
+ }
40
+ if (stopped) return;
41
+ let frame;
42
+ try {
43
+ frame = renderFrame({ snapshot, renderError, now });
44
+ } catch (err) {
45
+ frame = `remnic console: render failed: ${describeError(err)}
46
+ `;
47
+ }
48
+ safeWrite(output, ANSI_CLEAR_HOME);
49
+ safeWrite(output, frame);
50
+ if (snapshot && options.traceRecorder && !traceWritePending) {
51
+ traceWritePending = true;
52
+ void options.traceRecorder.append(snapshot).catch(() => {
53
+ }).finally(() => {
54
+ traceWritePending = false;
55
+ });
56
+ } else if (snapshot && options.traceRecorder) {
57
+ traceFramesDropped += 1;
58
+ }
59
+ } finally {
60
+ inFlight = false;
61
+ }
62
+ };
63
+ const launchTick = () => {
64
+ const p = runTickSafely(tick);
65
+ inFlightTickPromise = p;
66
+ void p.then(() => {
67
+ if (inFlightTickPromise === p) {
68
+ inFlightTickPromise = null;
69
+ }
70
+ });
71
+ };
72
+ launchTick();
73
+ const handle = setInterval(launchTick, refreshIntervalMs);
74
+ const sigintHandler = () => {
75
+ stop();
76
+ };
77
+ if (installSigintHandler) {
78
+ process.on("SIGINT", sigintHandler);
79
+ }
80
+ const stop = () => {
81
+ if (stopped) return;
82
+ stopped = true;
83
+ clearInterval(handle);
84
+ if (installSigintHandler) {
85
+ try {
86
+ process.removeListener("SIGINT", sigintHandler);
87
+ } catch {
88
+ }
89
+ }
90
+ safeWrite(output, ANSI_SHOW_CURSOR);
91
+ void (async () => {
92
+ try {
93
+ const pendingTick = inFlightTickPromise;
94
+ if (pendingTick) {
95
+ await pendingTick;
96
+ }
97
+ } finally {
98
+ resolveDone();
99
+ }
100
+ })();
101
+ };
102
+ return {
103
+ stop,
104
+ done,
105
+ getDroppedTraceFrames: () => traceFramesDropped
106
+ };
107
+ }
108
+ function renderFrame(input) {
109
+ const ts = new Date(input.now()).toISOString();
110
+ const lines = [];
111
+ lines.push(renderHeader(ts));
112
+ for (const panel of renderPanels(input)) {
113
+ lines.push(panel);
114
+ }
115
+ lines.push(renderFooter());
116
+ return lines.join("\n") + "\n";
117
+ }
118
+ function renderHeader(ts) {
119
+ const title = " remnic console ";
120
+ const trailing = ` ${ts} `;
121
+ const fillerLen = Math.max(
122
+ 1,
123
+ FRAME_INNER_WIDTH - title.length - trailing.length
124
+ );
125
+ const filler = "\u2550".repeat(fillerLen);
126
+ return `\u2554${title}${filler}${trailing}\u2557`;
127
+ }
128
+ function renderFooter() {
129
+ return `\u255A${"\u2550".repeat(FRAME_INNER_WIDTH)}\u255D`;
130
+ }
131
+ function renderPanels(input) {
132
+ const lines = [];
133
+ const snap = input.snapshot;
134
+ if (input.renderError !== null) {
135
+ lines.push(panelLine("Error", `refresh failed: ${input.renderError}`));
136
+ lines.push(panelLine("Buffer", "(unavailable)"));
137
+ lines.push(panelLine("Extraction", "(unavailable)"));
138
+ lines.push(panelLine("Dedup", "(unavailable)"));
139
+ lines.push(panelLine("Maintenance", "(unavailable)"));
140
+ lines.push(panelLine("QMD", "(unavailable)"));
141
+ return lines;
142
+ }
143
+ if (snap) {
144
+ lines.push(
145
+ panelLine(
146
+ "Buffer",
147
+ `turns=${snap.bufferState.turnsCount} bytes=${snap.bufferState.byteCount}`
148
+ )
149
+ );
150
+ const verdicts = snap.extractionQueue.recentVerdicts;
151
+ const accepts = verdicts.filter((v) => v.kind === "accept").length;
152
+ const rejects = verdicts.filter((v) => v.kind === "reject").length;
153
+ lines.push(
154
+ panelLine(
155
+ "Extraction",
156
+ `queue=${snap.extractionQueue.depth} recent verdicts: accept(${accepts})/reject(${rejects})`
157
+ )
158
+ );
159
+ const dedupSummary = formatDedupSummary(snap.dedupRecent, input.now);
160
+ lines.push(panelLine("Dedup", dedupSummary));
161
+ const maintSummary = formatMaintenanceTail(snap.maintenanceLedgerTail);
162
+ lines.push(panelLine("Maintenance", maintSummary));
163
+ lines.push(panelLine("QMD", formatQmdSummary(snap)));
164
+ }
165
+ if (snap && snap.errors.length > 0) {
166
+ const head = snap.errors[0];
167
+ lines.push(panelLine("Errors", head ?? ""));
168
+ }
169
+ return lines;
170
+ }
171
+ function formatDedupSummary(decisions, now) {
172
+ if (decisions.length === 0) return "no recent decisions";
173
+ const last = decisions[decisions.length - 1];
174
+ if (!last) return "no recent decisions";
175
+ const ageMs = ageMsFromIso(last.ts, now);
176
+ const ageStr = ageMs === null ? "T-?" : `T-${Math.round(ageMs / 1e3)}s`;
177
+ const fp = last.fingerprint ? `hash=${last.fingerprint}` : "hash=?";
178
+ return `recent: ${fp} decision=${last.decision} (${ageStr})`;
179
+ }
180
+ function formatMaintenanceTail(events) {
181
+ if (events.length === 0) return "no events";
182
+ const last = events[events.length - 1];
183
+ if (!last) return "no events";
184
+ return `n=${events.length} last: ${last.category} ${truncate(last.summary, 40)}`;
185
+ }
186
+ function formatQmdSummary(snap) {
187
+ const probe = snap.qmdProbe.available ? "ok" : "down";
188
+ const uptimeH = snap.daemon.uptimeMs / 36e5;
189
+ const uptimeStr = uptimeH < 1 ? `${Math.round(snap.daemon.uptimeMs / 1e3)}s` : `${uptimeH.toFixed(1)}h`;
190
+ const mode = snap.qmdProbe.daemonMode ? "daemon" : "cli";
191
+ return `probe=${probe} mode=${mode} uptime=${uptimeStr}`;
192
+ }
193
+ function panelLine(label, value) {
194
+ const LABEL_WIDTH = 13;
195
+ const labelCol = padRight(label, LABEL_WIDTH);
196
+ const remaining = FRAME_INNER_WIDTH - LABEL_WIDTH - 2;
197
+ const valueCol = padRight(truncate(value, remaining), remaining);
198
+ return `\u2551 ${labelCol}${valueCol} \u2551`;
199
+ }
200
+ function padRight(s, width) {
201
+ if (s.length >= width) return s;
202
+ return s + " ".repeat(width - s.length);
203
+ }
204
+ function truncate(s, max) {
205
+ if (max <= 0) return "";
206
+ if (s.length <= max) return s;
207
+ if (max <= 1) return s.slice(0, max);
208
+ return s.slice(0, max - 1) + "\u2026";
209
+ }
210
+ function ageMsFromIso(iso, now) {
211
+ const ms = Date.parse(iso);
212
+ if (!Number.isFinite(ms)) return null;
213
+ const delta = now() - ms;
214
+ return delta < 0 ? 0 : delta;
215
+ }
216
+ async function runTickSafely(tick) {
217
+ try {
218
+ await tick();
219
+ } catch {
220
+ }
221
+ }
222
+ function safeWrite(output, chunk) {
223
+ try {
224
+ output.write(chunk);
225
+ } catch {
226
+ }
227
+ }
228
+ function describeError(err) {
229
+ if (err instanceof Error) return err.message;
230
+ try {
231
+ return String(err);
232
+ } catch {
233
+ return "unknown error";
234
+ }
235
+ }
236
+ function stripAnsi(s) {
237
+ return s.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
238
+ }
239
+
240
+ export {
241
+ runConsoleTui,
242
+ renderFrame,
243
+ stripAnsi
244
+ };
@@ -0,0 +1,78 @@
1
+ // ../remnic-core/src/tier-migration.ts
2
+ import { appendFile, mkdir } from "fs/promises";
3
+ import path from "path";
4
+ var TierMigrationExecutor = class {
5
+ storage;
6
+ qmd;
7
+ hotCollection;
8
+ coldCollection;
9
+ autoEmbed;
10
+ journalPath;
11
+ constructor(options) {
12
+ this.storage = options.storage;
13
+ this.qmd = options.qmd;
14
+ this.hotCollection = options.hotCollection;
15
+ this.coldCollection = options.coldCollection;
16
+ this.autoEmbed = options.autoEmbed === true;
17
+ this.journalPath = options.journalPath ?? path.join(this.storage.dir, "state", "tier-migration-journal.jsonl");
18
+ }
19
+ async migrateMemory(request) {
20
+ const { memory, fromTier, toTier, reason } = request;
21
+ const targetPath = this.storage.buildTierMemoryPath(memory, toTier);
22
+ if (fromTier === toTier) {
23
+ const noChange = {
24
+ memoryId: memory.frontmatter.id,
25
+ fromTier,
26
+ toTier,
27
+ changed: false,
28
+ reason,
29
+ targetPath
30
+ };
31
+ await this.appendJournal(noChange);
32
+ return noChange;
33
+ }
34
+ const moved = await this.storage.migrateMemoryToTier(memory, toTier);
35
+ const result = {
36
+ memoryId: memory.frontmatter.id,
37
+ fromTier,
38
+ toTier,
39
+ changed: moved.changed,
40
+ reason,
41
+ targetPath: moved.targetPath
42
+ };
43
+ await this.appendJournal(result);
44
+ if (result.changed) {
45
+ const destinationCollection = this.collectionForTier(toTier);
46
+ const sourceCollection = this.collectionForTier(fromTier);
47
+ await this.qmd.updateCollection(destinationCollection);
48
+ if (this.autoEmbed) {
49
+ await this.qmd.embedCollection(destinationCollection);
50
+ if (sourceCollection !== destinationCollection) {
51
+ await this.qmd.embedCollection(sourceCollection);
52
+ }
53
+ }
54
+ }
55
+ return result;
56
+ }
57
+ collectionForTier(tier) {
58
+ return tier === "cold" ? this.coldCollection : this.hotCollection;
59
+ }
60
+ async appendJournal(result) {
61
+ const entry = {
62
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
63
+ memoryId: result.memoryId,
64
+ fromTier: result.fromTier,
65
+ toTier: result.toTier,
66
+ changed: result.changed,
67
+ reason: result.reason,
68
+ targetPath: result.targetPath
69
+ };
70
+ await mkdir(path.dirname(this.journalPath), { recursive: true });
71
+ await appendFile(this.journalPath, `${JSON.stringify(entry)}
72
+ `, "utf-8");
73
+ }
74
+ };
75
+
76
+ export {
77
+ TierMigrationExecutor
78
+ };