@remnic/plugin-openclaw 1.0.53 → 9.3.515

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 (84) hide show
  1. package/dist/index.js +510 -2071
  2. package/openclaw.plugin.json +3 -3
  3. package/package.json +4 -3
  4. package/scripts/faiss_index.py +141 -29
  5. package/dist/calibration-RKL2LRW4.js +0 -250
  6. package/dist/capsule-cli-EHZPMXBC.js +0 -33
  7. package/dist/capsule-crypto-JS67OSWM.js +0 -17
  8. package/dist/capsule-export-DX53CPIT.js +0 -17
  9. package/dist/capsule-import-4OXCPHOT.js +0 -16
  10. package/dist/capsule-merge-25AUN33Q.js +0 -195
  11. package/dist/causal-chain-BVTOWZKC.js +0 -23
  12. package/dist/causal-consolidation-V533DIGW.js +0 -233
  13. package/dist/causal-retrieval-XAP6QKHZ.js +0 -182
  14. package/dist/causal-trajectory-graph-ZWQWZ7N5.js +0 -59
  15. package/dist/chunk-25J4PXDH.js +0 -30
  16. package/dist/chunk-2RQU6GVD.js +0 -453
  17. package/dist/chunk-3A5ELHTT.js +0 -61
  18. package/dist/chunk-3G7FAF6S.js +0 -60
  19. package/dist/chunk-3IKMUNW5.js +0 -177
  20. package/dist/chunk-4XDQ3KEC.js +0 -4048
  21. package/dist/chunk-5ZW5XJQ6.js +0 -128
  22. package/dist/chunk-6IWEAUN6.js +0 -148
  23. package/dist/chunk-7JOLBJJ5.js +0 -874
  24. package/dist/chunk-B52XADV3.js +0 -244
  25. package/dist/chunk-BQZ7JACP.js +0 -389
  26. package/dist/chunk-BU5KJVWF.js +0 -78
  27. package/dist/chunk-BZ4EYURA.js +0 -181
  28. package/dist/chunk-CEL5ZLKP.js +0 -233
  29. package/dist/chunk-EH4AXGRO.js +0 -48
  30. package/dist/chunk-I2KLQ2HA.js +0 -22
  31. package/dist/chunk-IO5WWY6A.js +0 -156
  32. package/dist/chunk-JC3FCKYL.js +0 -516
  33. package/dist/chunk-JZBOXOUC.js +0 -259
  34. package/dist/chunk-KC7KSQR4.js +0 -302
  35. package/dist/chunk-LZCGPRHS.js +0 -228
  36. package/dist/chunk-MBIFE6SA.js +0 -250
  37. package/dist/chunk-MWLY7VQX.js +0 -896
  38. package/dist/chunk-MXFJXUHC.js +0 -292
  39. package/dist/chunk-NUWDSTP7.js +0 -233
  40. package/dist/chunk-PSAPZGDX.js +0 -725
  41. package/dist/chunk-QCCP4RU5.js +0 -190
  42. package/dist/chunk-QMUQV5NP.js +0 -146
  43. package/dist/chunk-QQXJODFL.js +0 -328
  44. package/dist/chunk-QVTGUY3H.js +0 -1295
  45. package/dist/chunk-SWOYEQN2.js +0 -1005
  46. package/dist/chunk-TH5FF5SC.js +0 -16
  47. package/dist/chunk-TXOEHSVP.js +0 -275
  48. package/dist/chunk-UFU5GGGA.js +0 -47
  49. package/dist/chunk-UZJ7EERS.js +0 -272
  50. package/dist/chunk-W6EEFUCJ.js +0 -349
  51. package/dist/chunk-YGGGUTG3.js +0 -125
  52. package/dist/chunk-YJYZMLD5.js +0 -360
  53. package/dist/chunk-YKV4EFUI.js +0 -199
  54. package/dist/chunk-YXDXRE6N.js +0 -6500
  55. package/dist/chunk-ZS6VABML.js +0 -185
  56. package/dist/cipher-E23BHBSO.js +0 -27
  57. package/dist/consolidation-undo-FKJZCJHS.js +0 -426
  58. package/dist/contradiction-review-WJRWNQ5N.js +0 -29
  59. package/dist/contradiction-scan-5X423QGT.js +0 -12
  60. package/dist/dreams-ledger-KDX44I7R.js +0 -290
  61. package/dist/engine-7VG3IXKN.js +0 -16
  62. package/dist/extraction-judge-telemetry-O4ZVGLTU.js +0 -14
  63. package/dist/fallback-llm-43UMEXNJ.js +0 -10
  64. package/dist/first-start-migration-H2SAXAGR.js +0 -263
  65. package/dist/forget-ZECIDNL5.js +0 -68
  66. package/dist/fs-utils-OYXSZSVV.js +0 -39
  67. package/dist/graph-edge-decay-24ZKD5QL.js +0 -202
  68. package/dist/kdf-RXKIWHRU.js +0 -25
  69. package/dist/logger-XG7JKLPS.js +0 -9
  70. package/dist/memory-governance-TK4B4ZZ2.js +0 -25
  71. package/dist/metadata-WK2TRPYZ.js +0 -20
  72. package/dist/migrate-from-identity-anchor-SNDNKHZD.js +0 -7
  73. package/dist/path-ZKO74XXC.js +0 -7
  74. package/dist/peers-W53WSDXG.js +0 -43
  75. package/dist/purge-IKJISXEQ.js +0 -204
  76. package/dist/resolution-BN35OXDS.js +0 -11
  77. package/dist/secure-store-6RWYM6GK.js +0 -155
  78. package/dist/state-4ITLYMAU.js +0 -7
  79. package/dist/state-store-ET3ADVY5.js +0 -14
  80. package/dist/storage-HUNVVHZ7.js +0 -27
  81. package/dist/tier-stats-ZRQBV6G2.js +0 -147
  82. package/dist/trace-IL2Y34EH.js +0 -289
  83. package/dist/tui-7KRDCMYK.js +0 -12
  84. package/dist/types-MBUINTB2.js +0 -30
