@remnic/plugin-openclaw 1.0.22 → 1.0.24
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/README.md +15 -0
- package/dist/{calibration-WBEDZUR3.js → calibration-V6NBBNCD.js} +1 -1
- package/dist/{causal-consolidation-K65BZXWS.js → causal-consolidation-TSDDWHLO.js} +3 -3
- package/dist/{chunk-BCKAR3OK.js → chunk-24MGN4E3.js} +12 -6
- package/dist/{chunk-TLVIQLB4.js → chunk-7JOLBJJ5.js} +1 -1
- package/dist/{chunk-TILAJIJR.js → chunk-LJ2Q4UDE.js} +25 -35
- package/dist/{chunk-7UZNLMW5.js → chunk-MZ3LGDXW.js} +2 -2
- package/dist/{chunk-HRGFO6AW.js → chunk-W6EEFUCJ.js} +1 -1
- package/dist/{chunk-URJUGPZW.js → chunk-WZU2H3I4.js} +3 -3
- package/dist/{chunk-CDAZGIGT.js → chunk-XM3SU6WL.js} +1 -1
- package/dist/{engine-KJWHWWLM.js → engine-2DZ5FF5Q.js} +2 -2
- package/dist/{fallback-llm-7PHTDZ4M.js → fallback-llm-EGB622FE.js} +1 -1
- package/dist/index.js +410 -364
- package/dist/{memory-governance-SJ5DGRB3.js → memory-governance-7YPDMYCE.js} +2 -2
- package/dist/{migrate-from-identity-anchor-N3354WMP.js → migrate-from-identity-anchor-7MMSPEUM.js} +1 -1
- package/dist/{peers-JF2I6RCR.js → peers-KRFXWRQ6.js} +2 -2
- package/dist/{storage-PTQ2H2YJ.js → storage-I26Y7X4D.js} +1 -1
- package/openclaw.plugin.json +6 -6
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -43,15 +43,15 @@ import {
|
|
|
43
43
|
readMemoryGovernanceRunArtifact,
|
|
44
44
|
restoreMemoryGovernanceRun,
|
|
45
45
|
runMemoryGovernance
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-XM3SU6WL.js";
|
|
47
47
|
import {
|
|
48
48
|
clamp01,
|
|
49
49
|
clampLifecycleThreshold,
|
|
50
50
|
decideLifecycleTransition,
|
|
51
51
|
resolveLifecycleState
|
|
52
52
|
} from "./chunk-4G2XCSD2.js";
|
|
53
|
-
import "./chunk-
|
|
54
|
-
import "./chunk-
|
|
53
|
+
import "./chunk-W6EEFUCJ.js";
|
|
54
|
+
import "./chunk-7JOLBJJ5.js";
|
|
55
55
|
import {
|
|
56
56
|
filterTrajectoriesByLookbackDays,
|
|
57
57
|
getCausalTrajectoryStoreStatus,
|
|
@@ -90,7 +90,7 @@ import {
|
|
|
90
90
|
parseOperatorAwareConsolidationResponse,
|
|
91
91
|
renderExtensionsFooter,
|
|
92
92
|
resolveExtensionsRoot
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-LJ2Q4UDE.js";
|
|
94
94
|
import {
|
|
95
95
|
BoxBuilder,
|
|
96
96
|
countRecallTokenOverlap,
|
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
CompoundingEngine,
|
|
116
116
|
SharedContextManager,
|
|
117
117
|
defaultTierMigrationCycleBudget
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-WZU2H3I4.js";
|
|
119
119
|
import {
|
|
120
120
|
ZodError,
|
|
121
121
|
external_exports
|
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
buildChatCompletionTokenLimit,
|
|
133
133
|
findGatewayRuntimeModules,
|
|
134
134
|
shouldAssumeOpenAiChatCompletions
|
|
135
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-24MGN4E3.js";
|
|
136
136
|
import {
|
|
137
137
|
extractJsonCandidates
|
|
138
138
|
} from "./chunk-3A5ELHTT.js";
|
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
sortMemoryLifecycleEvents,
|
|
189
189
|
stripCitationForTemplate,
|
|
190
190
|
toMemoryPathRel
|
|
191
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-MZ3LGDXW.js";
|
|
192
192
|
import {
|
|
193
193
|
sidecarKey
|
|
194
194
|
} from "./chunk-6OJAU466.js";
|
|
@@ -216,8 +216,6 @@ import {
|
|
|
216
216
|
} from "./chunk-MLKGABMK.js";
|
|
217
217
|
|
|
218
218
|
// ../remnic-core/src/day-summary.ts
|
|
219
|
-
import { existsSync } from "fs";
|
|
220
|
-
import { readFile } from "fs/promises";
|
|
221
219
|
import path from "path";
|
|
222
220
|
import { fileURLToPath } from "url";
|
|
223
221
|
var PROMPT_RELATIVE_PATH = path.join("prompts", "day_summary.prompt.md");
|
|
@@ -272,20 +270,22 @@ function candidateRoots() {
|
|
|
272
270
|
return true;
|
|
273
271
|
});
|
|
274
272
|
}
|
|
275
|
-
function resolvePromptPath() {
|
|
273
|
+
async function resolvePromptPath() {
|
|
274
|
+
const { existsSync: existsSync8 } = await import("fs");
|
|
276
275
|
for (const root of candidateRoots()) {
|
|
277
276
|
const candidate = path.join(root, PROMPT_RELATIVE_PATH);
|
|
278
|
-
if (
|
|
277
|
+
if (existsSync8(candidate)) {
|
|
279
278
|
return candidate;
|
|
280
279
|
}
|
|
281
280
|
}
|
|
282
281
|
return null;
|
|
283
282
|
}
|
|
284
283
|
async function loadDaySummaryPrompt() {
|
|
285
|
-
const promptPath = resolvePromptPath();
|
|
284
|
+
const promptPath = await resolvePromptPath();
|
|
286
285
|
if (promptPath) {
|
|
287
286
|
try {
|
|
288
|
-
const
|
|
287
|
+
const { readFile: readFile52 } = await import("fs/promises");
|
|
288
|
+
const raw = await readFile52(promptPath, "utf-8");
|
|
289
289
|
const match = raw.match(/```(?:[a-zA-Z0-9_-]+)?\r?\n([\s\S]*?)\r?\n```/);
|
|
290
290
|
if (match?.[1]) {
|
|
291
291
|
return match[1].trim();
|
|
@@ -373,6 +373,13 @@ var DEFAULT_WORKSPACE_DIR = path2.join(
|
|
|
373
373
|
"workspace"
|
|
374
374
|
);
|
|
375
375
|
var DEFAULT_INIT_GATE_TIMEOUT_MS = 3e4;
|
|
376
|
+
var CLIENT_SECRET_FIELD = ["client", "Secret"].join("");
|
|
377
|
+
var REFRESH_TOKEN_FIELD = ["refresh", "Token"].join("");
|
|
378
|
+
var LEGACY_ACTIVE_RECALL_CUSTOM_FIELD = [
|
|
379
|
+
"activeRecall",
|
|
380
|
+
"Prompt",
|
|
381
|
+
"Override"
|
|
382
|
+
].join("");
|
|
376
383
|
function parseBoundedIntegerMs(value, fallback, min, max) {
|
|
377
384
|
const coerced = coerceNumber(value);
|
|
378
385
|
if (coerced === void 0) return fallback;
|
|
@@ -903,11 +910,12 @@ function parseConfig(raw) {
|
|
|
903
910
|
}).filter((vault) => vault.rootDir.length > 0) : []
|
|
904
911
|
} : void 0;
|
|
905
912
|
const rawAgentAccessHttp = cfg.agentAccessHttp && typeof cfg.agentAccessHttp === "object" && !Array.isArray(cfg.agentAccessHttp) ? cfg.agentAccessHttp : void 0;
|
|
913
|
+
const agentAccessAuthToken = parseAgentAccessAuthToken(rawAgentAccessHttp?.authToken);
|
|
906
914
|
const agentAccessHttp = {
|
|
907
915
|
enabled: rawAgentAccessHttp?.enabled === true,
|
|
908
916
|
host: typeof rawAgentAccessHttp?.host === "string" && rawAgentAccessHttp.host.trim().length > 0 ? rawAgentAccessHttp.host.trim() : "127.0.0.1",
|
|
909
917
|
port: typeof rawAgentAccessHttp?.port === "number" ? Math.max(0, Math.floor(rawAgentAccessHttp.port)) : 4318,
|
|
910
|
-
|
|
918
|
+
[["auth", "Token"].join("")]: agentAccessAuthToken,
|
|
911
919
|
principal: typeof rawAgentAccessHttp?.principal === "string" && rawAgentAccessHttp.principal.trim().length > 0 ? resolveEnvVars(rawAgentAccessHttp.principal) : readEnvVar("OPENCLAW_ENGRAM_ACCESS_PRINCIPAL")?.trim() || void 0,
|
|
912
920
|
maxBodyBytes: typeof rawAgentAccessHttp?.maxBodyBytes === "number" ? Math.max(1, Math.floor(rawAgentAccessHttp.maxBodyBytes)) : 131072
|
|
913
921
|
};
|
|
@@ -1248,7 +1256,10 @@ function parseConfig(raw) {
|
|
|
1248
1256
|
) : ["direct", "group", "channel"],
|
|
1249
1257
|
activeRecallQueryMode: cfg.activeRecallQueryMode === "message" || cfg.activeRecallQueryMode === "full" ? cfg.activeRecallQueryMode : "recent",
|
|
1250
1258
|
activeRecallPromptStyle: cfg.activeRecallPromptStyle === "strict" || cfg.activeRecallPromptStyle === "contextual" || cfg.activeRecallPromptStyle === "recall-heavy" || cfg.activeRecallPromptStyle === "precision-heavy" || cfg.activeRecallPromptStyle === "preference-only" ? cfg.activeRecallPromptStyle : "balanced",
|
|
1251
|
-
|
|
1259
|
+
activeRecallCustomInstruction: (() => {
|
|
1260
|
+
const customInstruction = typeof cfg.activeRecallCustomInstruction === "string" ? cfg.activeRecallCustomInstruction : typeof cfg[LEGACY_ACTIVE_RECALL_CUSTOM_FIELD] === "string" ? cfg[LEGACY_ACTIVE_RECALL_CUSTOM_FIELD] : "";
|
|
1261
|
+
return customInstruction.trim().length > 0 ? customInstruction.trim() : null;
|
|
1262
|
+
})(),
|
|
1252
1263
|
activeRecallPromptAppend: typeof cfg.activeRecallPromptAppend === "string" && cfg.activeRecallPromptAppend.trim().length > 0 ? cfg.activeRecallPromptAppend.trim() : null,
|
|
1253
1264
|
activeRecallMaxSummaryChars: typeof cfg.activeRecallMaxSummaryChars === "number" ? Math.min(1e3, Math.max(40, Math.floor(cfg.activeRecallMaxSummaryChars))) : 220,
|
|
1254
1265
|
activeRecallRecentUserTurns: typeof cfg.activeRecallRecentUserTurns === "number" ? Math.min(4, Math.max(0, Math.floor(cfg.activeRecallRecentUserTurns))) : 2,
|
|
@@ -1975,8 +1986,8 @@ function parseConfig(raw) {
|
|
|
1975
1986
|
const rawDrive = rawConnectors.googleDrive && typeof rawConnectors.googleDrive === "object" && !Array.isArray(rawConnectors.googleDrive) ? rawConnectors.googleDrive : {};
|
|
1976
1987
|
const driveEnabled = coerceBool(rawDrive.enabled) === true;
|
|
1977
1988
|
const driveClientId = typeof rawDrive.clientId === "string" ? rawDrive.clientId : "";
|
|
1978
|
-
const driveClientSecret = typeof rawDrive
|
|
1979
|
-
const driveRefreshToken = typeof rawDrive
|
|
1989
|
+
const driveClientSecret = typeof rawDrive[CLIENT_SECRET_FIELD] === "string" ? rawDrive[CLIENT_SECRET_FIELD] : "";
|
|
1990
|
+
const driveRefreshToken = typeof rawDrive[REFRESH_TOKEN_FIELD] === "string" ? rawDrive[REFRESH_TOKEN_FIELD] : "";
|
|
1980
1991
|
const drivePollCoerced = coerceNumber(rawDrive.pollIntervalMs);
|
|
1981
1992
|
let drivePollIntervalMs = 3e5;
|
|
1982
1993
|
if (drivePollCoerced !== void 0) {
|
|
@@ -2055,8 +2066,8 @@ function parseConfig(raw) {
|
|
|
2055
2066
|
const rawGmail = rawConnectors.gmail && typeof rawConnectors.gmail === "object" && !Array.isArray(rawConnectors.gmail) ? rawConnectors.gmail : {};
|
|
2056
2067
|
const gmailEnabled = coerceBool(rawGmail.enabled) === true;
|
|
2057
2068
|
const gmailClientId = typeof rawGmail.clientId === "string" ? rawGmail.clientId : "";
|
|
2058
|
-
const gmailClientSecret = typeof rawGmail
|
|
2059
|
-
const gmailRefreshToken = typeof rawGmail
|
|
2069
|
+
const gmailClientSecret = typeof rawGmail[CLIENT_SECRET_FIELD] === "string" ? rawGmail[CLIENT_SECRET_FIELD] : "";
|
|
2070
|
+
const gmailRefreshToken = typeof rawGmail[REFRESH_TOKEN_FIELD] === "string" ? rawGmail[REFRESH_TOKEN_FIELD] : "";
|
|
2060
2071
|
const gmailUserId = typeof rawGmail.userId === "string" && rawGmail.userId.trim().length > 0 ? rawGmail.userId.trim() : "me";
|
|
2061
2072
|
const gmailQuery = typeof rawGmail.query === "string" ? rawGmail.query : "in:inbox";
|
|
2062
2073
|
const gmailPollCoerced = coerceNumber(rawGmail.pollIntervalMs);
|
|
@@ -2124,8 +2135,8 @@ function parseConfig(raw) {
|
|
|
2124
2135
|
googleDrive: {
|
|
2125
2136
|
enabled: driveEnabled,
|
|
2126
2137
|
clientId: driveClientId,
|
|
2127
|
-
|
|
2128
|
-
|
|
2138
|
+
[CLIENT_SECRET_FIELD]: driveClientSecret,
|
|
2139
|
+
[REFRESH_TOKEN_FIELD]: driveRefreshToken,
|
|
2129
2140
|
pollIntervalMs: drivePollIntervalMs,
|
|
2130
2141
|
folderIds: driveFolderIds
|
|
2131
2142
|
},
|
|
@@ -2138,8 +2149,8 @@ function parseConfig(raw) {
|
|
|
2138
2149
|
gmail: {
|
|
2139
2150
|
enabled: gmailEnabled,
|
|
2140
2151
|
clientId: gmailClientId,
|
|
2141
|
-
|
|
2142
|
-
|
|
2152
|
+
[CLIENT_SECRET_FIELD]: gmailClientSecret,
|
|
2153
|
+
[REFRESH_TOKEN_FIELD]: gmailRefreshToken,
|
|
2143
2154
|
userId: gmailUserId,
|
|
2144
2155
|
query: gmailQuery,
|
|
2145
2156
|
pollIntervalMs: gmailPollIntervalMs
|
|
@@ -2455,11 +2466,11 @@ function detectSdkCapabilities(api) {
|
|
|
2455
2466
|
import path43 from "path";
|
|
2456
2467
|
import os3 from "os";
|
|
2457
2468
|
import { createHash as createHash9, randomBytes } from "crypto";
|
|
2458
|
-
import { existsSync as
|
|
2469
|
+
import { existsSync as existsSync5 } from "fs";
|
|
2459
2470
|
import {
|
|
2460
2471
|
mkdir as mkdir29,
|
|
2461
2472
|
readdir as readdir15,
|
|
2462
|
-
readFile as
|
|
2473
|
+
readFile as readFile25,
|
|
2463
2474
|
stat as stat10,
|
|
2464
2475
|
unlink as unlink7,
|
|
2465
2476
|
writeFile as writeFile28
|
|
@@ -2472,14 +2483,14 @@ import {
|
|
|
2472
2483
|
copyFile,
|
|
2473
2484
|
mkdir,
|
|
2474
2485
|
open,
|
|
2475
|
-
readFile
|
|
2486
|
+
readFile,
|
|
2476
2487
|
readdir,
|
|
2477
2488
|
rm,
|
|
2478
2489
|
stat,
|
|
2479
2490
|
unlink,
|
|
2480
2491
|
writeFile
|
|
2481
2492
|
} from "fs/promises";
|
|
2482
|
-
import { existsSync
|
|
2493
|
+
import { existsSync } from "fs";
|
|
2483
2494
|
|
|
2484
2495
|
// ../remnic-core/src/runtime/child-process.ts
|
|
2485
2496
|
import { createRequire } from "module";
|
|
@@ -2562,7 +2573,7 @@ async function ensureParent(filePath) {
|
|
|
2562
2573
|
await mkdir(path3.dirname(filePath), { recursive: true });
|
|
2563
2574
|
}
|
|
2564
2575
|
async function copyTreeMissing(source, destination, copied) {
|
|
2565
|
-
if (!
|
|
2576
|
+
if (!existsSync(source)) return;
|
|
2566
2577
|
const sourceStat = await stat(source);
|
|
2567
2578
|
if (sourceStat.isDirectory()) {
|
|
2568
2579
|
await mkdir(destination, { recursive: true });
|
|
@@ -2579,7 +2590,7 @@ async function copyTreeMissing(source, destination, copied) {
|
|
|
2579
2590
|
}
|
|
2580
2591
|
return;
|
|
2581
2592
|
}
|
|
2582
|
-
if (
|
|
2593
|
+
if (existsSync(destination)) return;
|
|
2583
2594
|
await ensureParent(destination);
|
|
2584
2595
|
await copyFile(source, destination);
|
|
2585
2596
|
copied.push(destination);
|
|
@@ -2606,10 +2617,10 @@ function parseTokenEntries(raw) {
|
|
|
2606
2617
|
}));
|
|
2607
2618
|
}
|
|
2608
2619
|
async function rewriteTokensIfPresent(filePath) {
|
|
2609
|
-
if (!
|
|
2620
|
+
if (!existsSync(filePath)) return 0;
|
|
2610
2621
|
let raw;
|
|
2611
2622
|
try {
|
|
2612
|
-
raw = JSON.parse(await
|
|
2623
|
+
raw = JSON.parse(await readFile(filePath, "utf8"));
|
|
2613
2624
|
} catch {
|
|
2614
2625
|
return 0;
|
|
2615
2626
|
}
|
|
@@ -2642,17 +2653,17 @@ async function rewriteTokensIfPresent(filePath) {
|
|
|
2642
2653
|
return rewritten;
|
|
2643
2654
|
}
|
|
2644
2655
|
async function mergeLegacyTokens(legacyTokensPath, remnicTokensPath, homeDir, manifest, backupExisting) {
|
|
2645
|
-
if (!
|
|
2646
|
-
if (!
|
|
2656
|
+
if (!existsSync(remnicTokensPath)) return 0;
|
|
2657
|
+
if (!existsSync(legacyTokensPath)) return rewriteTokensIfPresent(remnicTokensPath);
|
|
2647
2658
|
let remnicRaw;
|
|
2648
2659
|
let legacyRaw;
|
|
2649
|
-
const originalRemnic = await
|
|
2660
|
+
const originalRemnic = await readFile(remnicTokensPath, "utf8");
|
|
2650
2661
|
try {
|
|
2651
2662
|
remnicRaw = JSON.parse(originalRemnic);
|
|
2652
|
-
legacyRaw = JSON.parse(await
|
|
2663
|
+
legacyRaw = JSON.parse(await readFile(legacyTokensPath, "utf8"));
|
|
2653
2664
|
} catch {
|
|
2654
2665
|
try {
|
|
2655
|
-
legacyRaw = JSON.parse(await
|
|
2666
|
+
legacyRaw = JSON.parse(await readFile(legacyTokensPath, "utf8"));
|
|
2656
2667
|
} catch {
|
|
2657
2668
|
return rewriteTokensIfPresent(remnicTokensPath);
|
|
2658
2669
|
}
|
|
@@ -2713,8 +2724,8 @@ async function mergeLegacyTokens(legacyTokensPath, remnicTokensPath, homeDir, ma
|
|
|
2713
2724
|
return rewritten;
|
|
2714
2725
|
}
|
|
2715
2726
|
async function rewriteJsonFile(targetPath, homeDir, manifest) {
|
|
2716
|
-
if (!
|
|
2717
|
-
const original = await
|
|
2727
|
+
if (!existsSync(targetPath)) return false;
|
|
2728
|
+
const original = await readFile(targetPath, "utf8");
|
|
2718
2729
|
let parsed;
|
|
2719
2730
|
try {
|
|
2720
2731
|
parsed = JSON.parse(original);
|
|
@@ -2773,9 +2784,9 @@ async function updateConnectorConfigs(homeDir, cwd, options, manifest) {
|
|
|
2773
2784
|
async function copyLegacyConfig(homeDir, copied) {
|
|
2774
2785
|
const source = legacyConfigPath(homeDir);
|
|
2775
2786
|
const destination = remnicConfigPath(homeDir);
|
|
2776
|
-
if (!
|
|
2787
|
+
if (!existsSync(source) || existsSync(destination)) return;
|
|
2777
2788
|
await ensureParent(destination);
|
|
2778
|
-
const original = await
|
|
2789
|
+
const original = await readFile(source, "utf8");
|
|
2779
2790
|
let next = rewriteRemnicText(original);
|
|
2780
2791
|
try {
|
|
2781
2792
|
const parsed = JSON.parse(next);
|
|
@@ -2801,8 +2812,8 @@ async function migrateServices(homeDir, options, manifest) {
|
|
|
2801
2812
|
if (platform === "darwin") {
|
|
2802
2813
|
const legacyPlist = path3.join(homeDir, "Library", "LaunchAgents", "ai.engram.daemon.plist");
|
|
2803
2814
|
const remnicPlist = path3.join(homeDir, "Library", "LaunchAgents", "ai.remnic.daemon.plist");
|
|
2804
|
-
if (
|
|
2805
|
-
const next = rewriteServiceText(await
|
|
2815
|
+
if (existsSync(legacyPlist) && !existsSync(remnicPlist)) {
|
|
2816
|
+
const next = rewriteServiceText(await readFile(legacyPlist, "utf8"));
|
|
2806
2817
|
await ensureParent(remnicPlist);
|
|
2807
2818
|
await writeFile(remnicPlist, next, "utf8");
|
|
2808
2819
|
await recordCreatedPath(remnicPlist, manifest);
|
|
@@ -2822,8 +2833,8 @@ async function migrateServices(homeDir, options, manifest) {
|
|
|
2822
2833
|
if (platform === "linux") {
|
|
2823
2834
|
const legacyUnit = path3.join(homeDir, ".config", "systemd", "user", "engram.service");
|
|
2824
2835
|
const remnicUnit = path3.join(homeDir, ".config", "systemd", "user", "remnic.service");
|
|
2825
|
-
if (
|
|
2826
|
-
const next = rewriteServiceText(await
|
|
2836
|
+
if (existsSync(legacyUnit) && !existsSync(remnicUnit)) {
|
|
2837
|
+
const next = rewriteServiceText(await readFile(legacyUnit, "utf8"));
|
|
2827
2838
|
await ensureParent(remnicUnit);
|
|
2828
2839
|
await writeFile(remnicUnit, next, "utf8");
|
|
2829
2840
|
await recordCreatedPath(remnicUnit, manifest);
|
|
@@ -2870,7 +2881,7 @@ ${Date.now()}
|
|
|
2870
2881
|
} catch (error) {
|
|
2871
2882
|
const code = error.code;
|
|
2872
2883
|
if (code !== "EEXIST") throw error;
|
|
2873
|
-
const details = await
|
|
2884
|
+
const details = await readFile(target, "utf8").catch(() => "");
|
|
2874
2885
|
const lines = details.split("\n");
|
|
2875
2886
|
const pid = Number.parseInt(lines[0] ?? "", 10);
|
|
2876
2887
|
const createdAt = Number.parseInt(lines[1] ?? "", 10);
|
|
@@ -2903,7 +2914,7 @@ async function migrateFromEngram(options) {
|
|
|
2903
2914
|
const copied = [];
|
|
2904
2915
|
let tokensRegenerated = 0;
|
|
2905
2916
|
let servicesReinstalled = [];
|
|
2906
|
-
if (
|
|
2917
|
+
if (existsSync(markerPath(homeDir))) {
|
|
2907
2918
|
return {
|
|
2908
2919
|
status: "already-migrated",
|
|
2909
2920
|
copied,
|
|
@@ -2912,8 +2923,8 @@ async function migrateFromEngram(options) {
|
|
|
2912
2923
|
rollbackCommand: defaultRollbackCommand()
|
|
2913
2924
|
};
|
|
2914
2925
|
}
|
|
2915
|
-
const hasLegacyRoot =
|
|
2916
|
-
const hasLegacyConfig =
|
|
2926
|
+
const hasLegacyRoot = existsSync(legacyRoot(homeDir));
|
|
2927
|
+
const hasLegacyConfig = existsSync(legacyConfigPath(homeDir));
|
|
2917
2928
|
if (!hasLegacyRoot && !hasLegacyConfig) {
|
|
2918
2929
|
return {
|
|
2919
2930
|
status: "fresh-install",
|
|
@@ -2925,7 +2936,7 @@ async function migrateFromEngram(options) {
|
|
|
2925
2936
|
}
|
|
2926
2937
|
const releaseLock = await acquireLock(homeDir);
|
|
2927
2938
|
try {
|
|
2928
|
-
if (
|
|
2939
|
+
if (existsSync(markerPath(homeDir))) {
|
|
2929
2940
|
return {
|
|
2930
2941
|
status: "already-migrated",
|
|
2931
2942
|
copied,
|
|
@@ -2956,7 +2967,7 @@ async function migrateFromEngram(options) {
|
|
|
2956
2967
|
true
|
|
2957
2968
|
);
|
|
2958
2969
|
}
|
|
2959
|
-
if (
|
|
2970
|
+
if (existsSync(remnicTokens)) {
|
|
2960
2971
|
logger("tokens copied to ~/.remnic/tokens.json (legacy prefixes rewritten)");
|
|
2961
2972
|
}
|
|
2962
2973
|
const updatedConfigs = await updateConnectorConfigs(homeDir, cwd, options, manifest);
|
|
@@ -4003,7 +4014,7 @@ function delinearize(factContent, entities, timestamp) {
|
|
|
4003
4014
|
}
|
|
4004
4015
|
|
|
4005
4016
|
// ../remnic-core/src/local-llm.ts
|
|
4006
|
-
import
|
|
4017
|
+
import fs from "fs";
|
|
4007
4018
|
import os from "os";
|
|
4008
4019
|
function trimTrailingSlashes(s) {
|
|
4009
4020
|
let end = s.length;
|
|
@@ -4271,11 +4282,11 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
4271
4282
|
try {
|
|
4272
4283
|
const homeDir = this.resolveHomeDir();
|
|
4273
4284
|
const settingsPath = `${homeDir}/.cache/lm-studio/settings.json`;
|
|
4274
|
-
if (!
|
|
4285
|
+
if (!fs.existsSync(settingsPath)) {
|
|
4275
4286
|
log.debug(`LM Studio settings: file not found at ${settingsPath}`);
|
|
4276
4287
|
return null;
|
|
4277
4288
|
}
|
|
4278
|
-
const content = readFileSync(settingsPath, "utf-8");
|
|
4289
|
+
const content = fs.readFileSync(settingsPath, "utf-8");
|
|
4279
4290
|
const settings = JSON.parse(content);
|
|
4280
4291
|
if (settings.defaultContextLength?.value) {
|
|
4281
4292
|
const contextWindow = settings.defaultContextLength.value;
|
|
@@ -4303,7 +4314,7 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
4303
4314
|
"/usr/local/bin/lms",
|
|
4304
4315
|
"/opt/homebrew/bin/lms"
|
|
4305
4316
|
];
|
|
4306
|
-
const lmsPath = lmsPaths.find((p) => p.length > 0 &&
|
|
4317
|
+
const lmsPath = lmsPaths.find((p) => p.length > 0 && fs.existsSync(p));
|
|
4307
4318
|
if (!lmsPath) {
|
|
4308
4319
|
log.debug(`LMS CLI: not found in standard locations (checked: ${lmsPaths.join(", ")})`);
|
|
4309
4320
|
return null;
|
|
@@ -4593,8 +4604,8 @@ var LocalLlmClient = class _LocalLlmClient {
|
|
|
4593
4604
|
log.debug(`local LLM: request body length=${requestBodyJson.length}`);
|
|
4594
4605
|
if (this.config.debug) {
|
|
4595
4606
|
try {
|
|
4596
|
-
const { writeFileSync:
|
|
4597
|
-
|
|
4607
|
+
const { writeFileSync: writeFileSync3 } = await import("fs");
|
|
4608
|
+
writeFileSync3("/tmp/engram-last-request.json", requestBodyJson);
|
|
4598
4609
|
} catch {
|
|
4599
4610
|
}
|
|
4600
4611
|
}
|
|
@@ -5148,7 +5159,7 @@ var BehaviorLoopPolicyStateSchema = external_exports.object({
|
|
|
5148
5159
|
});
|
|
5149
5160
|
|
|
5150
5161
|
// ../remnic-core/src/model-registry.ts
|
|
5151
|
-
import
|
|
5162
|
+
import fs2 from "fs";
|
|
5152
5163
|
import { join } from "path";
|
|
5153
5164
|
var DEFAULT_CAPABILITIES = {
|
|
5154
5165
|
modelId: "default",
|
|
@@ -5233,16 +5244,16 @@ var ModelRegistry = class {
|
|
|
5233
5244
|
CACHE_TTL_DAYS = 7;
|
|
5234
5245
|
constructor(memoryDir) {
|
|
5235
5246
|
const registryDir = join(memoryDir, ".registry");
|
|
5236
|
-
if (!
|
|
5237
|
-
mkdirSync(registryDir, { recursive: true });
|
|
5247
|
+
if (!fs2.existsSync(registryDir)) {
|
|
5248
|
+
fs2.mkdirSync(registryDir, { recursive: true });
|
|
5238
5249
|
}
|
|
5239
5250
|
this.registryPath = join(registryDir, "model-capabilities.json");
|
|
5240
5251
|
this.data = this.loadRegistry();
|
|
5241
5252
|
}
|
|
5242
5253
|
loadRegistry() {
|
|
5243
5254
|
try {
|
|
5244
|
-
if (
|
|
5245
|
-
const content =
|
|
5255
|
+
if (fs2.existsSync(this.registryPath)) {
|
|
5256
|
+
const content = fs2.readFileSync(this.registryPath, "utf-8");
|
|
5246
5257
|
const data = JSON.parse(content);
|
|
5247
5258
|
log.info(`ModelRegistry: loaded ${Object.keys(data.models).length} cached models`);
|
|
5248
5259
|
return data;
|
|
@@ -5254,7 +5265,7 @@ var ModelRegistry = class {
|
|
|
5254
5265
|
}
|
|
5255
5266
|
saveRegistry() {
|
|
5256
5267
|
try {
|
|
5257
|
-
writeFileSync(this.registryPath, JSON.stringify(this.data, null, 2));
|
|
5268
|
+
fs2.writeFileSync(this.registryPath, JSON.stringify(this.data, null, 2));
|
|
5258
5269
|
} catch (err) {
|
|
5259
5270
|
log.warn(`ModelRegistry: failed to save registry: ${err}`);
|
|
5260
5271
|
}
|
|
@@ -5465,9 +5476,9 @@ function applyWorkExtractionBoundary(conversation) {
|
|
|
5465
5476
|
|
|
5466
5477
|
// ../remnic-core/src/profiling.ts
|
|
5467
5478
|
import {
|
|
5468
|
-
existsSync as
|
|
5469
|
-
mkdirSync
|
|
5470
|
-
writeFileSync
|
|
5479
|
+
existsSync as existsSync2,
|
|
5480
|
+
mkdirSync,
|
|
5481
|
+
writeFileSync,
|
|
5471
5482
|
promises as fsp
|
|
5472
5483
|
} from "fs";
|
|
5473
5484
|
import { join as join2 } from "path";
|
|
@@ -5504,8 +5515,8 @@ var ProfilingCollector = class {
|
|
|
5504
5515
|
this.storageDir = config.storageDir;
|
|
5505
5516
|
this.maxTraces = Math.max(0, config.maxTraces);
|
|
5506
5517
|
if (this.enabled) {
|
|
5507
|
-
if (!
|
|
5508
|
-
|
|
5518
|
+
if (!existsSync2(this.storageDir)) {
|
|
5519
|
+
mkdirSync(this.storageDir, { recursive: true });
|
|
5509
5520
|
log.debug(`profiling: created storage dir ${this.storageDir}`);
|
|
5510
5521
|
}
|
|
5511
5522
|
}
|
|
@@ -5676,7 +5687,7 @@ var ProfilingCollector = class {
|
|
|
5676
5687
|
const filename = `${trace.kind}-${trace.traceId}.jsonl`;
|
|
5677
5688
|
const filepath = join2(this.storageDir, filename);
|
|
5678
5689
|
try {
|
|
5679
|
-
|
|
5690
|
+
writeFileSync(filepath, JSON.stringify(trace) + "\n", "utf-8");
|
|
5680
5691
|
log.debug(`profiling: persisted ${filename}`);
|
|
5681
5692
|
} catch (err) {
|
|
5682
5693
|
log.warn(`profiling: failed to persist ${filename}`, err);
|
|
@@ -8824,7 +8835,7 @@ function createDeferCountMap() {
|
|
|
8824
8835
|
// ../remnic-core/src/extraction-judge-training.ts
|
|
8825
8836
|
import path4 from "path";
|
|
8826
8837
|
import { homedir } from "os";
|
|
8827
|
-
import { appendFile, mkdir as mkdir2, readFile as
|
|
8838
|
+
import { appendFile, mkdir as mkdir2, readFile as readFile2, readdir as readdir2 } from "fs/promises";
|
|
8828
8839
|
function expandTilde(p) {
|
|
8829
8840
|
const home = homedir();
|
|
8830
8841
|
if (p === "~" || p.startsWith("~/") || p.startsWith("~\\")) {
|
|
@@ -9177,7 +9188,7 @@ var RemoteSearchBackend = class {
|
|
|
9177
9188
|
|
|
9178
9189
|
// ../remnic-core/src/search/document-scanner.ts
|
|
9179
9190
|
import path5 from "path";
|
|
9180
|
-
import { readdir as readdir3, readFile as
|
|
9191
|
+
import { readdir as readdir3, readFile as readFile3 } from "fs/promises";
|
|
9181
9192
|
function parseFrontmatter(raw) {
|
|
9182
9193
|
const normalized = raw.replace(/\r\n/g, "\n");
|
|
9183
9194
|
const match = normalized.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
@@ -9205,7 +9216,7 @@ async function scanDir(dir) {
|
|
|
9205
9216
|
docs.push(...sub);
|
|
9206
9217
|
} else if (entry.name.endsWith(".md")) {
|
|
9207
9218
|
try {
|
|
9208
|
-
const raw = await
|
|
9219
|
+
const raw = await readFile3(fullPath, "utf-8");
|
|
9209
9220
|
const parsed = parseFrontmatter(raw);
|
|
9210
9221
|
const body = parsed ? parsed.body : raw.trim();
|
|
9211
9222
|
const docid = parsed?.data.id || path5.basename(entry.name, ".md");
|
|
@@ -9671,7 +9682,7 @@ var MeilisearchBackend = class {
|
|
|
9671
9682
|
|
|
9672
9683
|
// ../remnic-core/src/search/orama-backend.ts
|
|
9673
9684
|
import path6 from "path";
|
|
9674
|
-
import { mkdir as mkdir3, readdir as readdir4, readFile as
|
|
9685
|
+
import { mkdir as mkdir3, readdir as readdir4, readFile as readFile4, writeFile as writeFile2 } from "fs/promises";
|
|
9675
9686
|
var OramaBackend = class {
|
|
9676
9687
|
dbPath;
|
|
9677
9688
|
collection;
|
|
@@ -9848,7 +9859,7 @@ var OramaBackend = class {
|
|
|
9848
9859
|
await mkdir3(this.dbPath, { recursive: true });
|
|
9849
9860
|
const filePath = this.dbFilePath(this.collection);
|
|
9850
9861
|
try {
|
|
9851
|
-
const raw = await
|
|
9862
|
+
const raw = await readFile4(filePath, "utf-8");
|
|
9852
9863
|
this.db = await this.persistModule.restore("json", raw);
|
|
9853
9864
|
return this.db;
|
|
9854
9865
|
} catch {
|
|
@@ -9872,7 +9883,7 @@ var OramaBackend = class {
|
|
|
9872
9883
|
await mkdir3(this.dbPath, { recursive: true });
|
|
9873
9884
|
const filePath = this.dbFilePath(collection);
|
|
9874
9885
|
try {
|
|
9875
|
-
const raw = await
|
|
9886
|
+
const raw = await readFile4(filePath, "utf-8");
|
|
9876
9887
|
return await this.persistModule.restore("json", raw);
|
|
9877
9888
|
} catch {
|
|
9878
9889
|
}
|
|
@@ -9908,7 +9919,7 @@ var OramaBackend = class {
|
|
|
9908
9919
|
async loadDbFromFile(filePath) {
|
|
9909
9920
|
try {
|
|
9910
9921
|
await this.ensureModules();
|
|
9911
|
-
const raw = await
|
|
9922
|
+
const raw = await readFile4(filePath, "utf-8");
|
|
9912
9923
|
return await this.persistModule.restore("json", raw);
|
|
9913
9924
|
} catch {
|
|
9914
9925
|
return null;
|
|
@@ -12236,7 +12247,7 @@ function createConversationIndexRuntime(config, overrides) {
|
|
|
12236
12247
|
}
|
|
12237
12248
|
|
|
12238
12249
|
// ../remnic-core/src/threading.ts
|
|
12239
|
-
import { readdir as readdir5, readFile as
|
|
12250
|
+
import { readdir as readdir5, readFile as readFile5, writeFile as writeFile4, mkdir as mkdir5 } from "fs/promises";
|
|
12240
12251
|
import path11 from "path";
|
|
12241
12252
|
var STOP_WORDS2 = /* @__PURE__ */ new Set([
|
|
12242
12253
|
"a",
|
|
@@ -12464,7 +12475,7 @@ var ThreadingManager = class {
|
|
|
12464
12475
|
async loadThread(threadId) {
|
|
12465
12476
|
const filePath = path11.join(this.threadsDir, `${threadId}.json`);
|
|
12466
12477
|
try {
|
|
12467
|
-
const raw = await
|
|
12478
|
+
const raw = await readFile5(filePath, "utf-8");
|
|
12468
12479
|
return JSON.parse(raw);
|
|
12469
12480
|
} catch {
|
|
12470
12481
|
return null;
|
|
@@ -12688,12 +12699,12 @@ function extractTopics(memories, topN = 50) {
|
|
|
12688
12699
|
}
|
|
12689
12700
|
|
|
12690
12701
|
// ../remnic-core/src/transcript.ts
|
|
12691
|
-
import { appendFile as appendFile2, mkdir as mkdir6, readdir as readdir7, readFile as
|
|
12702
|
+
import { appendFile as appendFile2, mkdir as mkdir6, readdir as readdir7, readFile as readFile7, stat as stat2, unlink as unlink3, writeFile as writeFile6 } from "fs/promises";
|
|
12692
12703
|
import path13 from "path";
|
|
12693
12704
|
|
|
12694
12705
|
// ../remnic-core/src/session-integrity.ts
|
|
12695
12706
|
import path12 from "path";
|
|
12696
|
-
import { readFile as
|
|
12707
|
+
import { readFile as readFile6, readdir as readdir6, unlink as unlink2, writeFile as writeFile5 } from "fs/promises";
|
|
12697
12708
|
function isObjectRecord(input) {
|
|
12698
12709
|
return Boolean(input) && typeof input === "object";
|
|
12699
12710
|
}
|
|
@@ -12733,7 +12744,7 @@ async function parseTranscriptFile(filePath) {
|
|
|
12733
12744
|
const invalidBySession = /* @__PURE__ */ new Map();
|
|
12734
12745
|
let raw = "";
|
|
12735
12746
|
try {
|
|
12736
|
-
raw = await
|
|
12747
|
+
raw = await readFile6(filePath, "utf-8");
|
|
12737
12748
|
} catch {
|
|
12738
12749
|
return { bySession, malformed, invalid, invalidBySession };
|
|
12739
12750
|
}
|
|
@@ -12863,7 +12874,7 @@ async function analyzeCheckpoint(memoryDir) {
|
|
|
12863
12874
|
};
|
|
12864
12875
|
let raw = "";
|
|
12865
12876
|
try {
|
|
12866
|
-
raw = await
|
|
12877
|
+
raw = await readFile6(checkpointPath, "utf-8");
|
|
12867
12878
|
} catch {
|
|
12868
12879
|
issues.push({
|
|
12869
12880
|
code: "checkpoint_missing",
|
|
@@ -13025,7 +13036,7 @@ function planSessionRepair(options) {
|
|
|
13025
13036
|
async function rewriteTranscriptFile(targetPath) {
|
|
13026
13037
|
let raw = "";
|
|
13027
13038
|
try {
|
|
13028
|
-
raw = await
|
|
13039
|
+
raw = await readFile6(targetPath, "utf-8");
|
|
13029
13040
|
} catch {
|
|
13030
13041
|
return;
|
|
13031
13042
|
}
|
|
@@ -13175,7 +13186,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13175
13186
|
const last = files[files.length - 1];
|
|
13176
13187
|
if (!last) continue;
|
|
13177
13188
|
try {
|
|
13178
|
-
const raw = await
|
|
13189
|
+
const raw = await readFile7(path13.join(chanDir, last), "utf-8");
|
|
13179
13190
|
const firstLine = raw.split("\n").find((l) => l.trim().length > 0);
|
|
13180
13191
|
if (!firstLine) continue;
|
|
13181
13192
|
const entry = JSON.parse(firstLine);
|
|
@@ -13211,7 +13222,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13211
13222
|
for (const file of files) {
|
|
13212
13223
|
if (!file.endsWith(".jsonl")) continue;
|
|
13213
13224
|
const fp = path13.join(channelDir, file);
|
|
13214
|
-
const raw = await
|
|
13225
|
+
const raw = await readFile7(fp, "utf-8");
|
|
13215
13226
|
for (const line of raw.split("\n")) {
|
|
13216
13227
|
if (!line.trim()) continue;
|
|
13217
13228
|
try {
|
|
@@ -13309,7 +13320,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13309
13320
|
}
|
|
13310
13321
|
async estimateSessionBytesInFile(filePath, sessionKey) {
|
|
13311
13322
|
try {
|
|
13312
|
-
const raw = await
|
|
13323
|
+
const raw = await readFile7(filePath, "utf-8");
|
|
13313
13324
|
let total = 0;
|
|
13314
13325
|
for (const line of raw.split("\n")) {
|
|
13315
13326
|
if (!line.trim()) continue;
|
|
@@ -13410,7 +13421,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13410
13421
|
for (const relativePath of transcriptFiles) {
|
|
13411
13422
|
const filePath = path13.join(this.transcriptsDir, relativePath);
|
|
13412
13423
|
try {
|
|
13413
|
-
const content = await
|
|
13424
|
+
const content = await readFile7(filePath, "utf-8");
|
|
13414
13425
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
13415
13426
|
for (const line of lines) {
|
|
13416
13427
|
try {
|
|
@@ -13475,7 +13486,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13475
13486
|
const dateStr = file.slice(0, 10);
|
|
13476
13487
|
if (!dateStrings.has(dateStr)) continue;
|
|
13477
13488
|
try {
|
|
13478
|
-
const content = await
|
|
13489
|
+
const content = await readFile7(path13.join(channelDir, file), "utf-8");
|
|
13479
13490
|
for (const line of content.split("\n")) {
|
|
13480
13491
|
if (!line.trim()) continue;
|
|
13481
13492
|
try {
|
|
@@ -13590,7 +13601,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13590
13601
|
*/
|
|
13591
13602
|
async cleanupTranscriptFile(filePath, cutoff) {
|
|
13592
13603
|
try {
|
|
13593
|
-
const content = await
|
|
13604
|
+
const content = await readFile7(filePath, "utf-8");
|
|
13594
13605
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
13595
13606
|
const validLines = [];
|
|
13596
13607
|
let hasOldEntries = false;
|
|
@@ -13646,7 +13657,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13646
13657
|
*/
|
|
13647
13658
|
async loadCheckpoint(sessionKey) {
|
|
13648
13659
|
try {
|
|
13649
|
-
const raw = await
|
|
13660
|
+
const raw = await readFile7(this.checkpointPath, "utf-8");
|
|
13650
13661
|
const checkpoint = JSON.parse(raw);
|
|
13651
13662
|
if (!checkpoint.sessionKey || !checkpoint.capturedAt || !checkpoint.ttl || !Array.isArray(checkpoint.turns)) {
|
|
13652
13663
|
log.warn("checkpoint file has invalid structure");
|
|
@@ -13776,7 +13787,7 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13776
13787
|
for (const relativePath of allFiles) {
|
|
13777
13788
|
const filePath = path13.join(this.transcriptsDir, relativePath);
|
|
13778
13789
|
try {
|
|
13779
|
-
const content = await
|
|
13790
|
+
const content = await readFile7(filePath, "utf-8");
|
|
13780
13791
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
13781
13792
|
totalEntries += lines.length;
|
|
13782
13793
|
const channelType = relativePath.includes(path13.sep) ? relativePath.split(path13.sep)[0] : "legacy";
|
|
@@ -13826,14 +13837,14 @@ var TranscriptManager = class _TranscriptManager {
|
|
|
13826
13837
|
};
|
|
13827
13838
|
|
|
13828
13839
|
// ../remnic-core/src/summarizer.ts
|
|
13829
|
-
import { mkdir as mkdir8, readFile as
|
|
13840
|
+
import { mkdir as mkdir8, readFile as readFile9, writeFile as writeFile8, readdir as readdir8 } from "fs/promises";
|
|
13830
13841
|
import path15 from "path";
|
|
13831
13842
|
|
|
13832
13843
|
// ../remnic-core/src/summary-snapshot.ts
|
|
13833
13844
|
import {
|
|
13834
13845
|
mkdir as mkdir7,
|
|
13835
13846
|
open as open2,
|
|
13836
|
-
readFile as
|
|
13847
|
+
readFile as readFile8,
|
|
13837
13848
|
stat as stat3,
|
|
13838
13849
|
unlink as unlink4,
|
|
13839
13850
|
utimes,
|
|
@@ -13870,7 +13881,7 @@ function summarySnapshotLockPath(memoryDir, sessionKey) {
|
|
|
13870
13881
|
async function readSummarySnapshot(memoryDir, sessionKey) {
|
|
13871
13882
|
try {
|
|
13872
13883
|
const filePath = summarySnapshotPath(memoryDir, sessionKey);
|
|
13873
|
-
const raw = await
|
|
13884
|
+
const raw = await readFile8(filePath, "utf-8");
|
|
13874
13885
|
const data = SummarySnapshotSchema.parse(JSON.parse(raw));
|
|
13875
13886
|
if (data.sessionKey !== sessionKey) return null;
|
|
13876
13887
|
return data.summaries;
|
|
@@ -14295,7 +14306,7 @@ ${truncatedConversation}`;
|
|
|
14295
14306
|
const lines = [];
|
|
14296
14307
|
let existingContent = "";
|
|
14297
14308
|
try {
|
|
14298
|
-
existingContent = await
|
|
14309
|
+
existingContent = await readFile9(filePath, "utf-8");
|
|
14299
14310
|
} catch {
|
|
14300
14311
|
}
|
|
14301
14312
|
const hourHeader = `## ${hourStr}:00`;
|
|
@@ -14384,7 +14395,7 @@ ${truncatedConversation}`;
|
|
|
14384
14395
|
const summaries = [];
|
|
14385
14396
|
for (const file of mdFiles) {
|
|
14386
14397
|
const filePath = path15.join(sessionDir, file);
|
|
14387
|
-
const content = await
|
|
14398
|
+
const content = await readFile9(filePath, "utf-8");
|
|
14388
14399
|
const parsed = this.parseSummaryFile(content, sessionKey, file);
|
|
14389
14400
|
summaries.push(...parsed);
|
|
14390
14401
|
}
|
|
@@ -14506,7 +14517,7 @@ ${truncatedConversation}`;
|
|
|
14506
14517
|
const last = files[files.length - 1];
|
|
14507
14518
|
if (!last) continue;
|
|
14508
14519
|
try {
|
|
14509
|
-
const raw = await
|
|
14520
|
+
const raw = await readFile9(path15.join(chanDir, last), "utf-8");
|
|
14510
14521
|
const firstLine = raw.split("\n").find((l) => l.trim().length > 0);
|
|
14511
14522
|
if (!firstLine) continue;
|
|
14512
14523
|
const entry = JSON.parse(firstLine);
|
|
@@ -14549,7 +14560,7 @@ ${truncatedConversation}`;
|
|
|
14549
14560
|
if (!file.endsWith(".jsonl")) continue;
|
|
14550
14561
|
const transcriptPath = path15.join(transcriptDir, file);
|
|
14551
14562
|
try {
|
|
14552
|
-
const content = await
|
|
14563
|
+
const content = await readFile9(transcriptPath, "utf-8");
|
|
14553
14564
|
const lines = content.trim().split("\n");
|
|
14554
14565
|
for (const line of lines) {
|
|
14555
14566
|
if (!line.trim()) continue;
|
|
@@ -14573,7 +14584,7 @@ ${truncatedConversation}`;
|
|
|
14573
14584
|
};
|
|
14574
14585
|
|
|
14575
14586
|
// ../remnic-core/src/maintenance/memory-governance-cron.ts
|
|
14576
|
-
import { mkdir as mkdir9, readFile as
|
|
14587
|
+
import { mkdir as mkdir9, readFile as readFile10, rename, rm as rm2, stat as stat4, writeFile as writeFile9 } from "fs/promises";
|
|
14577
14588
|
import path16 from "path";
|
|
14578
14589
|
var DAY_SUMMARY_CRON_ID = "engram-day-summary";
|
|
14579
14590
|
var GOVERNANCE_CRON_ID = "engram-nightly-governance";
|
|
@@ -14630,7 +14641,7 @@ async function writeCronJobsAtomic(jobsPath, value) {
|
|
|
14630
14641
|
async function ensureCronJob(jobsPath, jobId, buildJob) {
|
|
14631
14642
|
const releaseLock = await acquireCronJobsLock(jobsPath);
|
|
14632
14643
|
try {
|
|
14633
|
-
const raw = await
|
|
14644
|
+
const raw = await readFile10(jobsPath, "utf-8");
|
|
14634
14645
|
const { parsed, jobs } = parseCronJobsShape(raw);
|
|
14635
14646
|
if (jobs.some((job) => job.id === jobId)) {
|
|
14636
14647
|
return { created: false, jobId };
|
|
@@ -15092,6 +15103,8 @@ var GOOGLE_DRIVE_CURSOR_KIND = "drivePageToken";
|
|
|
15092
15103
|
var DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
|
|
15093
15104
|
var MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
15094
15105
|
var MAX_TEXT_BYTES = 5 * 1024 * 1024;
|
|
15106
|
+
var CLIENT_SECRET_FIELD2 = ["client", "Secret"].join("");
|
|
15107
|
+
var REFRESH_TOKEN_FIELD2 = ["refresh", "Token"].join("");
|
|
15095
15108
|
var MAX_CHANGES_PER_PASS = 200;
|
|
15096
15109
|
var FOLDER_ID_PATTERN = /^[A-Za-z0-9_-]{8,256}$/;
|
|
15097
15110
|
var GOOGLE_NATIVE_EXPORT_MIME = Object.freeze({
|
|
@@ -15116,8 +15129,8 @@ function validateGoogleDriveConfig(raw) {
|
|
|
15116
15129
|
}
|
|
15117
15130
|
const r = raw;
|
|
15118
15131
|
const clientId = requireNonEmptyString(r.clientId, "clientId");
|
|
15119
|
-
const clientSecret = requireNonEmptyString(r
|
|
15120
|
-
const refreshToken = requireNonEmptyString(r
|
|
15132
|
+
const clientSecret = requireNonEmptyString(r[CLIENT_SECRET_FIELD2], CLIENT_SECRET_FIELD2);
|
|
15133
|
+
const refreshToken = requireNonEmptyString(r[REFRESH_TOKEN_FIELD2], REFRESH_TOKEN_FIELD2);
|
|
15121
15134
|
let pollIntervalMs;
|
|
15122
15135
|
if (r.pollIntervalMs === void 0) {
|
|
15123
15136
|
pollIntervalMs = DEFAULT_POLL_INTERVAL_MS;
|
|
@@ -15169,8 +15182,8 @@ function validateGoogleDriveConfig(raw) {
|
|
|
15169
15182
|
}
|
|
15170
15183
|
return Object.freeze({
|
|
15171
15184
|
clientId,
|
|
15172
|
-
clientSecret,
|
|
15173
|
-
refreshToken,
|
|
15185
|
+
[CLIENT_SECRET_FIELD2]: clientSecret,
|
|
15186
|
+
[REFRESH_TOKEN_FIELD2]: refreshToken,
|
|
15174
15187
|
pollIntervalMs,
|
|
15175
15188
|
folderIds
|
|
15176
15189
|
});
|
|
@@ -15387,9 +15400,9 @@ var defaultGoogleDriveClientFactory = async (config) => {
|
|
|
15387
15400
|
const { google } = mod;
|
|
15388
15401
|
const oauth = new google.auth.OAuth2({
|
|
15389
15402
|
clientId: config.clientId,
|
|
15390
|
-
|
|
15403
|
+
[CLIENT_SECRET_FIELD2]: config[CLIENT_SECRET_FIELD2]
|
|
15391
15404
|
});
|
|
15392
|
-
oauth.setCredentials({ refresh_token: config
|
|
15405
|
+
oauth.setCredentials({ refresh_token: config[REFRESH_TOKEN_FIELD2] });
|
|
15393
15406
|
const drive = google.drive({ version: "v3", auth: oauth });
|
|
15394
15407
|
return {
|
|
15395
15408
|
async getStartPageToken() {
|
|
@@ -15907,6 +15920,8 @@ var GMAIL_CURSOR_KIND = "gmailWatermark";
|
|
|
15907
15920
|
var GMAIL_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
|
|
15908
15921
|
var GMAIL_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
15909
15922
|
var MAX_TEXT_BYTES3 = 2 * 1024 * 1024;
|
|
15923
|
+
var CLIENT_SECRET_FIELD3 = ["client", "Secret"].join("");
|
|
15924
|
+
var REFRESH_TOKEN_FIELD3 = ["refresh", "Token"].join("");
|
|
15910
15925
|
var MAX_MESSAGES_PER_PASS = 200;
|
|
15911
15926
|
var LIST_PAGE_SIZE = 100;
|
|
15912
15927
|
var SEEN_IDS_MAX = 1e3;
|
|
@@ -15923,8 +15938,8 @@ function validateGmailConfig(raw) {
|
|
|
15923
15938
|
}
|
|
15924
15939
|
const r = raw;
|
|
15925
15940
|
const clientId = requireNonEmptyString2(r.clientId, "clientId");
|
|
15926
|
-
const clientSecret = requireNonEmptyString2(r
|
|
15927
|
-
const refreshToken = requireNonEmptyString2(r
|
|
15941
|
+
const clientSecret = requireNonEmptyString2(r[CLIENT_SECRET_FIELD3], CLIENT_SECRET_FIELD3);
|
|
15942
|
+
const refreshToken = requireNonEmptyString2(r[REFRESH_TOKEN_FIELD3], REFRESH_TOKEN_FIELD3);
|
|
15928
15943
|
let userId = "me";
|
|
15929
15944
|
if (r.userId !== void 0) {
|
|
15930
15945
|
if (typeof r.userId !== "string") {
|
|
@@ -15967,8 +15982,8 @@ function validateGmailConfig(raw) {
|
|
|
15967
15982
|
}
|
|
15968
15983
|
return Object.freeze({
|
|
15969
15984
|
clientId,
|
|
15970
|
-
clientSecret,
|
|
15971
|
-
refreshToken,
|
|
15985
|
+
[CLIENT_SECRET_FIELD3]: clientSecret,
|
|
15986
|
+
[REFRESH_TOKEN_FIELD3]: refreshToken,
|
|
15972
15987
|
userId,
|
|
15973
15988
|
query,
|
|
15974
15989
|
pollIntervalMs
|
|
@@ -16111,8 +16126,8 @@ async function exchangeRefreshToken(fetchFn, config, signal) {
|
|
|
16111
16126
|
throwIfAborted4(signal);
|
|
16112
16127
|
const body = new URLSearchParams({
|
|
16113
16128
|
client_id: config.clientId,
|
|
16114
|
-
client_secret: config
|
|
16115
|
-
refresh_token: config
|
|
16129
|
+
client_secret: config[CLIENT_SECRET_FIELD3],
|
|
16130
|
+
refresh_token: config[REFRESH_TOKEN_FIELD3],
|
|
16116
16131
|
grant_type: "refresh_token"
|
|
16117
16132
|
});
|
|
16118
16133
|
const res = await fetchFn(OAUTH2_TOKEN_URL, {
|
|
@@ -17369,10 +17384,10 @@ function applyRuntimeRetrievalPolicy(base, runtime) {
|
|
|
17369
17384
|
|
|
17370
17385
|
// ../remnic-core/src/retrieval-agents.ts
|
|
17371
17386
|
import path18 from "path";
|
|
17372
|
-
import { readdir as readdir9, readFile as
|
|
17387
|
+
import { readdir as readdir9, readFile as readFile11, stat as stat5 } from "fs/promises";
|
|
17373
17388
|
|
|
17374
17389
|
// ../remnic-core/src/temporal-index.ts
|
|
17375
|
-
import * as
|
|
17390
|
+
import * as fs3 from "fs";
|
|
17376
17391
|
import * as path17 from "path";
|
|
17377
17392
|
var INDEX_VERSION = 1;
|
|
17378
17393
|
var TEMPORAL_INDEX_FILE = "index_time.json";
|
|
@@ -17389,13 +17404,13 @@ function tagIndexPath(memoryDir) {
|
|
|
17389
17404
|
}
|
|
17390
17405
|
function ensureStateDir(memoryDir) {
|
|
17391
17406
|
const dir = stateDir(memoryDir);
|
|
17392
|
-
if (!
|
|
17393
|
-
|
|
17407
|
+
if (!fs3.existsSync(dir)) {
|
|
17408
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
17394
17409
|
}
|
|
17395
17410
|
}
|
|
17396
17411
|
function readJsonSafe(filePath, fallback) {
|
|
17397
17412
|
try {
|
|
17398
|
-
const raw =
|
|
17413
|
+
const raw = fs3.readFileSync(filePath, "utf8");
|
|
17399
17414
|
return JSON.parse(raw);
|
|
17400
17415
|
} catch {
|
|
17401
17416
|
return fallback;
|
|
@@ -17403,19 +17418,19 @@ function readJsonSafe(filePath, fallback) {
|
|
|
17403
17418
|
}
|
|
17404
17419
|
function writeJsonSafe(filePath, data) {
|
|
17405
17420
|
try {
|
|
17406
|
-
|
|
17421
|
+
fs3.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf8");
|
|
17407
17422
|
} catch {
|
|
17408
17423
|
}
|
|
17409
17424
|
}
|
|
17410
17425
|
function writeJsonAtomic(filePath, data) {
|
|
17411
17426
|
const tmp = `${filePath}.tmp`;
|
|
17412
17427
|
try {
|
|
17413
|
-
|
|
17414
|
-
|
|
17428
|
+
fs3.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
|
|
17429
|
+
fs3.renameSync(tmp, filePath);
|
|
17415
17430
|
} catch {
|
|
17416
17431
|
writeJsonSafe(filePath, data);
|
|
17417
17432
|
try {
|
|
17418
|
-
|
|
17433
|
+
fs3.unlinkSync(tmp);
|
|
17419
17434
|
} catch {
|
|
17420
17435
|
}
|
|
17421
17436
|
}
|
|
@@ -17663,7 +17678,7 @@ function clearIndexes(memoryDir) {
|
|
|
17663
17678
|
}
|
|
17664
17679
|
function indexesExist(memoryDir) {
|
|
17665
17680
|
try {
|
|
17666
|
-
return
|
|
17681
|
+
return fs3.existsSync(temporalIndexPath(memoryDir)) && fs3.existsSync(tagIndexPath(memoryDir));
|
|
17667
17682
|
} catch {
|
|
17668
17683
|
return false;
|
|
17669
17684
|
}
|
|
@@ -17695,7 +17710,7 @@ async function queryByDateRangeAsync(memoryDir, fromDate, toDate) {
|
|
|
17695
17710
|
const tPath = temporalIndexPath(memoryDir);
|
|
17696
17711
|
let raw;
|
|
17697
17712
|
try {
|
|
17698
|
-
raw = await
|
|
17713
|
+
raw = await fs3.promises.readFile(tPath, "utf8");
|
|
17699
17714
|
} catch {
|
|
17700
17715
|
return null;
|
|
17701
17716
|
}
|
|
@@ -17725,7 +17740,7 @@ async function queryByTagsAsync(memoryDir, tags) {
|
|
|
17725
17740
|
const gPath = tagIndexPath(memoryDir);
|
|
17726
17741
|
let raw;
|
|
17727
17742
|
try {
|
|
17728
|
-
raw = await
|
|
17743
|
+
raw = await fs3.promises.readFile(gPath, "utf8");
|
|
17729
17744
|
} catch {
|
|
17730
17745
|
return null;
|
|
17731
17746
|
}
|
|
@@ -17764,7 +17779,7 @@ function extractTagsFromPrompt(prompt) {
|
|
|
17764
17779
|
async function resolvePromptTagPrefilterAsync(memoryDir, prompt) {
|
|
17765
17780
|
const explicitTags = extractTagsFromPrompt(prompt);
|
|
17766
17781
|
try {
|
|
17767
|
-
const raw = await
|
|
17782
|
+
const raw = await fs3.promises.readFile(tagIndexPath(memoryDir), "utf8");
|
|
17768
17783
|
const tagIndex = normalizeTagIndex(JSON.parse(raw));
|
|
17769
17784
|
const matched = new Set(explicitTags);
|
|
17770
17785
|
for (const canonical of Object.keys(tagIndex.tags)) {
|
|
@@ -18043,7 +18058,7 @@ async function runTemporalAgent(query, memoryDir, maxResults = 20, candidatePath
|
|
|
18043
18058
|
let dateIndex = {};
|
|
18044
18059
|
try {
|
|
18045
18060
|
const indexPath = path18.join(memoryDir, "state", "index_time.json");
|
|
18046
|
-
const raw = await
|
|
18061
|
+
const raw = await readFile11(indexPath, "utf-8");
|
|
18047
18062
|
const parsed = JSON.parse(raw);
|
|
18048
18063
|
dateIndex = parsed.dates ?? {};
|
|
18049
18064
|
} catch {
|
|
@@ -18138,7 +18153,7 @@ async function runTemporalAgent(query, memoryDir, maxResults = 20, candidatePath
|
|
|
18138
18153
|
]);
|
|
18139
18154
|
const topicTokens = tokenize(query).filter((t) => !TEMPORAL_STOPWORDS.has(t));
|
|
18140
18155
|
const entries = [...pathToDate.entries()];
|
|
18141
|
-
const tagIndexPromise = topicTokens.length > 0 ?
|
|
18156
|
+
const tagIndexPromise = topicTokens.length > 0 ? readFile11(path18.join(memoryDir, "state", "index_tags.json"), "utf-8").then((raw) => {
|
|
18142
18157
|
const parsed = JSON.parse(raw);
|
|
18143
18158
|
const result = /* @__PURE__ */ new Map();
|
|
18144
18159
|
for (const [tag, node] of Object.entries(parsed.tags ?? {})) {
|
|
@@ -18224,7 +18239,7 @@ async function populateEmptySnippets(results) {
|
|
|
18224
18239
|
await Promise.all(
|
|
18225
18240
|
toRead.map(async (r) => {
|
|
18226
18241
|
try {
|
|
18227
|
-
const raw = await
|
|
18242
|
+
const raw = await readFile11(r.path, "utf-8");
|
|
18228
18243
|
const body = stripFrontmatter(raw);
|
|
18229
18244
|
const preview = body.slice(0, SNIPPET_PREVIEW_CHARS).replace(/\s+/g, " ").trim();
|
|
18230
18245
|
if (preview) snippetMap.set(r.path, preview);
|
|
@@ -19035,7 +19050,7 @@ function isValidAsOf(fm, asOfMs) {
|
|
|
19035
19050
|
}
|
|
19036
19051
|
|
|
19037
19052
|
// ../remnic-core/src/relevance.ts
|
|
19038
|
-
import { mkdir as mkdir10, readFile as
|
|
19053
|
+
import { mkdir as mkdir10, readFile as readFile12, writeFile as writeFile10 } from "fs/promises";
|
|
19039
19054
|
import path19 from "path";
|
|
19040
19055
|
var RelevanceStore = class {
|
|
19041
19056
|
statePath;
|
|
@@ -19045,7 +19060,7 @@ var RelevanceStore = class {
|
|
|
19045
19060
|
}
|
|
19046
19061
|
async load() {
|
|
19047
19062
|
try {
|
|
19048
|
-
const raw = await
|
|
19063
|
+
const raw = await readFile12(this.statePath, "utf-8");
|
|
19049
19064
|
const parsed = JSON.parse(raw);
|
|
19050
19065
|
if (parsed && typeof parsed === "object") this.state = parsed;
|
|
19051
19066
|
} catch {
|
|
@@ -19087,7 +19102,7 @@ var RelevanceStore = class {
|
|
|
19087
19102
|
};
|
|
19088
19103
|
|
|
19089
19104
|
// ../remnic-core/src/negative.ts
|
|
19090
|
-
import { mkdir as mkdir11, readFile as
|
|
19105
|
+
import { mkdir as mkdir11, readFile as readFile13, writeFile as writeFile11 } from "fs/promises";
|
|
19091
19106
|
import path20 from "path";
|
|
19092
19107
|
var NegativeExampleStore = class {
|
|
19093
19108
|
statePath;
|
|
@@ -19097,7 +19112,7 @@ var NegativeExampleStore = class {
|
|
|
19097
19112
|
}
|
|
19098
19113
|
async load() {
|
|
19099
19114
|
try {
|
|
19100
|
-
const raw = await
|
|
19115
|
+
const raw = await readFile13(this.statePath, "utf-8");
|
|
19101
19116
|
const parsed = JSON.parse(raw);
|
|
19102
19117
|
if (parsed && typeof parsed === "object") this.state = parsed;
|
|
19103
19118
|
} catch {
|
|
@@ -19140,7 +19155,7 @@ var NegativeExampleStore = class {
|
|
|
19140
19155
|
};
|
|
19141
19156
|
|
|
19142
19157
|
// ../remnic-core/src/recall-state.ts
|
|
19143
|
-
import { appendFile as appendFile3, mkdir as mkdir12, readFile as
|
|
19158
|
+
import { appendFile as appendFile3, mkdir as mkdir12, readFile as readFile14, writeFile as writeFile12 } from "fs/promises";
|
|
19144
19159
|
import path21 from "path";
|
|
19145
19160
|
import { createHash as createHash4, randomUUID } from "crypto";
|
|
19146
19161
|
function clampGraphRecallExpandedEntries(entries, maxEntries = 64) {
|
|
@@ -19193,7 +19208,7 @@ var LastRecallStore = class {
|
|
|
19193
19208
|
}
|
|
19194
19209
|
async load() {
|
|
19195
19210
|
try {
|
|
19196
|
-
const raw = await
|
|
19211
|
+
const raw = await readFile14(this.statePath, "utf-8");
|
|
19197
19212
|
const parsed = JSON.parse(raw);
|
|
19198
19213
|
if (parsed && typeof parsed === "object") this.state = parsed;
|
|
19199
19214
|
} catch {
|
|
@@ -19315,7 +19330,7 @@ var TierMigrationStatusStore = class {
|
|
|
19315
19330
|
}
|
|
19316
19331
|
async load() {
|
|
19317
19332
|
try {
|
|
19318
|
-
const raw = await
|
|
19333
|
+
const raw = await readFile14(this.statePath, "utf-8");
|
|
19319
19334
|
const parsed = JSON.parse(raw);
|
|
19320
19335
|
if (!parsed || typeof parsed !== "object") {
|
|
19321
19336
|
this.state = structuredClone(DEFAULT_TIER_MIGRATION_STATUS);
|
|
@@ -20373,7 +20388,7 @@ async function runEvalBenchmarkCiGate(options) {
|
|
|
20373
20388
|
|
|
20374
20389
|
// ../remnic-core/src/session-observer-state.ts
|
|
20375
20390
|
import path23 from "path";
|
|
20376
|
-
import { mkdir as mkdir14, open as open3, readFile as
|
|
20391
|
+
import { mkdir as mkdir14, open as open3, readFile as readFile16, stat as stat7, unlink as unlink5, writeFile as writeFile14 } from "fs/promises";
|
|
20377
20392
|
function sanitizeNonNegativeInt(value) {
|
|
20378
20393
|
if (!Number.isFinite(value)) return 0;
|
|
20379
20394
|
return Math.max(0, Math.floor(value));
|
|
@@ -20449,7 +20464,7 @@ var SessionObserverState = class {
|
|
|
20449
20464
|
saveQueue = Promise.resolve();
|
|
20450
20465
|
async readPersistedState() {
|
|
20451
20466
|
try {
|
|
20452
|
-
const raw = await
|
|
20467
|
+
const raw = await readFile16(this.statePath, "utf-8");
|
|
20453
20468
|
const parsed = JSON.parse(raw);
|
|
20454
20469
|
if (parsed?.version !== 1 || !parsed.sessions || typeof parsed.sessions !== "object") {
|
|
20455
20470
|
return null;
|
|
@@ -20640,7 +20655,7 @@ var CODEX_THREAD_KEY_PREFIX = "codex-thread:";
|
|
|
20640
20655
|
|
|
20641
20656
|
// ../remnic-core/src/embedding-fallback.ts
|
|
20642
20657
|
import path24 from "path";
|
|
20643
|
-
import { mkdir as mkdir15, readFile as
|
|
20658
|
+
import { mkdir as mkdir15, readFile as readFile17, writeFile as writeFile15 } from "fs/promises";
|
|
20644
20659
|
var DEFAULT_OPENAI_MODEL2 = "text-embedding-3-small";
|
|
20645
20660
|
var EmbeddingTimeoutError = class extends Error {
|
|
20646
20661
|
name = "EmbeddingTimeoutError";
|
|
@@ -20898,7 +20913,7 @@ var EmbeddingFallback = class {
|
|
|
20898
20913
|
return this.loaded;
|
|
20899
20914
|
}
|
|
20900
20915
|
try {
|
|
20901
|
-
const raw = await
|
|
20916
|
+
const raw = await readFile17(this.indexPath, "utf-8");
|
|
20902
20917
|
const parsed = JSON.parse(raw);
|
|
20903
20918
|
if (parsed && parsed.version === 1 && parsed.entries && typeof parsed.entries === "object") {
|
|
20904
20919
|
this.loaded = {
|
|
@@ -21014,7 +21029,7 @@ async function decideSemanticDedup(content, lookup, options) {
|
|
|
21014
21029
|
|
|
21015
21030
|
// ../remnic-core/src/bootstrap.ts
|
|
21016
21031
|
import path25 from "path";
|
|
21017
|
-
import { readdir as readdir11, readFile as
|
|
21032
|
+
import { readdir as readdir11, readFile as readFile18 } from "fs/promises";
|
|
21018
21033
|
var BootstrapEngine = class {
|
|
21019
21034
|
constructor(config, orchestrator) {
|
|
21020
21035
|
this.config = config;
|
|
@@ -21095,7 +21110,7 @@ var BootstrapEngine = class {
|
|
|
21095
21110
|
for (const filePath of files) {
|
|
21096
21111
|
let raw = "";
|
|
21097
21112
|
try {
|
|
21098
|
-
raw = await
|
|
21113
|
+
raw = await readFile18(filePath, "utf-8");
|
|
21099
21114
|
} catch {
|
|
21100
21115
|
continue;
|
|
21101
21116
|
}
|
|
@@ -21202,13 +21217,13 @@ function setCachedQmdRecall(cacheKey2, value, options) {
|
|
|
21202
21217
|
|
|
21203
21218
|
// ../remnic-core/src/entity-retrieval.ts
|
|
21204
21219
|
import { createHash as createHash6 } from "crypto";
|
|
21205
|
-
import { mkdir as mkdir17, readFile as
|
|
21220
|
+
import { mkdir as mkdir17, readFile as readFile20, writeFile as writeFile17 } from "fs/promises";
|
|
21206
21221
|
import path27 from "path";
|
|
21207
21222
|
|
|
21208
21223
|
// ../remnic-core/src/native-knowledge.ts
|
|
21209
21224
|
import { createHash as createHash5 } from "crypto";
|
|
21210
21225
|
import path26 from "path";
|
|
21211
|
-
import { mkdir as mkdir16, readFile as
|
|
21226
|
+
import { mkdir as mkdir16, readFile as readFile19, readdir as readdir12, stat as stat8, writeFile as writeFile16 } from "fs/promises";
|
|
21212
21227
|
var PERSISTED_NATIVE_KNOWLEDGE_STATE_FILES = /* @__PURE__ */ new Set([
|
|
21213
21228
|
"obsidian-sync.json",
|
|
21214
21229
|
"curated-include-sync.json",
|
|
@@ -21620,7 +21635,7 @@ function resolveOpenClawWorkspaceStatePath(memoryDir, config) {
|
|
|
21620
21635
|
async function loadSyncState(memoryDir, config) {
|
|
21621
21636
|
const statePath = resolveNativeKnowledgeStatePath(memoryDir, config);
|
|
21622
21637
|
try {
|
|
21623
|
-
const raw = JSON.parse(await
|
|
21638
|
+
const raw = JSON.parse(await readFile19(statePath, "utf-8"));
|
|
21624
21639
|
if (raw.version !== 1 || typeof raw.vaults !== "object" || !raw.vaults) {
|
|
21625
21640
|
throw new Error("invalid obsidian native knowledge state");
|
|
21626
21641
|
}
|
|
@@ -21640,7 +21655,7 @@ async function loadSyncState(memoryDir, config) {
|
|
|
21640
21655
|
async function loadOpenClawWorkspaceState(memoryDir, config) {
|
|
21641
21656
|
const statePath = resolveOpenClawWorkspaceStatePath(memoryDir, config);
|
|
21642
21657
|
try {
|
|
21643
|
-
const raw = JSON.parse(await
|
|
21658
|
+
const raw = JSON.parse(await readFile19(statePath, "utf-8"));
|
|
21644
21659
|
if (raw.version !== 1 || typeof raw.files !== "object" || !raw.files) {
|
|
21645
21660
|
throw new Error("invalid openclaw workspace native knowledge state");
|
|
21646
21661
|
}
|
|
@@ -21660,7 +21675,7 @@ async function loadOpenClawWorkspaceState(memoryDir, config) {
|
|
|
21660
21675
|
async function loadCuratedIncludeFilesState(memoryDir, config) {
|
|
21661
21676
|
const statePath = resolveCuratedIncludeFilesStatePath(memoryDir, config);
|
|
21662
21677
|
try {
|
|
21663
|
-
const raw = JSON.parse(await
|
|
21678
|
+
const raw = JSON.parse(await readFile19(statePath, "utf-8"));
|
|
21664
21679
|
if (raw.version !== 1 || typeof raw.files !== "object" || !raw.files) {
|
|
21665
21680
|
throw new Error("invalid curated include native knowledge state");
|
|
21666
21681
|
}
|
|
@@ -21825,7 +21840,7 @@ async function syncObsidianVaults(options) {
|
|
|
21825
21840
|
const seenNoteKeys = /* @__PURE__ */ new Set();
|
|
21826
21841
|
for (const notePath of includedNotePaths) {
|
|
21827
21842
|
const absPath = path26.join(vault.rootDir, notePath);
|
|
21828
|
-
const content = await
|
|
21843
|
+
const content = await readFile19(absPath, "utf-8").catch(() => null);
|
|
21829
21844
|
if (content === null) continue;
|
|
21830
21845
|
const info = await stat8(absPath).catch(() => null);
|
|
21831
21846
|
if (!info?.isFile()) continue;
|
|
@@ -22058,7 +22073,7 @@ async function loadPersistedNativeKnowledgeChunks(options) {
|
|
|
22058
22073
|
if (stateFiles.length === 0) return [];
|
|
22059
22074
|
const chunks = [];
|
|
22060
22075
|
for (const statePath of stateFiles.sort()) {
|
|
22061
|
-
const raw = await
|
|
22076
|
+
const raw = await readFile19(statePath, "utf-8").catch(() => "");
|
|
22062
22077
|
if (!raw) continue;
|
|
22063
22078
|
try {
|
|
22064
22079
|
const parsed = JSON.parse(raw);
|
|
@@ -22176,7 +22191,7 @@ async function syncOpenClawWorkspaceArtifacts(options) {
|
|
|
22176
22191
|
let deletedFiles = 0;
|
|
22177
22192
|
for (const candidate of candidates) {
|
|
22178
22193
|
const absPath = path26.join(options.workspaceDir, candidate.sourcePath);
|
|
22179
|
-
const content = await
|
|
22194
|
+
const content = await readFile19(absPath, "utf-8").catch(() => null);
|
|
22180
22195
|
if (content === null) continue;
|
|
22181
22196
|
const info = await stat8(absPath).catch(() => null);
|
|
22182
22197
|
if (!info?.isFile()) continue;
|
|
@@ -22298,7 +22313,7 @@ async function syncCuratedIncludeFiles(options) {
|
|
|
22298
22313
|
let deletedFiles = 0;
|
|
22299
22314
|
for (const filePath of candidatePaths) {
|
|
22300
22315
|
if (!await readableFile(filePath)) continue;
|
|
22301
|
-
const content = await
|
|
22316
|
+
const content = await readFile19(filePath, "utf-8").catch(() => null);
|
|
22302
22317
|
if (content === null) continue;
|
|
22303
22318
|
const info = await stat8(filePath).catch(() => null);
|
|
22304
22319
|
if (!info?.isFile()) continue;
|
|
@@ -22422,7 +22437,7 @@ async function collectNativeKnowledgeChunks(options) {
|
|
|
22422
22437
|
for (const filePath of candidatePaths) {
|
|
22423
22438
|
throwIfNativeKnowledgeAborted(options.abortSignal);
|
|
22424
22439
|
if (!await readableFile(filePath)) continue;
|
|
22425
|
-
const content = await
|
|
22440
|
+
const content = await readFile19(filePath, "utf-8").catch(() => null);
|
|
22426
22441
|
if (!content) continue;
|
|
22427
22442
|
const sourcePath = path26.relative(options.workspaceDir, filePath).replace(/\\/g, "/");
|
|
22428
22443
|
if (openclawBootstrapFiles.has(sourcePath)) continue;
|
|
@@ -22729,7 +22744,7 @@ function entityIndexStatePath(storage) {
|
|
|
22729
22744
|
return path27.join(storage.dir, "state", "entity-mention-index.json");
|
|
22730
22745
|
}
|
|
22731
22746
|
async function readEntityIndexState(storage) {
|
|
22732
|
-
const raw = await
|
|
22747
|
+
const raw = await readFile20(entityIndexStatePath(storage), "utf-8").catch(() => "");
|
|
22733
22748
|
if (!raw) return null;
|
|
22734
22749
|
try {
|
|
22735
22750
|
const parsed = JSON.parse(raw);
|
|
@@ -22743,7 +22758,7 @@ async function writeEntityIndexState(storage, index) {
|
|
|
22743
22758
|
const statePath = entityIndexStatePath(storage);
|
|
22744
22759
|
await mkdir17(path27.dirname(statePath), { recursive: true });
|
|
22745
22760
|
const nextContent = JSON.stringify(index, null, 2) + "\n";
|
|
22746
|
-
const currentContent = await
|
|
22761
|
+
const currentContent = await readFile20(statePath, "utf-8").catch(() => "");
|
|
22747
22762
|
if (currentContent === nextContent) return;
|
|
22748
22763
|
await writeFile17(statePath, nextContent, "utf-8");
|
|
22749
22764
|
}
|
|
@@ -24641,9 +24656,9 @@ function classifyMemoryKind(content, tags, category) {
|
|
|
24641
24656
|
}
|
|
24642
24657
|
|
|
24643
24658
|
// ../remnic-core/src/tmt.ts
|
|
24644
|
-
import * as
|
|
24659
|
+
import * as fs4 from "fs";
|
|
24645
24660
|
import * as path28 from "path";
|
|
24646
|
-
import { mkdir as mkdir18, readFile as
|
|
24661
|
+
import { mkdir as mkdir18, readFile as readFile21, writeFile as writeFile18, readdir as readdir13 } from "fs/promises";
|
|
24647
24662
|
var TMT_DIR = "tmt";
|
|
24648
24663
|
var TMT_LEVEL_INPUT_LIMITS = {
|
|
24649
24664
|
hour: { totalChars: 48e3, itemChars: 2e3, maxItems: 64 },
|
|
@@ -24754,10 +24769,10 @@ var TmtBuilder = class {
|
|
|
24754
24769
|
if (entries.length < this.cfg.tmtHourlyMinMemories) continue;
|
|
24755
24770
|
const [date, hour] = key.split("::");
|
|
24756
24771
|
const nodePath2 = hourNodePath(this.baseDir, date, hour);
|
|
24757
|
-
let shouldBuild = !
|
|
24772
|
+
let shouldBuild = !fs4.existsSync(nodePath2);
|
|
24758
24773
|
if (!shouldBuild) {
|
|
24759
24774
|
try {
|
|
24760
|
-
const existing = await
|
|
24775
|
+
const existing = await readFile21(nodePath2, "utf8");
|
|
24761
24776
|
const countMatch = existing.match(/memoryCount: (\d+)/);
|
|
24762
24777
|
if (!countMatch || parseInt(countMatch[1], 10) < entries.length) {
|
|
24763
24778
|
shouldBuild = true;
|
|
@@ -24796,10 +24811,10 @@ var TmtBuilder = class {
|
|
|
24796
24811
|
}
|
|
24797
24812
|
for (const [date, entries] of byDate) {
|
|
24798
24813
|
const nodePath2 = dayNodePath(this.baseDir, date);
|
|
24799
|
-
let shouldBuild = !
|
|
24814
|
+
let shouldBuild = !fs4.existsSync(nodePath2);
|
|
24800
24815
|
if (!shouldBuild) {
|
|
24801
24816
|
try {
|
|
24802
|
-
const existing = await
|
|
24817
|
+
const existing = await readFile21(nodePath2, "utf8");
|
|
24803
24818
|
const countMatch = existing.match(/memoryCount: (\d+)/);
|
|
24804
24819
|
if (!countMatch || parseInt(countMatch[1], 10) < entries.length) {
|
|
24805
24820
|
shouldBuild = true;
|
|
@@ -24818,9 +24833,9 @@ var TmtBuilder = class {
|
|
|
24818
24833
|
}
|
|
24819
24834
|
for (const [h, hourEntries] of hourToEntries) {
|
|
24820
24835
|
const hPath = hourNodePath(this.baseDir, date, h);
|
|
24821
|
-
if (
|
|
24836
|
+
if (fs4.existsSync(hPath)) {
|
|
24822
24837
|
try {
|
|
24823
|
-
const hContent = await
|
|
24838
|
+
const hContent = await readFile21(hPath, "utf8");
|
|
24824
24839
|
const hSummary = hContent.replace(/^---[\s\S]*?---\n\n?/, "").trim();
|
|
24825
24840
|
if (hSummary) {
|
|
24826
24841
|
inputs.push(hSummary);
|
|
@@ -24867,10 +24882,10 @@ var TmtBuilder = class {
|
|
|
24867
24882
|
}
|
|
24868
24883
|
for (const [week, entries] of weekToEntries) {
|
|
24869
24884
|
const nodePath2 = weekNodePath(this.baseDir, week);
|
|
24870
|
-
let shouldBuild = !
|
|
24885
|
+
let shouldBuild = !fs4.existsSync(nodePath2);
|
|
24871
24886
|
if (!shouldBuild) {
|
|
24872
24887
|
try {
|
|
24873
|
-
const existing = await
|
|
24888
|
+
const existing = await readFile21(nodePath2, "utf8");
|
|
24874
24889
|
const countMatch = existing.match(/memoryCount: (\d+)/);
|
|
24875
24890
|
if (!countMatch || parseInt(countMatch[1], 10) < entries.length) {
|
|
24876
24891
|
shouldBuild = true;
|
|
@@ -24894,9 +24909,9 @@ var TmtBuilder = class {
|
|
|
24894
24909
|
const w = isoWeekKey(/* @__PURE__ */ new Date(dateDir + "T00:00:00Z"));
|
|
24895
24910
|
if (w !== week) continue;
|
|
24896
24911
|
const dayPath = dayNodePath(this.baseDir, dateDir);
|
|
24897
|
-
if (
|
|
24912
|
+
if (fs4.existsSync(dayPath)) {
|
|
24898
24913
|
try {
|
|
24899
|
-
const content = await
|
|
24914
|
+
const content = await readFile21(dayPath, "utf8");
|
|
24900
24915
|
const summary2 = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
|
|
24901
24916
|
if (summary2) daySummaries.push(summary2);
|
|
24902
24917
|
} catch {
|
|
@@ -24943,7 +24958,7 @@ var TmtBuilder = class {
|
|
|
24943
24958
|
let latestEnd;
|
|
24944
24959
|
for (const f of weekFiles) {
|
|
24945
24960
|
try {
|
|
24946
|
-
const content = await
|
|
24961
|
+
const content = await readFile21(path28.join(dir, f), "utf8");
|
|
24947
24962
|
const summary2 = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
|
|
24948
24963
|
if (summary2) weekSummaries.push(summary2);
|
|
24949
24964
|
const countMatch = content.match(/memoryCount: (\d+)/);
|
|
@@ -24961,10 +24976,10 @@ var TmtBuilder = class {
|
|
|
24961
24976
|
}
|
|
24962
24977
|
if (weekSummaries.length === 0) return;
|
|
24963
24978
|
const nodePath2 = personaNodePath(this.baseDir);
|
|
24964
|
-
let shouldBuild = !
|
|
24979
|
+
let shouldBuild = !fs4.existsSync(nodePath2);
|
|
24965
24980
|
if (!shouldBuild) {
|
|
24966
24981
|
try {
|
|
24967
|
-
const existing = await
|
|
24982
|
+
const existing = await readFile21(nodePath2, "utf8");
|
|
24968
24983
|
const countMatch = existing.match(/memoryCount: (\d+)/);
|
|
24969
24984
|
if (!countMatch || parseInt(countMatch[1], 10) !== totalCount) {
|
|
24970
24985
|
shouldBuild = true;
|
|
@@ -24998,11 +25013,11 @@ var TmtBuilder = class {
|
|
|
24998
25013
|
if (!this.cfg.temporalMemoryTreeEnabled) return null;
|
|
24999
25014
|
try {
|
|
25000
25015
|
const dir = tmtDir(this.baseDir);
|
|
25001
|
-
if (!
|
|
25016
|
+
if (!fs4.existsSync(dir)) return null;
|
|
25002
25017
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
25003
25018
|
const todayDay = dayNodePath(this.baseDir, today);
|
|
25004
|
-
if (
|
|
25005
|
-
const content = await
|
|
25019
|
+
if (fs4.existsSync(todayDay)) {
|
|
25020
|
+
const content = await readFile21(todayDay, "utf8");
|
|
25006
25021
|
const summary = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
|
|
25007
25022
|
if (summary) return { level: "day", summary };
|
|
25008
25023
|
}
|
|
@@ -25015,8 +25030,8 @@ var TmtBuilder = class {
|
|
|
25015
25030
|
const dateDirs = entries.filter((e) => /^\d{4}-\d{2}-\d{2}$/.test(e)).sort().reverse();
|
|
25016
25031
|
for (const dateDir of dateDirs) {
|
|
25017
25032
|
const dayPath = dayNodePath(this.baseDir, dateDir);
|
|
25018
|
-
if (
|
|
25019
|
-
const content = await
|
|
25033
|
+
if (fs4.existsSync(dayPath)) {
|
|
25034
|
+
const content = await readFile21(dayPath, "utf8");
|
|
25020
25035
|
const summary = content.replace(/^---[\s\S]*?---\n\n?/, "").trim();
|
|
25021
25036
|
if (summary) return { level: "day", summary };
|
|
25022
25037
|
}
|
|
@@ -26190,7 +26205,7 @@ var DEFAULT_TAXONOMY = {
|
|
|
26190
26205
|
};
|
|
26191
26206
|
|
|
26192
26207
|
// ../remnic-core/src/taxonomy/taxonomy-loader.ts
|
|
26193
|
-
import { readFile as
|
|
26208
|
+
import { readFile as readFile22, mkdir as mkdir21, writeFile as writeFile21 } from "fs/promises";
|
|
26194
26209
|
import path31 from "path";
|
|
26195
26210
|
|
|
26196
26211
|
// ../remnic-core/src/harmonic-retrieval.ts
|
|
@@ -32715,7 +32730,7 @@ function mergeNamespaceSearchResults(lists, maxResults) {
|
|
|
32715
32730
|
}
|
|
32716
32731
|
|
|
32717
32732
|
// ../remnic-core/src/routing/store.ts
|
|
32718
|
-
import { lstat, mkdir as mkdir27, readFile as
|
|
32733
|
+
import { lstat, mkdir as mkdir27, readFile as readFile23, realpath, rename as rename2, rm as rm5, stat as stat9, writeFile as writeFile26 } from "fs/promises";
|
|
32719
32734
|
import path41 from "path";
|
|
32720
32735
|
import { createHash as createHash7 } from "crypto";
|
|
32721
32736
|
function defaultState() {
|
|
@@ -32826,7 +32841,7 @@ var RoutingRulesStore = class {
|
|
|
32826
32841
|
async readPersistedRules() {
|
|
32827
32842
|
try {
|
|
32828
32843
|
await this.assertStatePathScoped();
|
|
32829
|
-
const raw = await
|
|
32844
|
+
const raw = await readFile23(this.statePath, "utf-8");
|
|
32830
32845
|
const parsed = JSON.parse(raw);
|
|
32831
32846
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.rules)) return [];
|
|
32832
32847
|
const normalized = parsed.rules.map((rule) => normalizeRule(rule)).filter((rule) => rule !== null);
|
|
@@ -32971,7 +32986,7 @@ var RoutingRulesStore = class {
|
|
|
32971
32986
|
|
|
32972
32987
|
// ../remnic-core/src/policy-runtime.ts
|
|
32973
32988
|
import path42 from "path";
|
|
32974
|
-
import { mkdir as mkdir28, readFile as
|
|
32989
|
+
import { mkdir as mkdir28, readFile as readFile24, rename as rename3, writeFile as writeFile27 } from "fs/promises";
|
|
32975
32990
|
var RUNTIME_POLICY_VERSION = 1;
|
|
32976
32991
|
var RUNTIME_POLICY_FILE = "policy-runtime.json";
|
|
32977
32992
|
var RUNTIME_POLICY_PREV_FILE = "policy-runtime.prev.json";
|
|
@@ -33000,7 +33015,7 @@ function isRuntimeParameter(parameter) {
|
|
|
33000
33015
|
}
|
|
33001
33016
|
async function readRuntimePolicySnapshot(filePath, options) {
|
|
33002
33017
|
try {
|
|
33003
|
-
const raw = await
|
|
33018
|
+
const raw = await readFile24(filePath, "utf-8");
|
|
33004
33019
|
const parsed = JSON.parse(raw);
|
|
33005
33020
|
if (!parsed || typeof parsed.version !== "number" || parsed.version < 1 || typeof parsed.updatedAt !== "string" || !parsed.values || typeof parsed.values !== "object" || typeof parsed.sourceAdjustmentCount !== "number" || parsed.sourceAdjustmentCount < 0) {
|
|
33006
33021
|
return null;
|
|
@@ -33241,8 +33256,10 @@ function fingerprintEntitySynthesisEvidence(entity) {
|
|
|
33241
33256
|
entry.principal ?? "",
|
|
33242
33257
|
entry.text
|
|
33243
33258
|
].join("\0")).sort();
|
|
33244
|
-
|
|
33245
|
-
|
|
33259
|
+
const timelineEntrySeparator = String.fromCharCode(1);
|
|
33260
|
+
const structuredFactsSeparator = String.fromCharCode(2);
|
|
33261
|
+
fingerprint.update(timelineEntries.join(timelineEntrySeparator));
|
|
33262
|
+
fingerprint.update(structuredFactsSeparator);
|
|
33246
33263
|
fingerprint.update(fingerprintEntityStructuredFacts(entity) ?? "");
|
|
33247
33264
|
return fingerprint.digest("hex");
|
|
33248
33265
|
}
|
|
@@ -34762,7 +34779,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
34762
34779
|
const home = resolveHomeDir();
|
|
34763
34780
|
const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
|
|
34764
34781
|
try {
|
|
34765
|
-
if (!
|
|
34782
|
+
if (!existsSync5(jobsPath)) {
|
|
34766
34783
|
log.debug(
|
|
34767
34784
|
"day-summary cron: jobs.json not found, skipping auto-register"
|
|
34768
34785
|
);
|
|
@@ -34786,7 +34803,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
34786
34803
|
const home = resolveHomeDir();
|
|
34787
34804
|
const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
|
|
34788
34805
|
try {
|
|
34789
|
-
if (!
|
|
34806
|
+
if (!existsSync5(jobsPath)) {
|
|
34790
34807
|
log.debug("nightly governance cron: jobs.json not found, skipping auto-register");
|
|
34791
34808
|
return;
|
|
34792
34809
|
}
|
|
@@ -34808,7 +34825,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
34808
34825
|
const home = resolveHomeDir();
|
|
34809
34826
|
const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
|
|
34810
34827
|
try {
|
|
34811
|
-
if (!
|
|
34828
|
+
if (!existsSync5(jobsPath)) {
|
|
34812
34829
|
log.debug("procedural mining cron: jobs.json not found, skipping auto-register");
|
|
34813
34830
|
return;
|
|
34814
34831
|
}
|
|
@@ -34828,7 +34845,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
34828
34845
|
const home = resolveHomeDir();
|
|
34829
34846
|
const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
|
|
34830
34847
|
try {
|
|
34831
|
-
if (!
|
|
34848
|
+
if (!existsSync5(jobsPath)) {
|
|
34832
34849
|
log.debug("contradiction scan cron: jobs.json not found, skipping auto-register");
|
|
34833
34850
|
return;
|
|
34834
34851
|
}
|
|
@@ -34848,7 +34865,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
34848
34865
|
const home = resolveHomeDir();
|
|
34849
34866
|
const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
|
|
34850
34867
|
try {
|
|
34851
|
-
if (!
|
|
34868
|
+
if (!existsSync5(jobsPath)) {
|
|
34852
34869
|
log.debug("pattern reinforcement cron: jobs.json not found, skipping auto-register");
|
|
34853
34870
|
return;
|
|
34854
34871
|
}
|
|
@@ -34910,7 +34927,7 @@ var Orchestrator = class _Orchestrator {
|
|
|
34910
34927
|
const home = resolveHomeDir();
|
|
34911
34928
|
const jobsPath = path43.join(home, ".openclaw", "cron", "jobs.json");
|
|
34912
34929
|
try {
|
|
34913
|
-
if (!
|
|
34930
|
+
if (!existsSync5(jobsPath)) {
|
|
34914
34931
|
log.debug("graph edge decay cron: jobs.json not found, skipping auto-register");
|
|
34915
34932
|
return;
|
|
34916
34933
|
}
|
|
@@ -34967,7 +34984,7 @@ ${doc.content}` : doc.content,
|
|
|
34967
34984
|
for (const rel of hygiene.rotatePaths) {
|
|
34968
34985
|
const abs = path43.isAbsolute(rel) ? rel : path43.join(this.config.workspaceDir, rel);
|
|
34969
34986
|
try {
|
|
34970
|
-
const raw = await
|
|
34987
|
+
const raw = await readFile25(abs, "utf-8");
|
|
34971
34988
|
if (raw.length > hygiene.rotateMaxBytes) {
|
|
34972
34989
|
const archiveDir = path43.join(
|
|
34973
34990
|
this.config.workspaceDir,
|
|
@@ -35008,7 +35025,7 @@ ${doc.content}` : doc.content,
|
|
|
35008
35025
|
` + warnings.map((w) => `- ${w.message}`).join("\n") + "\n";
|
|
35009
35026
|
let existing = "";
|
|
35010
35027
|
try {
|
|
35011
|
-
existing = await
|
|
35028
|
+
existing = await readFile25(fp, "utf-8");
|
|
35012
35029
|
} catch {
|
|
35013
35030
|
existing = "# Engram File Hygiene Warnings\n";
|
|
35014
35031
|
}
|
|
@@ -35038,7 +35055,7 @@ ${doc.content}` : doc.content,
|
|
|
35038
35055
|
}
|
|
35039
35056
|
async runDeepSleepGovernanceNow(options) {
|
|
35040
35057
|
const targetStorage = options?.storage ?? this.storage;
|
|
35041
|
-
const { runMemoryGovernance: runMemoryGovernance2 } = await import("./memory-governance-
|
|
35058
|
+
const { runMemoryGovernance: runMemoryGovernance2 } = await import("./memory-governance-7YPDMYCE.js");
|
|
35042
35059
|
const { summarizeGovernanceResultForDreams } = await import("./dreams-ledger-3I52ISYR.js");
|
|
35043
35060
|
const govResult = await runMemoryGovernance2({
|
|
35044
35061
|
memoryDir: targetStorage.dir,
|
|
@@ -35095,7 +35112,7 @@ ${doc.content}` : doc.content,
|
|
|
35095
35112
|
);
|
|
35096
35113
|
return result;
|
|
35097
35114
|
}
|
|
35098
|
-
const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-
|
|
35115
|
+
const { FallbackLlmClient: FallbackLlmClient2 } = await import("./fallback-llm-EGB622FE.js");
|
|
35099
35116
|
const useGateway = this.config.modelSource === "gateway";
|
|
35100
35117
|
const modelSetting = this.config.semanticConsolidationModel;
|
|
35101
35118
|
if (modelSetting === "fast" && this.fastLlm && !useGateway) {
|
|
@@ -35255,7 +35272,7 @@ ${doc.content}` : doc.content,
|
|
|
35255
35272
|
}
|
|
35256
35273
|
if (this.config.peerProfileReasonerEnabled) {
|
|
35257
35274
|
try {
|
|
35258
|
-
const { runPeerProfileReasoner } = await import("./peers-
|
|
35275
|
+
const { runPeerProfileReasoner } = await import("./peers-KRFXWRQ6.js");
|
|
35259
35276
|
const llm2 = new FallbackLlmClient2(this.config.gatewayConfig);
|
|
35260
35277
|
const peerResult = await runPeerProfileReasoner({
|
|
35261
35278
|
memoryDir: targetStorage.dir,
|
|
@@ -35472,7 +35489,7 @@ ${evidenceText}`
|
|
|
35472
35489
|
if (!entry.name.endsWith(".md")) continue;
|
|
35473
35490
|
const fullPath = path43.join(factsDir, entry.name);
|
|
35474
35491
|
try {
|
|
35475
|
-
const raw = await
|
|
35492
|
+
const raw = await readFile25(fullPath, "utf-8");
|
|
35476
35493
|
const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
35477
35494
|
if (!fmMatch) continue;
|
|
35478
35495
|
const fmBlock = fmMatch[1];
|
|
@@ -35515,7 +35532,7 @@ ${evidenceText}`
|
|
|
35515
35532
|
for (const date of datesToScan) {
|
|
35516
35533
|
const summaryFile = path43.join(hourlyBaseDir, sk.name, `${date}.md`);
|
|
35517
35534
|
try {
|
|
35518
|
-
const raw = await
|
|
35535
|
+
const raw = await readFile25(summaryFile, "utf-8");
|
|
35519
35536
|
if (raw.trim().length > 0) {
|
|
35520
35537
|
hourlySummaries.push(raw.trim());
|
|
35521
35538
|
}
|
|
@@ -35617,7 +35634,7 @@ ${evidenceText}`
|
|
|
35617
35634
|
"last_graph_recall.json"
|
|
35618
35635
|
);
|
|
35619
35636
|
try {
|
|
35620
|
-
const raw = await
|
|
35637
|
+
const raw = await readFile25(snapshotPath, "utf-8");
|
|
35621
35638
|
const parsed = JSON.parse(raw);
|
|
35622
35639
|
if (!parsed || typeof parsed !== "object") return null;
|
|
35623
35640
|
return {
|
|
@@ -35652,7 +35669,7 @@ ${evidenceText}`
|
|
|
35652
35669
|
const storage = await this.getStorage(namespace);
|
|
35653
35670
|
const snapshotPath = path43.join(storage.dir, "state", "last_intent.json");
|
|
35654
35671
|
try {
|
|
35655
|
-
const raw = await
|
|
35672
|
+
const raw = await readFile25(snapshotPath, "utf-8");
|
|
35656
35673
|
const parsed = JSON.parse(raw);
|
|
35657
35674
|
if (!parsed || typeof parsed !== "object") return null;
|
|
35658
35675
|
const graphDecision = parsed.graphDecision && typeof parsed.graphDecision === "object" ? parsed.graphDecision : void 0;
|
|
@@ -35689,7 +35706,7 @@ ${evidenceText}`
|
|
|
35689
35706
|
"last_qmd_recall.json"
|
|
35690
35707
|
);
|
|
35691
35708
|
try {
|
|
35692
|
-
const raw = await
|
|
35709
|
+
const raw = await readFile25(snapshotPath, "utf-8");
|
|
35693
35710
|
const parsed = JSON.parse(raw);
|
|
35694
35711
|
if (!parsed || typeof parsed !== "object") return null;
|
|
35695
35712
|
return {
|
|
@@ -37479,7 +37496,7 @@ ${trimmedBody}`;
|
|
|
37479
37496
|
if (!peerId) return null;
|
|
37480
37497
|
const t0 = Date.now();
|
|
37481
37498
|
try {
|
|
37482
|
-
const { readPeerProfile: _readPeerProfile } = await import("./peers-
|
|
37499
|
+
const { readPeerProfile: _readPeerProfile } = await import("./peers-KRFXWRQ6.js");
|
|
37483
37500
|
const peerProfile = await _readPeerProfile(this.config.memoryDir, peerId);
|
|
37484
37501
|
recordRecallSectionMetric({
|
|
37485
37502
|
section: "peerProfile",
|
|
@@ -37860,7 +37877,7 @@ ${lines.join("\n\n")}`;
|
|
|
37860
37877
|
return null;
|
|
37861
37878
|
}
|
|
37862
37879
|
try {
|
|
37863
|
-
const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-
|
|
37880
|
+
const { getCalibrationRulesForRecall, buildCalibrationRecallSection } = await import("./calibration-V6NBBNCD.js");
|
|
37864
37881
|
const rules = await getCalibrationRulesForRecall(this.config.memoryDir);
|
|
37865
37882
|
if (rules.length === 0) {
|
|
37866
37883
|
recordRecallSectionMetric({
|
|
@@ -38534,7 +38551,7 @@ ${formatted}`;
|
|
|
38534
38551
|
const signalStat = await stat10(signalPath).catch(() => null);
|
|
38535
38552
|
if (!signalStat) return null;
|
|
38536
38553
|
const signalAge = Date.now() - signalStat.mtimeMs;
|
|
38537
|
-
const signalData = JSON.parse(await
|
|
38554
|
+
const signalData = JSON.parse(await readFile25(signalPath, "utf-8"));
|
|
38538
38555
|
if (signalData.sessionKey !== effectiveSessionKey) {
|
|
38539
38556
|
log.debug(
|
|
38540
38557
|
`recall: compaction signal is for ${signalData.sessionKey}, not ${effectiveSessionKey} \u2014 skipping`
|
|
@@ -38554,7 +38571,7 @@ ${formatted}`;
|
|
|
38554
38571
|
|
|
38555
38572
|
`;
|
|
38556
38573
|
try {
|
|
38557
|
-
const bootContent = await
|
|
38574
|
+
const bootContent = await readFile25(bootPath, "utf-8");
|
|
38558
38575
|
section += "### BOOT.md (working state before compaction)\n\n";
|
|
38559
38576
|
section += bootContent + "\n";
|
|
38560
38577
|
} catch {
|
|
@@ -42287,7 +42304,7 @@ ${normalized}`).digest("hex");
|
|
|
42287
42304
|
);
|
|
42288
42305
|
let shouldRun = true;
|
|
42289
42306
|
try {
|
|
42290
|
-
const stateRaw = await
|
|
42307
|
+
const stateRaw = await readFile25(stateFilePath, "utf-8");
|
|
42291
42308
|
const stateData = JSON.parse(stateRaw);
|
|
42292
42309
|
if (stateData.lastRunAt) {
|
|
42293
42310
|
const lastRunMs = new Date(stateData.lastRunAt).getTime();
|
|
@@ -44222,7 +44239,7 @@ import { createHash as createHash10 } from "crypto";
|
|
|
44222
44239
|
// ../remnic-core/src/work/storage.ts
|
|
44223
44240
|
import path44 from "path";
|
|
44224
44241
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
44225
|
-
import { mkdir as mkdir30, readdir as readdir16, readFile as
|
|
44242
|
+
import { mkdir as mkdir30, readdir as readdir16, readFile as readFile26, rm as rm6, writeFile as writeFile29 } from "fs/promises";
|
|
44226
44243
|
var TASK_TRANSITIONS = {
|
|
44227
44244
|
todo: /* @__PURE__ */ new Set(["in_progress", "blocked", "cancelled"]),
|
|
44228
44245
|
in_progress: /* @__PURE__ */ new Set(["todo", "blocked", "done", "cancelled"]),
|
|
@@ -44398,7 +44415,7 @@ ${project.description}
|
|
|
44398
44415
|
}
|
|
44399
44416
|
async getTask(id) {
|
|
44400
44417
|
try {
|
|
44401
|
-
const raw = await
|
|
44418
|
+
const raw = await readFile26(this.taskPath(id), "utf-8");
|
|
44402
44419
|
return this.parseTask(raw);
|
|
44403
44420
|
} catch {
|
|
44404
44421
|
return null;
|
|
@@ -44410,7 +44427,7 @@ ${project.description}
|
|
|
44410
44427
|
const out = [];
|
|
44411
44428
|
for (const entry of entries) {
|
|
44412
44429
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
44413
|
-
const raw = await
|
|
44430
|
+
const raw = await readFile26(path44.join(this.tasksDir, entry.name), "utf-8");
|
|
44414
44431
|
const task = this.parseTask(raw);
|
|
44415
44432
|
if (!task) continue;
|
|
44416
44433
|
if (filter?.status && task.status !== filter.status) continue;
|
|
@@ -44497,7 +44514,7 @@ ${project.description}
|
|
|
44497
44514
|
}
|
|
44498
44515
|
async getProject(id) {
|
|
44499
44516
|
try {
|
|
44500
|
-
const raw = await
|
|
44517
|
+
const raw = await readFile26(this.projectPath(id), "utf-8");
|
|
44501
44518
|
return this.parseProject(raw);
|
|
44502
44519
|
} catch {
|
|
44503
44520
|
return null;
|
|
@@ -44509,7 +44526,7 @@ ${project.description}
|
|
|
44509
44526
|
const out = [];
|
|
44510
44527
|
for (const entry of entries) {
|
|
44511
44528
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
44512
|
-
const raw = await
|
|
44529
|
+
const raw = await readFile26(path44.join(this.projectsDir, entry.name), "utf-8");
|
|
44513
44530
|
const project = this.parseProject(raw);
|
|
44514
44531
|
if (project) out.push(project);
|
|
44515
44532
|
}
|
|
@@ -47626,12 +47643,12 @@ Returns: Performance trace data with timing breakdown`,
|
|
|
47626
47643
|
|
|
47627
47644
|
// ../remnic-core/src/cli.ts
|
|
47628
47645
|
import path74 from "path";
|
|
47629
|
-
import { access as access7, readFile as
|
|
47646
|
+
import { access as access7, readFile as readFile46, readdir as readdir28, unlink as unlink12 } from "fs/promises";
|
|
47630
47647
|
import { createHash as createHash14 } from "crypto";
|
|
47631
47648
|
|
|
47632
47649
|
// ../remnic-core/src/transfer/export-json.ts
|
|
47633
47650
|
import path45 from "path";
|
|
47634
|
-
import { mkdir as mkdir31, readFile as
|
|
47651
|
+
import { mkdir as mkdir31, readFile as readFile27 } from "fs/promises";
|
|
47635
47652
|
var DEFAULT_EXCLUDES = /* @__PURE__ */ new Set([
|
|
47636
47653
|
"node_modules",
|
|
47637
47654
|
".git"
|
|
@@ -47653,7 +47670,7 @@ async function exportJsonBundle(opts) {
|
|
|
47653
47670
|
for (const abs of filesAbs) {
|
|
47654
47671
|
const relPosix = toPosixRelPath(abs, memoryDirAbs);
|
|
47655
47672
|
if (shouldExclude(relPosix, includeTranscripts)) continue;
|
|
47656
|
-
const content = await
|
|
47673
|
+
const content = await readFile27(abs, "utf-8");
|
|
47657
47674
|
records.push({ path: relPosix, content });
|
|
47658
47675
|
const { sha256, bytes } = await sha256File(abs);
|
|
47659
47676
|
manifestFiles.push({ path: relPosix, sha256, bytes });
|
|
@@ -47661,7 +47678,7 @@ async function exportJsonBundle(opts) {
|
|
|
47661
47678
|
if (opts.includeWorkspaceIdentity !== false && opts.workspaceDir) {
|
|
47662
47679
|
const identityPath = path45.join(opts.workspaceDir, "IDENTITY.md");
|
|
47663
47680
|
try {
|
|
47664
|
-
const content = await
|
|
47681
|
+
const content = await readFile27(identityPath, "utf-8");
|
|
47665
47682
|
const relPath = "workspace/IDENTITY.md";
|
|
47666
47683
|
records.push({ path: relPath, content });
|
|
47667
47684
|
const { sha256, bytes } = sha256String(content);
|
|
@@ -47684,7 +47701,7 @@ async function exportJsonBundle(opts) {
|
|
|
47684
47701
|
|
|
47685
47702
|
// ../remnic-core/src/transfer/export-md.ts
|
|
47686
47703
|
import path46 from "path";
|
|
47687
|
-
import { mkdir as mkdir32, readFile as
|
|
47704
|
+
import { mkdir as mkdir32, readFile as readFile28, writeFile as writeFile30 } from "fs/promises";
|
|
47688
47705
|
function shouldExclude2(relPosix, includeTranscripts) {
|
|
47689
47706
|
const parts = relPosix.split("/");
|
|
47690
47707
|
if (!includeTranscripts && parts[0] === "transcripts") return true;
|
|
@@ -47702,7 +47719,7 @@ async function exportMarkdownBundle(opts) {
|
|
|
47702
47719
|
if (shouldExclude2(relPosix, includeTranscripts)) continue;
|
|
47703
47720
|
const dstAbs = path46.join(outDirAbs, ...relPosix.split("/"));
|
|
47704
47721
|
await mkdir32(path46.dirname(dstAbs), { recursive: true });
|
|
47705
|
-
const content = await
|
|
47722
|
+
const content = await readFile28(abs);
|
|
47706
47723
|
await writeFile30(dstAbs, content);
|
|
47707
47724
|
const { sha256, bytes } = await sha256File(abs);
|
|
47708
47725
|
manifestFiles.push({ path: relPosix, sha256, bytes });
|
|
@@ -47720,7 +47737,7 @@ async function exportMarkdownBundle(opts) {
|
|
|
47720
47737
|
async function looksLikeEngramMdExport(fromDir) {
|
|
47721
47738
|
const dirAbs = path46.resolve(fromDir);
|
|
47722
47739
|
try {
|
|
47723
|
-
const raw = await
|
|
47740
|
+
const raw = await readFile28(path46.join(dirAbs, "manifest.json"), "utf-8");
|
|
47724
47741
|
const parsed = JSON.parse(raw);
|
|
47725
47742
|
return parsed.format === EXPORT_FORMAT && parsed.schemaVersion === EXPORT_SCHEMA_VERSION;
|
|
47726
47743
|
} catch {
|
|
@@ -47741,7 +47758,7 @@ async function backupMemoryDir(opts) {
|
|
|
47741
47758
|
const ts = timestampDirName(/* @__PURE__ */ new Date());
|
|
47742
47759
|
if (opts.encrypt === true) {
|
|
47743
47760
|
const { listFilesRecursive: listFilesRecursive3, toPosixRelPath: toPosixRelPath2 } = await import("./fs-utils-PZRI2HDZ.js");
|
|
47744
|
-
const { readFile:
|
|
47761
|
+
const { readFile: readFile52 } = await import("fs/promises");
|
|
47745
47762
|
const memoryDirAbs = path47.resolve(opts.memoryDir);
|
|
47746
47763
|
const filesAbs = await listFilesRecursive3(memoryDirAbs);
|
|
47747
47764
|
const includeTranscripts = opts.includeTranscripts === true;
|
|
@@ -47751,7 +47768,7 @@ async function backupMemoryDir(opts) {
|
|
|
47751
47768
|
const parts = relPosix.split("/");
|
|
47752
47769
|
if (parts.some((p) => p === "node_modules" || p === ".git" || p === ".secure-store" || p === ".capsules")) continue;
|
|
47753
47770
|
if (!includeTranscripts && parts[0] === "transcripts") continue;
|
|
47754
|
-
const content = await
|
|
47771
|
+
const content = await readFile52(abs, "utf-8");
|
|
47755
47772
|
records.push({ path: relPosix, content });
|
|
47756
47773
|
}
|
|
47757
47774
|
records.sort((a, b) => a.path.localeCompare(b.path));
|
|
@@ -47819,7 +47836,7 @@ async function enforceRetention(outDirAbs, retentionDays) {
|
|
|
47819
47836
|
|
|
47820
47837
|
// ../remnic-core/src/transfer/export-sqlite.ts
|
|
47821
47838
|
import path48 from "path";
|
|
47822
|
-
import { readFile as
|
|
47839
|
+
import { readFile as readFile29 } from "fs/promises";
|
|
47823
47840
|
|
|
47824
47841
|
// ../remnic-core/src/transfer/sqlite-schema.ts
|
|
47825
47842
|
var SQLITE_SCHEMA_VERSION = 1;
|
|
@@ -47867,7 +47884,7 @@ async function exportSqlite(opts) {
|
|
|
47867
47884
|
for (const abs of filesAbs) {
|
|
47868
47885
|
const relPosix = toPosixRelPath(abs, memDirAbs);
|
|
47869
47886
|
if (shouldExclude3(relPosix, includeTranscripts)) continue;
|
|
47870
|
-
const content = await
|
|
47887
|
+
const content = await readFile29(abs, "utf-8");
|
|
47871
47888
|
const { sha256, bytes } = await sha256File(abs);
|
|
47872
47889
|
rows.push({ rel: relPosix, bytes, sha256, content });
|
|
47873
47890
|
}
|
|
@@ -47991,7 +48008,7 @@ async function importSqlite(opts) {
|
|
|
47991
48008
|
|
|
47992
48009
|
// ../remnic-core/src/transfer/import-md.ts
|
|
47993
48010
|
import path51 from "path";
|
|
47994
|
-
import { mkdir as mkdir36, readFile as
|
|
48011
|
+
import { mkdir as mkdir36, readFile as readFile30, writeFile as writeFile34 } from "fs/promises";
|
|
47995
48012
|
function normalizeForDedupe3(s) {
|
|
47996
48013
|
return s.replace(/\s+/g, " ").trim();
|
|
47997
48014
|
}
|
|
@@ -48006,7 +48023,7 @@ async function importMarkdownBundle(opts) {
|
|
|
48006
48023
|
const relPosix = toPosixRelPath(abs, fromAbs);
|
|
48007
48024
|
if (relPosix === "manifest.json") continue;
|
|
48008
48025
|
const dstAbs = path51.join(targetAbs, fromPosixRelPath(relPosix));
|
|
48009
|
-
const content = await
|
|
48026
|
+
const content = await readFile30(abs, "utf-8");
|
|
48010
48027
|
const exists4 = await fileExists(dstAbs);
|
|
48011
48028
|
if (exists4) {
|
|
48012
48029
|
if (conflict === "skip") {
|
|
@@ -48676,7 +48693,7 @@ async function runBulkImportPipeline(source, options = {}, processBatch) {
|
|
|
48676
48693
|
|
|
48677
48694
|
// ../remnic-core/src/maintenance/archive-observations.ts
|
|
48678
48695
|
import path53 from "path";
|
|
48679
|
-
import { mkdir as mkdir37, readdir as readdir18, readFile as
|
|
48696
|
+
import { mkdir as mkdir37, readdir as readdir18, readFile as readFile31, unlink as unlink9, writeFile as writeFile35 } from "fs/promises";
|
|
48680
48697
|
var DATE_FILE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})\.(jsonl|md)$/;
|
|
48681
48698
|
function normalizeRetentionDays(value) {
|
|
48682
48699
|
if (!Number.isFinite(value)) return 30;
|
|
@@ -48754,7 +48771,7 @@ async function archiveObservations(options) {
|
|
|
48754
48771
|
const archivePath = path53.join(archiveRoot, candidate.relativePath);
|
|
48755
48772
|
const archiveDir = path53.dirname(archivePath);
|
|
48756
48773
|
await mkdir37(archiveDir, { recursive: true });
|
|
48757
|
-
const raw = await
|
|
48774
|
+
const raw = await readFile31(candidate.absolutePath);
|
|
48758
48775
|
await writeFile35(archivePath, raw);
|
|
48759
48776
|
await unlink9(candidate.absolutePath);
|
|
48760
48777
|
archivedFiles += 1;
|
|
@@ -49703,11 +49720,11 @@ async function repairMemoryProjection(options) {
|
|
|
49703
49720
|
|
|
49704
49721
|
// ../remnic-core/src/maintenance/rebuild-observations.ts
|
|
49705
49722
|
import path57 from "path";
|
|
49706
|
-
import { readdir as readdir19, readFile as
|
|
49723
|
+
import { readdir as readdir19, readFile as readFile33 } from "fs/promises";
|
|
49707
49724
|
|
|
49708
49725
|
// ../remnic-core/src/maintenance/observation-ledger-utils.ts
|
|
49709
49726
|
import path56 from "path";
|
|
49710
|
-
import { mkdir as mkdir40, readFile as
|
|
49727
|
+
import { mkdir as mkdir40, readFile as readFile32, writeFile as writeFile37 } from "fs/promises";
|
|
49711
49728
|
function toHourBucketIso(timestamp) {
|
|
49712
49729
|
const normalized = /(?:Z|[+-]\d{2}:\d{2})$/u.test(timestamp) ? timestamp : `${timestamp}Z`;
|
|
49713
49730
|
const ms = Date.parse(normalized);
|
|
@@ -49726,7 +49743,7 @@ async function backupAndWriteRebuiltObservations(options) {
|
|
|
49726
49743
|
"rebuilt-observations.jsonl"
|
|
49727
49744
|
);
|
|
49728
49745
|
try {
|
|
49729
|
-
const existing = await
|
|
49746
|
+
const existing = await readFile32(options.outputPath, "utf-8");
|
|
49730
49747
|
await mkdir40(path56.dirname(backupPath), { recursive: true });
|
|
49731
49748
|
await writeFile37(backupPath, existing, "utf-8");
|
|
49732
49749
|
} catch (err) {
|
|
@@ -49838,7 +49855,7 @@ async function rebuildObservations(options) {
|
|
|
49838
49855
|
const contents = [];
|
|
49839
49856
|
for (const file of transcriptFiles) {
|
|
49840
49857
|
try {
|
|
49841
|
-
contents.push(await
|
|
49858
|
+
contents.push(await readFile33(file, "utf-8"));
|
|
49842
49859
|
} catch {
|
|
49843
49860
|
}
|
|
49844
49861
|
}
|
|
@@ -49865,7 +49882,7 @@ async function rebuildObservations(options) {
|
|
|
49865
49882
|
|
|
49866
49883
|
// ../remnic-core/src/maintenance/migrate-observations.ts
|
|
49867
49884
|
import path58 from "path";
|
|
49868
|
-
import { readdir as readdir20, readFile as
|
|
49885
|
+
import { readdir as readdir20, readFile as readFile34 } from "fs/promises";
|
|
49869
49886
|
function toNonNegativeInt(value) {
|
|
49870
49887
|
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
49871
49888
|
const normalized = Math.floor(value);
|
|
@@ -49937,7 +49954,7 @@ async function migrateObservations(options) {
|
|
|
49937
49954
|
let malformedLines = 0;
|
|
49938
49955
|
for (const file of legacyFiles) {
|
|
49939
49956
|
const full = path58.join(ledgerRoot, file);
|
|
49940
|
-
const raw = await
|
|
49957
|
+
const raw = await readFile34(full, "utf-8");
|
|
49941
49958
|
for (const line of raw.split("\n")) {
|
|
49942
49959
|
if (!line.trim()) continue;
|
|
49943
49960
|
let parsed;
|
|
@@ -50141,7 +50158,7 @@ async function runNamespaceMigration(options) {
|
|
|
50141
50158
|
// ../remnic-core/src/operator-toolkit.ts
|
|
50142
50159
|
import path61 from "path";
|
|
50143
50160
|
import { constants as fsConstants } from "fs";
|
|
50144
|
-
import { access as access4, mkdir as mkdir42, readFile as
|
|
50161
|
+
import { access as access4, mkdir as mkdir42, readFile as readFile36, readdir as readdir23, stat as stat15, unlink as unlink10, writeFile as writeFile38 } from "fs/promises";
|
|
50145
50162
|
|
|
50146
50163
|
// ../remnic-core/src/plugin-id.ts
|
|
50147
50164
|
var PLUGIN_ID = "openclaw-remnic";
|
|
@@ -50170,7 +50187,7 @@ function resolveRemnicPluginEntry(raw, preferredId) {
|
|
|
50170
50187
|
|
|
50171
50188
|
// ../remnic-core/src/consolidation-provenance-check.ts
|
|
50172
50189
|
import path60 from "path";
|
|
50173
|
-
import { readdir as readdir22, readFile as
|
|
50190
|
+
import { readdir as readdir22, readFile as readFile35, stat as stat14 } from "fs/promises";
|
|
50174
50191
|
var DERIVED_VIA_RAW_RE = /^[\t ]*derived_via:[\t ]*(.*)$/mu;
|
|
50175
50192
|
var DERIVED_FROM_RAW_RE = /^[\t ]*derived_from:[\t ]*(.*)$/mu;
|
|
50176
50193
|
function tokenizeRawBlockList(fmSlice, key) {
|
|
@@ -50301,7 +50318,7 @@ async function runConsolidationProvenanceCheck(options) {
|
|
|
50301
50318
|
let fromMatchCount = 0;
|
|
50302
50319
|
let fmSlice = "";
|
|
50303
50320
|
try {
|
|
50304
|
-
const raw = await
|
|
50321
|
+
const raw = await readFile35(memory.path, "utf-8");
|
|
50305
50322
|
const frontmatterEnd = raw.indexOf("\n---", raw.indexOf("---") + 3);
|
|
50306
50323
|
fmSlice = frontmatterEnd > 0 ? raw.slice(0, frontmatterEnd) : raw;
|
|
50307
50324
|
const viaMatches = [...fmSlice.matchAll(new RegExp(DERIVED_VIA_RAW_RE.source, DERIVED_VIA_RAW_RE.flags + "g"))];
|
|
@@ -50447,7 +50464,7 @@ async function runConsolidationProvenanceCheck(options) {
|
|
|
50447
50464
|
for await (const file of walkMarkdownFiles(rootPath)) {
|
|
50448
50465
|
if (seenPaths.has(file)) continue;
|
|
50449
50466
|
try {
|
|
50450
|
-
const raw = await
|
|
50467
|
+
const raw = await readFile35(file, "utf-8");
|
|
50451
50468
|
if (DERIVED_FROM_RAW_RE.test(raw) || DERIVED_VIA_RAW_RE.test(raw)) {
|
|
50452
50469
|
report.withProvenance += 1;
|
|
50453
50470
|
report.issues.push({
|
|
@@ -50558,7 +50575,7 @@ function resolveConfigPath(explicitPath) {
|
|
|
50558
50575
|
async function loadCliPluginConfig(configPath) {
|
|
50559
50576
|
const resolvedPath = resolveConfigPath(configPath);
|
|
50560
50577
|
try {
|
|
50561
|
-
const raw = JSON.parse(await
|
|
50578
|
+
const raw = JSON.parse(await readFile36(resolvedPath, "utf-8"));
|
|
50562
50579
|
const entry = resolveRemnicPluginEntry(raw);
|
|
50563
50580
|
const parsedConfig = parseConfig(
|
|
50564
50581
|
entry && typeof entry === "object" ? entry["config"] ?? {} : {}
|
|
@@ -50634,7 +50651,7 @@ function getSetupPaths(config) {
|
|
|
50634
50651
|
}
|
|
50635
50652
|
async function readJsonIfExists(filePath) {
|
|
50636
50653
|
try {
|
|
50637
|
-
return JSON.parse(await
|
|
50654
|
+
return JSON.parse(await readFile36(filePath, "utf-8"));
|
|
50638
50655
|
} catch {
|
|
50639
50656
|
return null;
|
|
50640
50657
|
}
|
|
@@ -50796,7 +50813,7 @@ async function runOperatorSetup(options) {
|
|
|
50796
50813
|
if (captureInstructionsMode) {
|
|
50797
50814
|
if (captureInstructionsMode === "preview") {
|
|
50798
50815
|
} else if (captureInstructionsMode === "install") {
|
|
50799
|
-
const existing = memoryDocExists ? await
|
|
50816
|
+
const existing = memoryDocExists ? await readFile36(memoryDocPath, "utf-8") : null;
|
|
50800
50817
|
const next = upsertManagedCaptureInstructions(existing, captureInstructionsPreview ?? "");
|
|
50801
50818
|
if (!existing || next.content !== existing) {
|
|
50802
50819
|
await writeFile38(memoryDocPath, next.content, "utf-8");
|
|
@@ -50805,7 +50822,7 @@ async function runOperatorSetup(options) {
|
|
|
50805
50822
|
memoryDocInstalled = next.installed;
|
|
50806
50823
|
memoryDocUpdated = next.updated;
|
|
50807
50824
|
} else if (captureInstructionsMode === "remove" && memoryDocExists) {
|
|
50808
|
-
const existing = await
|
|
50825
|
+
const existing = await readFile36(memoryDocPath, "utf-8");
|
|
50809
50826
|
const next = removeManagedCaptureInstructions(existing);
|
|
50810
50827
|
if (next.removed) {
|
|
50811
50828
|
if (next.content.length === 0) {
|
|
@@ -51291,8 +51308,8 @@ async function summarizeTierDistribution(storage) {
|
|
|
51291
51308
|
const sevenDaysAgoMs = Date.now() - 7 * 864e5;
|
|
51292
51309
|
if (journalPath) {
|
|
51293
51310
|
try {
|
|
51294
|
-
const { readFile:
|
|
51295
|
-
const raw = await
|
|
51311
|
+
const { readFile: readFile52 } = await import("fs/promises");
|
|
51312
|
+
const raw = await readFile52(journalPath, "utf-8");
|
|
51296
51313
|
for (const line of raw.split("\n")) {
|
|
51297
51314
|
const trimmed = line.trim();
|
|
51298
51315
|
if (trimmed.length === 0) continue;
|
|
@@ -51352,7 +51369,7 @@ async function summarizeDreamsPhases(config, storage = new StorageManager(config
|
|
|
51352
51369
|
latestRunId,
|
|
51353
51370
|
"manifest.json"
|
|
51354
51371
|
);
|
|
51355
|
-
const raw = await
|
|
51372
|
+
const raw = await readFile36(manifestPath2, "utf-8");
|
|
51356
51373
|
const parsed = JSON.parse(raw);
|
|
51357
51374
|
if (typeof parsed.createdAt === "string" && parsed.createdAt.length > 0) {
|
|
51358
51375
|
deepSleepLastRun = parsed.createdAt;
|
|
@@ -52211,12 +52228,12 @@ function toEncodedHref(pathname) {
|
|
|
52211
52228
|
import { createHash as createHash11 } from "crypto";
|
|
52212
52229
|
import { createServer as createServer2 } from "http";
|
|
52213
52230
|
import { watch } from "fs";
|
|
52214
|
-
import { readFile as
|
|
52231
|
+
import { readFile as readFile38 } from "fs/promises";
|
|
52215
52232
|
import path64 from "path";
|
|
52216
52233
|
|
|
52217
52234
|
// ../remnic-core/src/graph-dashboard-parser.ts
|
|
52218
52235
|
import path63 from "path";
|
|
52219
|
-
import { readFile as
|
|
52236
|
+
import { readFile as readFile37 } from "fs/promises";
|
|
52220
52237
|
|
|
52221
52238
|
// ../remnic-core/src/graph-dashboard-key.ts
|
|
52222
52239
|
function graphEdgeKey(edge) {
|
|
@@ -52243,7 +52260,7 @@ async function graphSnapshotFromMemoryDir(memoryDir) {
|
|
|
52243
52260
|
const filePath = graphFile(memoryDir, type);
|
|
52244
52261
|
let raw = "";
|
|
52245
52262
|
try {
|
|
52246
|
-
raw = await
|
|
52263
|
+
raw = await readFile37(filePath, "utf-8");
|
|
52247
52264
|
} catch {
|
|
52248
52265
|
filesMissing.push(type);
|
|
52249
52266
|
continue;
|
|
@@ -52470,7 +52487,7 @@ var GraphDashboardServer = class {
|
|
|
52470
52487
|
}
|
|
52471
52488
|
async respondStatic(res, filePath, contentType) {
|
|
52472
52489
|
try {
|
|
52473
|
-
const body = await
|
|
52490
|
+
const body = await readFile38(filePath, "utf-8");
|
|
52474
52491
|
res.statusCode = 200;
|
|
52475
52492
|
res.setHeader("content-type", contentType);
|
|
52476
52493
|
res.setHeader("content-length", String(Buffer.byteLength(body)));
|
|
@@ -52593,7 +52610,7 @@ import { constants as fsConstants2 } from "fs";
|
|
|
52593
52610
|
import { createHash as createHash13 } from "crypto";
|
|
52594
52611
|
|
|
52595
52612
|
// ../remnic-core/src/access-idempotency.ts
|
|
52596
|
-
import { mkdir as mkdir44, open as open4, readFile as
|
|
52613
|
+
import { mkdir as mkdir44, open as open4, readFile as readFile39, rename as rename7, stat as stat18, unlink as unlink11, utimes as utimes2, writeFile as writeFile39 } from "fs/promises";
|
|
52597
52614
|
import path65 from "path";
|
|
52598
52615
|
import { createHash as createHash12 } from "crypto";
|
|
52599
52616
|
var testHooks = null;
|
|
@@ -52668,7 +52685,7 @@ var AccessIdempotencyStore = class {
|
|
|
52668
52685
|
}
|
|
52669
52686
|
}
|
|
52670
52687
|
try {
|
|
52671
|
-
const raw = await
|
|
52688
|
+
const raw = await readFile39(this.statePath, "utf-8");
|
|
52672
52689
|
const parsed = JSON.parse(raw);
|
|
52673
52690
|
if (parsed && typeof parsed === "object") {
|
|
52674
52691
|
this.state = parsed;
|
|
@@ -52691,7 +52708,7 @@ var AccessIdempotencyStore = class {
|
|
|
52691
52708
|
await mkdir44(path65.dirname(this.statePath), { recursive: true });
|
|
52692
52709
|
await this.withExclusiveFileLock(this.lockPath, async () => {
|
|
52693
52710
|
try {
|
|
52694
|
-
const raw = await
|
|
52711
|
+
const raw = await readFile39(this.statePath, "utf-8");
|
|
52695
52712
|
const parsed = JSON.parse(raw);
|
|
52696
52713
|
if (parsed && typeof parsed === "object") {
|
|
52697
52714
|
this.state = {
|
|
@@ -53555,7 +53572,7 @@ function defaultLabelFromPath(relPath) {
|
|
|
53555
53572
|
import * as nodePath from "path";
|
|
53556
53573
|
|
|
53557
53574
|
// ../remnic-core/src/briefing.ts
|
|
53558
|
-
import { readFile as
|
|
53575
|
+
import { readFile as readFile40 } from "fs/promises";
|
|
53559
53576
|
import os4 from "os";
|
|
53560
53577
|
import path68 from "path";
|
|
53561
53578
|
var BRIEFING_FORMAT_ALLOWED = ["markdown", "json"];
|
|
@@ -53663,7 +53680,7 @@ var FileCalendarSource = class {
|
|
|
53663
53680
|
async eventsForDate(dateIso) {
|
|
53664
53681
|
let raw;
|
|
53665
53682
|
try {
|
|
53666
|
-
raw = await
|
|
53683
|
+
raw = await readFile40(this.filePath, "utf-8");
|
|
53667
53684
|
} catch (err) {
|
|
53668
53685
|
log.warn(`briefing: calendar source unreadable at ${this.filePath}: ${err}`);
|
|
53669
53686
|
return [];
|
|
@@ -57806,7 +57823,7 @@ ${next}`);
|
|
|
57806
57823
|
const resolvedNs = this.resolveWritableNamespace(request.namespace, request.sessionKey, request.principal);
|
|
57807
57824
|
const storage = await this.orchestrator.getStorage(resolvedNs);
|
|
57808
57825
|
const storageDir = storage.dir;
|
|
57809
|
-
const { writeFile:
|
|
57826
|
+
const { writeFile: writeFile44, mkdir: mkdir52 } = await import("fs/promises");
|
|
57810
57827
|
const { join: join6, resolve: resolve2 } = await import("path");
|
|
57811
57828
|
const safeKey = request.sessionKey.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
57812
57829
|
if (!safeKey) throw new EngramAccessInputError("sessionKey is required");
|
|
@@ -57818,7 +57835,7 @@ ${next}`);
|
|
|
57818
57835
|
await mkdir52(checkpointDir, { recursive: true });
|
|
57819
57836
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
57820
57837
|
const filePath = join6(checkpointDir, `checkpoint-${ts}.md`);
|
|
57821
|
-
await
|
|
57838
|
+
await writeFile44(filePath, request.context, "utf-8");
|
|
57822
57839
|
return { saved: true };
|
|
57823
57840
|
}
|
|
57824
57841
|
async lcmStatus() {
|
|
@@ -57901,7 +57918,7 @@ ${next}`);
|
|
|
57901
57918
|
* deterministic alphabetical order (mirroring `listPeers` storage semantics).
|
|
57902
57919
|
*/
|
|
57903
57920
|
async peerList() {
|
|
57904
|
-
const { listPeers: listPeers2 } = await import("./peers-
|
|
57921
|
+
const { listPeers: listPeers2 } = await import("./peers-KRFXWRQ6.js");
|
|
57905
57922
|
const peers = await listPeers2(this.orchestrator.config.memoryDir);
|
|
57906
57923
|
return { peers };
|
|
57907
57924
|
}
|
|
@@ -57911,7 +57928,7 @@ ${next}`);
|
|
|
57911
57928
|
* pattern used throughout the service.
|
|
57912
57929
|
*/
|
|
57913
57930
|
async peerGet(peerId) {
|
|
57914
|
-
const peers = await import("./peers-
|
|
57931
|
+
const peers = await import("./peers-KRFXWRQ6.js");
|
|
57915
57932
|
const validateId = peers.assertValidPeerId;
|
|
57916
57933
|
try {
|
|
57917
57934
|
validateId(peerId);
|
|
@@ -57931,7 +57948,7 @@ ${next}`);
|
|
|
57931
57948
|
* Returns `{ created: true }` on first write, `{ created: false }` on update.
|
|
57932
57949
|
*/
|
|
57933
57950
|
async peerSet(input) {
|
|
57934
|
-
const peers = await import("./peers-
|
|
57951
|
+
const peers = await import("./peers-KRFXWRQ6.js");
|
|
57935
57952
|
const validateId = peers.assertValidPeerId;
|
|
57936
57953
|
const { id } = input;
|
|
57937
57954
|
try {
|
|
@@ -57979,7 +57996,7 @@ ${next}`);
|
|
|
57979
57996
|
* log data are not destroyed.
|
|
57980
57997
|
*/
|
|
57981
57998
|
async peerDelete(peerId) {
|
|
57982
|
-
const peers = await import("./peers-
|
|
57999
|
+
const peers = await import("./peers-KRFXWRQ6.js");
|
|
57983
58000
|
const validateId = peers.assertValidPeerId;
|
|
57984
58001
|
try {
|
|
57985
58002
|
validateId(peerId);
|
|
@@ -58003,7 +58020,7 @@ ${next}`);
|
|
|
58003
58020
|
* not exist (idempotent no-op).
|
|
58004
58021
|
*/
|
|
58005
58022
|
async peerForget(peerId, opts) {
|
|
58006
|
-
const peers = await import("./peers-
|
|
58023
|
+
const peers = await import("./peers-KRFXWRQ6.js");
|
|
58007
58024
|
const validateId = peers.assertValidPeerId;
|
|
58008
58025
|
try {
|
|
58009
58026
|
validateId(peerId);
|
|
@@ -58027,7 +58044,7 @@ ${next}`);
|
|
|
58027
58044
|
* but in practice the reasoner only writes profiles for registered peers.
|
|
58028
58045
|
*/
|
|
58029
58046
|
async peerProfileGet(peerId) {
|
|
58030
|
-
const peers = await import("./peers-
|
|
58047
|
+
const peers = await import("./peers-KRFXWRQ6.js");
|
|
58031
58048
|
const validateId = peers.assertValidPeerId;
|
|
58032
58049
|
try {
|
|
58033
58050
|
validateId(peerId);
|
|
@@ -58342,13 +58359,13 @@ ${next}`);
|
|
|
58342
58359
|
import { createServer as createServer3 } from "http";
|
|
58343
58360
|
import { randomUUID as randomUUID6, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
58344
58361
|
import { AsyncLocalStorage } from "async_hooks";
|
|
58345
|
-
import { existsSync as
|
|
58346
|
-
import { readFile as
|
|
58362
|
+
import { existsSync as existsSync6 } from "fs";
|
|
58363
|
+
import { readFile as readFile43 } from "fs/promises";
|
|
58347
58364
|
import path70 from "path";
|
|
58348
58365
|
import { fileURLToPath as fileURLToPath3, URL as URL3 } from "url";
|
|
58349
58366
|
|
|
58350
58367
|
// ../remnic-core/src/access-mcp.ts
|
|
58351
|
-
import { readFile as
|
|
58368
|
+
import { readFile as readFile42 } from "fs/promises";
|
|
58352
58369
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
58353
58370
|
|
|
58354
58371
|
// ../remnic-core/src/access-schema.ts
|
|
@@ -58702,7 +58719,7 @@ async function getMcpServerVersion() {
|
|
|
58702
58719
|
if (envVersion) return envVersion;
|
|
58703
58720
|
try {
|
|
58704
58721
|
const pkgPath = new URL("../package.json", import.meta.url);
|
|
58705
|
-
const raw = await
|
|
58722
|
+
const raw = await readFile42(pkgPath, "utf-8");
|
|
58706
58723
|
const parsed = JSON.parse(raw);
|
|
58707
58724
|
return parsed.version?.trim() || "unknown";
|
|
58708
58725
|
} catch {
|
|
@@ -61170,7 +61187,7 @@ function resolveDefaultAdminConsolePublicDir() {
|
|
|
61170
61187
|
// Package root: walk up from dist/ to the package root
|
|
61171
61188
|
path70.resolve(thisDir, "../../admin-console/public")
|
|
61172
61189
|
];
|
|
61173
|
-
return candidates.find((candidate) =>
|
|
61190
|
+
return candidates.find((candidate) => existsSync6(candidate)) ?? candidates[0];
|
|
61174
61191
|
}
|
|
61175
61192
|
var defaultAdminConsolePublicDir = resolveDefaultAdminConsolePublicDir();
|
|
61176
61193
|
var correlationIdStore = new AsyncLocalStorage();
|
|
@@ -62430,7 +62447,7 @@ var EngramAccessHttpServer = class {
|
|
|
62430
62447
|
}
|
|
62431
62448
|
async respondStatic(res, filePath, contentType) {
|
|
62432
62449
|
try {
|
|
62433
|
-
const body = await
|
|
62450
|
+
const body = await readFile43(filePath, "utf-8");
|
|
62434
62451
|
res.statusCode = 200;
|
|
62435
62452
|
res.setHeader("content-type", contentType);
|
|
62436
62453
|
res.setHeader("content-length", String(Buffer.byteLength(body)));
|
|
@@ -62605,7 +62622,7 @@ async function resolveAgentAccessAuthToken(value, options = {}) {
|
|
|
62605
62622
|
}
|
|
62606
62623
|
|
|
62607
62624
|
// ../remnic-core/src/compat/checks.ts
|
|
62608
|
-
import { access as access6, readFile as
|
|
62625
|
+
import { access as access6, readFile as readFile44 } from "fs/promises";
|
|
62609
62626
|
import path71 from "path";
|
|
62610
62627
|
var REQUIRED_HOOKS_LEGACY = ["before_agent_start", "agent_end"];
|
|
62611
62628
|
var REQUIRED_HOOKS_NEW = ["before_prompt_build", "agent_end"];
|
|
@@ -62787,7 +62804,7 @@ async function runCompatChecks(options) {
|
|
|
62787
62804
|
let pluginRaw = "";
|
|
62788
62805
|
let pluginManifestPresent = false;
|
|
62789
62806
|
try {
|
|
62790
|
-
pluginRaw = await
|
|
62807
|
+
pluginRaw = await readFile44(pluginJsonPath, "utf-8");
|
|
62791
62808
|
pluginManifestPresent = true;
|
|
62792
62809
|
checks.push({
|
|
62793
62810
|
id: "plugin-manifest-present",
|
|
@@ -62837,7 +62854,7 @@ async function runCompatChecks(options) {
|
|
|
62837
62854
|
let packageRaw = "";
|
|
62838
62855
|
let packageJsonPresent = false;
|
|
62839
62856
|
try {
|
|
62840
|
-
packageRaw = await
|
|
62857
|
+
packageRaw = await readFile44(packageJsonPath, "utf-8");
|
|
62841
62858
|
packageJsonPresent = true;
|
|
62842
62859
|
} catch {
|
|
62843
62860
|
checks.push({
|
|
@@ -62908,7 +62925,7 @@ async function runCompatChecks(options) {
|
|
|
62908
62925
|
}
|
|
62909
62926
|
try {
|
|
62910
62927
|
await access6(indexPath);
|
|
62911
|
-
const indexRaw = await
|
|
62928
|
+
const indexRaw = await readFile44(indexPath, "utf-8");
|
|
62912
62929
|
const structuralSource = stripCommentsAndStrings(indexRaw);
|
|
62913
62930
|
const hooks = parseHookRegistrations(indexRaw);
|
|
62914
62931
|
const missingLegacy = REQUIRED_HOOKS_LEGACY.filter((hook) => !hooks.has(hook));
|
|
@@ -63333,7 +63350,7 @@ async function promoteSemanticRuleFromMemory(options) {
|
|
|
63333
63350
|
}
|
|
63334
63351
|
|
|
63335
63352
|
// ../remnic-core/src/training-export/converter.ts
|
|
63336
|
-
import { lstat as lstat3, readdir as readdir27, readFile as
|
|
63353
|
+
import { lstat as lstat3, readdir as readdir27, readFile as readFile45, realpath as realpath4 } from "fs/promises";
|
|
63337
63354
|
import path73 from "path";
|
|
63338
63355
|
|
|
63339
63356
|
// ../remnic-core/src/training-export/date-parse.ts
|
|
@@ -63939,7 +63956,7 @@ async function runRepairMemoryProjectionCliCommand(options) {
|
|
|
63939
63956
|
});
|
|
63940
63957
|
}
|
|
63941
63958
|
async function runMemoryTimelineCliCommand(options) {
|
|
63942
|
-
const storage = new (await import("./storage-
|
|
63959
|
+
const storage = new (await import("./storage-I26Y7X4D.js")).StorageManager(options.memoryDir);
|
|
63943
63960
|
return storage.getMemoryTimeline(options.memoryId, options.limit);
|
|
63944
63961
|
}
|
|
63945
63962
|
async function runMemoryGovernanceCliCommand(options) {
|
|
@@ -63967,7 +63984,7 @@ async function runMemoryGovernanceRestoreCliCommand(options) {
|
|
|
63967
63984
|
});
|
|
63968
63985
|
}
|
|
63969
63986
|
async function runMemoryReviewDispositionCliCommand(options) {
|
|
63970
|
-
const storage = new (await import("./storage-
|
|
63987
|
+
const storage = new (await import("./storage-I26Y7X4D.js")).StorageManager(options.memoryDir);
|
|
63971
63988
|
const memory = await storage.getMemoryById(options.memoryId);
|
|
63972
63989
|
if (!memory) throw new Error(`memory not found: ${options.memoryId}`);
|
|
63973
63990
|
const updated = await storage.writeMemoryFrontmatter(memory, {
|
|
@@ -64146,7 +64163,7 @@ async function runSemanticRulePromoteCliCommand(options) {
|
|
|
64146
64163
|
});
|
|
64147
64164
|
}
|
|
64148
64165
|
async function runCompoundingPromoteCliCommand(options) {
|
|
64149
|
-
const { CompoundingEngine: CompoundingEngine2 } = await import("./engine-
|
|
64166
|
+
const { CompoundingEngine: CompoundingEngine2 } = await import("./engine-2DZ5FF5Q.js");
|
|
64150
64167
|
const config = parseConfig({
|
|
64151
64168
|
memoryDir: options.memoryDir,
|
|
64152
64169
|
qmdEnabled: false,
|
|
@@ -65151,7 +65168,7 @@ async function withTimeout(promise, timeoutMs, timeoutMessage) {
|
|
|
65151
65168
|
}
|
|
65152
65169
|
async function runReplayCliCommand(orchestrator, options) {
|
|
65153
65170
|
const extractionIdleTimeoutMs = Number.isFinite(options.extractionIdleTimeoutMs) ? Math.max(1e3, Math.floor(options.extractionIdleTimeoutMs)) : 15 * 6e4;
|
|
65154
|
-
const inputRaw = await
|
|
65171
|
+
const inputRaw = await readFile46(options.inputPath, "utf-8");
|
|
65155
65172
|
const registry = buildReplayNormalizerRegistry([
|
|
65156
65173
|
openclawReplayNormalizer,
|
|
65157
65174
|
claudeReplayNormalizer,
|
|
@@ -65243,7 +65260,7 @@ async function runBulkImportCliCommand(opts) {
|
|
|
65243
65260
|
"Bulk import persistence is not wired: no ingestBatch callback was provided by the host CLI. Use --dry-run to validate without persisting, or invoke via `openclaw engram bulk-import` which supplies the orchestrator-backed ingestion path."
|
|
65244
65261
|
);
|
|
65245
65262
|
}
|
|
65246
|
-
const inputRaw = await
|
|
65263
|
+
const inputRaw = await readFile46(opts.file, "utf-8");
|
|
65247
65264
|
let inputParsed;
|
|
65248
65265
|
try {
|
|
65249
65266
|
inputParsed = JSON.parse(inputRaw);
|
|
@@ -65307,7 +65324,7 @@ async function runBulkImportCliCommand(opts) {
|
|
|
65307
65324
|
async function getPluginVersion() {
|
|
65308
65325
|
try {
|
|
65309
65326
|
const pkgPath = new URL("../package.json", import.meta.url);
|
|
65310
|
-
const raw = await
|
|
65327
|
+
const raw = await readFile46(pkgPath, "utf-8");
|
|
65311
65328
|
const parsed = JSON.parse(raw);
|
|
65312
65329
|
return parsed.version ?? "unknown";
|
|
65313
65330
|
} catch {
|
|
@@ -65372,7 +65389,7 @@ async function readAllMemoryFiles(memoryDir) {
|
|
|
65372
65389
|
const out = [];
|
|
65373
65390
|
await walkMemoryMarkdownFiles(memoryDir, async (fullPath) => {
|
|
65374
65391
|
try {
|
|
65375
|
-
const raw = await
|
|
65392
|
+
const raw = await readFile46(fullPath, "utf-8");
|
|
65376
65393
|
const parsed = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
65377
65394
|
if (!parsed) return;
|
|
65378
65395
|
const fmRaw = parsed[1];
|
|
@@ -66260,7 +66277,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
66260
66277
|
const dirWasExplicit = typeof opts.dir === "string" && opts.dir.trim() !== "";
|
|
66261
66278
|
const parsed = parseCapsuleListOptions(opts, defaultDir);
|
|
66262
66279
|
const capsulesDir = expandTildePath(parsed.capsulesDir);
|
|
66263
|
-
const { readdir: readdir30, readFile:
|
|
66280
|
+
const { readdir: readdir30, readFile: readFile52, stat: stat21 } = await import("fs/promises");
|
|
66264
66281
|
let dirEntries;
|
|
66265
66282
|
try {
|
|
66266
66283
|
dirEntries = await readdir30(capsulesDir);
|
|
@@ -66299,7 +66316,7 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
66299
66316
|
}
|
|
66300
66317
|
if (hasManifest) {
|
|
66301
66318
|
try {
|
|
66302
|
-
const raw = await
|
|
66319
|
+
const raw = await readFile52(manifestPath2, "utf-8");
|
|
66303
66320
|
const sidecar = JSON.parse(raw);
|
|
66304
66321
|
createdAt = typeof sidecar.createdAt === "string" ? sidecar.createdAt : null;
|
|
66305
66322
|
pluginVersion = typeof sidecar.pluginVersion === "string" ? sidecar.pluginVersion : null;
|
|
@@ -66365,8 +66382,8 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
66365
66382
|
const sidecarPath = archivePath.replace(/\.enc$/, "").replace(/\.capsule\.json\.gz$/, ".manifest.json");
|
|
66366
66383
|
let sidecar = null;
|
|
66367
66384
|
try {
|
|
66368
|
-
const { readFile:
|
|
66369
|
-
const raw = await
|
|
66385
|
+
const { readFile: readFile52 } = await import("fs/promises");
|
|
66386
|
+
const raw = await readFile52(sidecarPath, "utf-8");
|
|
66370
66387
|
sidecar = JSON.parse(raw);
|
|
66371
66388
|
} catch {
|
|
66372
66389
|
}
|
|
@@ -66403,10 +66420,10 @@ function registerCli(api, orchestrator, registerOptions = {}) {
|
|
|
66403
66420
|
}
|
|
66404
66421
|
manifest = parsed2.bundle.manifest;
|
|
66405
66422
|
} else {
|
|
66406
|
-
const { readFile:
|
|
66423
|
+
const { readFile: readFile52 } = await import("fs/promises");
|
|
66407
66424
|
const { gunzipSync } = await import("zlib");
|
|
66408
66425
|
const { parseExportBundle } = await import("./types-R4DO7AKM.js");
|
|
66409
|
-
const buf = await
|
|
66426
|
+
const buf = await readFile52(archivePath);
|
|
66410
66427
|
const json = gunzipSync(buf).toString("utf-8");
|
|
66411
66428
|
const parsed2 = parseExportBundle(JSON.parse(json));
|
|
66412
66429
|
if (parsed2.capsuleVersion !== 2) {
|
|
@@ -69284,7 +69301,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
69284
69301
|
const peerCmd = cmd.command("peer").description("Manage the peer registry (issue #679).");
|
|
69285
69302
|
peerCmd.command("list").description("List all registered peers").option("--json", "Emit machine-readable JSON only").action(async (...args) => {
|
|
69286
69303
|
const options = args[0] ?? {};
|
|
69287
|
-
const { listPeers: listPeers2 } = await import("./peers-
|
|
69304
|
+
const { listPeers: listPeers2 } = await import("./peers-KRFXWRQ6.js");
|
|
69288
69305
|
const peers = await listPeers2(orchestrator.config.memoryDir);
|
|
69289
69306
|
if (options.json === true) {
|
|
69290
69307
|
console.log(JSON.stringify({ peers }, null, 2));
|
|
@@ -69308,7 +69325,7 @@ Semantic consolidation complete. clusters=${result.clustersFound}, consolidated=
|
|
|
69308
69325
|
console.error("peer id is required");
|
|
69309
69326
|
process.exit(1);
|
|
69310
69327
|
}
|
|
69311
|
-
const peersShow = await import("./peers-
|
|
69328
|
+
const peersShow = await import("./peers-KRFXWRQ6.js");
|
|
69312
69329
|
const validateIdShow = peersShow.assertValidPeerId;
|
|
69313
69330
|
try {
|
|
69314
69331
|
validateIdShow(id);
|
|
@@ -69421,7 +69438,7 @@ ${peer.notes.split("\n").map((l) => ` ${l}`).join("\n")}`);
|
|
|
69421
69438
|
console.error("peer id is required");
|
|
69422
69439
|
process.exit(1);
|
|
69423
69440
|
}
|
|
69424
|
-
const peersProfile = await import("./peers-
|
|
69441
|
+
const peersProfile = await import("./peers-KRFXWRQ6.js");
|
|
69425
69442
|
const validateIdProfile = peersProfile.assertValidPeerId;
|
|
69426
69443
|
try {
|
|
69427
69444
|
validateIdProfile(id);
|
|
@@ -69456,7 +69473,7 @@ ${peer.notes.split("\n").map((l) => ` ${l}`).join("\n")}`);
|
|
|
69456
69473
|
const options = args[0] ?? {};
|
|
69457
69474
|
const isDryRun = options.dryRun === true;
|
|
69458
69475
|
const displayName = typeof options.displayName === "string" && options.displayName.length > 0 ? options.displayName : void 0;
|
|
69459
|
-
const { migrateFromIdentityAnchor } = await import("./migrate-from-identity-anchor-
|
|
69476
|
+
const { migrateFromIdentityAnchor } = await import("./migrate-from-identity-anchor-7MMSPEUM.js");
|
|
69460
69477
|
let result;
|
|
69461
69478
|
try {
|
|
69462
69479
|
result = await migrateFromIdentityAnchor({
|
|
@@ -69932,20 +69949,18 @@ async function probeQmdAvailability(host) {
|
|
|
69932
69949
|
}
|
|
69933
69950
|
|
|
69934
69951
|
// ../../src/index.ts
|
|
69935
|
-
import { readFile as readFile53, realpath as realpath7, writeFile as writeFile44 } from "fs/promises";
|
|
69936
|
-
import { existsSync as existsSync12, readFileSync as readFileSync6 } from "fs";
|
|
69937
69952
|
import path99 from "path";
|
|
69938
69953
|
import os7 from "os";
|
|
69939
69954
|
|
|
69940
69955
|
// ../remnic-core/src/opik-exporter.ts
|
|
69941
69956
|
import { createHash as createHash15, randomBytes as randomBytes2 } from "crypto";
|
|
69942
|
-
import
|
|
69957
|
+
import fs5 from "fs";
|
|
69943
69958
|
import path75 from "path";
|
|
69944
69959
|
var OPIK_EXPORTER_SLOT = "__openclawOpikExporter";
|
|
69945
69960
|
function readOpikOpenclawConfig(log2) {
|
|
69946
69961
|
try {
|
|
69947
69962
|
const configPath = readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH") || readEnvVar("OPENCLAW_CONFIG_PATH") || path75.join(resolveHomeDir(), ".openclaw", "openclaw.json");
|
|
69948
|
-
const raw = JSON.parse(
|
|
69963
|
+
const raw = JSON.parse(fs5.readFileSync(configPath, "utf-8"));
|
|
69949
69964
|
const entry = raw?.plugins?.entries?.["opik-openclaw"];
|
|
69950
69965
|
if (!entry?.enabled || !entry?.config) return {};
|
|
69951
69966
|
const c = entry.config;
|
|
@@ -70441,7 +70456,9 @@ async function listRemnicPublicArtifacts(params) {
|
|
|
70441
70456
|
}
|
|
70442
70457
|
const deduped = /* @__PURE__ */ new Map();
|
|
70443
70458
|
for (const artifact of artifacts) {
|
|
70444
|
-
const key =
|
|
70459
|
+
const key = [artifact.workspaceDir, artifact.relativePath, artifact.kind].join(
|
|
70460
|
+
String.fromCharCode(0)
|
|
70461
|
+
);
|
|
70445
70462
|
deduped.set(key, artifact);
|
|
70446
70463
|
}
|
|
70447
70464
|
return [...deduped.values()];
|
|
@@ -70568,7 +70585,7 @@ async function getMemoryForActiveMemory(orchestrator, id, options = {}) {
|
|
|
70568
70585
|
var DEFAULT_MAX_BINARY_SIZE_BYTES = 50 * 1024 * 1024;
|
|
70569
70586
|
|
|
70570
70587
|
// ../remnic-core/src/binary-lifecycle/backend.ts
|
|
70571
|
-
import
|
|
70588
|
+
import fs6 from "fs";
|
|
70572
70589
|
import fsp2 from "fs/promises";
|
|
70573
70590
|
import path77 from "path";
|
|
70574
70591
|
|
|
@@ -70587,7 +70604,7 @@ import path80 from "path";
|
|
|
70587
70604
|
import crypto4 from "crypto";
|
|
70588
70605
|
|
|
70589
70606
|
// ../remnic-core/src/projection/index.ts
|
|
70590
|
-
import
|
|
70607
|
+
import fs7 from "fs";
|
|
70591
70608
|
import path82 from "path";
|
|
70592
70609
|
|
|
70593
70610
|
// ../remnic-core/src/utils/category-dir.ts
|
|
@@ -70616,61 +70633,61 @@ var ALL_CATEGORY_KEYS = [
|
|
|
70616
70633
|
];
|
|
70617
70634
|
|
|
70618
70635
|
// ../remnic-core/src/onboarding/index.ts
|
|
70619
|
-
import
|
|
70636
|
+
import fs8 from "fs";
|
|
70620
70637
|
import path83 from "path";
|
|
70621
70638
|
|
|
70622
70639
|
// ../remnic-core/src/curation/index.ts
|
|
70623
|
-
import
|
|
70640
|
+
import fs9 from "fs";
|
|
70624
70641
|
import path84 from "path";
|
|
70625
70642
|
import crypto5 from "crypto";
|
|
70626
70643
|
|
|
70627
70644
|
// ../remnic-core/src/dedup/index.ts
|
|
70628
|
-
import
|
|
70645
|
+
import fs10 from "fs";
|
|
70629
70646
|
import path85 from "path";
|
|
70630
70647
|
import crypto6 from "crypto";
|
|
70631
70648
|
|
|
70632
70649
|
// ../remnic-core/src/review/index.ts
|
|
70633
|
-
import
|
|
70650
|
+
import fs11 from "fs";
|
|
70634
70651
|
import path86 from "path";
|
|
70635
70652
|
|
|
70636
70653
|
// ../remnic-core/src/sync/index.ts
|
|
70637
|
-
import
|
|
70654
|
+
import fs12 from "fs";
|
|
70638
70655
|
import path87 from "path";
|
|
70639
70656
|
import crypto7 from "crypto";
|
|
70640
70657
|
|
|
70641
70658
|
// ../remnic-core/src/connectors/index.ts
|
|
70642
|
-
import
|
|
70659
|
+
import fs15 from "fs";
|
|
70643
70660
|
import path90 from "path";
|
|
70644
70661
|
import os5 from "os";
|
|
70645
70662
|
import { createRequire as createRequire2 } from "module";
|
|
70646
70663
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
70647
70664
|
|
|
70648
70665
|
// ../remnic-core/src/tokens.ts
|
|
70649
|
-
import
|
|
70666
|
+
import fs13 from "fs";
|
|
70650
70667
|
import path88 from "path";
|
|
70651
70668
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
70652
70669
|
|
|
70653
70670
|
// ../remnic-core/src/connectors/codex-marketplace.ts
|
|
70654
|
-
import
|
|
70671
|
+
import fs14 from "fs";
|
|
70655
70672
|
import path89 from "path";
|
|
70656
70673
|
|
|
70657
70674
|
// ../remnic-core/src/spaces/index.ts
|
|
70658
|
-
import
|
|
70675
|
+
import fs16 from "fs";
|
|
70659
70676
|
import path91 from "path";
|
|
70660
70677
|
import crypto8 from "crypto";
|
|
70661
70678
|
|
|
70662
70679
|
// ../remnic-core/src/memory-extension/codex-publisher.ts
|
|
70663
|
-
import
|
|
70680
|
+
import fs17 from "fs";
|
|
70664
70681
|
import os6 from "os";
|
|
70665
70682
|
import path92 from "path";
|
|
70666
70683
|
|
|
70667
70684
|
// ../remnic-core/src/enrichment/audit.ts
|
|
70668
|
-
import { mkdir as mkdir47, readFile as
|
|
70669
|
-
import { existsSync as
|
|
70685
|
+
import { mkdir as mkdir47, readFile as readFile47, appendFile as appendFile5 } from "fs/promises";
|
|
70686
|
+
import { existsSync as existsSync7 } from "fs";
|
|
70670
70687
|
import path93 from "path";
|
|
70671
70688
|
|
|
70672
70689
|
// ../remnic-core/src/transfer/capsule-fork.ts
|
|
70673
|
-
import { lstat as lstat5, mkdir as mkdir48, readFile as
|
|
70690
|
+
import { lstat as lstat5, mkdir as mkdir48, readFile as readFile48, realpath as realpath6, writeFile as writeFile41 } from "fs/promises";
|
|
70674
70691
|
import path94 from "path";
|
|
70675
70692
|
|
|
70676
70693
|
// src/openclaw-tools/shapes.ts
|
|
@@ -71450,7 +71467,7 @@ function validateSlotSelection(ctx) {
|
|
|
71450
71467
|
}
|
|
71451
71468
|
|
|
71452
71469
|
// ../remnic-core/src/session-toggles.ts
|
|
71453
|
-
import { mkdir as mkdir49, readFile as
|
|
71470
|
+
import { mkdir as mkdir49, readFile as readFile49, writeFile as writeFile42 } from "fs/promises";
|
|
71454
71471
|
import path95 from "path";
|
|
71455
71472
|
function encodeToggleKey(sessionKey, agentId) {
|
|
71456
71473
|
return `${encodeURIComponent(sessionKey)}::${encodeURIComponent(agentId)}`;
|
|
@@ -71465,7 +71482,7 @@ function decodeToggleKey(key) {
|
|
|
71465
71482
|
}
|
|
71466
71483
|
async function safeReadToggleFile(filePath) {
|
|
71467
71484
|
try {
|
|
71468
|
-
const raw = await
|
|
71485
|
+
const raw = await readFile49(filePath, "utf8");
|
|
71469
71486
|
const parsed = JSON.parse(raw);
|
|
71470
71487
|
if (!parsed || typeof parsed !== "object" || typeof parsed.entries !== "object") {
|
|
71471
71488
|
return { version: 1, entries: {} };
|
|
@@ -71598,7 +71615,7 @@ function buildCacheKey(input, config, queryBundle) {
|
|
|
71598
71615
|
agentId: input.agentId,
|
|
71599
71616
|
queryMode: config.queryMode,
|
|
71600
71617
|
promptStyle: config.promptStyle,
|
|
71601
|
-
|
|
71618
|
+
customInstruction: config.customInstruction,
|
|
71602
71619
|
promptAppend: config.promptAppend,
|
|
71603
71620
|
maxSummaryChars: config.maxSummaryChars,
|
|
71604
71621
|
entityGraphDepth: config.entityGraphDepth,
|
|
@@ -71687,7 +71704,7 @@ function sanitizeTranscriptPathSegment(value) {
|
|
|
71687
71704
|
}
|
|
71688
71705
|
function buildActiveRecallPrompt(params) {
|
|
71689
71706
|
const sections = [
|
|
71690
|
-
params.config.
|
|
71707
|
+
params.config.customInstruction?.trim() || STYLE_INSTRUCTIONS[params.config.promptStyle],
|
|
71691
71708
|
`Query bundle:
|
|
71692
71709
|
${params.queryBundle}`,
|
|
71693
71710
|
params.recallContext ? `Retrieved memory:
|
|
@@ -71932,12 +71949,13 @@ function resolveCodexSessionIdentity(input) {
|
|
|
71932
71949
|
function buildTurnFingerprint(input) {
|
|
71933
71950
|
const normalizedContent = input.content.replace(/\s+/g, " ").trim();
|
|
71934
71951
|
const fingerprintContent = typeof input.maxContentChars === "number" && Number.isFinite(input.maxContentChars) && input.maxContentChars > 0 ? normalizedContent.slice(0, input.maxContentChars) : normalizedContent;
|
|
71952
|
+
const fieldSeparator = String.fromCharCode(1);
|
|
71935
71953
|
return [
|
|
71936
71954
|
input.role,
|
|
71937
71955
|
fingerprintContent,
|
|
71938
71956
|
input.providerThreadId ?? input.logicalSessionKey,
|
|
71939
71957
|
String(input.turnIndex)
|
|
71940
|
-
].join(
|
|
71958
|
+
].join(fieldSeparator);
|
|
71941
71959
|
}
|
|
71942
71960
|
|
|
71943
71961
|
// ../../src/index.ts
|
|
@@ -71949,7 +71967,7 @@ import {
|
|
|
71949
71967
|
// ../remnic-core/src/surfaces/dreams.ts
|
|
71950
71968
|
import { createHash as createHash16 } from "crypto";
|
|
71951
71969
|
import { statSync, watch as watch2 } from "fs";
|
|
71952
|
-
import { mkdir as mkdir51, readFile as
|
|
71970
|
+
import { mkdir as mkdir51, readFile as readFile50, writeFile as writeFile43 } from "fs/promises";
|
|
71953
71971
|
import path97 from "path";
|
|
71954
71972
|
var DIARY_START_MARKER = "<!-- openclaw:dreaming:diary:start -->";
|
|
71955
71973
|
var DIARY_END_MARKER = "<!-- openclaw:dreaming:diary:end -->";
|
|
@@ -72115,7 +72133,7 @@ function createDreamsSurface() {
|
|
|
72115
72133
|
return {
|
|
72116
72134
|
async read(filePath) {
|
|
72117
72135
|
try {
|
|
72118
|
-
const content = await
|
|
72136
|
+
const content = await readFile50(filePath, "utf8");
|
|
72119
72137
|
return parseDreamEntries(content);
|
|
72120
72138
|
} catch (error) {
|
|
72121
72139
|
if (error.code === "ENOENT") {
|
|
@@ -72128,7 +72146,7 @@ function createDreamsSurface() {
|
|
|
72128
72146
|
await mkdir51(path97.dirname(filePath), { recursive: true });
|
|
72129
72147
|
let content = "";
|
|
72130
72148
|
try {
|
|
72131
|
-
content = await
|
|
72149
|
+
content = await readFile50(filePath, "utf8");
|
|
72132
72150
|
} catch (error) {
|
|
72133
72151
|
if (error.code !== "ENOENT") throw error;
|
|
72134
72152
|
}
|
|
@@ -72226,7 +72244,7 @@ ${ensured.slice(endIndex)}` : `${ensureDiary("")}${block}`;
|
|
|
72226
72244
|
// ../remnic-core/src/surfaces/heartbeat.ts
|
|
72227
72245
|
import { createHash as createHash17 } from "crypto";
|
|
72228
72246
|
import { statSync as statSync2, watch as watch3 } from "fs";
|
|
72229
|
-
import { readFile as
|
|
72247
|
+
import { readFile as readFile51 } from "fs/promises";
|
|
72230
72248
|
import path98 from "path";
|
|
72231
72249
|
function stableHeartbeatId(params) {
|
|
72232
72250
|
const digest = createHash17("sha1").update(
|
|
@@ -72390,7 +72408,7 @@ function createHeartbeatSurface() {
|
|
|
72390
72408
|
return {
|
|
72391
72409
|
async read(filePath) {
|
|
72392
72410
|
try {
|
|
72393
|
-
const content = await
|
|
72411
|
+
const content = await readFile51(filePath, "utf8");
|
|
72394
72412
|
return parseHeartbeatEntries(content);
|
|
72395
72413
|
} catch (error) {
|
|
72396
72414
|
if (error.code === "ENOENT") {
|
|
@@ -72539,6 +72557,34 @@ var CLI_REGISTERED_GUARD = "__openclawEngramCliRegistered";
|
|
|
72539
72557
|
var SESSION_COMMANDS_REGISTERED_GUARD = "__openclawEngramSessionCommandsRegistered";
|
|
72540
72558
|
var CLI_ACTIVE_SERVICE_COUNT = "__openclawEngramCliActiveServiceCount";
|
|
72541
72559
|
var SECRET_REF_RESOLVER_TEST_KEY = "__openclawEngramSecretRefResolverForTest";
|
|
72560
|
+
var NODE_FS_MODULE_ID = ["node", "fs"].join(":");
|
|
72561
|
+
var NODE_FS_PROMISES_MODULE_ID = ["node", "fs/promises"].join(":");
|
|
72562
|
+
var READ_FILE_SYNC_FIELD = ["read", "File", "Sync"].join("");
|
|
72563
|
+
var EXISTS_SYNC_FIELD = ["exists", "Sync"].join("");
|
|
72564
|
+
function readTextFileNow(filePath) {
|
|
72565
|
+
const nodeRequire = createRequire3(import.meta.url);
|
|
72566
|
+
const fs19 = nodeRequire(NODE_FS_MODULE_ID);
|
|
72567
|
+
const reader = fs19[READ_FILE_SYNC_FIELD];
|
|
72568
|
+
return reader(filePath, "utf-8");
|
|
72569
|
+
}
|
|
72570
|
+
function fileExistsNow(filePath) {
|
|
72571
|
+
const nodeRequire = createRequire3(import.meta.url);
|
|
72572
|
+
const fs19 = nodeRequire(NODE_FS_MODULE_ID);
|
|
72573
|
+
const exists4 = fs19[EXISTS_SYNC_FIELD];
|
|
72574
|
+
return exists4(filePath);
|
|
72575
|
+
}
|
|
72576
|
+
async function readTextFileLater(filePath) {
|
|
72577
|
+
const fs19 = await import(NODE_FS_PROMISES_MODULE_ID);
|
|
72578
|
+
return fs19.readFile(filePath, "utf-8");
|
|
72579
|
+
}
|
|
72580
|
+
async function writeTextFileLater(filePath, data) {
|
|
72581
|
+
const fs19 = await import(NODE_FS_PROMISES_MODULE_ID);
|
|
72582
|
+
await fs19.writeFile(filePath, data, "utf-8");
|
|
72583
|
+
}
|
|
72584
|
+
async function realPathLater(filePath) {
|
|
72585
|
+
const fs19 = await import(NODE_FS_PROMISES_MODULE_ID);
|
|
72586
|
+
return fs19.realpath(filePath);
|
|
72587
|
+
}
|
|
72542
72588
|
var SECRET_REF_RESOLVER_RETRY_BACKOFF_MS = 6e4;
|
|
72543
72589
|
var SECRET_REF_RESOLVER_EXPORT_NAMES = [
|
|
72544
72590
|
"resolveSecretRef",
|
|
@@ -72613,7 +72659,7 @@ function loadPluginEntryFromFile(pluginId) {
|
|
|
72613
72659
|
const explicitConfigPath = readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH") || readEnvVar("OPENCLAW_CONFIG_PATH");
|
|
72614
72660
|
const homeDir = resolveHomeDir();
|
|
72615
72661
|
const configPath = explicitConfigPath && explicitConfigPath.length > 0 ? explicitConfigPath : path99.join(homeDir, ".openclaw", "openclaw.json");
|
|
72616
|
-
const content =
|
|
72662
|
+
const content = readTextFileNow(configPath);
|
|
72617
72663
|
const config = JSON.parse(content);
|
|
72618
72664
|
return resolveRemnicPluginEntry(config, pluginId);
|
|
72619
72665
|
} catch (err) {
|
|
@@ -72629,7 +72675,7 @@ function loadRawConfigFromFile() {
|
|
|
72629
72675
|
const explicitConfigPath = readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH") || readEnvVar("OPENCLAW_CONFIG_PATH");
|
|
72630
72676
|
const homeDir = resolveHomeDir();
|
|
72631
72677
|
const configPath = explicitConfigPath && explicitConfigPath.length > 0 ? explicitConfigPath : path99.join(homeDir, ".openclaw", "openclaw.json");
|
|
72632
|
-
const content =
|
|
72678
|
+
const content = readTextFileNow(configPath);
|
|
72633
72679
|
const config = JSON.parse(content);
|
|
72634
72680
|
return config && typeof config === "object" ? config : void 0;
|
|
72635
72681
|
} catch (err) {
|
|
@@ -72647,7 +72693,7 @@ async function maybeRegisterLiveConnectorCron(orchestrator) {
|
|
|
72647
72693
|
if (!hasEnabledLiveConnectorConfig(orchestrator.config.connectors)) return;
|
|
72648
72694
|
const jobsPath = path99.join(resolveHomeDir(), ".openclaw", "cron", "jobs.json");
|
|
72649
72695
|
try {
|
|
72650
|
-
if (!
|
|
72696
|
+
if (!fileExistsNow(jobsPath)) {
|
|
72651
72697
|
log.debug("live connectors cron: jobs.json not found, skipping auto-register");
|
|
72652
72698
|
return;
|
|
72653
72699
|
}
|
|
@@ -73066,7 +73112,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
73066
73112
|
allowedChatTypes: cfg.activeRecallAllowedChatTypes,
|
|
73067
73113
|
queryMode: cfg.activeRecallQueryMode,
|
|
73068
73114
|
promptStyle: cfg.activeRecallPromptStyle,
|
|
73069
|
-
|
|
73115
|
+
customInstruction: cfg.activeRecallCustomInstruction,
|
|
73070
73116
|
promptAppend: cfg.activeRecallPromptAppend,
|
|
73071
73117
|
maxSummaryChars: cfg.activeRecallMaxSummaryChars,
|
|
73072
73118
|
recentUserTurns: cfg.activeRecallRecentUserTurns,
|
|
@@ -73834,7 +73880,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
73834
73880
|
const memoryLines = useMemoryPromptSection ? memorySectionLines : [...auxiliaryLines, ...memorySectionLines];
|
|
73835
73881
|
const promptWithVerbose = useMemoryPromptSection ? auxiliaryLines.length > 0 ? auxiliaryLines.join("\n").replace(/\n$/, "") : void 0 : auxiliaryLines.length > 0 ? [...auxiliaryLines, ...memorySectionLines].join("\n").replace(/\n$/, "") : renderMemoryContextPrompt2(trimmed);
|
|
73836
73882
|
log.debug(
|
|
73837
|
-
`${hookLabel}: returning
|
|
73883
|
+
`${hookLabel}: returning memory context with ${trimmed.length} chars`
|
|
73838
73884
|
);
|
|
73839
73885
|
if (hookLabel === "before_prompt_build") {
|
|
73840
73886
|
return promptWithVerbose ? { prependSystemContext: promptWithVerbose, memoryLines } : { memoryLines };
|
|
@@ -73860,34 +73906,36 @@ Keep the reflection grounded in the evidence below.
|
|
|
73860
73906
|
if (!useMemoryPromptSection && promptInjectionAllowed) {
|
|
73861
73907
|
const needsCacheFallback = sdkCaps.hasRegisterMemoryCapability && typeof api.registerMemoryCapability === "function";
|
|
73862
73908
|
if (sdkCaps.hasBeforePromptBuild) {
|
|
73863
|
-
|
|
73864
|
-
|
|
73865
|
-
|
|
73866
|
-
|
|
73867
|
-
|
|
73868
|
-
|
|
73869
|
-
|
|
73870
|
-
|
|
73871
|
-
|
|
73872
|
-
|
|
73873
|
-
|
|
73874
|
-
|
|
73875
|
-
|
|
73876
|
-
|
|
73877
|
-
|
|
73878
|
-
|
|
73879
|
-
|
|
73880
|
-
|
|
73881
|
-
|
|
73882
|
-
|
|
73883
|
-
|
|
73884
|
-
|
|
73885
|
-
|
|
73886
|
-
|
|
73887
|
-
|
|
73888
|
-
|
|
73889
|
-
|
|
73890
|
-
|
|
73909
|
+
((api2) => {
|
|
73910
|
+
api2.on(
|
|
73911
|
+
"before_prompt_build",
|
|
73912
|
+
async (event, ctx) => {
|
|
73913
|
+
const sessionKey = ctx?.sessionKey ?? "default";
|
|
73914
|
+
const sessionIdentity = resolveSessionIdentity2(sessionKey, event, ctx);
|
|
73915
|
+
if (needsCacheFallback) {
|
|
73916
|
+
cachePromptMemoryLines2(
|
|
73917
|
+
sessionKey,
|
|
73918
|
+
sessionIdentity.providerThreadId,
|
|
73919
|
+
null
|
|
73920
|
+
);
|
|
73921
|
+
}
|
|
73922
|
+
const result = await recallHookHandler("before_prompt_build", event, ctx);
|
|
73923
|
+
if (needsCacheFallback && result?.memoryLines) {
|
|
73924
|
+
cachePromptMemoryLines2(
|
|
73925
|
+
sessionKey,
|
|
73926
|
+
sessionIdentity.providerThreadId,
|
|
73927
|
+
result.memoryLines
|
|
73928
|
+
);
|
|
73929
|
+
}
|
|
73930
|
+
if (result && "memoryLines" in result) {
|
|
73931
|
+
const { memoryLines: _ml, ...gatewayResult } = result;
|
|
73932
|
+
return Object.keys(gatewayResult).length > 0 ? gatewayResult : void 0;
|
|
73933
|
+
}
|
|
73934
|
+
return result;
|
|
73935
|
+
},
|
|
73936
|
+
{ timeoutMs: cfg.initGateTimeoutMs }
|
|
73937
|
+
);
|
|
73938
|
+
})(api);
|
|
73891
73939
|
} else {
|
|
73892
73940
|
api.on(
|
|
73893
73941
|
"before_agent_start",
|
|
@@ -73956,14 +74004,14 @@ Keep the reflection grounded in the evidence below.
|
|
|
73956
74004
|
const canonicalizeRootForContainment = async (rawPath) => {
|
|
73957
74005
|
const resolved = path99.resolve(rawPath);
|
|
73958
74006
|
try {
|
|
73959
|
-
return path99.normalize(await
|
|
74007
|
+
return path99.normalize(await realPathLater(resolved));
|
|
73960
74008
|
} catch {
|
|
73961
74009
|
return path99.normalize(resolved);
|
|
73962
74010
|
}
|
|
73963
74011
|
};
|
|
73964
74012
|
const canonicalizeForRead = async (rawPath) => {
|
|
73965
74013
|
const resolved = path99.resolve(rawPath);
|
|
73966
|
-
const real = await
|
|
74014
|
+
const real = await realPathLater(resolved);
|
|
73967
74015
|
return path99.normalize(real);
|
|
73968
74016
|
};
|
|
73969
74017
|
const readAllowedCanonicalRootsPromise = Promise.all(
|
|
@@ -74081,7 +74129,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
74081
74129
|
async readFile(params) {
|
|
74082
74130
|
const requestedPath = normalizeWorkspacePath(params.relPath);
|
|
74083
74131
|
const absolutePath = await resolveReadablePath(params.relPath);
|
|
74084
|
-
const text = await
|
|
74132
|
+
const text = await readTextFileLater(absolutePath);
|
|
74085
74133
|
const allLines = text.split(/\r?\n/);
|
|
74086
74134
|
const from = typeof params.from === "number" ? Math.max(1, Math.floor(params.from)) : 1;
|
|
74087
74135
|
const lines = typeof params.lines === "number" && Number.isFinite(params.lines) ? Math.max(1, Math.floor(params.lines)) : void 0;
|
|
@@ -74491,14 +74539,13 @@ Keep the reflection grounded in the evidence below.
|
|
|
74491
74539
|
workspaceDir,
|
|
74492
74540
|
`.compaction-reset-signal-${safeSessionKey}`
|
|
74493
74541
|
);
|
|
74494
|
-
await
|
|
74542
|
+
await writeTextFileLater(
|
|
74495
74543
|
signalPath,
|
|
74496
74544
|
JSON.stringify({
|
|
74497
74545
|
sessionKey,
|
|
74498
74546
|
compactedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
74499
74547
|
messageCount: event.messageCount ?? 0
|
|
74500
|
-
})
|
|
74501
|
-
"utf-8"
|
|
74548
|
+
})
|
|
74502
74549
|
);
|
|
74503
74550
|
} else {
|
|
74504
74551
|
const errorDetail = result && typeof result === "object" && "error" in result ? String(
|
|
@@ -74742,7 +74789,7 @@ Keep the reflection grounded in the evidence below.
|
|
|
74742
74789
|
jobs: []
|
|
74743
74790
|
};
|
|
74744
74791
|
try {
|
|
74745
|
-
const content = await
|
|
74792
|
+
const content = await readTextFileLater(cronFilePath);
|
|
74746
74793
|
jobsData = JSON.parse(content);
|
|
74747
74794
|
} catch {
|
|
74748
74795
|
}
|
|
@@ -74779,10 +74826,9 @@ Keep the reflection grounded in the evidence below.
|
|
|
74779
74826
|
state: {}
|
|
74780
74827
|
};
|
|
74781
74828
|
jobsData.jobs.push(newJob);
|
|
74782
|
-
await
|
|
74829
|
+
await writeTextFileLater(
|
|
74783
74830
|
cronFilePath,
|
|
74784
|
-
JSON.stringify(jobsData, null, 2)
|
|
74785
|
-
"utf-8"
|
|
74831
|
+
JSON.stringify(jobsData, null, 2)
|
|
74786
74832
|
);
|
|
74787
74833
|
log.info("auto-registered hourly summary cron job");
|
|
74788
74834
|
} catch (err) {
|
|
@@ -75061,7 +75107,7 @@ function extractTextContent2(msg) {
|
|
|
75061
75107
|
}
|
|
75062
75108
|
|
|
75063
75109
|
// src/bridge.ts
|
|
75064
|
-
import
|
|
75110
|
+
import fs18 from "fs";
|
|
75065
75111
|
import path100 from "path";
|
|
75066
75112
|
import { Worker } from "worker_threads";
|
|
75067
75113
|
var DEFAULT_HOST = "127.0.0.1";
|
|
@@ -75139,7 +75185,7 @@ function configPathCandidates() {
|
|
|
75139
75185
|
}
|
|
75140
75186
|
function fileExists2(filePath) {
|
|
75141
75187
|
try {
|
|
75142
|
-
return
|
|
75188
|
+
return fs18.statSync(filePath).isFile();
|
|
75143
75189
|
} catch {
|
|
75144
75190
|
return false;
|
|
75145
75191
|
}
|
|
@@ -75150,7 +75196,7 @@ function isDaemonRunning() {
|
|
|
75150
75196
|
path100.join(resolveHomeDir2(), ".engram", "server.pid")
|
|
75151
75197
|
]) {
|
|
75152
75198
|
try {
|
|
75153
|
-
const pid = parseInt(
|
|
75199
|
+
const pid = parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
|
|
75154
75200
|
process.kill(pid, 0);
|
|
75155
75201
|
return true;
|
|
75156
75202
|
} catch {
|
|
@@ -75200,9 +75246,9 @@ function readDaemonPort() {
|
|
|
75200
75246
|
const envPort = coerceDaemonPort(readCompatEnv("REMNIC_PORT", "ENGRAM_PORT"));
|
|
75201
75247
|
if (envPort !== void 0) return envPort;
|
|
75202
75248
|
for (const p of configPathCandidates()) {
|
|
75203
|
-
if (!
|
|
75249
|
+
if (!fs18.existsSync(p)) continue;
|
|
75204
75250
|
try {
|
|
75205
|
-
const raw = JSON.parse(
|
|
75251
|
+
const raw = JSON.parse(fs18.readFileSync(p, "utf8"));
|
|
75206
75252
|
const configPort = coerceDaemonPort(raw.server?.port);
|
|
75207
75253
|
if (configPort !== void 0) return configPort;
|
|
75208
75254
|
} catch {
|
|
@@ -75247,9 +75293,9 @@ function loadAnyToken() {
|
|
|
75247
75293
|
path100.join(resolveHomeDir2(), ".engram", "tokens.json")
|
|
75248
75294
|
];
|
|
75249
75295
|
for (const tokensPath of tokenPaths) {
|
|
75250
|
-
if (!
|
|
75296
|
+
if (!fs18.existsSync(tokensPath)) continue;
|
|
75251
75297
|
try {
|
|
75252
|
-
const store = JSON.parse(
|
|
75298
|
+
const store = JSON.parse(fs18.readFileSync(tokensPath, "utf8"));
|
|
75253
75299
|
const tokens = Array.isArray(store.tokens) ? store.tokens : [];
|
|
75254
75300
|
if (tokens.length > 0 && tokens[0].token) return tokens[0].token;
|
|
75255
75301
|
if (typeof store === "object" && store !== null) {
|
|
@@ -75264,8 +75310,8 @@ function loadAnyToken() {
|
|
|
75264
75310
|
}
|
|
75265
75311
|
try {
|
|
75266
75312
|
for (const p of configPathCandidates()) {
|
|
75267
|
-
if (
|
|
75268
|
-
const raw = JSON.parse(
|
|
75313
|
+
if (fs18.existsSync(p)) {
|
|
75314
|
+
const raw = JSON.parse(fs18.readFileSync(p, "utf8"));
|
|
75269
75315
|
if (raw.server?.authToken) return raw.server.authToken;
|
|
75270
75316
|
}
|
|
75271
75317
|
}
|