@remnic/plugin-openclaw 1.0.7 → 1.0.9
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-BAC7KNKR.js → calibration-674TDQNV.js} +1 -1
- package/dist/{causal-consolidation-S6M7UTZG.js → causal-consolidation-5BEXLQV5.js} +7 -6
- package/dist/chunk-5ZW5XJQ6.js +125 -0
- package/dist/chunk-6OJAU466.js +148 -0
- package/dist/{chunk-NXLHSCLU.js → chunk-7TENHBV2.js} +22 -8
- package/dist/{chunk-SVGN3ACY.js → chunk-HCFFXBLV.js} +3 -3
- package/dist/{chunk-KPMXWORS.js → chunk-JJSNPSCD.js} +608 -354
- package/dist/{chunk-QHMR3D7U.js → chunk-S2ISS4AH.js} +115 -5
- package/dist/consolidation-undo-5ZSX4MWO.js +426 -0
- package/dist/{contradiction-scan-LRRLWUOS.js → contradiction-scan-U3QKHWQN.js} +42 -6
- package/dist/{engine-WGNTTFYE.js → engine-65C2J63X.js} +3 -2
- package/dist/extraction-judge-telemetry-GHOTVYMP.js +14 -0
- package/dist/{fallback-llm-QEAPMDW7.js → fallback-llm-LVK5PDIM.js} +1 -1
- package/dist/index.js +6134 -1298
- package/dist/{storage-BA6OBLMK.js → storage-DM4ZGOCN.js} +2 -1
- package/openclaw.plugin.json +259 -14
- package/package.json +2 -2
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildExtensionsBlockForConsolidation,
|
|
3
3
|
runPostConsolidationMaterialize
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import
|
|
4
|
+
} from "./chunk-S2ISS4AH.js";
|
|
5
|
+
import {
|
|
6
|
+
FallbackLlmClient
|
|
7
|
+
} from "./chunk-7TENHBV2.js";
|
|
8
|
+
import "./chunk-3A5ELHTT.js";
|
|
9
|
+
import "./chunk-JJSNPSCD.js";
|
|
10
|
+
import "./chunk-6OJAU466.js";
|
|
6
11
|
import {
|
|
7
12
|
readChainIndex,
|
|
8
13
|
resolveChainsDir
|
|
@@ -10,10 +15,6 @@ import {
|
|
|
10
15
|
import {
|
|
11
16
|
isRecord
|
|
12
17
|
} from "./chunk-YHH3SXKD.js";
|
|
13
|
-
import {
|
|
14
|
-
FallbackLlmClient
|
|
15
|
-
} from "./chunk-NXLHSCLU.js";
|
|
16
|
-
import "./chunk-3A5ELHTT.js";
|
|
17
18
|
import {
|
|
18
19
|
listJsonFiles,
|
|
19
20
|
readJsonFile
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
log
|
|
3
|
+
} from "./chunk-UFU5GGGA.js";
|
|
4
|
+
|
|
5
|
+
// ../remnic-core/src/extraction-judge-telemetry.ts
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { appendFile, mkdir, readFile } from "fs/promises";
|
|
8
|
+
var EXTRACTION_JUDGE_VERDICT_CATEGORY = "EXTRACTION_JUDGE_VERDICT";
|
|
9
|
+
function judgeTelemetryPath(memoryDir) {
|
|
10
|
+
return path.join(
|
|
11
|
+
memoryDir,
|
|
12
|
+
"state",
|
|
13
|
+
"observation-ledger",
|
|
14
|
+
"extraction-judge-verdicts.jsonl"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
async function recordJudgeVerdict(event, options) {
|
|
18
|
+
if (!options.enabled) return;
|
|
19
|
+
const filePath = judgeTelemetryPath(options.memoryDir);
|
|
20
|
+
try {
|
|
21
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
22
|
+
await appendFile(filePath, `${JSON.stringify(event)}
|
|
23
|
+
`, "utf-8");
|
|
24
|
+
} catch (err) {
|
|
25
|
+
log.debug(
|
|
26
|
+
`extraction-judge-telemetry: append failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function readJudgeVerdictStats(memoryDir, opts = {}) {
|
|
31
|
+
const filePath = judgeTelemetryPath(memoryDir);
|
|
32
|
+
let raw;
|
|
33
|
+
try {
|
|
34
|
+
raw = await readFile(filePath, "utf-8");
|
|
35
|
+
} catch (err) {
|
|
36
|
+
const code = err.code;
|
|
37
|
+
if (code === "ENOENT") {
|
|
38
|
+
return {
|
|
39
|
+
total: 0,
|
|
40
|
+
accept: 0,
|
|
41
|
+
reject: 0,
|
|
42
|
+
defer: 0,
|
|
43
|
+
deferCapTriggered: 0,
|
|
44
|
+
meanElapsedMs: 0,
|
|
45
|
+
deferRate: 0,
|
|
46
|
+
malformed: 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
let total = 0;
|
|
52
|
+
let accept = 0;
|
|
53
|
+
let reject = 0;
|
|
54
|
+
let defer = 0;
|
|
55
|
+
let deferCapTriggered = 0;
|
|
56
|
+
let elapsedSum = 0;
|
|
57
|
+
let malformed = 0;
|
|
58
|
+
let firstTs;
|
|
59
|
+
let lastTs;
|
|
60
|
+
for (const line of raw.split("\n")) {
|
|
61
|
+
if (!line.trim()) continue;
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = JSON.parse(line);
|
|
65
|
+
} catch {
|
|
66
|
+
malformed += 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
70
|
+
malformed += 1;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const p = parsed;
|
|
74
|
+
if (p.category !== EXTRACTION_JUDGE_VERDICT_CATEGORY) {
|
|
75
|
+
malformed += 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const ts = typeof p.ts === "string" ? p.ts : null;
|
|
79
|
+
if (ts === null) {
|
|
80
|
+
malformed += 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const tsMs = Date.parse(ts);
|
|
84
|
+
if (!Number.isFinite(tsMs)) {
|
|
85
|
+
malformed += 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (typeof opts.sinceMs === "number" && tsMs < opts.sinceMs) continue;
|
|
89
|
+
if (typeof opts.untilMs === "number" && tsMs >= opts.untilMs) continue;
|
|
90
|
+
const kind = p.verdictKind;
|
|
91
|
+
if (kind === "accept") accept += 1;
|
|
92
|
+
else if (kind === "reject") reject += 1;
|
|
93
|
+
else if (kind === "defer") defer += 1;
|
|
94
|
+
else {
|
|
95
|
+
malformed += 1;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (p.deferCapTriggered === true) deferCapTriggered += 1;
|
|
99
|
+
if (typeof p.elapsedMs === "number" && Number.isFinite(p.elapsedMs)) {
|
|
100
|
+
elapsedSum += p.elapsedMs;
|
|
101
|
+
}
|
|
102
|
+
total += 1;
|
|
103
|
+
if (firstTs === void 0 || ts < firstTs) firstTs = ts;
|
|
104
|
+
if (lastTs === void 0 || ts > lastTs) lastTs = ts;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
total,
|
|
108
|
+
accept,
|
|
109
|
+
reject,
|
|
110
|
+
defer,
|
|
111
|
+
deferCapTriggered,
|
|
112
|
+
meanElapsedMs: total > 0 ? elapsedSum / total : 0,
|
|
113
|
+
deferRate: total > 0 ? defer / total : 0,
|
|
114
|
+
firstTs,
|
|
115
|
+
lastTs,
|
|
116
|
+
malformed
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
EXTRACTION_JUDGE_VERDICT_CATEGORY,
|
|
122
|
+
judgeTelemetryPath,
|
|
123
|
+
recordJudgeVerdict,
|
|
124
|
+
readJudgeVerdictStats
|
|
125
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// ../remnic-core/src/page-versioning.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import {
|
|
5
|
+
access,
|
|
6
|
+
mkdir,
|
|
7
|
+
readFile,
|
|
8
|
+
writeFile,
|
|
9
|
+
unlink
|
|
10
|
+
} from "fs/promises";
|
|
11
|
+
var NOOP_LOGGER = {
|
|
12
|
+
debug: () => {
|
|
13
|
+
},
|
|
14
|
+
warn: () => {
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var writeLocks = /* @__PURE__ */ new Map();
|
|
18
|
+
function withPageLock(pageKey, fn) {
|
|
19
|
+
const prev = writeLocks.get(pageKey) ?? Promise.resolve();
|
|
20
|
+
const next = prev.then(fn, fn);
|
|
21
|
+
writeLocks.set(pageKey, next.then(() => {
|
|
22
|
+
}, () => {
|
|
23
|
+
}));
|
|
24
|
+
return next;
|
|
25
|
+
}
|
|
26
|
+
function contentHash(content) {
|
|
27
|
+
return createHash("sha256").update(content, "utf-8").digest("hex");
|
|
28
|
+
}
|
|
29
|
+
function sidecarKey(pagePath) {
|
|
30
|
+
const withoutExt = pagePath.replace(/\.md$/i, "");
|
|
31
|
+
return withoutExt.replace(/[\\/]/g, "__");
|
|
32
|
+
}
|
|
33
|
+
function sidecarDir(memoryDir, sidecar, pagePath) {
|
|
34
|
+
return path.join(memoryDir, sidecar, sidecarKey(pagePath));
|
|
35
|
+
}
|
|
36
|
+
function manifestPath(memoryDir, sidecar, pagePath) {
|
|
37
|
+
return path.join(sidecarDir(memoryDir, sidecar, pagePath), "manifest.json");
|
|
38
|
+
}
|
|
39
|
+
async function fileExists(p) {
|
|
40
|
+
try {
|
|
41
|
+
await access(p);
|
|
42
|
+
return true;
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function readManifest(memoryDir, sidecar, pagePath) {
|
|
48
|
+
const mp = manifestPath(memoryDir, sidecar, pagePath);
|
|
49
|
+
try {
|
|
50
|
+
const raw = await readFile(mp, "utf-8");
|
|
51
|
+
const parsed = JSON.parse(raw);
|
|
52
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
53
|
+
return { pagePath, versions: [], currentVersion: "0" };
|
|
54
|
+
}
|
|
55
|
+
const obj = parsed;
|
|
56
|
+
const versions = Array.isArray(obj.versions) ? obj.versions : [];
|
|
57
|
+
const currentVersion = typeof obj.currentVersion === "string" ? obj.currentVersion : "0";
|
|
58
|
+
return { pagePath: typeof obj.pagePath === "string" ? obj.pagePath : pagePath, versions, currentVersion };
|
|
59
|
+
} catch {
|
|
60
|
+
return { pagePath, versions: [], currentVersion: "0" };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function writeManifest(memoryDir, sidecar, pagePath, history) {
|
|
64
|
+
const dir = sidecarDir(memoryDir, sidecar, pagePath);
|
|
65
|
+
await mkdir(dir, { recursive: true });
|
|
66
|
+
const mp = manifestPath(memoryDir, sidecar, pagePath);
|
|
67
|
+
await writeFile(mp, JSON.stringify(history, null, 2) + "\n", "utf-8");
|
|
68
|
+
}
|
|
69
|
+
async function createVersion(pagePath, content, trigger, config, log = NOOP_LOGGER, note, memoryDir) {
|
|
70
|
+
const { sidecarDir: sidecar, maxVersionsPerPage } = config;
|
|
71
|
+
const resolvedMemoryDir = memoryDir ?? resolveMemoryDir(pagePath);
|
|
72
|
+
const mPath = manifestPath(resolvedMemoryDir, sidecar, relPath(pagePath, resolvedMemoryDir));
|
|
73
|
+
return withPageLock(mPath, async () => {
|
|
74
|
+
const history = await readManifest(resolvedMemoryDir, sidecar, relPath(pagePath, resolvedMemoryDir));
|
|
75
|
+
const nextId = String(history.versions.length > 0 ? Math.max(...history.versions.map((v) => Number(v.versionId))) + 1 : 1);
|
|
76
|
+
const hash = contentHash(content);
|
|
77
|
+
const version = {
|
|
78
|
+
versionId: nextId,
|
|
79
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
80
|
+
contentHash: hash,
|
|
81
|
+
sizeBytes: Buffer.byteLength(content, "utf-8"),
|
|
82
|
+
trigger,
|
|
83
|
+
...note !== void 0 ? { note } : {}
|
|
84
|
+
};
|
|
85
|
+
const dir = sidecarDir(resolvedMemoryDir, sidecar, relPath(pagePath, resolvedMemoryDir));
|
|
86
|
+
await mkdir(dir, { recursive: true });
|
|
87
|
+
const ext = path.extname(pagePath) || ".md";
|
|
88
|
+
const snapshotPath = path.join(dir, `${nextId}${ext}`);
|
|
89
|
+
await writeFile(snapshotPath, content, "utf-8");
|
|
90
|
+
history.versions.push(version);
|
|
91
|
+
history.currentVersion = nextId;
|
|
92
|
+
if (maxVersionsPerPage > 0 && history.versions.length > maxVersionsPerPage) {
|
|
93
|
+
const toRemove = history.versions.splice(0, history.versions.length - maxVersionsPerPage);
|
|
94
|
+
for (const old of toRemove) {
|
|
95
|
+
const oldPath = path.join(dir, `${old.versionId}${ext}`);
|
|
96
|
+
try {
|
|
97
|
+
await unlink(oldPath);
|
|
98
|
+
} catch {
|
|
99
|
+
log.debug(`page-versioning: could not remove old snapshot ${oldPath}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
await writeManifest(resolvedMemoryDir, sidecar, relPath(pagePath, resolvedMemoryDir), history);
|
|
104
|
+
log.debug(`page-versioning: created version ${nextId} for ${pagePath} (trigger=${trigger})`);
|
|
105
|
+
return version;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function getVersion(pagePath, versionId, config, memoryDir) {
|
|
109
|
+
const resolvedMemoryDir = memoryDir ?? resolveMemoryDir(pagePath);
|
|
110
|
+
const rel = relPath(pagePath, resolvedMemoryDir);
|
|
111
|
+
const ext = path.extname(pagePath) || ".md";
|
|
112
|
+
const dir = sidecarDir(resolvedMemoryDir, config.sidecarDir, rel);
|
|
113
|
+
const snapshotPath = path.join(dir, `${versionId}${ext}`);
|
|
114
|
+
if (!await fileExists(snapshotPath)) {
|
|
115
|
+
throw new Error(`Version ${versionId} not found for ${pagePath}`);
|
|
116
|
+
}
|
|
117
|
+
return readFile(snapshotPath, "utf-8");
|
|
118
|
+
}
|
|
119
|
+
function resolveMemoryDir(pagePath) {
|
|
120
|
+
const knownSubdirs = /* @__PURE__ */ new Set([
|
|
121
|
+
"facts",
|
|
122
|
+
"corrections",
|
|
123
|
+
"entities",
|
|
124
|
+
"state",
|
|
125
|
+
"artifacts",
|
|
126
|
+
"questions",
|
|
127
|
+
"profiles"
|
|
128
|
+
]);
|
|
129
|
+
let dir = path.dirname(pagePath);
|
|
130
|
+
for (let depth = 0; depth < 5; depth++) {
|
|
131
|
+
const base = path.basename(dir);
|
|
132
|
+
if (knownSubdirs.has(base) || /^\d{4}-\d{2}-\d{2}$/.test(base)) {
|
|
133
|
+
dir = path.dirname(dir);
|
|
134
|
+
} else {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return dir;
|
|
139
|
+
}
|
|
140
|
+
function relPath(pagePath, memoryDir) {
|
|
141
|
+
return path.relative(memoryDir, pagePath);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
sidecarKey,
|
|
146
|
+
createVersion,
|
|
147
|
+
getVersion
|
|
148
|
+
};
|
|
@@ -126,9 +126,8 @@ async function getGatewayResolver() {
|
|
|
126
126
|
return null;
|
|
127
127
|
}
|
|
128
128
|
async function findRuntimeModules() {
|
|
129
|
-
const { readdirSync } = await import("fs");
|
|
129
|
+
const { accessSync, constants, readdirSync, realpathSync, statSync } = await import("fs");
|
|
130
130
|
const { createRequire } = await import("module");
|
|
131
|
-
const { execFileSync } = await import("child_process");
|
|
132
131
|
const candidates = [];
|
|
133
132
|
const distDirs = [];
|
|
134
133
|
const pushDistDirs = (entryPath) => {
|
|
@@ -150,7 +149,6 @@ async function findRuntimeModules() {
|
|
|
150
149
|
} catch {
|
|
151
150
|
}
|
|
152
151
|
try {
|
|
153
|
-
const { realpathSync } = await import("fs");
|
|
154
152
|
const mainScript = process.argv[1];
|
|
155
153
|
if (mainScript) {
|
|
156
154
|
const realScript = realpathSync(mainScript);
|
|
@@ -161,12 +159,8 @@ async function findRuntimeModules() {
|
|
|
161
159
|
} catch {
|
|
162
160
|
}
|
|
163
161
|
try {
|
|
164
|
-
const openclawBin =
|
|
165
|
-
encoding: "utf8",
|
|
166
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
167
|
-
}).trim();
|
|
162
|
+
const openclawBin = findExecutableOnPath("openclaw", accessSync, statSync, constants.X_OK);
|
|
168
163
|
if (openclawBin) {
|
|
169
|
-
const { realpathSync } = await import("fs");
|
|
170
164
|
pushDistDirs(realpathSync(openclawBin));
|
|
171
165
|
}
|
|
172
166
|
} catch {
|
|
@@ -184,6 +178,26 @@ async function findRuntimeModules() {
|
|
|
184
178
|
}
|
|
185
179
|
return candidates;
|
|
186
180
|
}
|
|
181
|
+
function findExecutableOnPath(executableName, access, stat, executableMode) {
|
|
182
|
+
const pathEnv = readEnvVar("PATH");
|
|
183
|
+
if (!pathEnv) return void 0;
|
|
184
|
+
const pathExts = process.platform === "win32" ? (readEnvVar("PATHEXT") ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((ext) => ext.length > 0) : [""];
|
|
185
|
+
const hasExtension = path.extname(executableName).length > 0;
|
|
186
|
+
for (const dir of pathEnv.split(path.delimiter)) {
|
|
187
|
+
if (!dir) continue;
|
|
188
|
+
const candidateNames = process.platform === "win32" && !hasExtension ? pathExts.map((ext) => `${executableName}${ext}`) : [executableName];
|
|
189
|
+
for (const candidateName of candidateNames) {
|
|
190
|
+
const candidate = path.join(dir, candidateName);
|
|
191
|
+
try {
|
|
192
|
+
access(candidate, executableMode);
|
|
193
|
+
if (!stat(candidate).isFile()) continue;
|
|
194
|
+
return candidate;
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return void 0;
|
|
200
|
+
}
|
|
187
201
|
async function resolveProviderApiKey(providerId, apiKeyValue, gatewayConfig, agentDir) {
|
|
188
202
|
const resolvedAgentDir = path.resolve(
|
|
189
203
|
agentDir ?? path.join(os2.homedir(), ".openclaw", "agents", "main", "agent")
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
parseContinuityImprovementLoops,
|
|
4
4
|
parseContinuityIncident,
|
|
5
5
|
sanitizeMemoryContent
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JJSNPSCD.js";
|
|
7
7
|
import {
|
|
8
8
|
log
|
|
9
9
|
} from "./chunk-UFU5GGGA.js";
|
|
@@ -4881,7 +4881,7 @@ var CompoundingEngine = class {
|
|
|
4881
4881
|
let promotionCandidates = this.config.compoundingSemanticEnabled ? this.derivePromotionCandidates(outcomeSummary, mistakes.registry, rubrics) : [];
|
|
4882
4882
|
if (this.config.cmcConsolidationEnabled) {
|
|
4883
4883
|
try {
|
|
4884
|
-
const { deriveCausalPromotionCandidates, materializeAfterCausalConsolidation } = await import("./causal-consolidation-
|
|
4884
|
+
const { deriveCausalPromotionCandidates, materializeAfterCausalConsolidation } = await import("./causal-consolidation-5BEXLQV5.js");
|
|
4885
4885
|
const causalCandidates = await deriveCausalPromotionCandidates({
|
|
4886
4886
|
memoryDir: this.config.memoryDir,
|
|
4887
4887
|
causalTrajectoryStoreDir: this.config.causalTrajectoryStoreDir,
|
|
@@ -4913,7 +4913,7 @@ var CompoundingEngine = class {
|
|
|
4913
4913
|
}
|
|
4914
4914
|
if (this.config.calibrationEnabled) {
|
|
4915
4915
|
try {
|
|
4916
|
-
const { runCalibrationConsolidation } = await import("./calibration-
|
|
4916
|
+
const { runCalibrationConsolidation } = await import("./calibration-674TDQNV.js");
|
|
4917
4917
|
const calRules = await runCalibrationConsolidation({
|
|
4918
4918
|
memoryDir: this.config.memoryDir,
|
|
4919
4919
|
gatewayConfig: this.config.gatewayConfig,
|