@@ -1,177 +0,0 @@
1
- import {
2
- assertIsoRecordedAt,
3
- assertSafePathSegment,
4
- assertString,
5
- isRecord,
6
- optionalString,
7
- optionalStringArray,
8
- validateStringRecord
9
- } from "./chunk-3G7FAF6S.js";
10
- import {
11
- listJsonFiles,
12
- readJsonFile
13
- } from "./chunk-25J4PXDH.js";
14
-
15
- // ../remnic-core/src/boxes.ts
16
- import * as fsReadModule0 from "fs/promises";
17
- const mkdir = fsReadModule0.mkdir;
18
- const writeFile = fsReadModule0.writeFile;
19
- const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
20
- const readdir = fsReadModule0.readdir;
21
- import path from "path";
22
- import { createHash } from "crypto";
23
- function topicOverlapScore(a, b) {
24
- if (a.length === 0 || b.length === 0) return 0;
25
- const setA = new Set(a.map((t) => t.toLowerCase()));
26
- const setB = new Set(b.map((t) => t.toLowerCase()));
27
- const intersection = [...setA].filter((t) => setB.has(t)).length;
28
- const union = (/* @__PURE__ */ new Set([...setA, ...setB])).size;
29
- return union === 0 ? 0 : intersection / union;
30
- }
31
-
32
- // ../remnic-core/src/recall-tokenization.ts
33
- function normalizeRecallTokens(value, extraStopWords = []) {
34
- const stopWords = /* @__PURE__ */ new Set([
35
- "the",
36
- "and",
37
- "for",
38
- "with",
39
- "from",
40
- "into",
41
- "that",
42
- "this",
43
- "why",
44
- "did",
45
- ...extraStopWords
46
- ]);
47
- return value.toLowerCase().split(/[^a-z0-9]+/).map((token) => token.trim()).filter((token) => token.length >= 3 && !stopWords.has(token));
48
- }
49
- function countRecallTokenOverlap(queryTokens, value, extraStopWords = []) {
50
- if (!value) return 0;
51
- const tokens = new Set(normalizeRecallTokens(value, extraStopWords));
52
- let matches = 0;
53
- for (const token of queryTokens) {
54
- if (tokens.has(token)) matches += 1;
55
- }
56
- return matches;
57
- }
58
-
59
- // ../remnic-core/src/causal-trajectory.ts
60
- import path2 from "path";
61
- import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
62
- function validateMetadata(raw) {
63
- return validateStringRecord(raw, "metadata");
64
- }
65
- function resolveCausalTrajectoryStoreDir(memoryDir, overrideDir) {
66
- if (typeof overrideDir === "string" && overrideDir.trim().length > 0) {
67
- return overrideDir.trim();
68
- }
69
- return path2.join(memoryDir, "state", "causal-trajectories");
70
- }
71
- function validateCausalTrajectoryRecord(raw) {
72
- if (!isRecord(raw)) throw new Error("causal trajectory record must be an object");
73
- if (raw.schemaVersion !== 1) throw new Error("schemaVersion must be 1");
74
- const outcomeKind = assertString(raw.outcomeKind, "outcomeKind");
75
- if (!["success", "failure", "partial", "unknown"].includes(outcomeKind)) {
76
- throw new Error("outcomeKind must be one of success|failure|partial|unknown");
77
- }
78
- return {
79
- schemaVersion: 1,
80
- trajectoryId: assertSafePathSegment(assertString(raw.trajectoryId, "trajectoryId"), "trajectoryId"),
81
- recordedAt: assertIsoRecordedAt(assertString(raw.recordedAt, "recordedAt")),
82
- sessionKey: assertString(raw.sessionKey, "sessionKey"),
83
- goal: assertString(raw.goal, "goal"),
84
- actionSummary: assertString(raw.actionSummary, "actionSummary"),
85
- observationSummary: assertString(raw.observationSummary, "observationSummary"),
86
- outcomeKind,
87
- outcomeSummary: assertString(raw.outcomeSummary, "outcomeSummary"),
88
- followUpSummary: optionalString(raw.followUpSummary),
89
- objectiveStateSnapshotRefs: optionalStringArray(raw.objectiveStateSnapshotRefs, "objectiveStateSnapshotRefs"),
90
- entityRefs: optionalStringArray(raw.entityRefs, "entityRefs"),
91
- tags: optionalStringArray(raw.tags, "tags"),
92
- metadata: validateMetadata(raw.metadata)
93
- };
94
- }
95
- async function readCausalTrajectoryRecords(options) {
96
- const rootDir = resolveCausalTrajectoryStoreDir(options.memoryDir, options.causalTrajectoryStoreDir);
97
- const files = await listJsonFiles(path2.join(rootDir, "trajectories"));
98
- const trajectories = [];
99
- const invalidTrajectories = [];
100
- for (const filePath of files) {
101
- try {
102
- trajectories.push(validateCausalTrajectoryRecord(await readJsonFile(filePath)));
103
- } catch (error) {
104
- invalidTrajectories.push({
105
- path: filePath,
106
- error: error instanceof Error ? error.message : String(error)
107
- });
108
- }
109
- }
110
- return { files, trajectories, invalidTrajectories };
111
- }
112
- function lexicalScoreCausalTrajectoryRecord(record, queryTokens) {
113
- const weightedFields = [
114
- ["goal", record.goal, 4],
115
- ["action", record.actionSummary, 3],
116
- ["observation", record.observationSummary, 3],
117
- ["outcome", record.outcomeSummary, 3],
118
- ["follow_up", record.followUpSummary, 2],
119
- ["outcome_kind", record.outcomeKind, 1],
120
- ["tags", record.tags?.join(" "), 2],
121
- ["entity_refs", record.entityRefs?.join(" "), 2],
122
- ["objective_state_refs", record.objectiveStateSnapshotRefs?.join(" "), 1]
123
- ];
124
- let score = 0;
125
- const matchedFields = [];
126
- for (const [field, value, weight] of weightedFields) {
127
- const matches = countRecallTokenOverlap(queryTokens, value, ["make"]);
128
- if (matches > 0) matchedFields.push(field);
129
- score += matches * weight;
130
- }
131
- return { score, matchedFields };
132
- }
133
- function scoreCausalTrajectoryRecord(record, lexicalScore, sessionKey) {
134
- let score = lexicalScore;
135
- if (sessionKey && record.sessionKey === sessionKey) score += 1.5;
136
- const recordedAtMs = Date.parse(record.recordedAt);
137
- if (Number.isFinite(recordedAtMs)) {
138
- const ageHours = Math.max(0, (Date.now() - recordedAtMs) / 36e5);
139
- score += 1 / (1 + ageHours);
140
- }
141
- return score;
142
- }
143
- async function searchCausalTrajectories(options) {
144
- const maxResults = Math.max(0, Math.floor(options.maxResults));
145
- if (maxResults === 0) return [];
146
- const { trajectories } = await readCausalTrajectoryRecords(options);
147
- if (trajectories.length === 0) return [];
148
- const queryTokens = new Set(normalizeRecallTokens(options.query, ["make"]));
149
- if (queryTokens.size === 0) return [];
150
- const scored = trajectories.map((record) => {
151
- const lexical = lexicalScoreCausalTrajectoryRecord(record, queryTokens);
152
- return {
153
- record,
154
- matchedFields: lexical.matchedFields,
155
- lexicalScore: lexical.score,
156
- score: scoreCausalTrajectoryRecord(record, lexical.score, options.sessionKey)
157
- };
158
- });
159
- const filtered = scored.filter((result) => result.lexicalScore > 0);
160
- filtered.sort((left, right) => {
161
- if (right.score !== left.score) return right.score - left.score;
162
- return right.record.recordedAt.localeCompare(left.record.recordedAt);
163
- });
164
- return filtered.slice(0, maxResults).map(({ record, score, matchedFields }) => ({
165
- record,
166
- score,
167
- matchedFields
168
- }));
169
- }
170
-
171
- export {
172
- topicOverlapScore,
173
- normalizeRecallTokens,
174
- countRecallTokenOverlap,
175
- resolveCausalTrajectoryStoreDir,
176
- searchCausalTrajectories
177
- };