@remnic/cli 9.66.10 → 9.66.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +261 -262
- package/package.json +32 -32
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ async function persistEnrichmentCandidate(storage, entityName, candidate) {
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
import fs28 from "fs";
|
|
22
22
|
import os3 from "os";
|
|
23
|
-
import
|
|
23
|
+
import path18 from "path";
|
|
24
24
|
import { createHash as createHash4 } from "crypto";
|
|
25
25
|
import { writeFile as fsWriteFile } from "fs/promises";
|
|
26
26
|
import * as childProcess2 from "child_process";
|
|
@@ -356,7 +356,6 @@ async function runOkfBinaryCommand(rest) {
|
|
|
356
356
|
|
|
357
357
|
// src/commands/export-okf.ts
|
|
358
358
|
import fs6 from "fs";
|
|
359
|
-
import path from "path";
|
|
360
359
|
import { Orchestrator as Orchestrator4, parseConfig as parseConfig6, resolveRemnicConfigRecord as resolveRemnicConfigRecord6 } from "@remnic/core";
|
|
361
360
|
import { exportOkfBundle, parseIncludeStatus } from "@remnic/core/export-okf";
|
|
362
361
|
function takeFlag(rest, name) {
|
|
@@ -390,9 +389,9 @@ async function runExportOkfBinaryCommand(rest) {
|
|
|
390
389
|
orchestrator = new Orchestrator4(config);
|
|
391
390
|
await orchestrator.initialize();
|
|
392
391
|
await orchestrator.deferredReady;
|
|
393
|
-
const memoryDir = namespace ? path.join(orchestrator.config.memoryDir, "namespaces", namespace) : orchestrator.config.memoryDir;
|
|
394
392
|
const result = await exportOkfBundle({
|
|
395
|
-
memoryDir,
|
|
393
|
+
memoryDir: orchestrator.config.memoryDir,
|
|
394
|
+
namespace,
|
|
396
395
|
outDir: out,
|
|
397
396
|
includeStatus: parseIncludeStatus(takeFlag(args, "--include-status")),
|
|
398
397
|
includeCategories: takeFlag(args, "--include-categories")?.split(","),
|
|
@@ -1380,7 +1379,7 @@ async function loadWecloneExportModule() {
|
|
|
1380
1379
|
// src/converge.ts
|
|
1381
1380
|
import * as fs16 from "fs";
|
|
1382
1381
|
import { createHash as createHash3 } from "crypto";
|
|
1383
|
-
import * as
|
|
1382
|
+
import * as path2 from "path";
|
|
1384
1383
|
import {
|
|
1385
1384
|
CONVERGE_CONFLICT_POLICIES,
|
|
1386
1385
|
DEFAULT_CONVERGE_CONFLICT_POLICY,
|
|
@@ -1412,7 +1411,7 @@ import {
|
|
|
1412
1411
|
import { createDecipheriv, createHash } from "crypto";
|
|
1413
1412
|
import fs15 from "fs";
|
|
1414
1413
|
import { lstat, mkdtemp, readdir, rm } from "fs/promises";
|
|
1415
|
-
import
|
|
1414
|
+
import path from "path";
|
|
1416
1415
|
import {
|
|
1417
1416
|
OFFLINE_SYNC_FILE_CONTENT_TRANSFER_CHUNK_BYTES,
|
|
1418
1417
|
StorageManager as StorageManager2,
|
|
@@ -1439,10 +1438,10 @@ import {
|
|
|
1439
1438
|
} from "@remnic/core/secure-store";
|
|
1440
1439
|
var OFFLINE_SYNC_EXCLUSION_CONCURRENCY = 16;
|
|
1441
1440
|
function resolveOfflineDirectHydrationPath(memoryDir, relPath) {
|
|
1442
|
-
const base =
|
|
1443
|
-
const target =
|
|
1444
|
-
const relative =
|
|
1445
|
-
if (relative === "" || relative === ".." || relative.startsWith(`..${
|
|
1441
|
+
const base = path.resolve(memoryDir);
|
|
1442
|
+
const target = path.resolve(base, relPath);
|
|
1443
|
+
const relative = path.relative(base, target);
|
|
1444
|
+
if (relative === "" || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
1446
1445
|
throw new Error(`offline sync direct hydration path escapes memory dir: ${relPath}`);
|
|
1447
1446
|
}
|
|
1448
1447
|
return target;
|
|
@@ -1476,13 +1475,13 @@ async function createConfiguredOfflineStorage(memoryDir, secureStoreEncryptOnWri
|
|
|
1476
1475
|
return { storage, secureStoreKey, secureStoreRequired };
|
|
1477
1476
|
}
|
|
1478
1477
|
async function createOfflineStorageForPath(memoryDir, filePath, configured, secureStoreEncryptOnWrite) {
|
|
1479
|
-
const memoryRoot =
|
|
1480
|
-
const stateDir =
|
|
1481
|
-
if (
|
|
1478
|
+
const memoryRoot = path.resolve(memoryDir);
|
|
1479
|
+
const stateDir = path.dirname(filePath);
|
|
1480
|
+
if (path.basename(stateDir) !== "state" || path.basename(filePath) !== "memory-lifecycle-ledger.jsonl") {
|
|
1482
1481
|
throw new Error(`invalid lifecycle ledger path: ${filePath}`);
|
|
1483
1482
|
}
|
|
1484
|
-
const storageRoot =
|
|
1485
|
-
if (storageRoot !== memoryRoot && !storageRoot.startsWith(`${memoryRoot}${
|
|
1483
|
+
const storageRoot = path.resolve(path.dirname(stateDir));
|
|
1484
|
+
if (storageRoot !== memoryRoot && !storageRoot.startsWith(`${memoryRoot}${path.sep}`)) {
|
|
1486
1485
|
throw new Error(`lifecycle ledger path is outside the offline memory directory: ${filePath}`);
|
|
1487
1486
|
}
|
|
1488
1487
|
const storage = new StorageManager2(storageRoot);
|
|
@@ -1543,7 +1542,7 @@ async function cleanupOrphanedOfflineDecryptStaging(memoryDir) {
|
|
|
1543
1542
|
const now = Date.now();
|
|
1544
1543
|
for (const name of entries) {
|
|
1545
1544
|
if (!name.startsWith(OFFLINE_DECRYPT_STAGING_DIR_PREFIX)) continue;
|
|
1546
|
-
const dir =
|
|
1545
|
+
const dir = path.join(memoryDir, name);
|
|
1547
1546
|
try {
|
|
1548
1547
|
const info = await lstat(dir);
|
|
1549
1548
|
if (!info.isDirectory() || info.isSymbolicLink()) continue;
|
|
@@ -1611,8 +1610,8 @@ async function* readEncryptedOfflineFileChunks(options) {
|
|
|
1611
1610
|
const aadCandidates = offlineFileAadCandidates(options.filePath, options.memoryDir);
|
|
1612
1611
|
let lastError;
|
|
1613
1612
|
for (const aad of aadCandidates) {
|
|
1614
|
-
const tempDir = await mkdtemp(
|
|
1615
|
-
const tempPath =
|
|
1613
|
+
const tempDir = await mkdtemp(path.join(options.memoryDir, OFFLINE_DECRYPT_STAGING_DIR_PREFIX));
|
|
1614
|
+
const tempPath = path.join(tempDir, "content");
|
|
1616
1615
|
try {
|
|
1617
1616
|
const decipher = createDecipheriv("aes-256-gcm", options.key, iv, {
|
|
1618
1617
|
authTagLength: AUTH_TAG_LENGTH
|
|
@@ -1656,17 +1655,17 @@ async function* readEncryptedOfflineFileChunks(options) {
|
|
|
1656
1655
|
}
|
|
1657
1656
|
function offlineFileAadCandidates(filePath, memoryDir) {
|
|
1658
1657
|
const candidates = [filePathAad(filePath, memoryDir)];
|
|
1659
|
-
const relative =
|
|
1660
|
-
if (!relative || relative.startsWith("..") ||
|
|
1661
|
-
const parts = relative.split(
|
|
1658
|
+
const relative = path.relative(memoryDir, filePath);
|
|
1659
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return candidates;
|
|
1660
|
+
const parts = relative.split(path.sep);
|
|
1662
1661
|
if (parts[0] === "namespaces" && parts.length >= 3 && parts[1]) {
|
|
1663
|
-
candidates.push(filePathAad(filePath,
|
|
1662
|
+
candidates.push(filePathAad(filePath, path.join(memoryDir, "namespaces", parts[1])));
|
|
1664
1663
|
}
|
|
1665
|
-
const memoryParts =
|
|
1664
|
+
const memoryParts = path.resolve(memoryDir).split(path.sep);
|
|
1666
1665
|
if (memoryParts.length >= 3 && memoryParts.at(-2) === "namespaces" && memoryParts.at(-1)) {
|
|
1667
|
-
const topLevelRoot = memoryParts.slice(0, -2).join(
|
|
1668
|
-
const topRelative =
|
|
1669
|
-
if (topRelative && !topRelative.startsWith("..") && !
|
|
1666
|
+
const topLevelRoot = memoryParts.slice(0, -2).join(path.sep) || path.sep;
|
|
1667
|
+
const topRelative = path.relative(topLevelRoot, filePath);
|
|
1668
|
+
if (topRelative && !topRelative.startsWith("..") && !path.isAbsolute(topRelative) && topRelative.split(path.sep)[0] === "namespaces" && topRelative.split(path.sep)[1] === memoryParts.at(-1)) {
|
|
1670
1669
|
candidates.push(filePathAad(filePath, topLevelRoot));
|
|
1671
1670
|
}
|
|
1672
1671
|
}
|
|
@@ -2231,7 +2230,7 @@ async function readLocalTombstoneEvidence(rootDir) {
|
|
|
2231
2230
|
for (const relativePath of TOMBSTONE_PATHS) {
|
|
2232
2231
|
let content;
|
|
2233
2232
|
try {
|
|
2234
|
-
content = await fs16.promises.readFile(
|
|
2233
|
+
content = await fs16.promises.readFile(path2.join(rootDir, relativePath), "utf-8");
|
|
2235
2234
|
} catch (error) {
|
|
2236
2235
|
if (error.code === "ENOENT") continue;
|
|
2237
2236
|
throw error;
|
|
@@ -2243,7 +2242,7 @@ async function readLocalTombstoneEvidence(rootDir) {
|
|
|
2243
2242
|
return merged;
|
|
2244
2243
|
}
|
|
2245
2244
|
async function discoverCursorNamespaces(memoryDir, peerUrl) {
|
|
2246
|
-
const cursorDir =
|
|
2245
|
+
const cursorDir = path2.join(path2.resolve(memoryDir), ".remnic", "state", "converge-cursors");
|
|
2247
2246
|
let entries;
|
|
2248
2247
|
try {
|
|
2249
2248
|
entries = await fs16.promises.readdir(cursorDir, { withFileTypes: true });
|
|
@@ -2254,9 +2253,9 @@ async function discoverCursorNamespaces(memoryDir, peerUrl) {
|
|
|
2254
2253
|
const namespaces = /* @__PURE__ */ new Set();
|
|
2255
2254
|
for (const entry of entries) {
|
|
2256
2255
|
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
2257
|
-
const cursor = await readConvergeCursor(
|
|
2256
|
+
const cursor = await readConvergeCursor(path2.join(cursorDir, entry.name));
|
|
2258
2257
|
if (!cursor) throw new Error(`invalid converge cursor: ${entry.name}`);
|
|
2259
|
-
if (
|
|
2258
|
+
if (path2.basename(defaultConvergeCursorPath(memoryDir, peerUrl, cursor.namespace)) !== entry.name) continue;
|
|
2260
2259
|
namespaces.add(cursor.namespace);
|
|
2261
2260
|
}
|
|
2262
2261
|
return [...namespaces].sort();
|
|
@@ -2368,7 +2367,7 @@ async function computeConvergePlan(options = {}) {
|
|
|
2368
2367
|
return await readFile3({
|
|
2369
2368
|
root: rootInfo.rootDir,
|
|
2370
2369
|
path: file.path,
|
|
2371
|
-
filePath:
|
|
2370
|
+
filePath: path2.join(rootInfo.rootDir, file.path)
|
|
2372
2371
|
});
|
|
2373
2372
|
} catch (error) {
|
|
2374
2373
|
manifestReadFailed = true;
|
|
@@ -2730,7 +2729,7 @@ async function executeConvergeApply(options = {}) {
|
|
|
2730
2729
|
const rootDir = rootMap.get(entry.namespace);
|
|
2731
2730
|
if (rootDir) {
|
|
2732
2731
|
try {
|
|
2733
|
-
const filePath =
|
|
2732
|
+
const filePath = path2.join(rootDir, localPath);
|
|
2734
2733
|
const io = await createOfflineStorageIo(rootDir);
|
|
2735
2734
|
const current = await io.readFileDigest({ root: rootDir, path: localPath, filePath });
|
|
2736
2735
|
if (current.sha256 !== entry.localSha256) {
|
|
@@ -2827,7 +2826,7 @@ async function executeConvergeApply(options = {}) {
|
|
|
2827
2826
|
if (rootDir && entry.localSha256) {
|
|
2828
2827
|
try {
|
|
2829
2828
|
const io = await createOfflineStorageIo(rootDir);
|
|
2830
|
-
const filePath =
|
|
2829
|
+
const filePath = path2.join(rootDir, localPath);
|
|
2831
2830
|
const current = await io.readFileDigest({ root: rootDir, path: localPath, filePath });
|
|
2832
2831
|
if (current.sha256 === entry.localSha256) {
|
|
2833
2832
|
await io.deleteFile({ root: rootDir, path: localPath, filePath });
|
|
@@ -2880,7 +2879,7 @@ async function executeConvergeApply(options = {}) {
|
|
|
2880
2879
|
if (rootDir) {
|
|
2881
2880
|
try {
|
|
2882
2881
|
const io = await createOfflineStorageIo(rootDir);
|
|
2883
|
-
const filePath =
|
|
2882
|
+
const filePath = path2.join(rootDir, localPath);
|
|
2884
2883
|
const current = await io.readFileDigest({ root: rootDir, path: localPath, filePath });
|
|
2885
2884
|
if (current.sha256 === entry.localSha256) {
|
|
2886
2885
|
await io.deleteFile({ root: rootDir, path: localPath, filePath });
|
|
@@ -3371,15 +3370,15 @@ import {
|
|
|
3371
3370
|
readFileSync as readFileSync2,
|
|
3372
3371
|
statSync
|
|
3373
3372
|
} from "fs";
|
|
3374
|
-
import
|
|
3373
|
+
import path3 from "path";
|
|
3375
3374
|
import { fileURLToPath } from "url";
|
|
3376
3375
|
var STALE_BUILD_TOLERANCE_MS = 1e3;
|
|
3377
3376
|
function assertLocalBenchBuildFreshForDevelopment(currentModuleUrl) {
|
|
3378
3377
|
if (isTruthyEnv(process.env.REMNIC_BENCH_ALLOW_STALE_DIST)) {
|
|
3379
3378
|
return;
|
|
3380
3379
|
}
|
|
3381
|
-
const currentDir =
|
|
3382
|
-
const benchPackageDir =
|
|
3380
|
+
const currentDir = path3.dirname(fileURLToPath(currentModuleUrl));
|
|
3381
|
+
const benchPackageDir = path3.resolve(currentDir, "../../bench");
|
|
3383
3382
|
const freshness = checkBenchBuildFreshness(benchPackageDir);
|
|
3384
3383
|
if (!freshness.stale) {
|
|
3385
3384
|
return;
|
|
@@ -3396,7 +3395,7 @@ function assertLocalBenchBuildFreshForDevelopment(currentModuleUrl) {
|
|
|
3396
3395
|
);
|
|
3397
3396
|
}
|
|
3398
3397
|
function checkBenchBuildFreshness(benchPackageDir) {
|
|
3399
|
-
const packageJsonPath =
|
|
3398
|
+
const packageJsonPath = path3.join(benchPackageDir, "package.json");
|
|
3400
3399
|
if (!existsSync2(packageJsonPath)) {
|
|
3401
3400
|
return { stale: false };
|
|
3402
3401
|
}
|
|
@@ -3409,17 +3408,17 @@ function checkBenchBuildFreshness(benchPackageDir) {
|
|
|
3409
3408
|
if (packageName !== "@remnic/bench") {
|
|
3410
3409
|
return { stale: false };
|
|
3411
3410
|
}
|
|
3412
|
-
const srcDir =
|
|
3411
|
+
const srcDir = path3.join(benchPackageDir, "src");
|
|
3413
3412
|
if (!isDirectory(srcDir)) {
|
|
3414
3413
|
return { stale: false };
|
|
3415
3414
|
}
|
|
3416
3415
|
const sourceRoots = [
|
|
3417
3416
|
srcDir,
|
|
3418
3417
|
packageJsonPath,
|
|
3419
|
-
|
|
3420
|
-
|
|
3418
|
+
path3.join(benchPackageDir, "tsup.config.ts"),
|
|
3419
|
+
path3.join(benchPackageDir, "tsconfig.json")
|
|
3421
3420
|
];
|
|
3422
|
-
const distPath =
|
|
3421
|
+
const distPath = path3.join(benchPackageDir, "dist", "index.js");
|
|
3423
3422
|
if (!existsSync2(distPath)) {
|
|
3424
3423
|
return {
|
|
3425
3424
|
stale: true,
|
|
@@ -3462,7 +3461,7 @@ function newestMtime(roots) {
|
|
|
3462
3461
|
}
|
|
3463
3462
|
if (stat2.isDirectory()) {
|
|
3464
3463
|
for (const child of readdirSync(entryPath)) {
|
|
3465
|
-
visit(
|
|
3464
|
+
visit(path3.join(entryPath, child));
|
|
3466
3465
|
}
|
|
3467
3466
|
return;
|
|
3468
3467
|
}
|
|
@@ -3495,18 +3494,18 @@ function isTruthyEnv(value) {
|
|
|
3495
3494
|
|
|
3496
3495
|
// src/optional-bench.ts
|
|
3497
3496
|
import { existsSync as existsSync3 } from "fs";
|
|
3498
|
-
import
|
|
3497
|
+
import path4 from "path";
|
|
3499
3498
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
|
|
3500
3499
|
var SPECIFIER2 = "@remnic/bench";
|
|
3501
3500
|
var TSX_ESM_API_SPECIFIER = "tsx/esm/api";
|
|
3502
3501
|
var cached2;
|
|
3503
3502
|
var cachedFromLocalWorkspaceBenchSource = false;
|
|
3504
3503
|
function resolveLocalWorkspaceBenchPaths() {
|
|
3505
|
-
const currentDir =
|
|
3506
|
-
const benchPackageDir =
|
|
3504
|
+
const currentDir = path4.dirname(fileURLToPath2(import.meta.url));
|
|
3505
|
+
const benchPackageDir = path4.resolve(currentDir, "../../bench");
|
|
3507
3506
|
return {
|
|
3508
|
-
distEntry:
|
|
3509
|
-
sourceEntry:
|
|
3507
|
+
distEntry: path4.join(benchPackageDir, "dist", "index.js"),
|
|
3508
|
+
sourceEntry: path4.join(benchPackageDir, "src", "index.ts")
|
|
3510
3509
|
};
|
|
3511
3510
|
}
|
|
3512
3511
|
async function tryImportLocalWorkspaceBenchSource(err) {
|
|
@@ -3639,7 +3638,7 @@ async function cmdSecurity(rest) {
|
|
|
3639
3638
|
|
|
3640
3639
|
// src/daemon-service-candidates.ts
|
|
3641
3640
|
import fs20 from "fs";
|
|
3642
|
-
import
|
|
3641
|
+
import path5 from "path";
|
|
3643
3642
|
var LAUNCHD_LABEL = "ai.remnic.daemon";
|
|
3644
3643
|
var LEGACY_REMNIC_SERVER_LAUNCHD_LABEL = "ai.remnic.server";
|
|
3645
3644
|
var LEGACY_LAUNCHD_LABEL = "ai.engram.daemon";
|
|
@@ -3652,10 +3651,10 @@ var SYSTEMD_SERVICE = "remnic.service";
|
|
|
3652
3651
|
var LEGACY_SYSTEMD_SERVICE = "engram.service";
|
|
3653
3652
|
var SYSTEMD_SERVICE_CANDIDATES = [SYSTEMD_SERVICE, LEGACY_SYSTEMD_SERVICE];
|
|
3654
3653
|
function launchdPlistPaths(homeDir) {
|
|
3655
|
-
return LAUNCHD_LABEL_CANDIDATES.map((label) =>
|
|
3654
|
+
return LAUNCHD_LABEL_CANDIDATES.map((label) => path5.join(homeDir, "Library", "LaunchAgents", `${label}.plist`));
|
|
3656
3655
|
}
|
|
3657
3656
|
function systemdUnitPaths(homeDir) {
|
|
3658
|
-
return SYSTEMD_SERVICE_CANDIDATES.map((service) =>
|
|
3657
|
+
return SYSTEMD_SERVICE_CANDIDATES.map((service) => path5.join(homeDir, ".config", "systemd", "user", service));
|
|
3659
3658
|
}
|
|
3660
3659
|
function anyFileExists(paths) {
|
|
3661
3660
|
return paths.some((candidate) => {
|
|
@@ -3689,13 +3688,13 @@ function resolveShimNodeScript(filePath) {
|
|
|
3689
3688
|
} catch {
|
|
3690
3689
|
return void 0;
|
|
3691
3690
|
}
|
|
3692
|
-
const basedir =
|
|
3691
|
+
const basedir = path5.dirname(filePath);
|
|
3693
3692
|
const jsReferencePattern = /"([^"]+\.js)"|'([^']+\.js)'|([^\s"'`]+\.js)/g;
|
|
3694
3693
|
for (const match of text.matchAll(jsReferencePattern)) {
|
|
3695
3694
|
const raw = match[1] ?? match[2] ?? match[3];
|
|
3696
3695
|
if (!raw) continue;
|
|
3697
3696
|
const candidate = raw.replaceAll("${basedir}", basedir).replaceAll("$basedir", basedir).replaceAll("\\ ", " ");
|
|
3698
|
-
const resolved =
|
|
3697
|
+
const resolved = path5.isAbsolute(candidate) ? candidate : path5.resolve(basedir, candidate);
|
|
3699
3698
|
try {
|
|
3700
3699
|
if (fs20.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
|
|
3701
3700
|
return fs20.realpathSync(resolved);
|
|
@@ -3711,10 +3710,10 @@ function resolveRunnableNodeScript(filePath) {
|
|
|
3711
3710
|
return resolveShimNodeScript(realPath);
|
|
3712
3711
|
}
|
|
3713
3712
|
function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
|
|
3714
|
-
for (const dir of pathEnv.split(
|
|
3713
|
+
for (const dir of pathEnv.split(path5.delimiter)) {
|
|
3715
3714
|
if (!dir) continue;
|
|
3716
3715
|
for (const name of commandNames(command)) {
|
|
3717
|
-
const candidate =
|
|
3716
|
+
const candidate = path5.join(dir, name);
|
|
3718
3717
|
try {
|
|
3719
3718
|
const stat2 = fs20.statSync(candidate);
|
|
3720
3719
|
if (!stat2.isFile()) continue;
|
|
@@ -3728,11 +3727,11 @@ function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
|
|
|
3728
3727
|
return void 0;
|
|
3729
3728
|
}
|
|
3730
3729
|
function serverBinWrapperRequiredPath(candidate) {
|
|
3731
|
-
const filename =
|
|
3730
|
+
const filename = path5.basename(candidate);
|
|
3732
3731
|
if (filename !== "remnic-server.js" && filename !== "engram-server.js") return void 0;
|
|
3733
|
-
const binDir =
|
|
3734
|
-
if (
|
|
3735
|
-
return
|
|
3732
|
+
const binDir = path5.dirname(candidate);
|
|
3733
|
+
if (path5.basename(binDir) !== "bin") return void 0;
|
|
3734
|
+
return path5.join(path5.dirname(binDir), "dist", "index.js");
|
|
3736
3735
|
}
|
|
3737
3736
|
|
|
3738
3737
|
// src/service-candidates.ts
|
|
@@ -3754,7 +3753,7 @@ function firstSuccessfulCandidate(candidates, attempt) {
|
|
|
3754
3753
|
}
|
|
3755
3754
|
|
|
3756
3755
|
// src/bench-args.ts
|
|
3757
|
-
import
|
|
3756
|
+
import path7 from "path";
|
|
3758
3757
|
|
|
3759
3758
|
// src/bench-flags.ts
|
|
3760
3759
|
function readBenchOptionValue(argv, flag) {
|
|
@@ -4119,7 +4118,7 @@ function collectBenchmarks(argv) {
|
|
|
4119
4118
|
}
|
|
4120
4119
|
|
|
4121
4120
|
// src/bench-args-research.ts
|
|
4122
|
-
import
|
|
4121
|
+
import path6 from "path";
|
|
4123
4122
|
function readPositiveInteger(args, flag) {
|
|
4124
4123
|
const raw = readBenchOptionValue(args, flag);
|
|
4125
4124
|
if (raw === void 0) return void 0;
|
|
@@ -4165,7 +4164,7 @@ function parseBenchResearchArgs(action, args) {
|
|
|
4165
4164
|
}
|
|
4166
4165
|
const outRaw = readBenchOptionValue(args, "--out");
|
|
4167
4166
|
if (outRaw !== void 0) {
|
|
4168
|
-
out =
|
|
4167
|
+
out = path6.resolve(expandTilde(outRaw));
|
|
4169
4168
|
}
|
|
4170
4169
|
}
|
|
4171
4170
|
const epochs = readPositiveInteger(args, "--epochs");
|
|
@@ -4179,8 +4178,8 @@ function parseBenchResearchArgs(action, args) {
|
|
|
4179
4178
|
}
|
|
4180
4179
|
return {
|
|
4181
4180
|
runRef,
|
|
4182
|
-
memoryDir: memoryDirRaw ?
|
|
4183
|
-
qmdPath: qmdPathRaw ?
|
|
4181
|
+
memoryDir: memoryDirRaw ? path6.resolve(expandTilde(memoryDirRaw)) : void 0,
|
|
4182
|
+
qmdPath: qmdPathRaw ? path6.resolve(expandTilde(qmdPathRaw)) : void 0,
|
|
4184
4183
|
collection,
|
|
4185
4184
|
users: readPositiveInteger(args, "--users"),
|
|
4186
4185
|
epochs,
|
|
@@ -4400,7 +4399,7 @@ function parseBenchArgs(argv) {
|
|
|
4400
4399
|
}
|
|
4401
4400
|
validateBenchFlags(action, args);
|
|
4402
4401
|
const driftGenPositionals = action === "drift-gen" && driftGenAction === "validate" ? collectBenchmarks(args.slice(1)) : [];
|
|
4403
|
-
const driftGenDir = driftGenPositionals[0] ?
|
|
4402
|
+
const driftGenDir = driftGenPositionals[0] ? path7.resolve(expandTilde(driftGenPositionals[0])) : void 0;
|
|
4404
4403
|
const benchmarkArgs = action === "baseline" || action === "datasets" || action === "providers" || action === "runs" || action === "drift-gen" && (args[0] === "validate" || args[0] === "generate") ? args.slice(1) : args;
|
|
4405
4404
|
const benchmarks = collectBenchmarks(benchmarkArgs);
|
|
4406
4405
|
const datasetDir = readBenchOptionValue(args, "--dataset-dir") ?? readBenchOptionValue(args, "--dataset");
|
|
@@ -4950,13 +4949,13 @@ function parseBenchArgs(argv) {
|
|
|
4950
4949
|
mcpUrl,
|
|
4951
4950
|
mcpToolMap,
|
|
4952
4951
|
mcpDemo,
|
|
4953
|
-
datasetDir: datasetDir ?
|
|
4954
|
-
resultsDir: resultsDir ?
|
|
4955
|
-
baselinesDir: baselinesDir ?
|
|
4952
|
+
datasetDir: datasetDir ? path7.resolve(expandTilde(datasetDir)) : void 0,
|
|
4953
|
+
resultsDir: resultsDir ? path7.resolve(expandTilde(resultsDir)) : void 0,
|
|
4954
|
+
baselinesDir: baselinesDir ? path7.resolve(expandTilde(baselinesDir)) : void 0,
|
|
4956
4955
|
runtimeProfile,
|
|
4957
4956
|
matrixProfiles,
|
|
4958
|
-
remnicConfigPath: remnicConfigRaw ?
|
|
4959
|
-
openclawConfigPath: openclawConfigRaw ?
|
|
4957
|
+
remnicConfigPath: remnicConfigRaw ? path7.resolve(expandTilde(remnicConfigRaw)) : void 0,
|
|
4958
|
+
openclawConfigPath: openclawConfigRaw ? path7.resolve(expandTilde(openclawConfigRaw)) : void 0,
|
|
4960
4959
|
modelSource,
|
|
4961
4960
|
gatewayAgentId,
|
|
4962
4961
|
fastGatewayAgentId,
|
|
@@ -4979,13 +4978,13 @@ function parseBenchArgs(argv) {
|
|
|
4979
4978
|
internalDisableThinking: args.includes("--internal-disable-thinking"),
|
|
4980
4979
|
internalCodexReasoningEffort,
|
|
4981
4980
|
threshold,
|
|
4982
|
-
custom: customRaw ?
|
|
4981
|
+
custom: customRaw ? path7.resolve(expandTilde(customRaw)) : void 0,
|
|
4983
4982
|
baselineAction,
|
|
4984
4983
|
datasetAction,
|
|
4985
4984
|
providerAction,
|
|
4986
4985
|
runAction,
|
|
4987
4986
|
format,
|
|
4988
|
-
output: output ?
|
|
4987
|
+
output: output ? path7.resolve(expandTilde(output)) : void 0,
|
|
4989
4988
|
target,
|
|
4990
4989
|
publishedName,
|
|
4991
4990
|
publishedSeed,
|
|
@@ -4995,24 +4994,24 @@ function parseBenchArgs(argv) {
|
|
|
4995
4994
|
publishedIngestConcurrency,
|
|
4996
4995
|
publishedTaskFilter,
|
|
4997
4996
|
memcorrectAdapter,
|
|
4998
|
-
publishedOut: publishedOutRaw ?
|
|
4997
|
+
publishedOut: publishedOutRaw ? path7.resolve(expandTilde(publishedOutRaw)) : void 0,
|
|
4999
4998
|
publishedDryRun: args.includes("--dry-run"),
|
|
5000
4999
|
requestTimeout,
|
|
5001
5000
|
localJudgeRequestTimeout,
|
|
5002
5001
|
frontierJudgeRequestTimeout,
|
|
5003
|
-
calibrationDir: calibrationDirRaw ?
|
|
5002
|
+
calibrationDir: calibrationDirRaw ? path7.resolve(expandTilde(calibrationDirRaw)) : void 0,
|
|
5004
5003
|
calibrationLocalConfigSha256,
|
|
5005
5004
|
calibrationFrontierConfigSha256,
|
|
5006
5005
|
sourceResultId,
|
|
5007
5006
|
expectedAnswerSetSha256,
|
|
5008
5007
|
expectedQuestionIdListSha256,
|
|
5009
|
-
taskIdsFile: taskIdsFileRaw ?
|
|
5008
|
+
taskIdsFile: taskIdsFileRaw ? path7.resolve(expandTilde(taskIdsFileRaw)) : void 0,
|
|
5010
5009
|
expectedTaskIdListSha256,
|
|
5011
5010
|
drainTimeout,
|
|
5012
5011
|
// Issue #1573 PR1: surface judge-cache flags into the runner options.
|
|
5013
5012
|
noJudgeCache: args.includes("--no-judge-cache"),
|
|
5014
|
-
judgeCacheDir: judgeCacheDirRaw ?
|
|
5015
|
-
localLabManifestPath: localLabManifestRaw ?
|
|
5013
|
+
judgeCacheDir: judgeCacheDirRaw ? path7.resolve(expandTilde(judgeCacheDirRaw)) : void 0,
|
|
5014
|
+
localLabManifestPath: localLabManifestRaw ? path7.resolve(expandTilde(localLabManifestRaw)) : void 0,
|
|
5016
5015
|
max429WaitMs,
|
|
5017
5016
|
disableThinking: args.includes("--disable-thinking"),
|
|
5018
5017
|
amaBenchJudgeProtocol,
|
|
@@ -5050,9 +5049,9 @@ function assertCalibrationProvenanceMatches(binding, state, benchmarkId) {
|
|
|
5050
5049
|
|
|
5051
5050
|
// src/bench-status.ts
|
|
5052
5051
|
import { mkdir, readFile, readdir as readdir2, rename, writeFile } from "fs/promises";
|
|
5053
|
-
import
|
|
5052
|
+
import path8 from "path";
|
|
5054
5053
|
function createBenchStatusPath(resultsDir, pid, startedAtMs = Date.now()) {
|
|
5055
|
-
return
|
|
5054
|
+
return path8.join(resultsDir, `bench-status-${startedAtMs}-${pid}.json`);
|
|
5056
5055
|
}
|
|
5057
5056
|
var BENCH_STATUS_FILENAME = /^bench-status-\d+-\d+\.json$/;
|
|
5058
5057
|
var VALID_BENCH_ENTRY_STATUSES = /* @__PURE__ */ new Set(["pending", "running", "complete", "failed"]);
|
|
@@ -5065,7 +5064,7 @@ async function findLatestBenchStatusFile(resultsDir) {
|
|
|
5065
5064
|
}
|
|
5066
5065
|
const candidates = entries.filter((name) => BENCH_STATUS_FILENAME.test(name)).sort().reverse();
|
|
5067
5066
|
for (const name of candidates) {
|
|
5068
|
-
const filePath =
|
|
5067
|
+
const filePath = path8.join(resultsDir, name);
|
|
5069
5068
|
const status = await readBenchStatus(filePath);
|
|
5070
5069
|
if (status) {
|
|
5071
5070
|
return filePath;
|
|
@@ -5074,7 +5073,7 @@ async function findLatestBenchStatusFile(resultsDir) {
|
|
|
5074
5073
|
return null;
|
|
5075
5074
|
}
|
|
5076
5075
|
async function atomicWriteJSON(filePath, data) {
|
|
5077
|
-
await mkdir(
|
|
5076
|
+
await mkdir(path8.dirname(filePath), { recursive: true });
|
|
5078
5077
|
const tmp = `${filePath}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
|
|
5079
5078
|
await writeFile(tmp, JSON.stringify(data, null, 2) + "\n");
|
|
5080
5079
|
await rename(tmp, filePath);
|
|
@@ -5192,7 +5191,7 @@ function finalizeBenchStatus(filePath) {
|
|
|
5192
5191
|
|
|
5193
5192
|
// src/bench-fallback.ts
|
|
5194
5193
|
import fs21 from "fs";
|
|
5195
|
-
import
|
|
5194
|
+
import path9 from "path";
|
|
5196
5195
|
var FALLBACK_RESULTS_DIRNAME = "fallback-runs";
|
|
5197
5196
|
function buildBenchRunnerArgs(parsed, benchmarkId, outputDir) {
|
|
5198
5197
|
const args = ["--benchmark", benchmarkId];
|
|
@@ -5256,7 +5255,7 @@ function findUnsupportedFallbackBenchOptions(parsed) {
|
|
|
5256
5255
|
return unsupported;
|
|
5257
5256
|
}
|
|
5258
5257
|
function createFallbackBenchOutputDir(resultsDir, benchmarkId, pid, startedAtMs = Date.now()) {
|
|
5259
|
-
return
|
|
5258
|
+
return path9.join(
|
|
5260
5259
|
resultsDir,
|
|
5261
5260
|
FALLBACK_RESULTS_DIRNAME,
|
|
5262
5261
|
`${benchmarkId}-${startedAtMs}-${pid}`
|
|
@@ -5267,18 +5266,18 @@ function resolveFallbackBenchResultPath(outputDir) {
|
|
|
5267
5266
|
if (entries.length === 0) {
|
|
5268
5267
|
throw new Error(`Fallback benchmark runner did not write a JSON result artifact in ${outputDir}`);
|
|
5269
5268
|
}
|
|
5270
|
-
return
|
|
5269
|
+
return path9.join(outputDir, entries[0]);
|
|
5271
5270
|
}
|
|
5272
5271
|
|
|
5273
5272
|
// src/openclaw-upgrade-swap.ts
|
|
5274
5273
|
import fs22 from "fs";
|
|
5275
|
-
import
|
|
5274
|
+
import path10 from "path";
|
|
5276
5275
|
function describeError(error) {
|
|
5277
5276
|
return error instanceof Error ? error.message : String(error);
|
|
5278
5277
|
}
|
|
5279
5278
|
function createSiblingTempFilePath(targetPath, label) {
|
|
5280
5279
|
const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
5281
|
-
return
|
|
5280
|
+
return path10.join(path10.dirname(targetPath), `.${path10.basename(targetPath)}.${label}.${nonce}.tmp`);
|
|
5282
5281
|
}
|
|
5283
5282
|
function resolveAtomicWriteMode(targetPath, explicitMode) {
|
|
5284
5283
|
if (explicitMode !== void 0) return explicitMode;
|
|
@@ -5306,7 +5305,7 @@ function resolveAtomicReplacementPath(targetPath) {
|
|
|
5306
5305
|
}
|
|
5307
5306
|
function createSiblingSwapPath(targetDir, label) {
|
|
5308
5307
|
const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
5309
|
-
return
|
|
5308
|
+
return path10.join(path10.dirname(targetDir), `.${path10.basename(targetDir)}.${label}.${nonce}`);
|
|
5310
5309
|
}
|
|
5311
5310
|
function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
5312
5311
|
if (!displacedDir) return void 0;
|
|
@@ -5319,7 +5318,7 @@ function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
|
5319
5318
|
}
|
|
5320
5319
|
function atomicWriteFileSync(targetPath, data, options = {}) {
|
|
5321
5320
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
5322
|
-
fs22.mkdirSync(
|
|
5321
|
+
fs22.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
|
|
5323
5322
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "write");
|
|
5324
5323
|
const mode = resolveAtomicWriteMode(resolvedTargetPath, options.mode);
|
|
5325
5324
|
try {
|
|
@@ -5339,7 +5338,7 @@ function atomicWriteFileSync(targetPath, data, options = {}) {
|
|
|
5339
5338
|
function atomicCopyFileSync(sourcePath, targetPath, options = {}) {
|
|
5340
5339
|
if (!fs22.existsSync(sourcePath)) return;
|
|
5341
5340
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
5342
|
-
fs22.mkdirSync(
|
|
5341
|
+
fs22.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
|
|
5343
5342
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "copy");
|
|
5344
5343
|
const mode = fs22.statSync(sourcePath).mode & 4095;
|
|
5345
5344
|
try {
|
|
@@ -5370,7 +5369,7 @@ function restoreDirectoryFromRollback(targetDir, rollbackDir) {
|
|
|
5370
5369
|
if (!fs22.existsSync(rollbackDir)) {
|
|
5371
5370
|
throw new Error(`Rollback directory is missing: ${rollbackDir}`);
|
|
5372
5371
|
}
|
|
5373
|
-
fs22.mkdirSync(
|
|
5372
|
+
fs22.mkdirSync(path10.dirname(targetDir), { recursive: true });
|
|
5374
5373
|
const displacedDir = fs22.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
|
|
5375
5374
|
if (displacedDir) {
|
|
5376
5375
|
fs22.renameSync(targetDir, displacedDir);
|
|
@@ -5399,7 +5398,7 @@ function restoreDirectoryFromBackup(targetDir, backupDir) {
|
|
|
5399
5398
|
if (!fs22.existsSync(backupDir)) {
|
|
5400
5399
|
throw new Error(`Plugin backup directory is missing: ${backupDir}`);
|
|
5401
5400
|
}
|
|
5402
|
-
fs22.mkdirSync(
|
|
5401
|
+
fs22.mkdirSync(path10.dirname(targetDir), { recursive: true });
|
|
5403
5402
|
const stagedDir = createSiblingSwapPath(targetDir, "backup-restore");
|
|
5404
5403
|
const displacedDir = fs22.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
|
|
5405
5404
|
fs22.cpSync(backupDir, stagedDir, { recursive: true });
|
|
@@ -5540,7 +5539,7 @@ Run this manually when you're ready:
|
|
|
5540
5539
|
import { execFileSync } from "child_process";
|
|
5541
5540
|
import fs23 from "fs";
|
|
5542
5541
|
import os from "os";
|
|
5543
|
-
import
|
|
5542
|
+
import path11 from "path";
|
|
5544
5543
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "url";
|
|
5545
5544
|
var MANAGED_UPGRADE_SPECIFIER = "@remnic/plugin-openclaw/managed-upgrade";
|
|
5546
5545
|
var OPENCLAW_PLUGIN_PACKAGE = "@remnic/plugin-openclaw";
|
|
@@ -5612,8 +5611,8 @@ function buildOpenclawManagedUpgradePackageSpec(version = "latest") {
|
|
|
5612
5611
|
return `${OPENCLAW_PLUGIN_PACKAGE}@${version}`;
|
|
5613
5612
|
}
|
|
5614
5613
|
function readCliAdapterRange() {
|
|
5615
|
-
const moduleDir =
|
|
5616
|
-
const manifestPath =
|
|
5614
|
+
const moduleDir = path11.dirname(fileURLToPath3(import.meta.url));
|
|
5615
|
+
const manifestPath = path11.resolve(moduleDir, "../package.json");
|
|
5617
5616
|
const manifest = JSON.parse(fs23.readFileSync(manifestPath, "utf8"));
|
|
5618
5617
|
if (manifest.name !== "@remnic/cli") {
|
|
5619
5618
|
throw new Error(`Invalid @remnic/cli package manifest at ${manifestPath}.`);
|
|
@@ -5658,7 +5657,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
5658
5657
|
const adapterMissing = isSpecifierNotFoundError(error, OPENCLAW_PLUGIN_PACKAGE) || isSpecifierNotFoundError(error, MANAGED_UPGRADE_SPECIFIER) || isManagedUpgradeSubpathMissing(error);
|
|
5659
5658
|
if (!adapterMissing) throw error;
|
|
5660
5659
|
}
|
|
5661
|
-
const temporaryRoot = fs23.mkdtempSync(
|
|
5660
|
+
const temporaryRoot = fs23.mkdtempSync(path11.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
|
|
5662
5661
|
try {
|
|
5663
5662
|
const toolingPackageSpec = `${OPENCLAW_PLUGIN_PACKAGE}@${readCliAdapterRange()}`;
|
|
5664
5663
|
const installArgs = [
|
|
@@ -5672,7 +5671,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
5672
5671
|
toolingPackageSpec
|
|
5673
5672
|
];
|
|
5674
5673
|
(hooks.runNpmInstall ?? runNpmInstall)(installArgs);
|
|
5675
|
-
const resolverPath =
|
|
5674
|
+
const resolverPath = path11.join(temporaryRoot, "load-managed-upgrade.mjs");
|
|
5676
5675
|
fs23.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
|
|
5677
5676
|
`, "utf8");
|
|
5678
5677
|
return await importModule(pathToFileURL2(resolverPath).href);
|
|
@@ -5923,10 +5922,10 @@ async function remoteRecallXray(daemon, request) {
|
|
|
5923
5922
|
|
|
5924
5923
|
// src/daemon-service.ts
|
|
5925
5924
|
import fs25 from "fs";
|
|
5926
|
-
import
|
|
5925
|
+
import path12 from "path";
|
|
5927
5926
|
import * as childProcess from "child_process";
|
|
5928
5927
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
5929
|
-
var thisModuleDir =
|
|
5928
|
+
var thisModuleDir = path12.dirname(fileURLToPath4(import.meta.url));
|
|
5930
5929
|
function launchdLoadPlist(plistPath, processApi = childProcess) {
|
|
5931
5930
|
processApi.execFileSync("launchctl", ["load", "-w", plistPath], { stdio: "pipe" });
|
|
5932
5931
|
}
|
|
@@ -5948,8 +5947,8 @@ function resolveServerBinDetails(options = {}) {
|
|
|
5948
5947
|
});
|
|
5949
5948
|
} catch {
|
|
5950
5949
|
}
|
|
5951
|
-
const workspaceServerBin =
|
|
5952
|
-
const workspaceDistIndex =
|
|
5950
|
+
const workspaceServerBin = path12.resolve(moduleDir, "../../remnic-server/bin/remnic-server.js");
|
|
5951
|
+
const workspaceDistIndex = path12.resolve(moduleDir, "../../remnic-server/dist/index.js");
|
|
5953
5952
|
candidates.push(
|
|
5954
5953
|
{
|
|
5955
5954
|
path: workspaceServerBin,
|
|
@@ -5970,11 +5969,11 @@ function resolveServerBinDetails(options = {}) {
|
|
|
5970
5969
|
});
|
|
5971
5970
|
}
|
|
5972
5971
|
candidates.push({
|
|
5973
|
-
path:
|
|
5972
|
+
path: path12.resolve(moduleDir, "../../remnic-server/src/index.ts"),
|
|
5974
5973
|
source: "workspace-source"
|
|
5975
5974
|
});
|
|
5976
5975
|
const selected = candidates.find((candidate) => isCandidateReady(candidate, existsSync4)) ?? candidates.find((candidate) => existsSync4(candidate.path)) ?? candidates[0] ?? {
|
|
5977
|
-
path:
|
|
5976
|
+
path: path12.resolve(moduleDir, "../../remnic-server/dist/index.js"),
|
|
5978
5977
|
source: "workspace-dist"
|
|
5979
5978
|
};
|
|
5980
5979
|
const exists = existsSync4(selected.path);
|
|
@@ -6029,7 +6028,7 @@ function readVerifiedDaemonPid(options) {
|
|
|
6029
6028
|
}
|
|
6030
6029
|
function doesProcessCommandLookLikeRemnicDaemon(command, expectedServerBin) {
|
|
6031
6030
|
const normalizedCommand = command.trim();
|
|
6032
|
-
const normalizedExpected =
|
|
6031
|
+
const normalizedExpected = path12.resolve(expandTilde(expectedServerBin));
|
|
6033
6032
|
return normalizedCommand.includes(normalizedExpected) || /(?:^|\s|[/\\])(?:remnic-server|engram-server)(?:\.js)?(?:\s|$)/.test(normalizedCommand) || /@remnic[/\\]server[/\\]/.test(normalizedCommand) || /packages[/\\]remnic-server[/\\](?:bin[/\\]remnic-server\.js|dist[/\\]index\.js|src[/\\]index\.ts)/.test(normalizedCommand);
|
|
6034
6033
|
}
|
|
6035
6034
|
function parseDaemonPid(raw) {
|
|
@@ -6134,7 +6133,7 @@ function inspectLaunchdPlist(plistPath, options = {}) {
|
|
|
6134
6133
|
};
|
|
6135
6134
|
}
|
|
6136
6135
|
const expandedServerArg = expandTilde(serverArg);
|
|
6137
|
-
if (!
|
|
6136
|
+
if (!path12.isAbsolute(expandedServerArg)) {
|
|
6138
6137
|
return {
|
|
6139
6138
|
installed: true,
|
|
6140
6139
|
ok: false,
|
|
@@ -6206,8 +6205,8 @@ function normalizeResolvedPath(resolved) {
|
|
|
6206
6205
|
return resolved;
|
|
6207
6206
|
}
|
|
6208
6207
|
function packageServerBinFromEntry(packageEntry) {
|
|
6209
|
-
if (
|
|
6210
|
-
return
|
|
6208
|
+
if (path12.basename(packageEntry) === "index.js" && path12.basename(path12.dirname(packageEntry)) === "dist") {
|
|
6209
|
+
return path12.join(path12.dirname(path12.dirname(packageEntry)), "bin", "remnic-server.js");
|
|
6211
6210
|
}
|
|
6212
6211
|
return packageEntry;
|
|
6213
6212
|
}
|
|
@@ -6282,7 +6281,7 @@ import {
|
|
|
6282
6281
|
|
|
6283
6282
|
// src/import-bundle-detect.ts
|
|
6284
6283
|
import { lstatSync as lstatSync2, readdirSync as readdirSync2, readFileSync as readFileSync3 } from "fs";
|
|
6285
|
-
import
|
|
6284
|
+
import path13 from "path";
|
|
6286
6285
|
function detectBundleEntries(bundleDir, options = {}) {
|
|
6287
6286
|
const readdir3 = options.readdirImpl ?? defaultReaddir;
|
|
6288
6287
|
const readFileImpl = options.readFileImpl ?? defaultReadFile;
|
|
@@ -6313,7 +6312,7 @@ function detectBundleEntries(bundleDir, options = {}) {
|
|
|
6313
6312
|
for (const filePath of roots) {
|
|
6314
6313
|
if (seenFiles.has(filePath)) continue;
|
|
6315
6314
|
seenFiles.add(filePath);
|
|
6316
|
-
const name =
|
|
6315
|
+
const name = path13.basename(filePath);
|
|
6317
6316
|
const match = classifyFile(name, filePath, readFileImpl);
|
|
6318
6317
|
if (match) entries.push(match);
|
|
6319
6318
|
}
|
|
@@ -6351,7 +6350,7 @@ function collectCandidatePaths(root, readdir3, isDirectory2, isRegularFile) {
|
|
|
6351
6350
|
return;
|
|
6352
6351
|
}
|
|
6353
6352
|
for (const entry of entries) {
|
|
6354
|
-
const full =
|
|
6353
|
+
const full = path13.join(dir, entry);
|
|
6355
6354
|
if (isDirectory2(full)) {
|
|
6356
6355
|
walk(full, depth + 1);
|
|
6357
6356
|
} else if (isRegularFile(full)) {
|
|
@@ -6907,7 +6906,7 @@ async function cmdCapture(rest, io) {
|
|
|
6907
6906
|
|
|
6908
6907
|
// src/import-lossless-claw-cmd.ts
|
|
6909
6908
|
import fs27 from "fs";
|
|
6910
|
-
import
|
|
6909
|
+
import path14 from "path";
|
|
6911
6910
|
import {
|
|
6912
6911
|
applyLcmSchema,
|
|
6913
6912
|
ensureLcmStateDir,
|
|
@@ -7057,7 +7056,7 @@ async function cmdImportLosslessClaw(argv, io, deps = {}) {
|
|
|
7057
7056
|
let destDb;
|
|
7058
7057
|
try {
|
|
7059
7058
|
if (parsed.dryRun) {
|
|
7060
|
-
const lcmPath =
|
|
7059
|
+
const lcmPath = path14.join(memoryDir, "state", "lcm.sqlite");
|
|
7061
7060
|
if (fs27.existsSync(lcmPath)) {
|
|
7062
7061
|
destDb = mod.openExistingLcmDatabaseReadOnly(lcmPath);
|
|
7063
7062
|
} else {
|
|
@@ -7179,7 +7178,7 @@ function printBenchComparisonSummary(comparison, baseline, candidate) {
|
|
|
7179
7178
|
// src/bench-coding-commands.ts
|
|
7180
7179
|
import { lstat as lstat2, readFile as readFile2, realpath, stat } from "fs/promises";
|
|
7181
7180
|
import os2 from "os";
|
|
7182
|
-
import
|
|
7181
|
+
import path15 from "path";
|
|
7183
7182
|
var UINT32_MAX = 4294967295;
|
|
7184
7183
|
var FROZEN_GENERATOR_SEED = 81;
|
|
7185
7184
|
var FROZEN_TASK_COUNT = 30;
|
|
@@ -7189,7 +7188,7 @@ var FROZEN_MAX_STEPS = 12;
|
|
|
7189
7188
|
var FROZEN_MAX_TOOL_CALLS = 8;
|
|
7190
7189
|
var FROZEN_MAX_OUTPUT_CHARS = 16384;
|
|
7191
7190
|
var MAX_OUTPUT_BYTES = 16384;
|
|
7192
|
-
var DEFAULT_REPEATED_FAILURE_OUTPUT_DIR =
|
|
7191
|
+
var DEFAULT_REPEATED_FAILURE_OUTPUT_DIR = path15.join(
|
|
7193
7192
|
resolveHomeDir(),
|
|
7194
7193
|
".remnic",
|
|
7195
7194
|
"bench",
|
|
@@ -7523,7 +7522,7 @@ function parseBenchCodingArgs(args) {
|
|
|
7523
7522
|
throw new Error(`unknown bench coding subcommand ${args[0]}`);
|
|
7524
7523
|
}
|
|
7525
7524
|
function normalizeCommandPaths(command) {
|
|
7526
|
-
const resolve2 = (value) =>
|
|
7525
|
+
const resolve2 = (value) => path15.resolve(expandTilde(value));
|
|
7527
7526
|
if (command.kind === "repo-generate") {
|
|
7528
7527
|
return { ...command, outputDir: resolve2(command.outputDir) };
|
|
7529
7528
|
}
|
|
@@ -7554,23 +7553,23 @@ function normalizeCommandPaths(command) {
|
|
|
7554
7553
|
return command;
|
|
7555
7554
|
}
|
|
7556
7555
|
async function canonicalProspectivePath(value) {
|
|
7557
|
-
let candidate =
|
|
7556
|
+
let candidate = path15.resolve(value);
|
|
7558
7557
|
const missingSegments = [];
|
|
7559
7558
|
while (true) {
|
|
7560
7559
|
try {
|
|
7561
|
-
return
|
|
7560
|
+
return path15.join(await realpath(candidate), ...missingSegments.reverse());
|
|
7562
7561
|
} catch (error) {
|
|
7563
7562
|
if (error.code !== "ENOENT") throw error;
|
|
7564
|
-
const parent =
|
|
7563
|
+
const parent = path15.dirname(candidate);
|
|
7565
7564
|
if (parent === candidate) throw error;
|
|
7566
|
-
missingSegments.push(
|
|
7565
|
+
missingSegments.push(path15.basename(candidate));
|
|
7567
7566
|
candidate = parent;
|
|
7568
7567
|
}
|
|
7569
7568
|
}
|
|
7570
7569
|
}
|
|
7571
7570
|
function isSameOrDescendant(candidate, root) {
|
|
7572
|
-
const relative =
|
|
7573
|
-
return relative === "" || relative !== ".." && !relative.startsWith(`..${
|
|
7571
|
+
const relative = path15.relative(root, candidate);
|
|
7572
|
+
return relative === "" || relative !== ".." && !relative.startsWith(`..${path15.sep}`) && !path15.isAbsolute(relative);
|
|
7574
7573
|
}
|
|
7575
7574
|
async function pathExists(value) {
|
|
7576
7575
|
try {
|
|
@@ -7589,7 +7588,7 @@ async function assertSafeBenchmarkOutput(outputDir) {
|
|
|
7589
7588
|
const configured = process.env[variable]?.trim();
|
|
7590
7589
|
if (!configured) continue;
|
|
7591
7590
|
const memoryRoot = await canonicalProspectivePath(
|
|
7592
|
-
|
|
7591
|
+
path15.resolve(expandTilde(configured))
|
|
7593
7592
|
);
|
|
7594
7593
|
if (isSameOrDescendant(canonicalOutput, memoryRoot)) {
|
|
7595
7594
|
throw new Error(refusal);
|
|
@@ -7597,10 +7596,10 @@ async function assertSafeBenchmarkOutput(outputDir) {
|
|
|
7597
7596
|
}
|
|
7598
7597
|
let candidate = canonicalOutput;
|
|
7599
7598
|
while (true) {
|
|
7600
|
-
const hasProfile = await pathExists(
|
|
7601
|
-
const hasMemoryData = await pathExists(
|
|
7599
|
+
const hasProfile = await pathExists(path15.join(candidate, "profile.md"));
|
|
7600
|
+
const hasMemoryData = await pathExists(path15.join(candidate, "facts")) || await pathExists(path15.join(candidate, "entities")) || await pathExists(path15.join(candidate, "state"));
|
|
7602
7601
|
if (hasProfile && hasMemoryData) throw new Error(refusal);
|
|
7603
|
-
const parent =
|
|
7602
|
+
const parent = path15.dirname(candidate);
|
|
7604
7603
|
if (parent === candidate) break;
|
|
7605
7604
|
candidate = parent;
|
|
7606
7605
|
}
|
|
@@ -7612,7 +7611,7 @@ async function assertSafeBenchmarkOutput(outputDir) {
|
|
|
7612
7611
|
async function assertH6StatsRunDirectory(runDir, commandName = "stats") {
|
|
7613
7612
|
try {
|
|
7614
7613
|
const parsed = JSON.parse(
|
|
7615
|
-
await readFile2(
|
|
7614
|
+
await readFile2(path15.join(runDir, "run.json"), "utf8")
|
|
7616
7615
|
);
|
|
7617
7616
|
if (parsed.schemaVersion !== 1 || typeof parsed.runId !== "string" || parsed.runId.length === 0 || typeof parsed.suiteVersion !== "string" || !parsed.suiteVersion.startsWith("h6-failure-gate-v1-")) {
|
|
7618
7617
|
throw new Error("invalid H6 metadata");
|
|
@@ -7671,7 +7670,7 @@ async function runRepoVerification(command, bench) {
|
|
|
7671
7670
|
if (command.directory === void 0) {
|
|
7672
7671
|
dataset = await requireFunction(bench, "loadCommittedH6BenchmarkDataset")();
|
|
7673
7672
|
} else {
|
|
7674
|
-
const serialized = await readFile2(
|
|
7673
|
+
const serialized = await readFile2(path15.join(command.directory, "dataset.json"), "utf8").catch(
|
|
7675
7674
|
() => void 0
|
|
7676
7675
|
);
|
|
7677
7676
|
if (serialized === void 0) {
|
|
@@ -7799,8 +7798,8 @@ async function cmdBenchCoding(args) {
|
|
|
7799
7798
|
}
|
|
7800
7799
|
|
|
7801
7800
|
// src/bench-security-commands.ts
|
|
7802
|
-
import
|
|
7803
|
-
var DEFAULT_OUTPUT_DIR =
|
|
7801
|
+
import path16 from "path";
|
|
7802
|
+
var DEFAULT_OUTPUT_DIR = path16.join(
|
|
7804
7803
|
resolveHomeDir(),
|
|
7805
7804
|
".remnic",
|
|
7806
7805
|
"bench",
|
|
@@ -7949,7 +7948,7 @@ ${BENCH_SECURITY_USAGE}`);
|
|
|
7949
7948
|
}
|
|
7950
7949
|
|
|
7951
7950
|
// src/bench-research-commands.ts
|
|
7952
|
-
import
|
|
7951
|
+
import path17 from "path";
|
|
7953
7952
|
function emit(result) {
|
|
7954
7953
|
if (result.output) {
|
|
7955
7954
|
console.log(result.output);
|
|
@@ -7967,7 +7966,7 @@ async function runBenchResearchCommand(parsed) {
|
|
|
7967
7966
|
emit(
|
|
7968
7967
|
await runAttributeCliCommand({
|
|
7969
7968
|
runRef: parsed.runRef,
|
|
7970
|
-
resultsDir: parsed.resultsDir ??
|
|
7969
|
+
resultsDir: parsed.resultsDir ?? path17.join(resolveHomeDir(), ".remnic", "bench", "results"),
|
|
7971
7970
|
memoryDir: parsed.memoryDir,
|
|
7972
7971
|
qmdPath: parsed.qmdPath,
|
|
7973
7972
|
collection: parsed.collection,
|
|
@@ -8237,15 +8236,15 @@ registerPublisher("hermes", () => new HermesMemoryExtensionPublisher());
|
|
|
8237
8236
|
registerPublisher("pi", () => new LazyPluginPiPublisher("pi", (mod) => mod.PiMemoryExtensionPublisher));
|
|
8238
8237
|
registerPublisher("omp", () => new LazyPluginPiPublisher("omp", (mod) => mod.OmpMemoryExtensionPublisher));
|
|
8239
8238
|
registerPublisher("prime-agent", () => new LazyPluginPiPublisher("prime-agent", (mod) => mod.PrimeAgentMemoryExtensionPublisher));
|
|
8240
|
-
var PID_DIR =
|
|
8241
|
-
var LEGACY_PID_DIR =
|
|
8242
|
-
var PID_FILE =
|
|
8243
|
-
var LEGACY_PID_FILE =
|
|
8244
|
-
var LOG_FILE =
|
|
8245
|
-
var LEGACY_LOG_FILE =
|
|
8246
|
-
var CLI_MODULE_DIR =
|
|
8247
|
-
var CLI_REPO_ROOT =
|
|
8248
|
-
var EVAL_RUNNER_PATH =
|
|
8239
|
+
var PID_DIR = path18.join(resolveHomeDir(), ".remnic");
|
|
8240
|
+
var LEGACY_PID_DIR = path18.join(resolveHomeDir(), ".engram");
|
|
8241
|
+
var PID_FILE = path18.join(PID_DIR, "server.pid");
|
|
8242
|
+
var LEGACY_PID_FILE = path18.join(LEGACY_PID_DIR, "server.pid");
|
|
8243
|
+
var LOG_FILE = path18.join(PID_DIR, "server.log");
|
|
8244
|
+
var LEGACY_LOG_FILE = path18.join(LEGACY_PID_DIR, "server.log");
|
|
8245
|
+
var CLI_MODULE_DIR = path18.dirname(fileURLToPath5(import.meta.url));
|
|
8246
|
+
var CLI_REPO_ROOT = path18.resolve(CLI_MODULE_DIR, "../../..");
|
|
8247
|
+
var EVAL_RUNNER_PATH = path18.join(CLI_REPO_ROOT, "evals", "run.ts");
|
|
8249
8248
|
var OPENCLAW_GATEWAY_LABEL = "ai.openclaw.gateway";
|
|
8250
8249
|
var CLI_SUCCESS_EXIT_GRACE_MS = 5e3;
|
|
8251
8250
|
var CLI_OUTPUT_FLUSH_GRACE_MS = 250;
|
|
@@ -8465,8 +8464,8 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
|
|
|
8465
8464
|
process.exit(1);
|
|
8466
8465
|
}
|
|
8467
8466
|
const tsxCandidates = [
|
|
8468
|
-
|
|
8469
|
-
|
|
8467
|
+
path18.join(CLI_REPO_ROOT, "node_modules", ".bin", "tsx"),
|
|
8468
|
+
path18.join(CLI_REPO_ROOT, "packages", "remnic-cli", "node_modules", ".bin", "tsx")
|
|
8470
8469
|
];
|
|
8471
8470
|
const tsxCmd = tsxCandidates.find((candidate) => fs28.existsSync(candidate)) ?? "tsx";
|
|
8472
8471
|
const fallbackOutputDir = createFallbackBenchOutputDir(
|
|
@@ -8485,7 +8484,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
|
|
|
8485
8484
|
return resolveFallbackBenchResultPath(fallbackOutputDir);
|
|
8486
8485
|
}
|
|
8487
8486
|
function resolveBenchOutputDir() {
|
|
8488
|
-
return
|
|
8487
|
+
return path18.join(resolveHomeDir(), ".remnic", "bench", "results");
|
|
8489
8488
|
}
|
|
8490
8489
|
var DOWNLOADABLE_BENCHMARK_DATASETS = [
|
|
8491
8490
|
"ama-bench",
|
|
@@ -8530,8 +8529,8 @@ var MEMORY_AGENT_BENCH_SPLIT_FILENAMES = [
|
|
|
8530
8529
|
];
|
|
8531
8530
|
var MEMORY_AGENT_BENCH_ENTITY_MAPPING_CANDIDATES = [
|
|
8532
8531
|
"entity2id.json",
|
|
8533
|
-
|
|
8534
|
-
|
|
8532
|
+
path18.join("processed_data", "Recsys_Redial", "entity2id.json"),
|
|
8533
|
+
path18.join("Recsys_Redial", "entity2id.json")
|
|
8535
8534
|
];
|
|
8536
8535
|
var DOWNLOADED_DATASET_MARKERS = {
|
|
8537
8536
|
"ama-bench": { anyOf: ["open_end_qa_set.jsonl"] },
|
|
@@ -8606,7 +8605,7 @@ var PERSONAMEM_DATASET_FILE_CANDIDATES = [
|
|
|
8606
8605
|
"benchmark/benchmark.csv",
|
|
8607
8606
|
"benchmark.csv"
|
|
8608
8607
|
];
|
|
8609
|
-
var PERSONAMEM_COMPLETION_MARKER =
|
|
8608
|
+
var PERSONAMEM_COMPLETION_MARKER = path18.join(
|
|
8610
8609
|
"data",
|
|
8611
8610
|
"chat_history_32k",
|
|
8612
8611
|
".download-complete"
|
|
@@ -8614,10 +8613,10 @@ var PERSONAMEM_COMPLETION_MARKER = path19.join(
|
|
|
8614
8613
|
function resolveRealpathWithinDataset(datasetPath, relativePath) {
|
|
8615
8614
|
try {
|
|
8616
8615
|
const datasetRoot = fs28.realpathSync(datasetPath);
|
|
8617
|
-
const candidatePath =
|
|
8616
|
+
const candidatePath = path18.resolve(datasetRoot, relativePath);
|
|
8618
8617
|
const candidateRealPath = fs28.realpathSync(candidatePath);
|
|
8619
|
-
const relativeToRoot =
|
|
8620
|
-
if (relativeToRoot.startsWith("..") ||
|
|
8618
|
+
const relativeToRoot = path18.relative(datasetRoot, candidateRealPath);
|
|
8619
|
+
if (relativeToRoot.startsWith("..") || path18.isAbsolute(relativeToRoot)) {
|
|
8621
8620
|
return null;
|
|
8622
8621
|
}
|
|
8623
8622
|
return candidateRealPath;
|
|
@@ -8673,7 +8672,7 @@ function parseCsvRows(raw) {
|
|
|
8673
8672
|
}
|
|
8674
8673
|
function isPersonaMemDatasetComplete(datasetPath) {
|
|
8675
8674
|
try {
|
|
8676
|
-
const completionMarkerPath =
|
|
8675
|
+
const completionMarkerPath = path18.join(datasetPath, PERSONAMEM_COMPLETION_MARKER);
|
|
8677
8676
|
if (fs28.statSync(completionMarkerPath).isFile()) {
|
|
8678
8677
|
return true;
|
|
8679
8678
|
}
|
|
@@ -8681,7 +8680,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
8681
8680
|
}
|
|
8682
8681
|
const datasetFile = PERSONAMEM_DATASET_FILE_CANDIDATES.find((candidate) => {
|
|
8683
8682
|
try {
|
|
8684
|
-
return fs28.statSync(
|
|
8683
|
+
return fs28.statSync(path18.join(datasetPath, candidate)).isFile();
|
|
8685
8684
|
} catch {
|
|
8686
8685
|
return false;
|
|
8687
8686
|
}
|
|
@@ -8690,7 +8689,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
8690
8689
|
return false;
|
|
8691
8690
|
}
|
|
8692
8691
|
try {
|
|
8693
|
-
const rows = parseCsvRows(fs28.readFileSync(
|
|
8692
|
+
const rows = parseCsvRows(fs28.readFileSync(path18.join(datasetPath, datasetFile), "utf8"));
|
|
8694
8693
|
if (rows.length < 2) {
|
|
8695
8694
|
return false;
|
|
8696
8695
|
}
|
|
@@ -8713,14 +8712,14 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
8713
8712
|
}
|
|
8714
8713
|
function hasDatasetFile(datasetPath, relativePath) {
|
|
8715
8714
|
try {
|
|
8716
|
-
return fs28.statSync(
|
|
8715
|
+
return fs28.statSync(path18.join(datasetPath, relativePath)).isFile();
|
|
8717
8716
|
} catch {
|
|
8718
8717
|
return false;
|
|
8719
8718
|
}
|
|
8720
8719
|
}
|
|
8721
8720
|
function hasMemoryAgentBenchEntityMapping(datasetPath) {
|
|
8722
|
-
const absoluteDatasetPath =
|
|
8723
|
-
const roots = [absoluteDatasetPath,
|
|
8721
|
+
const absoluteDatasetPath = path18.resolve(datasetPath);
|
|
8722
|
+
const roots = [absoluteDatasetPath, path18.dirname(absoluteDatasetPath)];
|
|
8724
8723
|
return hasDatasetFile(absoluteDatasetPath, "entity2id.json") || roots.some(
|
|
8725
8724
|
(root) => MEMORY_AGENT_BENCH_ENTITY_MAPPING_CANDIDATES.filter((relativePath) => relativePath !== "entity2id.json").some((relativePath) => hasDatasetFile(root, relativePath))
|
|
8726
8725
|
);
|
|
@@ -8731,7 +8730,7 @@ function memoryAgentBenchDatasetHasRecSysSamples(datasetPath) {
|
|
|
8731
8730
|
...MEMORY_AGENT_BENCH_SPLIT_FILENAMES
|
|
8732
8731
|
];
|
|
8733
8732
|
return candidateFilenames.some((filename) => {
|
|
8734
|
-
const filePath =
|
|
8733
|
+
const filePath = path18.join(datasetPath, filename);
|
|
8735
8734
|
try {
|
|
8736
8735
|
if (!fs28.statSync(filePath).isFile()) {
|
|
8737
8736
|
return false;
|
|
@@ -8770,7 +8769,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8770
8769
|
if (marker.allOf) {
|
|
8771
8770
|
const hasAllRequiredFiles = marker.allOf.every((name) => {
|
|
8772
8771
|
try {
|
|
8773
|
-
return fs28.statSync(
|
|
8772
|
+
return fs28.statSync(path18.join(datasetPath, name)).isFile();
|
|
8774
8773
|
} catch {
|
|
8775
8774
|
return false;
|
|
8776
8775
|
}
|
|
@@ -8782,7 +8781,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8782
8781
|
if (marker.anyOf) {
|
|
8783
8782
|
const hasMarkerFile = marker.anyOf.some((name) => {
|
|
8784
8783
|
try {
|
|
8785
|
-
return fs28.statSync(
|
|
8784
|
+
return fs28.statSync(path18.join(datasetPath, name)).isFile();
|
|
8786
8785
|
} catch {
|
|
8787
8786
|
return false;
|
|
8788
8787
|
}
|
|
@@ -8810,9 +8809,9 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8810
8809
|
return false;
|
|
8811
8810
|
}
|
|
8812
8811
|
async function launchBenchUi(resultsDir) {
|
|
8813
|
-
const benchUiDir =
|
|
8812
|
+
const benchUiDir = path18.join(CLI_REPO_ROOT, "packages", "bench-ui");
|
|
8814
8813
|
const pnpmCmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
8815
|
-
if (!fs28.existsSync(
|
|
8814
|
+
if (!fs28.existsSync(path18.join(benchUiDir, "package.json"))) {
|
|
8816
8815
|
console.error("ERROR: @remnic/bench-ui is not available in this checkout.");
|
|
8817
8816
|
process.exit(1);
|
|
8818
8817
|
}
|
|
@@ -8839,24 +8838,24 @@ async function launchBenchUi(resultsDir) {
|
|
|
8839
8838
|
});
|
|
8840
8839
|
}
|
|
8841
8840
|
function resolveRepoDatasetRoot() {
|
|
8842
|
-
const repoCandidate =
|
|
8841
|
+
const repoCandidate = path18.join(CLI_REPO_ROOT, "evals", "datasets");
|
|
8843
8842
|
if (isRepoCheckout()) {
|
|
8844
8843
|
return repoCandidate;
|
|
8845
8844
|
}
|
|
8846
|
-
return
|
|
8845
|
+
return path18.join(resolveHomeDir(), ".remnic", "bench", "datasets");
|
|
8847
8846
|
}
|
|
8848
8847
|
function listDownloadableBenchmarks() {
|
|
8849
8848
|
return [...DOWNLOADABLE_BENCHMARK_DATASETS];
|
|
8850
8849
|
}
|
|
8851
8850
|
function resolveDatasetDownloadScriptPath() {
|
|
8852
|
-
const bundled =
|
|
8851
|
+
const bundled = path18.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
|
|
8853
8852
|
if (fs28.existsSync(bundled)) {
|
|
8854
8853
|
return bundled;
|
|
8855
8854
|
}
|
|
8856
|
-
return
|
|
8855
|
+
return path18.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh");
|
|
8857
8856
|
}
|
|
8858
8857
|
function isRepoCheckout() {
|
|
8859
|
-
return fs28.existsSync(
|
|
8858
|
+
return fs28.existsSync(path18.join(CLI_REPO_ROOT, "pnpm-workspace.yaml")) && fs28.existsSync(path18.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh"));
|
|
8860
8859
|
}
|
|
8861
8860
|
function runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, jsonMode) {
|
|
8862
8861
|
const stdio = jsonMode ? ["inherit", process.stderr, "inherit"] : "inherit";
|
|
@@ -8907,7 +8906,7 @@ function resolveBenchDatasetDir(benchmarkId, quick, datasetDirOverride) {
|
|
|
8907
8906
|
if (quick) {
|
|
8908
8907
|
return void 0;
|
|
8909
8908
|
}
|
|
8910
|
-
const datasetDir =
|
|
8909
|
+
const datasetDir = path18.join(resolveRepoDatasetRoot(), benchmarkId);
|
|
8911
8910
|
if (isDatasetDownloaded(datasetDir, benchmarkId)) {
|
|
8912
8911
|
return datasetDir;
|
|
8913
8912
|
}
|
|
@@ -9164,12 +9163,12 @@ async function exportBenchPackageResult(parsed) {
|
|
|
9164
9163
|
process.exit(1);
|
|
9165
9164
|
}
|
|
9166
9165
|
const result = await loadBenchmarkResult(summary.path);
|
|
9167
|
-
const reportCardProvenance = parsed.format === "html" ? await loadBenchmarkReportCardProvenance(
|
|
9166
|
+
const reportCardProvenance = parsed.format === "html" ? await loadBenchmarkReportCardProvenance(path18.dirname(summary.path), result.meta.id) : void 0;
|
|
9168
9167
|
const rendered = renderBenchmarkResultExport(result, parsed.format, {
|
|
9169
9168
|
...reportCardProvenance ? { reportCardProvenance } : {}
|
|
9170
9169
|
});
|
|
9171
9170
|
if (parsed.output) {
|
|
9172
|
-
fs28.mkdirSync(
|
|
9171
|
+
fs28.mkdirSync(path18.dirname(parsed.output), { recursive: true });
|
|
9173
9172
|
fs28.writeFileSync(parsed.output, rendered);
|
|
9174
9173
|
console.log(`Exported ${summary.id} as ${parsed.format} to ${parsed.output}`);
|
|
9175
9174
|
return;
|
|
@@ -9187,7 +9186,7 @@ async function manageBenchDatasets(parsed) {
|
|
|
9187
9186
|
process.exit(1);
|
|
9188
9187
|
}
|
|
9189
9188
|
const status = supported.map((benchmarkId) => {
|
|
9190
|
-
const datasetPath =
|
|
9189
|
+
const datasetPath = path18.join(datasetRoot, benchmarkId);
|
|
9191
9190
|
return {
|
|
9192
9191
|
benchmark: benchmarkId,
|
|
9193
9192
|
downloaded: isDatasetDownloaded(datasetPath, benchmarkId),
|
|
@@ -9225,7 +9224,7 @@ async function manageBenchDatasets(parsed) {
|
|
|
9225
9224
|
runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, parsed.json === true);
|
|
9226
9225
|
downloaded.push({
|
|
9227
9226
|
benchmark: benchmarkId,
|
|
9228
|
-
path:
|
|
9227
|
+
path: path18.join(datasetRoot, benchmarkId)
|
|
9229
9228
|
});
|
|
9230
9229
|
}
|
|
9231
9230
|
if (parsed.json) {
|
|
@@ -9364,10 +9363,10 @@ async function calibrateBenchJudges(parsed, rawArgs) {
|
|
|
9364
9363
|
}
|
|
9365
9364
|
const bench = await loadBenchModule();
|
|
9366
9365
|
const resultsDir = expandTilde(
|
|
9367
|
-
parsed.resultsDir ??
|
|
9366
|
+
parsed.resultsDir ?? path18.join(resolveHomeDir(), ".remnic", "bench", "results")
|
|
9368
9367
|
);
|
|
9369
9368
|
const calibrationDir = expandTilde(
|
|
9370
|
-
parsed.calibrationDir ??
|
|
9369
|
+
parsed.calibrationDir ?? path18.join(resolveHomeDir(), ".remnic", "bench", "calibration")
|
|
9371
9370
|
);
|
|
9372
9371
|
const stored = await bench.listBenchmarkResults(resultsDir);
|
|
9373
9372
|
const allForBenchmark = stored.filter((entry) => entry.benchmark === benchmarkId);
|
|
@@ -9927,7 +9926,7 @@ async function loadPublishedPromotionHelpers() {
|
|
|
9927
9926
|
return {
|
|
9928
9927
|
async promoteArtifactsToPublished(args) {
|
|
9929
9928
|
const { mkdirSync, readFileSync: readFileSync4, writeFileSync } = await import("fs");
|
|
9930
|
-
const
|
|
9929
|
+
const path19 = await import("path");
|
|
9931
9930
|
mkdirSync(args.publishedOutDir, { recursive: true });
|
|
9932
9931
|
if (args.artifactPaths.length === 0) {
|
|
9933
9932
|
console.warn(
|
|
@@ -9944,13 +9943,13 @@ async function loadPublishedPromotionHelpers() {
|
|
|
9944
9943
|
const modelSlug = args.model.replace(/[^a-zA-Z0-9_.-]/g, "-");
|
|
9945
9944
|
const rawProfile = parsedObj.config?.runtimeProfile;
|
|
9946
9945
|
const profileSlug = typeof rawProfile === "string" && rawProfile.length > 0 ? `-${rawProfile.replace(/[^a-zA-Z0-9_.-]/g, "-")}` : "";
|
|
9947
|
-
const target =
|
|
9946
|
+
const target = path19.join(
|
|
9948
9947
|
args.publishedOutDir,
|
|
9949
9948
|
`${today}-${args.benchmarkId}-${modelSlug}${profileSlug}-${gitShaShort}.json`
|
|
9950
9949
|
);
|
|
9951
9950
|
writeFileSync(target, raw, "utf8");
|
|
9952
9951
|
console.log(
|
|
9953
|
-
`[bench published] Promoted ${
|
|
9952
|
+
`[bench published] Promoted ${path19.basename(artifactPath)} \u2192 ${target}`
|
|
9954
9953
|
);
|
|
9955
9954
|
}
|
|
9956
9955
|
void benchModule;
|
|
@@ -10057,7 +10056,7 @@ async function runBenchViaPackage(parsed, benchmarkId, runtimeProfile, benchStat
|
|
|
10057
10056
|
const previousCodexDiagnosticsDir = process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV];
|
|
10058
10057
|
const previousCodexDiagnosticsMode = process.env[CODEX_CLI_BENCH_DIAGNOSTICS_MODE_ENV];
|
|
10059
10058
|
if (!previousCodexDiagnosticsDir) {
|
|
10060
|
-
process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV] =
|
|
10059
|
+
process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV] = path18.join(
|
|
10061
10060
|
outputDir,
|
|
10062
10061
|
"codex-cli-diagnostics"
|
|
10063
10062
|
);
|
|
@@ -10207,7 +10206,7 @@ async function preparePersistedJudgeCalibrationAttachment(benchModule, benchmark
|
|
|
10207
10206
|
);
|
|
10208
10207
|
}
|
|
10209
10208
|
const calibrationDir = expandTilde(
|
|
10210
|
-
calibrationBinding.calibrationDir ??
|
|
10209
|
+
calibrationBinding.calibrationDir ?? path18.join(resolveHomeDir(), ".remnic", "bench", "calibration")
|
|
10211
10210
|
);
|
|
10212
10211
|
const state = await benchModule.loadJudgeCalibrationState?.(benchmarkId, calibrationDir);
|
|
10213
10212
|
if (!state) {
|
|
@@ -10578,19 +10577,19 @@ function loadConvergeCommandConfig() {
|
|
|
10578
10577
|
return loadStandaloneConvergeCommandConfig();
|
|
10579
10578
|
}
|
|
10580
10579
|
function resolveConfigPath(cliPath) {
|
|
10581
|
-
if (cliPath) return
|
|
10580
|
+
if (cliPath) return path18.resolve(expandTilde(cliPath));
|
|
10582
10581
|
const envPath = readCompatEnv("REMNIC_CONFIG_PATH", "ENGRAM_CONFIG_PATH");
|
|
10583
|
-
if (envPath) return
|
|
10582
|
+
if (envPath) return path18.resolve(expandTilde(envPath));
|
|
10584
10583
|
const candidates = [
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10584
|
+
path18.join(process.cwd(), "remnic.config.json"),
|
|
10585
|
+
path18.join(process.cwd(), "engram.config.json"),
|
|
10586
|
+
path18.join(resolveHomeDir(), ".config", "remnic", "config.json"),
|
|
10587
|
+
path18.join(resolveHomeDir(), ".config", "engram", "config.json")
|
|
10589
10588
|
];
|
|
10590
10589
|
for (const candidate of candidates) {
|
|
10591
10590
|
if (fs28.existsSync(candidate)) return candidate;
|
|
10592
10591
|
}
|
|
10593
|
-
return
|
|
10592
|
+
return path18.join(resolveHomeDir(), ".config", "remnic", "config.json");
|
|
10594
10593
|
}
|
|
10595
10594
|
function resolveExistingBenchRemnicConfigPath(cliPath) {
|
|
10596
10595
|
const configPath = resolveConfigPath(cliPath);
|
|
@@ -10704,7 +10703,7 @@ async function resolvePackageBenchRuntime(benchModule, parsed, runtimeProfile) {
|
|
|
10704
10703
|
);
|
|
10705
10704
|
}
|
|
10706
10705
|
function normalizeMemoryDirPath(memoryDir) {
|
|
10707
|
-
return
|
|
10706
|
+
return path18.resolve(expandTilde(memoryDir));
|
|
10708
10707
|
}
|
|
10709
10708
|
function resolveMemoryDir() {
|
|
10710
10709
|
const configMemoryDir = (() => {
|
|
@@ -10717,9 +10716,9 @@ function resolveMemoryDir() {
|
|
|
10717
10716
|
return normalizeMemoryDirPath(remnicCfg.memoryDir);
|
|
10718
10717
|
}
|
|
10719
10718
|
const home = resolveHomeDir();
|
|
10720
|
-
const standalonePath =
|
|
10721
|
-
const legacyStandalonePath =
|
|
10722
|
-
const openclawPath =
|
|
10719
|
+
const standalonePath = path18.join(home, ".remnic", "memory");
|
|
10720
|
+
const legacyStandalonePath = path18.join(home, ".engram", "memory");
|
|
10721
|
+
const openclawPath = path18.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
10723
10722
|
if (fs28.existsSync(standalonePath)) return standalonePath;
|
|
10724
10723
|
if (fs28.existsSync(legacyStandalonePath)) return legacyStandalonePath;
|
|
10725
10724
|
return openclawPath;
|
|
@@ -10768,21 +10767,21 @@ function resolveFlagStrict(args, flag) {
|
|
|
10768
10767
|
var REMNIC_OPENCLAW_LEGACY_PLUGIN_ID = "openclaw-engram";
|
|
10769
10768
|
function resolveOpenclawStateDir() {
|
|
10770
10769
|
const configuredStateDir = process.env.OPENCLAW_STATE_DIR?.trim();
|
|
10771
|
-
return configuredStateDir ?
|
|
10770
|
+
return configuredStateDir ? path18.resolve(expandTilde(configuredStateDir)) : path18.join(resolveHomeDir(), ".openclaw");
|
|
10772
10771
|
}
|
|
10773
10772
|
var DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR = [
|
|
10774
10773
|
process.env.OPENCLAW_CONFIG_PATH,
|
|
10775
10774
|
process.env.OPENCLAW_ENGRAM_CONFIG_PATH,
|
|
10776
|
-
|
|
10775
|
+
path18.join(resolveOpenclawStateDir(), "openclaw.json")
|
|
10777
10776
|
].filter(Boolean);
|
|
10778
10777
|
function resolveOpenclawConfigPath(cliPath) {
|
|
10779
|
-
if (cliPath) return
|
|
10778
|
+
if (cliPath) return path18.resolve(expandTilde(cliPath));
|
|
10780
10779
|
const envPath = process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_ENGRAM_CONFIG_PATH;
|
|
10781
|
-
if (envPath) return
|
|
10780
|
+
if (envPath) return path18.resolve(expandTilde(envPath));
|
|
10782
10781
|
for (const candidate of DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR) {
|
|
10783
10782
|
if (fs28.existsSync(candidate)) return candidate;
|
|
10784
10783
|
}
|
|
10785
|
-
return
|
|
10784
|
+
return path18.join(resolveOpenclawStateDir(), "openclaw.json");
|
|
10786
10785
|
}
|
|
10787
10786
|
function readOpenclawConfig(configPath) {
|
|
10788
10787
|
if (!fs28.existsSync(configPath)) return {};
|
|
@@ -10841,10 +10840,10 @@ function buildRemnicOpenclawHooksPolicy(legacyHooks, existingHooks) {
|
|
|
10841
10840
|
function resolveOpenclawInstallMemoryDir(args) {
|
|
10842
10841
|
const existingMemoryDir = (typeof args.existingNewEntryConfig.memoryDir === "string" ? args.existingNewEntryConfig.memoryDir : void 0) || (args.migrateLegacy && typeof args.legacyConfigToMerge.memoryDir === "string" ? args.legacyConfigToMerge.memoryDir : void 0);
|
|
10843
10842
|
if (args.requestedMemoryDir) {
|
|
10844
|
-
return
|
|
10843
|
+
return path18.resolve(expandTilde(args.requestedMemoryDir));
|
|
10845
10844
|
}
|
|
10846
10845
|
if (existingMemoryDir) {
|
|
10847
|
-
return
|
|
10846
|
+
return path18.resolve(expandTilde(existingMemoryDir));
|
|
10848
10847
|
}
|
|
10849
10848
|
return args.fallbackMemoryDir;
|
|
10850
10849
|
}
|
|
@@ -10862,21 +10861,21 @@ function resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir) {
|
|
|
10862
10861
|
if (!config || typeof config !== "object" || Array.isArray(config)) continue;
|
|
10863
10862
|
const memoryDir = config.memoryDir;
|
|
10864
10863
|
if (typeof memoryDir === "string" && memoryDir.trim().length > 0) {
|
|
10865
|
-
return
|
|
10864
|
+
return path18.resolve(expandTilde(memoryDir));
|
|
10866
10865
|
}
|
|
10867
10866
|
}
|
|
10868
10867
|
return fallbackMemoryDir;
|
|
10869
10868
|
}
|
|
10870
10869
|
function resolveOpenclawPluginDir(cliPath) {
|
|
10871
|
-
if (cliPath) return
|
|
10870
|
+
if (cliPath) return path18.resolve(expandTilde(cliPath));
|
|
10872
10871
|
return resolveOpenclawManagedPluginDir();
|
|
10873
10872
|
}
|
|
10874
10873
|
function resolveOpenclawManagedPluginDir() {
|
|
10875
|
-
return
|
|
10874
|
+
return path18.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
|
|
10876
10875
|
}
|
|
10877
10876
|
function resolveOpenclawLegacyPluginDir(cliPath) {
|
|
10878
|
-
if (cliPath) return
|
|
10879
|
-
return
|
|
10877
|
+
if (cliPath) return path18.resolve(expandTilde(cliPath));
|
|
10878
|
+
return path18.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID);
|
|
10880
10879
|
}
|
|
10881
10880
|
function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
|
|
10882
10881
|
const yyyy = now.getFullYear().toString();
|
|
@@ -10889,7 +10888,7 @@ function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
|
|
|
10889
10888
|
}
|
|
10890
10889
|
function backupPathIfPresent(sourcePath, backupPath) {
|
|
10891
10890
|
if (!fs28.existsSync(sourcePath)) return false;
|
|
10892
|
-
fs28.mkdirSync(
|
|
10891
|
+
fs28.mkdirSync(path18.dirname(backupPath), { recursive: true });
|
|
10893
10892
|
fs28.cpSync(sourcePath, backupPath, { recursive: true });
|
|
10894
10893
|
return true;
|
|
10895
10894
|
}
|
|
@@ -10908,7 +10907,7 @@ function restartOpenclawGateway() {
|
|
|
10908
10907
|
});
|
|
10909
10908
|
}
|
|
10910
10909
|
function cmdInit() {
|
|
10911
|
-
const configPath =
|
|
10910
|
+
const configPath = path18.join(process.cwd(), "remnic.config.json");
|
|
10912
10911
|
if (fs28.existsSync(configPath)) {
|
|
10913
10912
|
console.log(`Config already exists: ${configPath}`);
|
|
10914
10913
|
return;
|
|
@@ -10916,7 +10915,7 @@ function cmdInit() {
|
|
|
10916
10915
|
const template = {
|
|
10917
10916
|
remnic: {
|
|
10918
10917
|
openaiApiKey: "${OPENAI_API_KEY}",
|
|
10919
|
-
memoryDir:
|
|
10918
|
+
memoryDir: path18.join(process.cwd(), ".remnic", "memory"),
|
|
10920
10919
|
memoryOsPreset: "balanced"
|
|
10921
10920
|
},
|
|
10922
10921
|
server: {
|
|
@@ -10978,7 +10977,7 @@ async function cmdStatus(json) {
|
|
|
10978
10977
|
console.log(`Remnic server: running${pid ? ` (pid ${pid})` : ""}`);
|
|
10979
10978
|
await printHealthCheck(resolveDaemonBaseUrl(resolveConfigPath()), resolveStatusProbeToken());
|
|
10980
10979
|
}
|
|
10981
|
-
async function oauthFetch(method,
|
|
10980
|
+
async function oauthFetch(method, path19, token, body) {
|
|
10982
10981
|
const controller = new AbortController();
|
|
10983
10982
|
const timeoutId = setTimeout(() => controller.abort(), 5e3);
|
|
10984
10983
|
try {
|
|
@@ -10997,7 +10996,7 @@ async function oauthFetch(method, path20, token, body) {
|
|
|
10997
10996
|
if (body !== void 0) {
|
|
10998
10997
|
init.body = JSON.stringify(body);
|
|
10999
10998
|
}
|
|
11000
|
-
const response = await fetch(`${resolveDaemonBaseUrl(resolveConfigPath())}${
|
|
10999
|
+
const response = await fetch(`${resolveDaemonBaseUrl(resolveConfigPath())}${path19}`, init);
|
|
11001
11000
|
if (response.status === 401) {
|
|
11002
11001
|
throw new Error(
|
|
11003
11002
|
"operator token rejected by remnic-server (HTTP 401). Update `server.authToken` or `REMNIC_AUTH_TOKEN` to match the running daemon."
|
|
@@ -11615,7 +11614,7 @@ async function cmdVersions(rest) {
|
|
|
11615
11614
|
console.error("Usage: remnic versions list <page-path>");
|
|
11616
11615
|
process.exit(1);
|
|
11617
11616
|
}
|
|
11618
|
-
const absPath =
|
|
11617
|
+
const absPath = path18.resolve(pagePath);
|
|
11619
11618
|
const history = await listVersions(absPath, versioningConfig, memDir);
|
|
11620
11619
|
if (json) {
|
|
11621
11620
|
console.log(JSON.stringify(history, null, 2));
|
|
@@ -11640,7 +11639,7 @@ async function cmdVersions(rest) {
|
|
|
11640
11639
|
console.error("Usage: remnic versions show <page-path> <version-id>");
|
|
11641
11640
|
process.exit(1);
|
|
11642
11641
|
}
|
|
11643
|
-
const absPath =
|
|
11642
|
+
const absPath = path18.resolve(pagePath);
|
|
11644
11643
|
try {
|
|
11645
11644
|
const content = await getVersion(absPath, versionId, versioningConfig, memDir);
|
|
11646
11645
|
console.log(content);
|
|
@@ -11658,7 +11657,7 @@ async function cmdVersions(rest) {
|
|
|
11658
11657
|
console.error("Usage: remnic versions diff <page-path> <v1> <v2>");
|
|
11659
11658
|
process.exit(1);
|
|
11660
11659
|
}
|
|
11661
|
-
const absPath =
|
|
11660
|
+
const absPath = path18.resolve(pagePath);
|
|
11662
11661
|
try {
|
|
11663
11662
|
const diffOutput = await diffVersions(absPath, v1, v2, versioningConfig, memDir);
|
|
11664
11663
|
console.log(diffOutput);
|
|
@@ -11675,7 +11674,7 @@ async function cmdVersions(rest) {
|
|
|
11675
11674
|
console.error("Usage: remnic versions revert <page-path> <version-id>");
|
|
11676
11675
|
process.exit(1);
|
|
11677
11676
|
}
|
|
11678
|
-
const absPath =
|
|
11677
|
+
const absPath = path18.resolve(pagePath);
|
|
11679
11678
|
try {
|
|
11680
11679
|
const version = await revertToVersion(absPath, versionId, versioningConfig, void 0, memDir);
|
|
11681
11680
|
if (json) {
|
|
@@ -11715,7 +11714,7 @@ async function cmdEnrich(rest) {
|
|
|
11715
11714
|
const subcommand = rest[0];
|
|
11716
11715
|
if (subcommand === "audit") {
|
|
11717
11716
|
const memoryDir2 = expandTilde(config.memoryDir);
|
|
11718
|
-
const auditDir2 =
|
|
11717
|
+
const auditDir2 = path18.join(memoryDir2, "enrichment");
|
|
11719
11718
|
const sinceFlag = resolveFlag(rest.slice(1), "--since");
|
|
11720
11719
|
const entries = await readAuditLog(auditDir2, sinceFlag ?? void 0);
|
|
11721
11720
|
if (entries.length === 0) {
|
|
@@ -11840,7 +11839,7 @@ Registered providers:`);
|
|
|
11840
11839
|
return;
|
|
11841
11840
|
}
|
|
11842
11841
|
const memoryDir = expandTilde(config.memoryDir);
|
|
11843
|
-
const auditDir =
|
|
11842
|
+
const auditDir = path18.join(memoryDir, "enrichment");
|
|
11844
11843
|
let totalPersisted = 0;
|
|
11845
11844
|
for (const result of results) {
|
|
11846
11845
|
for (const candidate of result.acceptedCandidates) {
|
|
@@ -11963,7 +11962,7 @@ Root: ${root}`);
|
|
|
11963
11962
|
const validNames = new Set(extensions.map((e) => e.name));
|
|
11964
11963
|
let errors = 0;
|
|
11965
11964
|
for (const entry of entries) {
|
|
11966
|
-
const entryPath =
|
|
11965
|
+
const entryPath = path18.join(root, entry);
|
|
11967
11966
|
try {
|
|
11968
11967
|
if (!fs28.statSync(entryPath).isDirectory()) continue;
|
|
11969
11968
|
} catch {
|
|
@@ -12079,7 +12078,7 @@ async function cmdBriefing(rest) {
|
|
|
12079
12078
|
const saveDir = resolveBriefingSaveDir(config.briefing.saveDir);
|
|
12080
12079
|
fs28.mkdirSync(saveDir, { recursive: true });
|
|
12081
12080
|
const filename = briefingFilename(new Date(result.window.to), format);
|
|
12082
|
-
const filePath =
|
|
12081
|
+
const filePath = path18.join(saveDir, filename);
|
|
12083
12082
|
fs28.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
|
|
12084
12083
|
console.error(`Saved briefing: ${filePath}`);
|
|
12085
12084
|
} catch (err) {
|
|
@@ -12235,7 +12234,7 @@ async function cmdDoctor() {
|
|
|
12235
12234
|
const rawMemoryDir = entryConfig?.memoryDir;
|
|
12236
12235
|
const configuredMemoryDir = typeof rawMemoryDir === "string" ? rawMemoryDir : void 0;
|
|
12237
12236
|
if (configuredMemoryDir) {
|
|
12238
|
-
const resolvedMemDir =
|
|
12237
|
+
const resolvedMemDir = path18.resolve(expandTilde(configuredMemoryDir));
|
|
12239
12238
|
let memDirOk = false;
|
|
12240
12239
|
let memDirDetail = `${resolvedMemDir} (not found)`;
|
|
12241
12240
|
let memDirRemediation = `Run \`remnic openclaw install --memory-dir "${resolvedMemDir}"\` to create the directory.`;
|
|
@@ -12448,7 +12447,7 @@ async function cmdMigrate(json, rollback) {
|
|
|
12448
12447
|
console.log(` Rollback: ${result.rollbackCommand}`);
|
|
12449
12448
|
}
|
|
12450
12449
|
function cmdOnboard(dirPath, json) {
|
|
12451
|
-
const directory =
|
|
12450
|
+
const directory = path18.resolve(dirPath || process.cwd());
|
|
12452
12451
|
const result = onboard({ directory });
|
|
12453
12452
|
if (json) {
|
|
12454
12453
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -12467,7 +12466,7 @@ Suggested namespace: ${result.plan.suggestedNamespace}`);
|
|
|
12467
12466
|
async function cmdCurate(targetPath, json) {
|
|
12468
12467
|
const memoryDir = resolveMemoryDir();
|
|
12469
12468
|
const result = await curate({
|
|
12470
|
-
targetPath:
|
|
12469
|
+
targetPath: path18.resolve(targetPath),
|
|
12471
12470
|
memoryDir,
|
|
12472
12471
|
source: "curation",
|
|
12473
12472
|
checkDuplicates: true,
|
|
@@ -12597,7 +12596,7 @@ async function cmdSync(action, rest, json) {
|
|
|
12597
12596
|
}
|
|
12598
12597
|
function localOfflineSourceId(memoryDir) {
|
|
12599
12598
|
const host = os3.hostname() || "unknown-host";
|
|
12600
|
-
const dirHash = createHash4("sha256").update(
|
|
12599
|
+
const dirHash = createHash4("sha256").update(path18.resolve(memoryDir)).digest("hex").slice(0, 16);
|
|
12601
12600
|
return `remnic-local:${host}:${dirHash}`;
|
|
12602
12601
|
}
|
|
12603
12602
|
function normalizeOfflineRemoteUrl(raw) {
|
|
@@ -12995,10 +12994,10 @@ var OFFLINE_SYNC_CONTENT_MISSING_RETRY_MAX = 3;
|
|
|
12995
12994
|
var OFFLINE_SYNC_CONTENT_MISSING_RETRY_DELAY_MS = 250;
|
|
12996
12995
|
var OfflineRemoteFileChangedError = class extends Error {
|
|
12997
12996
|
path;
|
|
12998
|
-
constructor(
|
|
12999
|
-
super(`remote file changed while fetching offline content: ${
|
|
12997
|
+
constructor(path19) {
|
|
12998
|
+
super(`remote file changed while fetching offline content: ${path19}`);
|
|
13000
12999
|
this.name = "OfflineRemoteFileChangedError";
|
|
13001
|
-
this.path =
|
|
13000
|
+
this.path = path19;
|
|
13002
13001
|
}
|
|
13003
13002
|
};
|
|
13004
13003
|
function isOfflineRemoteFileChangedError(error) {
|
|
@@ -13259,7 +13258,7 @@ async function pushOfflineFileContentFromChunkReader(args) {
|
|
|
13259
13258
|
}
|
|
13260
13259
|
const hash = createHash4("sha256");
|
|
13261
13260
|
const chunks = args.readFileChunks({
|
|
13262
|
-
root:
|
|
13261
|
+
root: path18.resolve(args.memoryDir),
|
|
13263
13262
|
path: args.file.path,
|
|
13264
13263
|
filePath,
|
|
13265
13264
|
chunkSize: OFFLINE_SYNC_FILE_CONTENT_UPLOAD_CHUNK_BYTES
|
|
@@ -14369,7 +14368,7 @@ Environment fallbacks:
|
|
|
14369
14368
|
REMNIC_OFFLINE_REMOTE_URL, REMNIC_OFFLINE_TOKEN, REMNIC_AUTH_TOKEN`);
|
|
14370
14369
|
return;
|
|
14371
14370
|
}
|
|
14372
|
-
const memoryDir =
|
|
14371
|
+
const memoryDir = path18.resolve(expandTilde(resolveRequiredValueFlag(rest, "--memory-dir") ?? resolveMemoryDir()));
|
|
14373
14372
|
const namespace = resolveRequiredValueFlag(rest, "--namespace");
|
|
14374
14373
|
const includeTranscripts = !hasFlag(rest, "--no-transcripts");
|
|
14375
14374
|
const stateOverride = resolveRequiredValueFlag(rest, "--state");
|
|
@@ -14389,7 +14388,7 @@ Environment fallbacks:
|
|
|
14389
14388
|
const needsRemote = action === "prepare" || action === "sync" || action === "watch";
|
|
14390
14389
|
const remoteUrl = needsRemote ? resolveOfflineRemoteUrl(rest) : resolveOptionalOfflineRemoteUrl(rest);
|
|
14391
14390
|
const token = needsRemote ? resolveOfflineToken(rest) : void 0;
|
|
14392
|
-
const statePath = statePathExplicit ?
|
|
14391
|
+
const statePath = statePathExplicit ? path18.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
|
|
14393
14392
|
if (action === "prepare") {
|
|
14394
14393
|
if (!remoteUrl || !token || !statePath) throw new Error("offline prepare requires remote URL and token");
|
|
14395
14394
|
fs28.mkdirSync(memoryDir, { recursive: true });
|
|
@@ -14571,11 +14570,11 @@ Environment fallbacks:
|
|
|
14571
14570
|
failures: result.largeFilePushFailures
|
|
14572
14571
|
});
|
|
14573
14572
|
largeFileFailureCounts = advanced.counts;
|
|
14574
|
-
for (const
|
|
14575
|
-
if (skippedLargeFiles.has(
|
|
14576
|
-
skippedLargeFiles.add(
|
|
14573
|
+
for (const path19 of advanced.newlySkipped) {
|
|
14574
|
+
if (skippedLargeFiles.has(path19)) continue;
|
|
14575
|
+
skippedLargeFiles.add(path19);
|
|
14577
14576
|
console.warn(
|
|
14578
|
-
`offline sync: permanently skipping ${
|
|
14577
|
+
`offline sync: permanently skipping ${path19} after ${OFFLINE_LARGE_FILE_SKIP_AFTER_FAILURES} failed large-file pushes for this watcher process (see issue #1786; use --exclude or offlineSyncExcludes to silence permanently)`
|
|
14579
14578
|
);
|
|
14580
14579
|
}
|
|
14581
14580
|
const pulled = result.pull ? result.pull.upserted + result.pull.deleted : 0;
|
|
@@ -14590,11 +14589,11 @@ Environment fallbacks:
|
|
|
14590
14589
|
failures: error.failures
|
|
14591
14590
|
});
|
|
14592
14591
|
largeFileFailureCounts = advanced.counts;
|
|
14593
|
-
for (const
|
|
14594
|
-
if (skippedLargeFiles.has(
|
|
14595
|
-
skippedLargeFiles.add(
|
|
14592
|
+
for (const path19 of advanced.newlySkipped) {
|
|
14593
|
+
if (skippedLargeFiles.has(path19)) continue;
|
|
14594
|
+
skippedLargeFiles.add(path19);
|
|
14596
14595
|
console.warn(
|
|
14597
|
-
`offline sync: permanently skipping ${
|
|
14596
|
+
`offline sync: permanently skipping ${path19} after ${OFFLINE_LARGE_FILE_SKIP_AFTER_FAILURES} failed large-file pushes for this watcher process (see issue #1786; use --exclude or offlineSyncExcludes to silence permanently)`
|
|
14598
14597
|
);
|
|
14599
14598
|
}
|
|
14600
14599
|
}
|
|
@@ -14735,7 +14734,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
14735
14734
|
const connectorDaemonUrl = typeof effectiveConnectorConfig.remnicDaemonUrl === "string" && effectiveConnectorConfig.remnicDaemonUrl.trim().length > 0 ? effectiveConnectorConfig.remnicDaemonUrl.trim() : void 0;
|
|
14736
14735
|
const pubResult = await pub.publish({
|
|
14737
14736
|
config: { memoryDir, namespace: connectorNamespace, daemonUrl: connectorDaemonUrl },
|
|
14738
|
-
skillsRoot:
|
|
14737
|
+
skillsRoot: path18.join(memoryDir, "skills"),
|
|
14739
14738
|
rollbackTokenEntry: preInstallTokenEntry,
|
|
14740
14739
|
log: { info: console.log, warn: console.warn, error: console.error }
|
|
14741
14740
|
});
|
|
@@ -15095,15 +15094,15 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
|
|
|
15095
15094
|
}
|
|
15096
15095
|
const manifest = generateMarketplaceManifest();
|
|
15097
15096
|
await writeMarketplaceManifest(outputDir, manifest);
|
|
15098
|
-
const outPath =
|
|
15097
|
+
const outPath = path18.join(outputDir, "marketplace.json");
|
|
15099
15098
|
if (json) {
|
|
15100
15099
|
console.log(JSON.stringify({ status: "generated", path: outPath }, null, 2));
|
|
15101
15100
|
} else {
|
|
15102
15101
|
console.log(`Generated marketplace.json at ${outPath}`);
|
|
15103
15102
|
}
|
|
15104
15103
|
} else if (subAction === "validate") {
|
|
15105
|
-
const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ??
|
|
15106
|
-
const resolved =
|
|
15104
|
+
const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path18.join(process.cwd(), "marketplace.json");
|
|
15105
|
+
const resolved = path18.resolve(targetPath);
|
|
15107
15106
|
if (!fs28.existsSync(resolved)) {
|
|
15108
15107
|
console.error(`File not found: ${resolved}`);
|
|
15109
15108
|
process.exit(1);
|
|
@@ -15515,7 +15514,7 @@ async function cmdBench(rest) {
|
|
|
15515
15514
|
}
|
|
15516
15515
|
const completeCount = prevStatus.benchmarks.filter((b) => b.status === "complete").length;
|
|
15517
15516
|
const failedCount = prevStatus.benchmarks.filter((b) => b.status === "failed").length;
|
|
15518
|
-
printBenchStatusLine(parsed.json, `Resuming from: ${
|
|
15517
|
+
printBenchStatusLine(parsed.json, `Resuming from: ${path18.basename(latestStatusPath)}`);
|
|
15519
15518
|
printBenchStatusLine(parsed.json, ` Previous run: ${prevStatus.startedAt}`);
|
|
15520
15519
|
printBenchStatusLine(parsed.json, ` Benchmarks: ${prevStatus.benchmarks.length} total, ${completeCount} complete, ${failedCount} failed`);
|
|
15521
15520
|
const before = selectedBenchmarks.length;
|
|
@@ -15683,9 +15682,9 @@ Options:
|
|
|
15683
15682
|
);
|
|
15684
15683
|
process.exit(1);
|
|
15685
15684
|
} else {
|
|
15686
|
-
fixturePath =
|
|
15685
|
+
fixturePath = path18.resolve(expandTilde(fixturePathRaw));
|
|
15687
15686
|
}
|
|
15688
|
-
const outPath =
|
|
15687
|
+
const outPath = path18.resolve(expandTilde(outPathRaw));
|
|
15689
15688
|
const benchModule = await loadBenchModule();
|
|
15690
15689
|
const runner = benchModule.runProceduralAblationCli;
|
|
15691
15690
|
if (typeof runner !== "function") {
|
|
@@ -15704,7 +15703,7 @@ Options:
|
|
|
15704
15703
|
);
|
|
15705
15704
|
console.log(`wrote ${outPath}`);
|
|
15706
15705
|
}
|
|
15707
|
-
var LOGS_DIR =
|
|
15706
|
+
var LOGS_DIR = path18.join(PID_DIR, "logs");
|
|
15708
15707
|
var LAUNCHD_PLIST_PATHS = launchdPlistPaths(resolveHomeDir());
|
|
15709
15708
|
var [LAUNCHD_PLIST_PATH] = LAUNCHD_PLIST_PATHS;
|
|
15710
15709
|
var SYSTEMD_UNIT_PATHS = systemdUnitPaths(resolveHomeDir());
|
|
@@ -15781,7 +15780,7 @@ function selectLaunchdInspection(openclawPluginModeConfigured) {
|
|
|
15781
15780
|
for (const plistPath of LAUNCHD_PLIST_PATHS.slice(1)) {
|
|
15782
15781
|
const legacy = inspectLaunchdPlist(plistPath);
|
|
15783
15782
|
if (!legacy.installed) continue;
|
|
15784
|
-
const label =
|
|
15783
|
+
const label = path18.basename(plistPath, ".plist");
|
|
15785
15784
|
return legacy.ok ? {
|
|
15786
15785
|
...legacy,
|
|
15787
15786
|
warn: true,
|
|
@@ -15815,10 +15814,10 @@ function daemonInstall() {
|
|
|
15815
15814
|
const vars = { HOME: home, NODE_PATH: nodePath, REMNIC_SERVER_BIN: serverBin };
|
|
15816
15815
|
fs28.mkdirSync(LOGS_DIR, { recursive: true });
|
|
15817
15816
|
if (isMacOS()) {
|
|
15818
|
-
const templatePath =
|
|
15817
|
+
const templatePath = path18.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
|
|
15819
15818
|
const template = fs28.readFileSync(templatePath, "utf8");
|
|
15820
15819
|
const plist = renderTemplate(template, vars);
|
|
15821
|
-
fs28.mkdirSync(
|
|
15820
|
+
fs28.mkdirSync(path18.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
|
|
15822
15821
|
fs28.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
15823
15822
|
try {
|
|
15824
15823
|
launchdLoadPlist(LAUNCHD_PLIST_PATH);
|
|
@@ -15835,10 +15834,10 @@ function daemonInstall() {
|
|
|
15835
15834
|
console.log(` RunAtLoad: true, KeepAlive: true`);
|
|
15836
15835
|
console.log(` Logs: ${LOGS_DIR}/daemon.log`);
|
|
15837
15836
|
} else if (isLinux()) {
|
|
15838
|
-
const templatePath =
|
|
15837
|
+
const templatePath = path18.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
|
|
15839
15838
|
const template = fs28.readFileSync(templatePath, "utf8");
|
|
15840
15839
|
const unit = renderTemplate(template, vars);
|
|
15841
|
-
fs28.mkdirSync(
|
|
15840
|
+
fs28.mkdirSync(path18.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
|
|
15842
15841
|
fs28.writeFileSync(SYSTEMD_UNIT_PATH, unit);
|
|
15843
15842
|
try {
|
|
15844
15843
|
childProcess2.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
|
|
@@ -16317,7 +16316,7 @@ Clean complete: cleaned=${result.cleaned}`
|
|
|
16317
16316
|
}
|
|
16318
16317
|
async function cmdOpenclawInstall(opts) {
|
|
16319
16318
|
const configPath = resolveOpenclawConfigPath(opts.configPath);
|
|
16320
|
-
const fallbackMemoryDir =
|
|
16319
|
+
const fallbackMemoryDir = path18.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
16321
16320
|
console.log(`OpenClaw config: ${configPath}`);
|
|
16322
16321
|
const existingConfig = readOpenclawConfig(configPath);
|
|
16323
16322
|
const { plugins, entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
|
|
@@ -16420,7 +16419,7 @@ Remove it first and re-run, or choose a different path with --memory-dir.`
|
|
|
16420
16419
|
fs28.mkdirSync(memoryDir, { recursive: true });
|
|
16421
16420
|
console.log(`Created memory directory: ${memoryDir}`);
|
|
16422
16421
|
}
|
|
16423
|
-
const configDir =
|
|
16422
|
+
const configDir = path18.dirname(configPath);
|
|
16424
16423
|
if (!fs28.existsSync(configDir)) {
|
|
16425
16424
|
fs28.mkdirSync(configDir, { recursive: true });
|
|
16426
16425
|
}
|
|
@@ -16449,12 +16448,12 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
16449
16448
|
const pluginDir = resolveOpenclawPluginDir(opts.pluginDir);
|
|
16450
16449
|
const managedTargetDir = resolveOpenclawManagedPluginDir();
|
|
16451
16450
|
const legacyPluginDirForBackup = opts.legacyPluginDirForBackup ? resolveOpenclawLegacyPluginDir(opts.legacyPluginDirForBackup) : void 0;
|
|
16452
|
-
const fallbackMemoryDir =
|
|
16451
|
+
const fallbackMemoryDir = path18.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
16453
16452
|
const packageSpec = buildOpenclawManagedUpgradePackageSpec(opts.version);
|
|
16454
16453
|
const configExistedBefore = fs28.existsSync(configPath);
|
|
16455
16454
|
const existingConfig = readOpenclawConfig(configPath);
|
|
16456
16455
|
const { entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
|
|
16457
|
-
const preservedMemoryDir = opts.memoryDir ?
|
|
16456
|
+
const preservedMemoryDir = opts.memoryDir ? path18.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
|
|
16458
16457
|
console.log(`OpenClaw config: ${configPath}`);
|
|
16459
16458
|
console.log(`Plugin dir: ${pluginDir}`);
|
|
16460
16459
|
if (legacyPluginDirForBackup) {
|
|
@@ -16462,7 +16461,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
16462
16461
|
}
|
|
16463
16462
|
console.log(`Memory dir: ${preservedMemoryDir}`);
|
|
16464
16463
|
console.log(`Package spec: ${packageSpec}`);
|
|
16465
|
-
console.log(`Backup root: ${
|
|
16464
|
+
console.log(`Backup root: ${path18.join(resolveOpenclawStateDir(), "backups")}`);
|
|
16466
16465
|
const plannedActions = [
|
|
16467
16466
|
`backup openclaw.json and the existing ${REMNIC_OPENCLAW_PLUGIN_ID} extension`,
|
|
16468
16467
|
...legacyPluginDirForBackup ? [`backup the existing ${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID} extension without modifying it`] : [],
|
|
@@ -16500,9 +16499,9 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
16500
16499
|
assertDirectoryPathOrMissing(legacyPluginDirForBackup, "Legacy OpenClaw plugin dir");
|
|
16501
16500
|
}
|
|
16502
16501
|
const backupDir = createOpenclawUpgradeBackupDir();
|
|
16503
|
-
const configBackupPath =
|
|
16504
|
-
const pluginBackupDir =
|
|
16505
|
-
const legacyPluginBackupDir = legacyPluginDirForBackup ?
|
|
16502
|
+
const configBackupPath = path18.join(backupDir, "openclaw.json");
|
|
16503
|
+
const pluginBackupDir = path18.join(backupDir, "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
|
|
16504
|
+
const legacyPluginBackupDir = legacyPluginDirForBackup ? path18.join(backupDir, "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID) : void 0;
|
|
16506
16505
|
const backupNotes = [];
|
|
16507
16506
|
if (backupPathIfPresent(configPath, configBackupPath)) {
|
|
16508
16507
|
backupNotes.push(`+ Backed up config to ${configBackupPath}`);
|
|
@@ -16552,7 +16551,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
16552
16551
|
const managedRollbackDir = publishedInstallError ? publishedInstallError.managedRollbackDir : installResult?.managedRollbackDir;
|
|
16553
16552
|
const managedRollbackTargetDir = publishedInstallError?.managedRollbackTargetDir ?? installResult?.managedRollbackTargetDir ?? managedTargetDir;
|
|
16554
16553
|
const requiresHostManagedRestore = publishedInstallError?.requiresHostManagedRestore ?? installResult?.requiresHostManagedRestore ?? false;
|
|
16555
|
-
const managedRollbackSharesPluginDir = managedRollbackDir &&
|
|
16554
|
+
const managedRollbackSharesPluginDir = managedRollbackDir && path18.resolve(managedRollbackTargetDir) === path18.resolve(pluginDir);
|
|
16556
16555
|
const pluginRollbackDir = managedRollbackSharesPluginDir ? requiresHostManagedRestore ? rollbackDir : rollbackDir ?? managedRollbackDir : rollbackDir;
|
|
16557
16556
|
const shouldRestorePlugin = Boolean(
|
|
16558
16557
|
installResult && !requiresHostManagedRestore || pluginRollbackDir || publishedInstallError?.shouldRestoreBackup
|
|
@@ -16609,7 +16608,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
16609
16608
|
rollbackErrors.push(error);
|
|
16610
16609
|
}
|
|
16611
16610
|
if (pendingConfigRestoreError) rollbackErrors.push(pendingConfigRestoreError);
|
|
16612
|
-
if (managedRollbackDir &&
|
|
16611
|
+
if (managedRollbackDir && path18.resolve(managedRollbackTargetDir) !== path18.resolve(pluginDir) && !requiresHostManagedRestore) {
|
|
16613
16612
|
try {
|
|
16614
16613
|
rollbackNotes.push(
|
|
16615
16614
|
...rollbackOpenclawUpgrade({
|
|
@@ -16675,9 +16674,9 @@ async function cmdOpenclawMigrateEngram(opts) {
|
|
|
16675
16674
|
console.log(" - Re-apply any local source patches to the new package only after verifying the published build.");
|
|
16676
16675
|
}
|
|
16677
16676
|
function createOpenclawUpgradeBackupDir() {
|
|
16678
|
-
const backupsRoot =
|
|
16677
|
+
const backupsRoot = path18.join(resolveOpenclawStateDir(), "backups");
|
|
16679
16678
|
fs28.mkdirSync(backupsRoot, { recursive: true });
|
|
16680
|
-
return fs28.mkdtempSync(
|
|
16679
|
+
return fs28.mkdtempSync(path18.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
|
|
16681
16680
|
}
|
|
16682
16681
|
async function cmdTaxonomy(rest) {
|
|
16683
16682
|
initLogger5();
|
|
@@ -16719,8 +16718,8 @@ async function cmdTaxonomy(rest) {
|
|
|
16719
16718
|
const doc = generateResolverDocument(taxonomy);
|
|
16720
16719
|
console.log(doc);
|
|
16721
16720
|
if (config.taxonomyAutoGenResolver) {
|
|
16722
|
-
const resolverPath =
|
|
16723
|
-
fs28.mkdirSync(
|
|
16721
|
+
const resolverPath = path18.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
16722
|
+
fs28.mkdirSync(path18.dirname(resolverPath), { recursive: true });
|
|
16724
16723
|
fs28.writeFileSync(resolverPath, doc);
|
|
16725
16724
|
console.error(`Written: ${resolverPath}`);
|
|
16726
16725
|
}
|
|
@@ -16766,7 +16765,7 @@ async function cmdTaxonomy(rest) {
|
|
|
16766
16765
|
console.log(`Added category "${id}" (${name}).`);
|
|
16767
16766
|
if (config.taxonomyAutoGenResolver) {
|
|
16768
16767
|
const doc = generateResolverDocument(taxonomy);
|
|
16769
|
-
const resolverPath =
|
|
16768
|
+
const resolverPath = path18.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
16770
16769
|
fs28.writeFileSync(resolverPath, doc);
|
|
16771
16770
|
console.error(`Regenerated: ${resolverPath}`);
|
|
16772
16771
|
}
|
|
@@ -16797,7 +16796,7 @@ async function cmdTaxonomy(rest) {
|
|
|
16797
16796
|
console.log(`Removed category "${id}".`);
|
|
16798
16797
|
if (config.taxonomyAutoGenResolver) {
|
|
16799
16798
|
const doc = generateResolverDocument(taxonomy);
|
|
16800
|
-
const resolverPath =
|
|
16799
|
+
const resolverPath = path18.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
16801
16800
|
fs28.writeFileSync(resolverPath, doc);
|
|
16802
16801
|
console.error(`Regenerated: ${resolverPath}`);
|
|
16803
16802
|
}
|
|
@@ -17079,7 +17078,7 @@ async function runTrainingExport(args, stdout = process.stdout) {
|
|
|
17079
17078
|
);
|
|
17080
17079
|
}
|
|
17081
17080
|
const formatted = adapter.formatRecords(records);
|
|
17082
|
-
const outDir =
|
|
17081
|
+
const outDir = path18.dirname(args.output);
|
|
17083
17082
|
fs28.mkdirSync(outDir, { recursive: true });
|
|
17084
17083
|
const tmpPath = `${args.output}.tmp-${process.pid}-${Date.now()}`;
|
|
17085
17084
|
fs28.writeFileSync(tmpPath, formatted, "utf-8");
|
|
@@ -17199,7 +17198,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
17199
17198
|
case "tree": {
|
|
17200
17199
|
const subAction = rest[0];
|
|
17201
17200
|
const json = rest.includes("--json");
|
|
17202
|
-
const outputDir = resolveFlag(rest, "--output") ??
|
|
17201
|
+
const outputDir = resolveFlag(rest, "--output") ?? path18.join(process.cwd(), ".remnic", "context-tree");
|
|
17203
17202
|
const categoriesFlag = resolveFlag(rest, "--categories");
|
|
17204
17203
|
const categories = categoriesFlag ? categoriesFlag.split(",") : void 0;
|
|
17205
17204
|
const maxPerCategoryRaw = resolveFlag(rest, "--max-per-category");
|
|
@@ -17276,7 +17275,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
17276
17275
|
console.error(`Context tree not found at ${treeDir}. Run 'remnic tree generate' first.`);
|
|
17277
17276
|
process.exit(1);
|
|
17278
17277
|
}
|
|
17279
|
-
const indexPath =
|
|
17278
|
+
const indexPath = path18.join(treeDir, "INDEX.md");
|
|
17280
17279
|
if (!fs28.existsSync(indexPath)) {
|
|
17281
17280
|
console.error(`INDEX.md missing in ${treeDir}. Tree may be corrupt \u2014 regenerate.`);
|
|
17282
17281
|
process.exit(1);
|