@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,289 @@
1
+ import {
2
+ renderFrame
3
+ } from "./chunk-B52XADV3.js";
4
+ import "./chunk-MBIFE6SA.js";
5
+ import "./chunk-MLKGABMK.js";
6
+
7
+ // ../remnic-core/src/console/trace.ts
8
+ import { promises as fs } from "fs";
9
+ import path from "path";
10
+ import readline from "readline";
11
+ import { createReadStream } from "fs";
12
+ var ANSI_CLEAR_HOME = "\x1B[2J\x1B[H";
13
+ var ANSI_HIDE_CURSOR = "\x1B[?25l";
14
+ var ANSI_SHOW_CURSOR = "\x1B[?25h";
15
+ var DEFAULT_REPLAY_DELAY_MS = 2e3;
16
+ var MAX_REPLAY_DELAY_MS = 6e4;
17
+ var MIN_REPLAY_DELAY_MS = 0;
18
+ async function openTraceRecorder(filePath, options = {}) {
19
+ const ensureParentDir = options.ensureParentDir ?? true;
20
+ if (ensureParentDir) {
21
+ const parent = path.dirname(filePath);
22
+ if (parent && parent !== "." && parent !== "/") {
23
+ await fs.mkdir(parent, { recursive: true });
24
+ }
25
+ }
26
+ const handle = await fs.open(filePath, "a");
27
+ let closed = false;
28
+ let lastError = null;
29
+ let writeChain = Promise.resolve();
30
+ const queueWrite = (line) => {
31
+ const next = writeChain.then(async () => {
32
+ if (closed) return;
33
+ try {
34
+ await handle.write(line);
35
+ } catch (err) {
36
+ const msg = describeError(err);
37
+ lastError = msg;
38
+ throw err;
39
+ }
40
+ });
41
+ writeChain = next.catch(() => {
42
+ });
43
+ return next;
44
+ };
45
+ return {
46
+ append: async (snapshot) => {
47
+ if (closed) return;
48
+ let line;
49
+ try {
50
+ line = JSON.stringify(snapshot) + "\n";
51
+ } catch (err) {
52
+ lastError = `serialize failed: ${describeError(err)}`;
53
+ return;
54
+ }
55
+ try {
56
+ await queueWrite(line);
57
+ } catch {
58
+ }
59
+ },
60
+ close: async (signal) => {
61
+ if (closed) return;
62
+ try {
63
+ if (signal) {
64
+ await Promise.race([
65
+ writeChain,
66
+ new Promise((_, reject) => {
67
+ if (signal.aborted) {
68
+ reject(makeAbortError());
69
+ return;
70
+ }
71
+ signal.addEventListener("abort", () => reject(makeAbortError()), {
72
+ once: true
73
+ });
74
+ })
75
+ ]);
76
+ } else {
77
+ await writeChain;
78
+ }
79
+ } catch {
80
+ }
81
+ closed = true;
82
+ try {
83
+ await handle.close();
84
+ } catch (err) {
85
+ lastError = describeError(err);
86
+ }
87
+ },
88
+ getLastError: () => lastError
89
+ };
90
+ }
91
+ async function replayTrace(filePath, options = {}) {
92
+ const output = options.output ?? process.stdout;
93
+ const speed = normalizeSpeed(options.speed);
94
+ const sleep = options.sleep ?? ((ms) => sleepAbortable(ms, options.signal));
95
+ const manageCursor = options.manageCursor ?? true;
96
+ const nowFn = options.now ?? ((snapshot) => {
97
+ const ms = Date.parse(snapshot.capturedAt);
98
+ return Number.isFinite(ms) ? ms : Date.now();
99
+ });
100
+ const stream = createReadStream(filePath, { encoding: "utf-8" });
101
+ const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
102
+ let framesRendered = 0;
103
+ let framesSkipped = 0;
104
+ let lastSnapshot = null;
105
+ let prevCapturedMs = null;
106
+ if (manageCursor) safeWrite(output, ANSI_HIDE_CURSOR);
107
+ try {
108
+ for await (const rawLine of rl) {
109
+ if (options.signal?.aborted) break;
110
+ const line = rawLine.trim();
111
+ if (line.length === 0) continue;
112
+ const snapshot = parseSnapshotLine(line);
113
+ if (snapshot === null) {
114
+ framesSkipped += 1;
115
+ continue;
116
+ }
117
+ const capturedMs = Date.parse(snapshot.capturedAt);
118
+ let waitMs = 0;
119
+ if (prevCapturedMs !== null && Number.isFinite(capturedMs)) {
120
+ const rawDelta = capturedMs - prevCapturedMs;
121
+ waitMs = computeReplayDelay(rawDelta, speed);
122
+ } else if (prevCapturedMs !== null) {
123
+ waitMs = computeReplayDelay(DEFAULT_REPLAY_DELAY_MS, speed);
124
+ }
125
+ if (waitMs > 0) {
126
+ try {
127
+ await sleep(waitMs);
128
+ } catch (err) {
129
+ if (isAbortError(err) || options.signal?.aborted) break;
130
+ throw err;
131
+ }
132
+ if (options.signal?.aborted) break;
133
+ }
134
+ let frame;
135
+ try {
136
+ frame = renderFrame({
137
+ snapshot,
138
+ renderError: null,
139
+ now: () => nowFn(snapshot, framesRendered)
140
+ });
141
+ } catch (err) {
142
+ frame = `remnic console replay: render failed: ${describeError(err)}
143
+ `;
144
+ }
145
+ safeWrite(output, ANSI_CLEAR_HOME);
146
+ safeWrite(output, frame);
147
+ framesRendered += 1;
148
+ lastSnapshot = snapshot;
149
+ if (Number.isFinite(capturedMs)) prevCapturedMs = capturedMs;
150
+ }
151
+ } finally {
152
+ rl.close();
153
+ stream.close();
154
+ if (manageCursor) safeWrite(output, ANSI_SHOW_CURSOR);
155
+ }
156
+ return { framesRendered, framesSkipped, lastSnapshot };
157
+ }
158
+ function parseSnapshotLine(line) {
159
+ let parsed;
160
+ try {
161
+ parsed = JSON.parse(line);
162
+ } catch {
163
+ return null;
164
+ }
165
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
166
+ return null;
167
+ }
168
+ return parsed;
169
+ }
170
+ function computeReplayDelay(rawDeltaMs, speed) {
171
+ if (!Number.isFinite(rawDeltaMs)) return 0;
172
+ if (rawDeltaMs <= 0) return 0;
173
+ if (!Number.isFinite(speed)) return 0;
174
+ const adjusted = rawDeltaMs / speed;
175
+ if (!Number.isFinite(adjusted)) return 0;
176
+ if (adjusted <= MIN_REPLAY_DELAY_MS) return MIN_REPLAY_DELAY_MS;
177
+ if (adjusted > MAX_REPLAY_DELAY_MS) return MAX_REPLAY_DELAY_MS;
178
+ return adjusted;
179
+ }
180
+ function parseSpeedFlag(raw) {
181
+ if (raw === void 0 || raw === null) return 1;
182
+ const num = typeof raw === "number" ? raw : Number(raw);
183
+ if (!Number.isFinite(num) && num !== Infinity) {
184
+ throw new Error(
185
+ `invalid --speed value: ${JSON.stringify(raw)} (must be a positive number)`
186
+ );
187
+ }
188
+ if (num <= 0) {
189
+ throw new Error(
190
+ `invalid --speed value: ${JSON.stringify(raw)} (must be > 0)`
191
+ );
192
+ }
193
+ return num;
194
+ }
195
+ function normalizeSpeed(speed) {
196
+ if (speed === void 0) return 1;
197
+ if (!Number.isFinite(speed) && speed !== Infinity) return 1;
198
+ if (speed <= 0) return 1;
199
+ return speed;
200
+ }
201
+ function sleepAbortable(ms, signal) {
202
+ return new Promise((resolve, reject) => {
203
+ if (signal?.aborted) {
204
+ reject(makeAbortError());
205
+ return;
206
+ }
207
+ const timer = setTimeout(() => {
208
+ if (signal && onAbort) signal.removeEventListener("abort", onAbort);
209
+ resolve();
210
+ }, ms);
211
+ let onAbort = null;
212
+ if (signal) {
213
+ onAbort = () => {
214
+ clearTimeout(timer);
215
+ reject(makeAbortError());
216
+ };
217
+ signal.addEventListener("abort", onAbort, { once: true });
218
+ }
219
+ });
220
+ }
221
+ function makeAbortError() {
222
+ if (typeof DOMException !== "undefined") {
223
+ return new DOMException("aborted", "AbortError");
224
+ }
225
+ const err = new Error("aborted");
226
+ err.name = "AbortError";
227
+ return err;
228
+ }
229
+ function isAbortError(err) {
230
+ return typeof err === "object" && err !== null && "name" in err && err.name === "AbortError";
231
+ }
232
+ async function flushWithTimeout(flush, timeoutMs) {
233
+ const TIMEOUT_SENTINEL = /* @__PURE__ */ Symbol("flush-timeout");
234
+ let error = null;
235
+ let timeoutHandle = null;
236
+ const ac = new AbortController();
237
+ const flushPromise = flush(ac.signal).then(
238
+ () => void 0,
239
+ (err) => {
240
+ error = err;
241
+ return void 0;
242
+ }
243
+ );
244
+ const timeoutPromise = new Promise((resolve) => {
245
+ timeoutHandle = setTimeout(() => resolve(TIMEOUT_SENTINEL), timeoutMs);
246
+ if (typeof timeoutHandle.unref === "function") {
247
+ timeoutHandle.unref();
248
+ }
249
+ });
250
+ try {
251
+ const winner = await Promise.race([
252
+ flushPromise,
253
+ timeoutPromise
254
+ ]);
255
+ if (winner === TIMEOUT_SENTINEL) {
256
+ ac.abort();
257
+ return { flushed: false, timedOut: true, error: null };
258
+ }
259
+ return { flushed: true, timedOut: false, error };
260
+ } finally {
261
+ if (timeoutHandle !== null) {
262
+ clearTimeout(timeoutHandle);
263
+ }
264
+ }
265
+ }
266
+ function safeWrite(output, chunk) {
267
+ try {
268
+ output.write(chunk);
269
+ } catch {
270
+ }
271
+ }
272
+ function describeError(err) {
273
+ if (err instanceof Error) return err.message;
274
+ try {
275
+ return String(err);
276
+ } catch {
277
+ return "unknown error";
278
+ }
279
+ }
280
+ export {
281
+ computeReplayDelay,
282
+ flushWithTimeout,
283
+ isAbortError,
284
+ openTraceRecorder,
285
+ parseSnapshotLine,
286
+ parseSpeedFlag,
287
+ replayTrace,
288
+ sleepAbortable
289
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ renderFrame,
3
+ runConsoleTui,
4
+ stripAnsi
5
+ } from "./chunk-B52XADV3.js";
6
+ import "./chunk-MBIFE6SA.js";
7
+ import "./chunk-MLKGABMK.js";
8
+ export {
9
+ renderFrame,
10
+ runConsoleTui,
11
+ stripAnsi
12
+ };
@@ -0,0 +1,30 @@
1
+ import {
2
+ CAPSULE_ID_PATTERN,
3
+ CapsuleBlockSchema,
4
+ CapsuleIncludesSchema,
5
+ CapsuleParentSchema,
6
+ CapsuleRetrievalPolicySchema,
7
+ ExportBundleV1Schema,
8
+ ExportBundleV2Schema,
9
+ ExportManifestV1Schema,
10
+ ExportManifestV2Schema,
11
+ ExportMemoryRecordV1Schema,
12
+ parseExportBundle,
13
+ parseExportManifest
14
+ } from "./chunk-4LYQ4ONL.js";
15
+ import "./chunk-EXDYWXMB.js";
16
+ import "./chunk-MLKGABMK.js";
17
+ export {
18
+ CAPSULE_ID_PATTERN,
19
+ CapsuleBlockSchema,
20
+ CapsuleIncludesSchema,
21
+ CapsuleParentSchema,
22
+ CapsuleRetrievalPolicySchema,
23
+ ExportBundleV1Schema,
24
+ ExportBundleV2Schema,
25
+ ExportManifestV1Schema,
26
+ ExportManifestV2Schema,
27
+ ExportMemoryRecordV1Schema,
28
+ parseExportBundle,
29
+ parseExportManifest
30
+ };