@remnic/cli 9.69.87 → 9.69.89
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 +625 -347
- package/package.json +32 -32
package/dist/index.js
CHANGED
|
@@ -488,7 +488,7 @@ function resetLegacyDatasetWarningState() {
|
|
|
488
488
|
// src/index.ts
|
|
489
489
|
import fs32 from "fs";
|
|
490
490
|
import os4 from "os";
|
|
491
|
-
import
|
|
491
|
+
import path24 from "path";
|
|
492
492
|
import { createHash as createHash6 } from "crypto";
|
|
493
493
|
import { writeFile as fsWriteFile } from "fs/promises";
|
|
494
494
|
import * as childProcess2 from "child_process";
|
|
@@ -573,7 +573,7 @@ import {
|
|
|
573
573
|
discoverMemoryExtensions,
|
|
574
574
|
resolveExtensionsRoot,
|
|
575
575
|
coerceInstallExtension,
|
|
576
|
-
StorageManager as
|
|
576
|
+
StorageManager as StorageManager5,
|
|
577
577
|
parseXrayCliOptions,
|
|
578
578
|
renderXray,
|
|
579
579
|
parseWhyCliOptions,
|
|
@@ -597,6 +597,8 @@ import {
|
|
|
597
597
|
offlineSyncStateFromSnapshot,
|
|
598
598
|
readOfflineSyncFileContentChunk,
|
|
599
599
|
readOfflineSyncState,
|
|
600
|
+
embeddingGenerationMembership as embeddingGenerationMembership2,
|
|
601
|
+
divergedEmbeddingGenerationDeferrals,
|
|
600
602
|
shouldPreferIncomingOfflineRuntimeFile,
|
|
601
603
|
summarizeOfflineSyncPendingChanges,
|
|
602
604
|
summarizeOfflineSyncPendingFiles,
|
|
@@ -2965,7 +2967,8 @@ async function createOfflineStorageIo(memoryDir, configuredStorage, persistedExc
|
|
|
2965
2967
|
chunkSize
|
|
2966
2968
|
}),
|
|
2967
2969
|
writeFile: async ({ filePath, content }) => storage.writeOfflineSyncFile(filePath, content),
|
|
2968
|
-
writeStagingFile: async ({ filePath, content }) => storage.writeOfflineSyncStagingFile(filePath, content),
|
|
2970
|
+
writeStagingFile: async ({ filePath, content, finalAadFilePath }) => storage.writeOfflineSyncStagingFile(filePath, content, finalAadFilePath === void 0 ? void 0 : { aadFilePath: finalAadFilePath }),
|
|
2971
|
+
readStagingFile: async ({ filePath, finalAadFilePath }) => storage.readOfflineSyncFile(filePath, finalAadFilePath === void 0 ? void 0 : { aadFilePath: finalAadFilePath }),
|
|
2969
2972
|
writeFileChunks: async ({ filePath, chunks }) => storage.writeOfflineSyncFileChunks(filePath, chunks),
|
|
2970
2973
|
deleteFile: async ({ filePath, mtimeMs }) => storage.deleteOfflineSyncFile(filePath, mtimeMs ?? null),
|
|
2971
2974
|
recordDeletionRevision: async ({ filePath, mtimeMs }) => storage.recordReplicatedDeletionRevision(filePath, mtimeMs)
|
|
@@ -3305,13 +3308,13 @@ async function planLocalNamespaceCensus(args) {
|
|
|
3305
3308
|
citationTemplate: args.citationTemplate,
|
|
3306
3309
|
cachedFiles: identityCache.size > 0 ? [...identityCache.values()] : priorFiles,
|
|
3307
3310
|
readFile: async (file) => {
|
|
3308
|
-
const
|
|
3309
|
-
if (!
|
|
3311
|
+
const readFile6 = io.readFile;
|
|
3312
|
+
if (!readFile6) {
|
|
3310
3313
|
manifestReadFailed = true;
|
|
3311
3314
|
throw new Error("offline storage cannot read reconciliation manifest files");
|
|
3312
3315
|
}
|
|
3313
3316
|
try {
|
|
3314
|
-
return await
|
|
3317
|
+
return await readFile6({
|
|
3315
3318
|
root: rootDir,
|
|
3316
3319
|
path: file.path,
|
|
3317
3320
|
filePath: path6.join(rootDir, file.path)
|
|
@@ -5447,6 +5450,157 @@ async function drainOfflineSyncImpressions(memoryDir, rotation) {
|
|
|
5447
5450
|
);
|
|
5448
5451
|
}
|
|
5449
5452
|
|
|
5453
|
+
// src/offline-generation-staging.ts
|
|
5454
|
+
import { lstat as lstat3, mkdir as mkdir2, mkdtemp as mkdtemp2, readFile as readFile2, readdir as readdir3, rm as rm3, writeFile as writeFile2 } from "fs/promises";
|
|
5455
|
+
import path8 from "path";
|
|
5456
|
+
import { hostname } from "os";
|
|
5457
|
+
import { StorageManager as StorageManager4, embeddingGenerationMembership } from "@remnic/core";
|
|
5458
|
+
var GENERATION_STAGING_PREFIX = "generation-incoming-";
|
|
5459
|
+
function generationMembersForStagedTransport(options) {
|
|
5460
|
+
const currentByPath = new Map((options.currentFiles ?? []).map((file) => [file.path, file]));
|
|
5461
|
+
const deferred = new Set(options.deferredPaths ?? []);
|
|
5462
|
+
return options.incomingFiles.filter(
|
|
5463
|
+
(file) => file.bytes >= options.minBytes && !deferred.has(file.path) && currentByPath.get(file.path)?.sha256 !== file.sha256 && embeddingGenerationMembership(file.path) !== null
|
|
5464
|
+
).sort((left, right) => right.bytes - left.bytes || left.path.localeCompare(right.path));
|
|
5465
|
+
}
|
|
5466
|
+
async function assertPrivateOfflineDir(offlineDir) {
|
|
5467
|
+
const info = await lstat3(offlineDir).catch((error) => {
|
|
5468
|
+
if (error.code === "ENOENT") return null;
|
|
5469
|
+
throw error;
|
|
5470
|
+
});
|
|
5471
|
+
if (info && (info.isSymbolicLink() || !info.isDirectory())) {
|
|
5472
|
+
throw new Error("offline-sync staging directory must be a real directory, not a symlink");
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
async function removeStage(offlineDir, stage) {
|
|
5476
|
+
await assertPrivateOfflineDir(offlineDir);
|
|
5477
|
+
const info = await lstat3(stage).catch((error) => {
|
|
5478
|
+
if (error.code === "ENOENT") return null;
|
|
5479
|
+
throw error;
|
|
5480
|
+
});
|
|
5481
|
+
if (info?.isDirectory() && !info.isSymbolicLink()) {
|
|
5482
|
+
await rm3(stage, { recursive: true, force: true });
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
async function reclaimAbandonedGenerationStages(offlineDir) {
|
|
5486
|
+
await assertPrivateOfflineDir(offlineDir);
|
|
5487
|
+
const names = await readdir3(offlineDir).catch((error) => {
|
|
5488
|
+
if (error.code === "ENOENT") return [];
|
|
5489
|
+
throw error;
|
|
5490
|
+
});
|
|
5491
|
+
for (const name of names) {
|
|
5492
|
+
if (!name.startsWith(GENERATION_STAGING_PREFIX)) continue;
|
|
5493
|
+
const dir = path8.join(offlineDir, name);
|
|
5494
|
+
try {
|
|
5495
|
+
const info = await lstat3(dir);
|
|
5496
|
+
if (!info.isDirectory() || info.isSymbolicLink()) continue;
|
|
5497
|
+
const owner = JSON.parse(await readFile2(path8.join(dir, "owner.json"), "utf-8"));
|
|
5498
|
+
if (owner?.hostname !== hostname() || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) continue;
|
|
5499
|
+
try {
|
|
5500
|
+
process.kill(owner.pid, 0);
|
|
5501
|
+
} catch (error) {
|
|
5502
|
+
if (error.code === "ESRCH") {
|
|
5503
|
+
await removeStage(offlineDir, dir);
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
} catch {
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
async function stageGenerationMembersForApply(options) {
|
|
5511
|
+
const noop = {
|
|
5512
|
+
stagedPaths: /* @__PURE__ */ new Set(),
|
|
5513
|
+
readIncomingFile: async () => null,
|
|
5514
|
+
cleanup: async () => {
|
|
5515
|
+
}
|
|
5516
|
+
};
|
|
5517
|
+
const candidates = generationMembersForStagedTransport({
|
|
5518
|
+
incomingFiles: options.incomingFiles,
|
|
5519
|
+
currentFiles: options.currentFiles,
|
|
5520
|
+
deferredPaths: options.deferredPaths,
|
|
5521
|
+
minBytes: options.minBytes
|
|
5522
|
+
});
|
|
5523
|
+
const offlineDir = path8.join(options.memoryDir, ".offline-sync");
|
|
5524
|
+
await reclaimAbandonedGenerationStages(offlineDir);
|
|
5525
|
+
if (candidates.length === 0) return noop;
|
|
5526
|
+
await mkdir2(offlineDir, { recursive: true });
|
|
5527
|
+
await assertPrivateOfflineDir(offlineDir);
|
|
5528
|
+
const stagingRoot = await mkdtemp2(path8.join(offlineDir, GENERATION_STAGING_PREFIX));
|
|
5529
|
+
try {
|
|
5530
|
+
await writeFile2(path8.join(stagingRoot, "owner.json"), JSON.stringify({
|
|
5531
|
+
pid: process.pid,
|
|
5532
|
+
hostname: hostname()
|
|
5533
|
+
}), { mode: 384, flag: "wx" });
|
|
5534
|
+
const configured = await createConfiguredOfflineStorage(options.memoryDir, options.secureStoreEncryptOnWrite);
|
|
5535
|
+
const stagingStorage = new StorageManager4(stagingRoot);
|
|
5536
|
+
if (configured.secureStoreRequired) stagingStorage.setSecureStoreRequired(true);
|
|
5537
|
+
if (configured.secureStoreKey) {
|
|
5538
|
+
await stagingStorage.setSecureStoreKeyAndWait(
|
|
5539
|
+
configured.secureStoreKey,
|
|
5540
|
+
options.secureStoreEncryptOnWrite ?? true
|
|
5541
|
+
);
|
|
5542
|
+
}
|
|
5543
|
+
const stagingIo = await createOfflineStorageIo(stagingRoot, {
|
|
5544
|
+
storage: stagingStorage,
|
|
5545
|
+
secureStoreKey: configured.secureStoreKey,
|
|
5546
|
+
secureStoreRequired: configured.secureStoreRequired
|
|
5547
|
+
});
|
|
5548
|
+
const stagingReadFile = stagingIo.readFile;
|
|
5549
|
+
const {
|
|
5550
|
+
readFileDigest: stagingReadFileDigest,
|
|
5551
|
+
writeFile: stagingWriteFile,
|
|
5552
|
+
writeStagingFile: stagingWriteStagingFile,
|
|
5553
|
+
writeFileChunks: stagingWriteFileChunks
|
|
5554
|
+
} = stagingIo;
|
|
5555
|
+
if (!stagingReadFile || !stagingReadFileDigest || !stagingWriteFile || !stagingWriteStagingFile || !stagingWriteFileChunks) {
|
|
5556
|
+
throw new Error("offline generation staging requires full storage IO hooks");
|
|
5557
|
+
}
|
|
5558
|
+
const stagedPaths = /* @__PURE__ */ new Set();
|
|
5559
|
+
for (const member of candidates) {
|
|
5560
|
+
const result = await options.hydrateFileContent({
|
|
5561
|
+
remoteUrl: options.remoteUrl,
|
|
5562
|
+
token: options.token,
|
|
5563
|
+
namespace: options.namespace,
|
|
5564
|
+
includeTranscripts: options.includeTranscripts,
|
|
5565
|
+
memoryDir: stagingRoot,
|
|
5566
|
+
sourceId: "remote",
|
|
5567
|
+
expected: member,
|
|
5568
|
+
readFile: stagingReadFile,
|
|
5569
|
+
readFileDigest: stagingReadFileDigest,
|
|
5570
|
+
writeFile: stagingWriteFile,
|
|
5571
|
+
writeStagingFile: stagingWriteStagingFile,
|
|
5572
|
+
writeFileChunks: stagingWriteFileChunks
|
|
5573
|
+
});
|
|
5574
|
+
if (result.conflict) {
|
|
5575
|
+
throw new Error(`offline generation staging conflict for ${member.path}`);
|
|
5576
|
+
}
|
|
5577
|
+
if (!result.done || !(result.applied || result.skipped)) {
|
|
5578
|
+
throw new Error(`offline generation staging did not finish for ${member.path}`);
|
|
5579
|
+
}
|
|
5580
|
+
stagedPaths.add(member.path);
|
|
5581
|
+
}
|
|
5582
|
+
return {
|
|
5583
|
+
stagedPaths,
|
|
5584
|
+
readIncomingFile: async (target) => {
|
|
5585
|
+
if (!stagedPaths.has(target.path)) return null;
|
|
5586
|
+
return await stagingReadFile({
|
|
5587
|
+
root: stagingRoot,
|
|
5588
|
+
path: target.path,
|
|
5589
|
+
filePath: resolveOfflineDirectHydrationPath(stagingRoot, target.path)
|
|
5590
|
+
});
|
|
5591
|
+
},
|
|
5592
|
+
cleanup: async () => {
|
|
5593
|
+
await removeStage(offlineDir, stagingRoot).catch(() => {
|
|
5594
|
+
});
|
|
5595
|
+
}
|
|
5596
|
+
};
|
|
5597
|
+
} catch (error) {
|
|
5598
|
+
await removeStage(offlineDir, stagingRoot).catch(() => {
|
|
5599
|
+
});
|
|
5600
|
+
throw error;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
|
|
5450
5604
|
// src/index.ts
|
|
5451
5605
|
import { briefingLocationSection, locationTaggingEnabled } from "@remnic/core/location";
|
|
5452
5606
|
|
|
@@ -5458,15 +5612,15 @@ import {
|
|
|
5458
5612
|
readFileSync as readFileSync3,
|
|
5459
5613
|
statSync
|
|
5460
5614
|
} from "fs";
|
|
5461
|
-
import
|
|
5615
|
+
import path9 from "path";
|
|
5462
5616
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5463
5617
|
var STALE_BUILD_TOLERANCE_MS = 1e3;
|
|
5464
5618
|
function assertLocalBenchBuildFreshForDevelopment(currentModuleUrl) {
|
|
5465
5619
|
if (isTruthyEnv(process.env.REMNIC_BENCH_ALLOW_STALE_DIST)) {
|
|
5466
5620
|
return;
|
|
5467
5621
|
}
|
|
5468
|
-
const currentDir =
|
|
5469
|
-
const benchPackageDir =
|
|
5622
|
+
const currentDir = path9.dirname(fileURLToPath2(currentModuleUrl));
|
|
5623
|
+
const benchPackageDir = path9.resolve(currentDir, "../../bench");
|
|
5470
5624
|
const freshness = checkBenchBuildFreshness(benchPackageDir);
|
|
5471
5625
|
if (!freshness.stale) {
|
|
5472
5626
|
return;
|
|
@@ -5483,7 +5637,7 @@ function assertLocalBenchBuildFreshForDevelopment(currentModuleUrl) {
|
|
|
5483
5637
|
);
|
|
5484
5638
|
}
|
|
5485
5639
|
function checkBenchBuildFreshness(benchPackageDir) {
|
|
5486
|
-
const packageJsonPath =
|
|
5640
|
+
const packageJsonPath = path9.join(benchPackageDir, "package.json");
|
|
5487
5641
|
if (!existsSync2(packageJsonPath)) {
|
|
5488
5642
|
return { stale: false };
|
|
5489
5643
|
}
|
|
@@ -5496,17 +5650,17 @@ function checkBenchBuildFreshness(benchPackageDir) {
|
|
|
5496
5650
|
if (packageName !== "@remnic/bench") {
|
|
5497
5651
|
return { stale: false };
|
|
5498
5652
|
}
|
|
5499
|
-
const srcDir =
|
|
5653
|
+
const srcDir = path9.join(benchPackageDir, "src");
|
|
5500
5654
|
if (!isDirectory(srcDir)) {
|
|
5501
5655
|
return { stale: false };
|
|
5502
5656
|
}
|
|
5503
5657
|
const sourceRoots = [
|
|
5504
5658
|
srcDir,
|
|
5505
5659
|
packageJsonPath,
|
|
5506
|
-
|
|
5507
|
-
|
|
5660
|
+
path9.join(benchPackageDir, "tsup.config.ts"),
|
|
5661
|
+
path9.join(benchPackageDir, "tsconfig.json")
|
|
5508
5662
|
];
|
|
5509
|
-
const distPath =
|
|
5663
|
+
const distPath = path9.join(benchPackageDir, "dist", "index.js");
|
|
5510
5664
|
if (!existsSync2(distPath)) {
|
|
5511
5665
|
return {
|
|
5512
5666
|
stale: true,
|
|
@@ -5549,7 +5703,7 @@ function newestMtime(roots) {
|
|
|
5549
5703
|
}
|
|
5550
5704
|
if (stat3.isDirectory()) {
|
|
5551
5705
|
for (const child of readdirSync(entryPath)) {
|
|
5552
|
-
visit(
|
|
5706
|
+
visit(path9.join(entryPath, child));
|
|
5553
5707
|
}
|
|
5554
5708
|
return;
|
|
5555
5709
|
}
|
|
@@ -5582,18 +5736,18 @@ function isTruthyEnv(value) {
|
|
|
5582
5736
|
|
|
5583
5737
|
// src/optional-bench.ts
|
|
5584
5738
|
import { existsSync as existsSync3 } from "fs";
|
|
5585
|
-
import
|
|
5739
|
+
import path10 from "path";
|
|
5586
5740
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
5587
5741
|
var SPECIFIER2 = "@remnic/bench";
|
|
5588
5742
|
var TSX_ESM_API_SPECIFIER = "tsx/esm/api";
|
|
5589
5743
|
var cached2;
|
|
5590
5744
|
var cachedFromLocalWorkspaceBenchSource = false;
|
|
5591
5745
|
function resolveLocalWorkspaceBenchPaths() {
|
|
5592
|
-
const currentDir =
|
|
5593
|
-
const benchPackageDir =
|
|
5746
|
+
const currentDir = path10.dirname(fileURLToPath3(import.meta.url));
|
|
5747
|
+
const benchPackageDir = path10.resolve(currentDir, "../../bench");
|
|
5594
5748
|
return {
|
|
5595
|
-
distEntry:
|
|
5596
|
-
sourceEntry:
|
|
5749
|
+
distEntry: path10.join(benchPackageDir, "dist", "index.js"),
|
|
5750
|
+
sourceEntry: path10.join(benchPackageDir, "src", "index.ts")
|
|
5597
5751
|
};
|
|
5598
5752
|
}
|
|
5599
5753
|
async function tryImportLocalWorkspaceBenchSource(err) {
|
|
@@ -5730,7 +5884,7 @@ async function cmdSecurity(rest) {
|
|
|
5730
5884
|
|
|
5731
5885
|
// src/daemon-service-candidates.ts
|
|
5732
5886
|
import fs25 from "fs";
|
|
5733
|
-
import
|
|
5887
|
+
import path11 from "path";
|
|
5734
5888
|
var LAUNCHD_LABEL = "ai.remnic.daemon";
|
|
5735
5889
|
var LEGACY_REMNIC_SERVER_LAUNCHD_LABEL = "ai.remnic.server";
|
|
5736
5890
|
var LEGACY_LAUNCHD_LABEL = "ai.engram.daemon";
|
|
@@ -5743,10 +5897,10 @@ var SYSTEMD_SERVICE = "remnic.service";
|
|
|
5743
5897
|
var LEGACY_SYSTEMD_SERVICE = "engram.service";
|
|
5744
5898
|
var SYSTEMD_SERVICE_CANDIDATES = [SYSTEMD_SERVICE, LEGACY_SYSTEMD_SERVICE];
|
|
5745
5899
|
function launchdPlistPaths(homeDir) {
|
|
5746
|
-
return LAUNCHD_LABEL_CANDIDATES.map((label) =>
|
|
5900
|
+
return LAUNCHD_LABEL_CANDIDATES.map((label) => path11.join(homeDir, "Library", "LaunchAgents", `${label}.plist`));
|
|
5747
5901
|
}
|
|
5748
5902
|
function systemdUnitPaths(homeDir) {
|
|
5749
|
-
return SYSTEMD_SERVICE_CANDIDATES.map((service) =>
|
|
5903
|
+
return SYSTEMD_SERVICE_CANDIDATES.map((service) => path11.join(homeDir, ".config", "systemd", "user", service));
|
|
5750
5904
|
}
|
|
5751
5905
|
function anyFileExists(paths) {
|
|
5752
5906
|
return paths.some((candidate) => {
|
|
@@ -5780,13 +5934,13 @@ function resolveShimNodeScript(filePath) {
|
|
|
5780
5934
|
} catch {
|
|
5781
5935
|
return void 0;
|
|
5782
5936
|
}
|
|
5783
|
-
const basedir =
|
|
5937
|
+
const basedir = path11.dirname(filePath);
|
|
5784
5938
|
const jsReferencePattern = /"([^"]+\.js)"|'([^']+\.js)'|([^\s"'`]+\.js)/g;
|
|
5785
5939
|
for (const match of text.matchAll(jsReferencePattern)) {
|
|
5786
5940
|
const raw = match[1] ?? match[2] ?? match[3];
|
|
5787
5941
|
if (!raw) continue;
|
|
5788
5942
|
const candidate = raw.replaceAll("${basedir}", basedir).replaceAll("$basedir", basedir).replaceAll("\\ ", " ");
|
|
5789
|
-
const resolved =
|
|
5943
|
+
const resolved = path11.isAbsolute(candidate) ? candidate : path11.resolve(basedir, candidate);
|
|
5790
5944
|
try {
|
|
5791
5945
|
if (fs25.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
|
|
5792
5946
|
return fs25.realpathSync(resolved);
|
|
@@ -5802,10 +5956,10 @@ function resolveRunnableNodeScript(filePath) {
|
|
|
5802
5956
|
return resolveShimNodeScript(realPath);
|
|
5803
5957
|
}
|
|
5804
5958
|
function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
|
|
5805
|
-
for (const dir of pathEnv.split(
|
|
5959
|
+
for (const dir of pathEnv.split(path11.delimiter)) {
|
|
5806
5960
|
if (!dir) continue;
|
|
5807
5961
|
for (const name of commandNames(command)) {
|
|
5808
|
-
const candidate =
|
|
5962
|
+
const candidate = path11.join(dir, name);
|
|
5809
5963
|
try {
|
|
5810
5964
|
const stat3 = fs25.statSync(candidate);
|
|
5811
5965
|
if (!stat3.isFile()) continue;
|
|
@@ -5819,11 +5973,11 @@ function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
|
|
|
5819
5973
|
return void 0;
|
|
5820
5974
|
}
|
|
5821
5975
|
function serverBinWrapperRequiredPath(candidate) {
|
|
5822
|
-
const filename =
|
|
5976
|
+
const filename = path11.basename(candidate);
|
|
5823
5977
|
if (filename !== "remnic-server.js" && filename !== "engram-server.js") return void 0;
|
|
5824
|
-
const binDir =
|
|
5825
|
-
if (
|
|
5826
|
-
return
|
|
5978
|
+
const binDir = path11.dirname(candidate);
|
|
5979
|
+
if (path11.basename(binDir) !== "bin") return void 0;
|
|
5980
|
+
return path11.join(path11.dirname(binDir), "dist", "index.js");
|
|
5827
5981
|
}
|
|
5828
5982
|
|
|
5829
5983
|
// src/service-candidates.ts
|
|
@@ -5845,7 +5999,7 @@ function firstSuccessfulCandidate(candidates, attempt) {
|
|
|
5845
5999
|
}
|
|
5846
6000
|
|
|
5847
6001
|
// src/bench-args.ts
|
|
5848
|
-
import
|
|
6002
|
+
import path13 from "path";
|
|
5849
6003
|
|
|
5850
6004
|
// src/bench-flags.ts
|
|
5851
6005
|
function readBenchOptionValue(argv, flag) {
|
|
@@ -6210,7 +6364,7 @@ function collectBenchmarks(argv) {
|
|
|
6210
6364
|
}
|
|
6211
6365
|
|
|
6212
6366
|
// src/bench-args-research.ts
|
|
6213
|
-
import
|
|
6367
|
+
import path12 from "path";
|
|
6214
6368
|
function readPositiveInteger(args, flag) {
|
|
6215
6369
|
const raw = readBenchOptionValue(args, flag);
|
|
6216
6370
|
if (raw === void 0) return void 0;
|
|
@@ -6256,7 +6410,7 @@ function parseBenchResearchArgs(action, args) {
|
|
|
6256
6410
|
}
|
|
6257
6411
|
const outRaw = readBenchOptionValue(args, "--out");
|
|
6258
6412
|
if (outRaw !== void 0) {
|
|
6259
|
-
out =
|
|
6413
|
+
out = path12.resolve(expandTilde(outRaw));
|
|
6260
6414
|
}
|
|
6261
6415
|
}
|
|
6262
6416
|
const epochs = readPositiveInteger(args, "--epochs");
|
|
@@ -6270,8 +6424,8 @@ function parseBenchResearchArgs(action, args) {
|
|
|
6270
6424
|
}
|
|
6271
6425
|
return {
|
|
6272
6426
|
runRef,
|
|
6273
|
-
memoryDir: memoryDirRaw ?
|
|
6274
|
-
qmdPath: qmdPathRaw ?
|
|
6427
|
+
memoryDir: memoryDirRaw ? path12.resolve(expandTilde(memoryDirRaw)) : void 0,
|
|
6428
|
+
qmdPath: qmdPathRaw ? path12.resolve(expandTilde(qmdPathRaw)) : void 0,
|
|
6275
6429
|
collection,
|
|
6276
6430
|
users: readPositiveInteger(args, "--users"),
|
|
6277
6431
|
epochs,
|
|
@@ -6491,7 +6645,7 @@ function parseBenchArgs(argv) {
|
|
|
6491
6645
|
}
|
|
6492
6646
|
validateBenchFlags(action, args);
|
|
6493
6647
|
const driftGenPositionals = action === "drift-gen" && driftGenAction === "validate" ? collectBenchmarks(args.slice(1)) : [];
|
|
6494
|
-
const driftGenDir = driftGenPositionals[0] ?
|
|
6648
|
+
const driftGenDir = driftGenPositionals[0] ? path13.resolve(expandTilde(driftGenPositionals[0])) : void 0;
|
|
6495
6649
|
const benchmarkArgs = action === "baseline" || action === "datasets" || action === "providers" || action === "runs" || action === "drift-gen" && (args[0] === "validate" || args[0] === "generate") ? args.slice(1) : args;
|
|
6496
6650
|
const benchmarks = collectBenchmarks(benchmarkArgs);
|
|
6497
6651
|
const datasetDir = readBenchOptionValue(args, "--dataset-dir") ?? readBenchOptionValue(args, "--dataset");
|
|
@@ -7041,13 +7195,13 @@ function parseBenchArgs(argv) {
|
|
|
7041
7195
|
mcpUrl,
|
|
7042
7196
|
mcpToolMap,
|
|
7043
7197
|
mcpDemo,
|
|
7044
|
-
datasetDir: datasetDir ?
|
|
7045
|
-
resultsDir: resultsDir ?
|
|
7046
|
-
baselinesDir: baselinesDir ?
|
|
7198
|
+
datasetDir: datasetDir ? path13.resolve(expandTilde(datasetDir)) : void 0,
|
|
7199
|
+
resultsDir: resultsDir ? path13.resolve(expandTilde(resultsDir)) : void 0,
|
|
7200
|
+
baselinesDir: baselinesDir ? path13.resolve(expandTilde(baselinesDir)) : void 0,
|
|
7047
7201
|
runtimeProfile,
|
|
7048
7202
|
matrixProfiles,
|
|
7049
|
-
remnicConfigPath: remnicConfigRaw ?
|
|
7050
|
-
openclawConfigPath: openclawConfigRaw ?
|
|
7203
|
+
remnicConfigPath: remnicConfigRaw ? path13.resolve(expandTilde(remnicConfigRaw)) : void 0,
|
|
7204
|
+
openclawConfigPath: openclawConfigRaw ? path13.resolve(expandTilde(openclawConfigRaw)) : void 0,
|
|
7051
7205
|
modelSource,
|
|
7052
7206
|
gatewayAgentId,
|
|
7053
7207
|
fastGatewayAgentId,
|
|
@@ -7070,13 +7224,13 @@ function parseBenchArgs(argv) {
|
|
|
7070
7224
|
internalDisableThinking: args.includes("--internal-disable-thinking"),
|
|
7071
7225
|
internalCodexReasoningEffort,
|
|
7072
7226
|
threshold,
|
|
7073
|
-
custom: customRaw ?
|
|
7227
|
+
custom: customRaw ? path13.resolve(expandTilde(customRaw)) : void 0,
|
|
7074
7228
|
baselineAction,
|
|
7075
7229
|
datasetAction,
|
|
7076
7230
|
providerAction,
|
|
7077
7231
|
runAction,
|
|
7078
7232
|
format,
|
|
7079
|
-
output: output ?
|
|
7233
|
+
output: output ? path13.resolve(expandTilde(output)) : void 0,
|
|
7080
7234
|
target,
|
|
7081
7235
|
publishedName,
|
|
7082
7236
|
publishedSeed,
|
|
@@ -7086,24 +7240,24 @@ function parseBenchArgs(argv) {
|
|
|
7086
7240
|
publishedIngestConcurrency,
|
|
7087
7241
|
publishedTaskFilter,
|
|
7088
7242
|
memcorrectAdapter,
|
|
7089
|
-
publishedOut: publishedOutRaw ?
|
|
7243
|
+
publishedOut: publishedOutRaw ? path13.resolve(expandTilde(publishedOutRaw)) : void 0,
|
|
7090
7244
|
publishedDryRun: args.includes("--dry-run"),
|
|
7091
7245
|
requestTimeout,
|
|
7092
7246
|
localJudgeRequestTimeout,
|
|
7093
7247
|
frontierJudgeRequestTimeout,
|
|
7094
|
-
calibrationDir: calibrationDirRaw ?
|
|
7248
|
+
calibrationDir: calibrationDirRaw ? path13.resolve(expandTilde(calibrationDirRaw)) : void 0,
|
|
7095
7249
|
calibrationLocalConfigSha256,
|
|
7096
7250
|
calibrationFrontierConfigSha256,
|
|
7097
7251
|
sourceResultId,
|
|
7098
7252
|
expectedAnswerSetSha256,
|
|
7099
7253
|
expectedQuestionIdListSha256,
|
|
7100
|
-
taskIdsFile: taskIdsFileRaw ?
|
|
7254
|
+
taskIdsFile: taskIdsFileRaw ? path13.resolve(expandTilde(taskIdsFileRaw)) : void 0,
|
|
7101
7255
|
expectedTaskIdListSha256,
|
|
7102
7256
|
drainTimeout,
|
|
7103
7257
|
// Issue #1573 PR1: surface judge-cache flags into the runner options.
|
|
7104
7258
|
noJudgeCache: args.includes("--no-judge-cache"),
|
|
7105
|
-
judgeCacheDir: judgeCacheDirRaw ?
|
|
7106
|
-
localLabManifestPath: localLabManifestRaw ?
|
|
7259
|
+
judgeCacheDir: judgeCacheDirRaw ? path13.resolve(expandTilde(judgeCacheDirRaw)) : void 0,
|
|
7260
|
+
localLabManifestPath: localLabManifestRaw ? path13.resolve(expandTilde(localLabManifestRaw)) : void 0,
|
|
7107
7261
|
max429WaitMs,
|
|
7108
7262
|
disableThinking: args.includes("--disable-thinking"),
|
|
7109
7263
|
amaBenchJudgeProtocol,
|
|
@@ -7140,23 +7294,23 @@ function assertCalibrationProvenanceMatches(binding, state, benchmarkId) {
|
|
|
7140
7294
|
}
|
|
7141
7295
|
|
|
7142
7296
|
// src/bench-status.ts
|
|
7143
|
-
import { mkdir as
|
|
7144
|
-
import
|
|
7297
|
+
import { mkdir as mkdir3, readFile as readFile3, readdir as readdir4, rename as rename2, writeFile as writeFile3 } from "fs/promises";
|
|
7298
|
+
import path14 from "path";
|
|
7145
7299
|
function createBenchStatusPath(resultsDir, pid, startedAtMs = Date.now()) {
|
|
7146
|
-
return
|
|
7300
|
+
return path14.join(resultsDir, `bench-status-${startedAtMs}-${pid}.json`);
|
|
7147
7301
|
}
|
|
7148
7302
|
var BENCH_STATUS_FILENAME = /^bench-status-\d+-\d+\.json$/;
|
|
7149
7303
|
var VALID_BENCH_ENTRY_STATUSES = /* @__PURE__ */ new Set(["pending", "running", "complete", "failed"]);
|
|
7150
7304
|
async function findLatestBenchStatusFile(resultsDir) {
|
|
7151
7305
|
let entries;
|
|
7152
7306
|
try {
|
|
7153
|
-
entries = await
|
|
7307
|
+
entries = await readdir4(resultsDir);
|
|
7154
7308
|
} catch {
|
|
7155
7309
|
return null;
|
|
7156
7310
|
}
|
|
7157
7311
|
const candidates = entries.filter((name) => BENCH_STATUS_FILENAME.test(name)).sort().reverse();
|
|
7158
7312
|
for (const name of candidates) {
|
|
7159
|
-
const filePath =
|
|
7313
|
+
const filePath = path14.join(resultsDir, name);
|
|
7160
7314
|
const status = await readBenchStatus(filePath);
|
|
7161
7315
|
if (status) {
|
|
7162
7316
|
return filePath;
|
|
@@ -7165,14 +7319,14 @@ async function findLatestBenchStatusFile(resultsDir) {
|
|
|
7165
7319
|
return null;
|
|
7166
7320
|
}
|
|
7167
7321
|
async function atomicWriteJSON(filePath, data) {
|
|
7168
|
-
await
|
|
7322
|
+
await mkdir3(path14.dirname(filePath), { recursive: true });
|
|
7169
7323
|
const tmp = `${filePath}.${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`;
|
|
7170
|
-
await
|
|
7324
|
+
await writeFile3(tmp, JSON.stringify(data, null, 2) + "\n");
|
|
7171
7325
|
await rename2(tmp, filePath);
|
|
7172
7326
|
}
|
|
7173
7327
|
async function readBenchStatus(filePath) {
|
|
7174
7328
|
try {
|
|
7175
|
-
const raw = await
|
|
7329
|
+
const raw = await readFile3(filePath, "utf-8");
|
|
7176
7330
|
const parsed = JSON.parse(raw);
|
|
7177
7331
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
7178
7332
|
const obj = parsed;
|
|
@@ -7283,13 +7437,13 @@ function finalizeBenchStatus(filePath) {
|
|
|
7283
7437
|
|
|
7284
7438
|
// src/openclaw-upgrade-swap.ts
|
|
7285
7439
|
import fs26 from "fs";
|
|
7286
|
-
import
|
|
7440
|
+
import path15 from "path";
|
|
7287
7441
|
function describeError(error) {
|
|
7288
7442
|
return error instanceof Error ? error.message : String(error);
|
|
7289
7443
|
}
|
|
7290
7444
|
function createSiblingTempFilePath(targetPath, label) {
|
|
7291
7445
|
const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
7292
|
-
return
|
|
7446
|
+
return path15.join(path15.dirname(targetPath), `.${path15.basename(targetPath)}.${label}.${nonce}.tmp`);
|
|
7293
7447
|
}
|
|
7294
7448
|
function resolveAtomicWriteMode(targetPath, explicitMode) {
|
|
7295
7449
|
if (explicitMode !== void 0) return explicitMode;
|
|
@@ -7317,7 +7471,7 @@ function resolveAtomicReplacementPath(targetPath) {
|
|
|
7317
7471
|
}
|
|
7318
7472
|
function createSiblingSwapPath(targetDir, label) {
|
|
7319
7473
|
const nonce = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
|
7320
|
-
return
|
|
7474
|
+
return path15.join(path15.dirname(targetDir), `.${path15.basename(targetDir)}.${label}.${nonce}`);
|
|
7321
7475
|
}
|
|
7322
7476
|
function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
7323
7477
|
if (!displacedDir) return void 0;
|
|
@@ -7330,7 +7484,7 @@ function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
|
7330
7484
|
}
|
|
7331
7485
|
function atomicWriteFileSync(targetPath, data, options = {}) {
|
|
7332
7486
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
7333
|
-
fs26.mkdirSync(
|
|
7487
|
+
fs26.mkdirSync(path15.dirname(resolvedTargetPath), { recursive: true });
|
|
7334
7488
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "write");
|
|
7335
7489
|
const mode = resolveAtomicWriteMode(resolvedTargetPath, options.mode);
|
|
7336
7490
|
try {
|
|
@@ -7350,7 +7504,7 @@ function atomicWriteFileSync(targetPath, data, options = {}) {
|
|
|
7350
7504
|
function atomicCopyFileSync(sourcePath, targetPath, options = {}) {
|
|
7351
7505
|
if (!fs26.existsSync(sourcePath)) return;
|
|
7352
7506
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
7353
|
-
fs26.mkdirSync(
|
|
7507
|
+
fs26.mkdirSync(path15.dirname(resolvedTargetPath), { recursive: true });
|
|
7354
7508
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "copy");
|
|
7355
7509
|
const mode = fs26.statSync(sourcePath).mode & 4095;
|
|
7356
7510
|
try {
|
|
@@ -7381,7 +7535,7 @@ function restoreDirectoryFromRollback(targetDir, rollbackDir) {
|
|
|
7381
7535
|
if (!fs26.existsSync(rollbackDir)) {
|
|
7382
7536
|
throw new Error(`Rollback directory is missing: ${rollbackDir}`);
|
|
7383
7537
|
}
|
|
7384
|
-
fs26.mkdirSync(
|
|
7538
|
+
fs26.mkdirSync(path15.dirname(targetDir), { recursive: true });
|
|
7385
7539
|
const displacedDir = fs26.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
|
|
7386
7540
|
if (displacedDir) {
|
|
7387
7541
|
fs26.renameSync(targetDir, displacedDir);
|
|
@@ -7410,7 +7564,7 @@ function restoreDirectoryFromBackup(targetDir, backupDir) {
|
|
|
7410
7564
|
if (!fs26.existsSync(backupDir)) {
|
|
7411
7565
|
throw new Error(`Plugin backup directory is missing: ${backupDir}`);
|
|
7412
7566
|
}
|
|
7413
|
-
fs26.mkdirSync(
|
|
7567
|
+
fs26.mkdirSync(path15.dirname(targetDir), { recursive: true });
|
|
7414
7568
|
const stagedDir = createSiblingSwapPath(targetDir, "backup-restore");
|
|
7415
7569
|
const displacedDir = fs26.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
|
|
7416
7570
|
fs26.cpSync(backupDir, stagedDir, { recursive: true });
|
|
@@ -7551,7 +7705,7 @@ Run this manually when you're ready:
|
|
|
7551
7705
|
import { execFileSync } from "child_process";
|
|
7552
7706
|
import fs27 from "fs";
|
|
7553
7707
|
import os from "os";
|
|
7554
|
-
import
|
|
7708
|
+
import path16 from "path";
|
|
7555
7709
|
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL2 } from "url";
|
|
7556
7710
|
var MANAGED_UPGRADE_SPECIFIER = "@remnic/plugin-openclaw/managed-upgrade";
|
|
7557
7711
|
var OPENCLAW_PLUGIN_PACKAGE = "@remnic/plugin-openclaw";
|
|
@@ -7623,8 +7777,8 @@ function buildOpenclawManagedUpgradePackageSpec(version = "latest") {
|
|
|
7623
7777
|
return `${OPENCLAW_PLUGIN_PACKAGE}@${version}`;
|
|
7624
7778
|
}
|
|
7625
7779
|
function readCliAdapterRange() {
|
|
7626
|
-
const moduleDir =
|
|
7627
|
-
const manifestPath =
|
|
7780
|
+
const moduleDir = path16.dirname(fileURLToPath4(import.meta.url));
|
|
7781
|
+
const manifestPath = path16.resolve(moduleDir, "../package.json");
|
|
7628
7782
|
const manifest = JSON.parse(fs27.readFileSync(manifestPath, "utf8"));
|
|
7629
7783
|
if (manifest.name !== "@remnic/cli") {
|
|
7630
7784
|
throw new Error(`Invalid @remnic/cli package manifest at ${manifestPath}.`);
|
|
@@ -7669,7 +7823,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
7669
7823
|
const adapterMissing = isSpecifierNotFoundError(error, OPENCLAW_PLUGIN_PACKAGE) || isSpecifierNotFoundError(error, MANAGED_UPGRADE_SPECIFIER) || isManagedUpgradeSubpathMissing(error);
|
|
7670
7824
|
if (!adapterMissing) throw error;
|
|
7671
7825
|
}
|
|
7672
|
-
const temporaryRoot = fs27.mkdtempSync(
|
|
7826
|
+
const temporaryRoot = fs27.mkdtempSync(path16.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
|
|
7673
7827
|
try {
|
|
7674
7828
|
const toolingPackageSpec = `${OPENCLAW_PLUGIN_PACKAGE}@${readCliAdapterRange()}`;
|
|
7675
7829
|
const installArgs = [
|
|
@@ -7683,7 +7837,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
7683
7837
|
toolingPackageSpec
|
|
7684
7838
|
];
|
|
7685
7839
|
(hooks.runNpmInstall ?? runNpmInstall)(installArgs);
|
|
7686
|
-
const resolverPath =
|
|
7840
|
+
const resolverPath = path16.join(temporaryRoot, "load-managed-upgrade.mjs");
|
|
7687
7841
|
fs27.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
|
|
7688
7842
|
`, "utf8");
|
|
7689
7843
|
return await importModule(pathToFileURL2(resolverPath).href);
|
|
@@ -7699,9 +7853,9 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
7699
7853
|
|
|
7700
7854
|
// src/report.ts
|
|
7701
7855
|
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync2, writeFileSync } from "fs";
|
|
7702
|
-
import { readFile as
|
|
7856
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
7703
7857
|
import os2 from "os";
|
|
7704
|
-
import
|
|
7858
|
+
import path17 from "path";
|
|
7705
7859
|
var REPORT_ALLOWED_CONFIG_FIELDS = Object.freeze([
|
|
7706
7860
|
"qmdEnabled",
|
|
7707
7861
|
"qmdAutoEmbedEnabled",
|
|
@@ -7752,7 +7906,7 @@ function countMemories(dir) {
|
|
|
7752
7906
|
let count = 0;
|
|
7753
7907
|
const walk = (d) => {
|
|
7754
7908
|
for (const entry of readdirSync2(d)) {
|
|
7755
|
-
const full =
|
|
7909
|
+
const full = path17.join(d, entry);
|
|
7756
7910
|
const st = statSync2(full);
|
|
7757
7911
|
if (st.isDirectory()) walk(full);
|
|
7758
7912
|
else if (entry.endsWith(".md")) count++;
|
|
@@ -7766,9 +7920,9 @@ function countMemories(dir) {
|
|
|
7766
7920
|
}
|
|
7767
7921
|
function findConfigPath() {
|
|
7768
7922
|
const candidates = [
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7923
|
+
path17.join(os2.homedir(), ".config", "remnic", "config.json"),
|
|
7924
|
+
path17.join(os2.homedir(), ".config", "openclaw", "openclaw.json"),
|
|
7925
|
+
path17.join(os2.homedir(), ".openclaw", "config.json")
|
|
7772
7926
|
];
|
|
7773
7927
|
for (const p of candidates) {
|
|
7774
7928
|
if (existsSync4(p)) return p;
|
|
@@ -7784,7 +7938,7 @@ function findMemoryDir(configPath) {
|
|
|
7784
7938
|
} catch {
|
|
7785
7939
|
}
|
|
7786
7940
|
}
|
|
7787
|
-
return
|
|
7941
|
+
return path17.join(os2.homedir(), ".remnic", "memory");
|
|
7788
7942
|
}
|
|
7789
7943
|
function extractConfigShape(rawConfig) {
|
|
7790
7944
|
const result = {};
|
|
@@ -7813,7 +7967,7 @@ function runDoctorChecks() {
|
|
|
7813
7967
|
} catch {
|
|
7814
7968
|
checks.push({ name: "Memory directory", ok: false });
|
|
7815
7969
|
}
|
|
7816
|
-
const openclawPath =
|
|
7970
|
+
const openclawPath = path17.join(os2.homedir(), ".config", "openclaw", "openclaw.json");
|
|
7817
7971
|
checks.push({ name: "OpenClaw config file", ok: existsSync4(openclawPath) });
|
|
7818
7972
|
return checks;
|
|
7819
7973
|
}
|
|
@@ -7895,9 +8049,9 @@ function summarizeBenchScorecard(raw) {
|
|
|
7895
8049
|
function readOwn(source, key) {
|
|
7896
8050
|
return Object.hasOwn(source, key) ? source[key] : void 0;
|
|
7897
8051
|
}
|
|
7898
|
-
function readNested(source, ...
|
|
8052
|
+
function readNested(source, ...path25) {
|
|
7899
8053
|
let current = source;
|
|
7900
|
-
for (const key of
|
|
8054
|
+
for (const key of path25) {
|
|
7901
8055
|
if (typeof current !== "object" || current === null) return void 0;
|
|
7902
8056
|
if (!Object.hasOwn(current, key)) return void 0;
|
|
7903
8057
|
current = current[key];
|
|
@@ -7960,9 +8114,9 @@ async function buildReport(options = {}) {
|
|
|
7960
8114
|
const sizeBucketLabel = sizeBucket(storeBytes);
|
|
7961
8115
|
let benchScorecard;
|
|
7962
8116
|
if (options.includeBench) {
|
|
7963
|
-
const scorecardPath =
|
|
8117
|
+
const scorecardPath = path17.join(os2.homedir(), ".remnic", "reports", "bench-scorecard.json");
|
|
7964
8118
|
try {
|
|
7965
|
-
const raw = JSON.parse(await
|
|
8119
|
+
const raw = JSON.parse(await readFile4(scorecardPath, "utf-8"));
|
|
7966
8120
|
benchScorecard = summarizeBenchScorecard(raw);
|
|
7967
8121
|
} catch {
|
|
7968
8122
|
}
|
|
@@ -8022,12 +8176,12 @@ function renderReportJson(report) {
|
|
|
8022
8176
|
return JSON.stringify(report, null, 2);
|
|
8023
8177
|
}
|
|
8024
8178
|
async function cmdReport(options = {}) {
|
|
8025
|
-
const reportDir =
|
|
8179
|
+
const reportDir = path17.join(os2.homedir(), ".remnic", "reports");
|
|
8026
8180
|
mkdirSync(reportDir, { recursive: true });
|
|
8027
8181
|
const report = await buildReport({ includeBench: options.includeBench });
|
|
8028
8182
|
const dateStr = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
|
|
8029
|
-
const mdPath =
|
|
8030
|
-
const jsonPath =
|
|
8183
|
+
const mdPath = path17.join(reportDir, `report-${dateStr}.md`);
|
|
8184
|
+
const jsonPath = path17.join(reportDir, `report-${dateStr}.json`);
|
|
8031
8185
|
const md = renderReportMarkdown(report);
|
|
8032
8186
|
const json = renderReportJson(report);
|
|
8033
8187
|
writeFileSync(mdPath, md, "utf-8");
|
|
@@ -8149,13 +8303,13 @@ function resolveRemoteDaemon(configPath) {
|
|
|
8149
8303
|
function resolveHostedOnlyDaemonRefusal(configPath) {
|
|
8150
8304
|
const remoteUrl = resolveRemoteDaemonUrl(configPath);
|
|
8151
8305
|
if (!remoteUrl) return void 0;
|
|
8152
|
-
let
|
|
8306
|
+
let hostname2;
|
|
8153
8307
|
try {
|
|
8154
|
-
|
|
8308
|
+
hostname2 = new URL(remoteUrl).hostname;
|
|
8155
8309
|
} catch {
|
|
8156
8310
|
return void 0;
|
|
8157
8311
|
}
|
|
8158
|
-
if (isLoopbackHost(
|
|
8312
|
+
if (isLoopbackHost(hostname2)) return void 0;
|
|
8159
8313
|
return { remoteUrl };
|
|
8160
8314
|
}
|
|
8161
8315
|
function hostedOnlyDaemonRefusalMessage(remoteUrl, action) {
|
|
@@ -8346,10 +8500,10 @@ async function remoteRecallWhy(daemon, request) {
|
|
|
8346
8500
|
|
|
8347
8501
|
// src/daemon-service.ts
|
|
8348
8502
|
import fs29 from "fs";
|
|
8349
|
-
import
|
|
8503
|
+
import path18 from "path";
|
|
8350
8504
|
import * as childProcess from "child_process";
|
|
8351
8505
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
8352
|
-
var thisModuleDir =
|
|
8506
|
+
var thisModuleDir = path18.dirname(fileURLToPath5(import.meta.url));
|
|
8353
8507
|
function launchdLoadPlist(plistPath, processApi = childProcess) {
|
|
8354
8508
|
processApi.execFileSync("launchctl", ["load", "-w", plistPath], { stdio: "pipe" });
|
|
8355
8509
|
}
|
|
@@ -8371,8 +8525,8 @@ function resolveServerBinDetails(options = {}) {
|
|
|
8371
8525
|
});
|
|
8372
8526
|
} catch {
|
|
8373
8527
|
}
|
|
8374
|
-
const workspaceServerBin =
|
|
8375
|
-
const workspaceDistIndex =
|
|
8528
|
+
const workspaceServerBin = path18.resolve(moduleDir, "../../remnic-server/bin/remnic-server.js");
|
|
8529
|
+
const workspaceDistIndex = path18.resolve(moduleDir, "../../remnic-server/dist/index.js");
|
|
8376
8530
|
candidates.push(
|
|
8377
8531
|
{
|
|
8378
8532
|
path: workspaceServerBin,
|
|
@@ -8393,11 +8547,11 @@ function resolveServerBinDetails(options = {}) {
|
|
|
8393
8547
|
});
|
|
8394
8548
|
}
|
|
8395
8549
|
candidates.push({
|
|
8396
|
-
path:
|
|
8550
|
+
path: path18.resolve(moduleDir, "../../remnic-server/src/index.ts"),
|
|
8397
8551
|
source: "workspace-source"
|
|
8398
8552
|
});
|
|
8399
8553
|
const selected = candidates.find((candidate) => isCandidateReady(candidate, existsSync5)) ?? candidates.find((candidate) => existsSync5(candidate.path)) ?? candidates[0] ?? {
|
|
8400
|
-
path:
|
|
8554
|
+
path: path18.resolve(moduleDir, "../../remnic-server/dist/index.js"),
|
|
8401
8555
|
source: "workspace-dist"
|
|
8402
8556
|
};
|
|
8403
8557
|
const exists = existsSync5(selected.path);
|
|
@@ -8452,7 +8606,7 @@ function readVerifiedDaemonPid(options) {
|
|
|
8452
8606
|
}
|
|
8453
8607
|
function doesProcessCommandLookLikeRemnicDaemon(command, expectedServerBin) {
|
|
8454
8608
|
const normalizedCommand = command.trim();
|
|
8455
|
-
const normalizedExpected =
|
|
8609
|
+
const normalizedExpected = path18.resolve(expandTilde(expectedServerBin));
|
|
8456
8610
|
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);
|
|
8457
8611
|
}
|
|
8458
8612
|
function parseDaemonPid(raw) {
|
|
@@ -8557,7 +8711,7 @@ function inspectLaunchdPlist(plistPath, options = {}) {
|
|
|
8557
8711
|
};
|
|
8558
8712
|
}
|
|
8559
8713
|
const expandedServerArg = expandTilde(serverArg);
|
|
8560
|
-
if (!
|
|
8714
|
+
if (!path18.isAbsolute(expandedServerArg)) {
|
|
8561
8715
|
return {
|
|
8562
8716
|
installed: true,
|
|
8563
8717
|
ok: false,
|
|
@@ -8629,8 +8783,8 @@ function normalizeResolvedPath(resolved) {
|
|
|
8629
8783
|
return resolved;
|
|
8630
8784
|
}
|
|
8631
8785
|
function packageServerBinFromEntry(packageEntry) {
|
|
8632
|
-
if (
|
|
8633
|
-
return
|
|
8786
|
+
if (path18.basename(packageEntry) === "index.js" && path18.basename(path18.dirname(packageEntry)) === "dist") {
|
|
8787
|
+
return path18.join(path18.dirname(path18.dirname(packageEntry)), "bin", "remnic-server.js");
|
|
8634
8788
|
}
|
|
8635
8789
|
return packageEntry;
|
|
8636
8790
|
}
|
|
@@ -8705,9 +8859,9 @@ import {
|
|
|
8705
8859
|
|
|
8706
8860
|
// src/import-bundle-detect.ts
|
|
8707
8861
|
import { lstatSync as lstatSync3, readdirSync as readdirSync3, readFileSync as readFileSync5 } from "fs";
|
|
8708
|
-
import
|
|
8862
|
+
import path19 from "path";
|
|
8709
8863
|
function detectBundleEntries(bundleDir, options = {}) {
|
|
8710
|
-
const
|
|
8864
|
+
const readdir5 = options.readdirImpl ?? defaultReaddir;
|
|
8711
8865
|
const readFileImpl = options.readFileImpl ?? defaultReadFile;
|
|
8712
8866
|
const isDirectory2 = options.isDirectoryImpl ?? defaultIsDirectory;
|
|
8713
8867
|
const isRegularFile = options.isRegularFileImpl ?? (options.readdirImpl !== void 0 || options.isDirectoryImpl !== void 0 ? (p) => !isDirectory2(p) : defaultIsRegularFile);
|
|
@@ -8727,7 +8881,7 @@ function detectBundleEntries(bundleDir, options = {}) {
|
|
|
8727
8881
|
}
|
|
8728
8882
|
const roots = collectCandidatePaths(
|
|
8729
8883
|
bundleDir,
|
|
8730
|
-
|
|
8884
|
+
readdir5,
|
|
8731
8885
|
isDirectory2,
|
|
8732
8886
|
isRegularFile
|
|
8733
8887
|
);
|
|
@@ -8736,7 +8890,7 @@ function detectBundleEntries(bundleDir, options = {}) {
|
|
|
8736
8890
|
for (const filePath of roots) {
|
|
8737
8891
|
if (seenFiles.has(filePath)) continue;
|
|
8738
8892
|
seenFiles.add(filePath);
|
|
8739
|
-
const name =
|
|
8893
|
+
const name = path19.basename(filePath);
|
|
8740
8894
|
const match = classifyFile(name, filePath, readFileImpl);
|
|
8741
8895
|
if (match) entries.push(match);
|
|
8742
8896
|
}
|
|
@@ -8756,9 +8910,9 @@ function detectBundleEntries(bundleDir, options = {}) {
|
|
|
8756
8910
|
return entries;
|
|
8757
8911
|
}
|
|
8758
8912
|
var MAX_WALK_DEPTH = 4;
|
|
8759
|
-
function collectCandidatePaths(root,
|
|
8913
|
+
function collectCandidatePaths(root, readdir5, isDirectory2, isRegularFile) {
|
|
8760
8914
|
try {
|
|
8761
|
-
|
|
8915
|
+
readdir5(root);
|
|
8762
8916
|
} catch {
|
|
8763
8917
|
throw new Error(
|
|
8764
8918
|
`Bundle directory '${root}' could not be read. Pass an existing directory.`
|
|
@@ -8769,12 +8923,12 @@ function collectCandidatePaths(root, readdir4, isDirectory2, isRegularFile) {
|
|
|
8769
8923
|
if (depth > MAX_WALK_DEPTH) return;
|
|
8770
8924
|
let entries;
|
|
8771
8925
|
try {
|
|
8772
|
-
entries =
|
|
8926
|
+
entries = readdir5(dir);
|
|
8773
8927
|
} catch {
|
|
8774
8928
|
return;
|
|
8775
8929
|
}
|
|
8776
8930
|
for (const entry of entries) {
|
|
8777
|
-
const full =
|
|
8931
|
+
const full = path19.join(dir, entry);
|
|
8778
8932
|
if (isDirectory2(full)) {
|
|
8779
8933
|
walk(full, depth + 1);
|
|
8780
8934
|
} else if (isRegularFile(full)) {
|
|
@@ -9330,7 +9484,7 @@ async function cmdCapture(rest, io) {
|
|
|
9330
9484
|
|
|
9331
9485
|
// src/import-lossless-claw-cmd.ts
|
|
9332
9486
|
import fs31 from "fs";
|
|
9333
|
-
import
|
|
9487
|
+
import path20 from "path";
|
|
9334
9488
|
import {
|
|
9335
9489
|
applyLcmSchema,
|
|
9336
9490
|
ensureLcmStateDir,
|
|
@@ -9480,7 +9634,7 @@ async function cmdImportLosslessClaw(argv, io, deps = {}) {
|
|
|
9480
9634
|
let destDb;
|
|
9481
9635
|
try {
|
|
9482
9636
|
if (parsed.dryRun) {
|
|
9483
|
-
const lcmPath =
|
|
9637
|
+
const lcmPath = path20.join(memoryDir, "state", "lcm.sqlite");
|
|
9484
9638
|
if (fs31.existsSync(lcmPath)) {
|
|
9485
9639
|
destDb = mod.openExistingLcmDatabaseReadOnly(lcmPath);
|
|
9486
9640
|
} else {
|
|
@@ -9600,9 +9754,9 @@ function printBenchComparisonSummary(comparison, baseline, candidate) {
|
|
|
9600
9754
|
}
|
|
9601
9755
|
|
|
9602
9756
|
// src/bench-coding-commands.ts
|
|
9603
|
-
import { lstat as
|
|
9757
|
+
import { lstat as lstat4, readFile as readFile5, realpath as realpath2, stat as stat2 } from "fs/promises";
|
|
9604
9758
|
import os3 from "os";
|
|
9605
|
-
import
|
|
9759
|
+
import path21 from "path";
|
|
9606
9760
|
var UINT32_MAX = 4294967295;
|
|
9607
9761
|
var FROZEN_GENERATOR_SEED = 81;
|
|
9608
9762
|
var FROZEN_TASK_COUNT = 30;
|
|
@@ -9612,7 +9766,7 @@ var FROZEN_MAX_STEPS = 12;
|
|
|
9612
9766
|
var FROZEN_MAX_TOOL_CALLS = 8;
|
|
9613
9767
|
var FROZEN_MAX_OUTPUT_CHARS = 16384;
|
|
9614
9768
|
var MAX_OUTPUT_BYTES = 16384;
|
|
9615
|
-
var DEFAULT_REPEATED_FAILURE_OUTPUT_DIR =
|
|
9769
|
+
var DEFAULT_REPEATED_FAILURE_OUTPUT_DIR = path21.join(
|
|
9616
9770
|
resolveHomeDir(),
|
|
9617
9771
|
".remnic",
|
|
9618
9772
|
"bench",
|
|
@@ -9946,7 +10100,7 @@ function parseBenchCodingArgs(args) {
|
|
|
9946
10100
|
throw new Error(`unknown bench coding subcommand ${args[0]}`);
|
|
9947
10101
|
}
|
|
9948
10102
|
function normalizeCommandPaths(command) {
|
|
9949
|
-
const resolve3 = (value) =>
|
|
10103
|
+
const resolve3 = (value) => path21.resolve(expandTilde(value));
|
|
9950
10104
|
if (command.kind === "repo-generate") {
|
|
9951
10105
|
return { ...command, outputDir: resolve3(command.outputDir) };
|
|
9952
10106
|
}
|
|
@@ -9977,27 +10131,27 @@ function normalizeCommandPaths(command) {
|
|
|
9977
10131
|
return command;
|
|
9978
10132
|
}
|
|
9979
10133
|
async function canonicalProspectivePath(value) {
|
|
9980
|
-
let candidate =
|
|
10134
|
+
let candidate = path21.resolve(value);
|
|
9981
10135
|
const missingSegments = [];
|
|
9982
10136
|
while (true) {
|
|
9983
10137
|
try {
|
|
9984
|
-
return
|
|
10138
|
+
return path21.join(await realpath2(candidate), ...missingSegments.reverse());
|
|
9985
10139
|
} catch (error) {
|
|
9986
10140
|
if (error.code !== "ENOENT") throw error;
|
|
9987
|
-
const parent =
|
|
10141
|
+
const parent = path21.dirname(candidate);
|
|
9988
10142
|
if (parent === candidate) throw error;
|
|
9989
|
-
missingSegments.push(
|
|
10143
|
+
missingSegments.push(path21.basename(candidate));
|
|
9990
10144
|
candidate = parent;
|
|
9991
10145
|
}
|
|
9992
10146
|
}
|
|
9993
10147
|
}
|
|
9994
10148
|
function isSameOrDescendant(candidate, root) {
|
|
9995
|
-
const relative2 =
|
|
9996
|
-
return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${
|
|
10149
|
+
const relative2 = path21.relative(root, candidate);
|
|
10150
|
+
return relative2 === "" || relative2 !== ".." && !relative2.startsWith(`..${path21.sep}`) && !path21.isAbsolute(relative2);
|
|
9997
10151
|
}
|
|
9998
10152
|
async function pathExists(value) {
|
|
9999
10153
|
try {
|
|
10000
|
-
await
|
|
10154
|
+
await lstat4(value);
|
|
10001
10155
|
return true;
|
|
10002
10156
|
} catch (error) {
|
|
10003
10157
|
if (error.code === "ENOENT") return false;
|
|
@@ -10012,7 +10166,7 @@ async function assertSafeBenchmarkOutput(outputDir) {
|
|
|
10012
10166
|
const configured = process.env[variable]?.trim();
|
|
10013
10167
|
if (!configured) continue;
|
|
10014
10168
|
const memoryRoot = await canonicalProspectivePath(
|
|
10015
|
-
|
|
10169
|
+
path21.resolve(expandTilde(configured))
|
|
10016
10170
|
);
|
|
10017
10171
|
if (isSameOrDescendant(canonicalOutput, memoryRoot)) {
|
|
10018
10172
|
throw new Error(refusal);
|
|
@@ -10020,10 +10174,10 @@ async function assertSafeBenchmarkOutput(outputDir) {
|
|
|
10020
10174
|
}
|
|
10021
10175
|
let candidate = canonicalOutput;
|
|
10022
10176
|
while (true) {
|
|
10023
|
-
const hasProfile = await pathExists(
|
|
10024
|
-
const hasMemoryData = await pathExists(
|
|
10177
|
+
const hasProfile = await pathExists(path21.join(candidate, "profile.md"));
|
|
10178
|
+
const hasMemoryData = await pathExists(path21.join(candidate, "facts")) || await pathExists(path21.join(candidate, "entities")) || await pathExists(path21.join(candidate, "state"));
|
|
10025
10179
|
if (hasProfile && hasMemoryData) throw new Error(refusal);
|
|
10026
|
-
const parent =
|
|
10180
|
+
const parent = path21.dirname(candidate);
|
|
10027
10181
|
if (parent === candidate) break;
|
|
10028
10182
|
candidate = parent;
|
|
10029
10183
|
}
|
|
@@ -10035,7 +10189,7 @@ async function assertSafeBenchmarkOutput(outputDir) {
|
|
|
10035
10189
|
async function assertH6StatsRunDirectory(runDir, commandName = "stats") {
|
|
10036
10190
|
try {
|
|
10037
10191
|
const parsed = JSON.parse(
|
|
10038
|
-
await
|
|
10192
|
+
await readFile5(path21.join(runDir, "run.json"), "utf8")
|
|
10039
10193
|
);
|
|
10040
10194
|
if (parsed.schemaVersion !== 1 || typeof parsed.runId !== "string" || parsed.runId.length === 0 || typeof parsed.suiteVersion !== "string" || !parsed.suiteVersion.startsWith("h6-failure-gate-v1-")) {
|
|
10041
10195
|
throw new Error("invalid H6 metadata");
|
|
@@ -10094,7 +10248,7 @@ async function runRepoVerification(command, bench) {
|
|
|
10094
10248
|
if (command.directory === void 0) {
|
|
10095
10249
|
dataset = await requireFunction(bench, "loadCommittedH6BenchmarkDataset")();
|
|
10096
10250
|
} else {
|
|
10097
|
-
const serialized = await
|
|
10251
|
+
const serialized = await readFile5(path21.join(command.directory, "dataset.json"), "utf8").catch(
|
|
10098
10252
|
() => void 0
|
|
10099
10253
|
);
|
|
10100
10254
|
if (serialized === void 0) {
|
|
@@ -10222,8 +10376,8 @@ async function cmdBenchCoding(args) {
|
|
|
10222
10376
|
}
|
|
10223
10377
|
|
|
10224
10378
|
// src/bench-security-commands.ts
|
|
10225
|
-
import
|
|
10226
|
-
var DEFAULT_OUTPUT_DIR =
|
|
10379
|
+
import path22 from "path";
|
|
10380
|
+
var DEFAULT_OUTPUT_DIR = path22.join(
|
|
10227
10381
|
resolveHomeDir(),
|
|
10228
10382
|
".remnic",
|
|
10229
10383
|
"bench",
|
|
@@ -10706,7 +10860,7 @@ ${BENCH_SECURITY_USAGE}`);
|
|
|
10706
10860
|
}
|
|
10707
10861
|
|
|
10708
10862
|
// src/bench-research-commands.ts
|
|
10709
|
-
import
|
|
10863
|
+
import path23 from "path";
|
|
10710
10864
|
function emit(result) {
|
|
10711
10865
|
if (result.output) {
|
|
10712
10866
|
console.log(result.output);
|
|
@@ -10724,7 +10878,7 @@ async function runBenchResearchCommand(parsed) {
|
|
|
10724
10878
|
emit(
|
|
10725
10879
|
await runAttributeCliCommand({
|
|
10726
10880
|
runRef: parsed.runRef,
|
|
10727
|
-
resultsDir: parsed.resultsDir ??
|
|
10881
|
+
resultsDir: parsed.resultsDir ?? path23.join(resolveHomeDir(), ".remnic", "bench", "results"),
|
|
10728
10882
|
memoryDir: parsed.memoryDir,
|
|
10729
10883
|
qmdPath: parsed.qmdPath,
|
|
10730
10884
|
collection: parsed.collection,
|
|
@@ -10954,6 +11108,7 @@ Examples:
|
|
|
10954
11108
|
}
|
|
10955
11109
|
|
|
10956
11110
|
// src/index.ts
|
|
11111
|
+
import { divergedEmbeddingGenerationDeferrals as divergedEmbeddingGenerationDeferrals2 } from "@remnic/core";
|
|
10957
11112
|
var LazyPluginPiPublisher = class {
|
|
10958
11113
|
constructor(hostId, select) {
|
|
10959
11114
|
this.hostId = hostId;
|
|
@@ -10994,14 +11149,14 @@ registerPublisher("hermes", () => new HermesMemoryExtensionPublisher());
|
|
|
10994
11149
|
registerPublisher("pi", () => new LazyPluginPiPublisher("pi", (mod) => mod.PiMemoryExtensionPublisher));
|
|
10995
11150
|
registerPublisher("omp", () => new LazyPluginPiPublisher("omp", (mod) => mod.OmpMemoryExtensionPublisher));
|
|
10996
11151
|
registerPublisher("prime-agent", () => new LazyPluginPiPublisher("prime-agent", (mod) => mod.PrimeAgentMemoryExtensionPublisher));
|
|
10997
|
-
var PID_DIR =
|
|
10998
|
-
var LEGACY_PID_DIR =
|
|
10999
|
-
var PID_FILE =
|
|
11000
|
-
var LEGACY_PID_FILE =
|
|
11001
|
-
var LOG_FILE =
|
|
11002
|
-
var LEGACY_LOG_FILE =
|
|
11003
|
-
var CLI_MODULE_DIR =
|
|
11004
|
-
var CLI_REPO_ROOT2 =
|
|
11152
|
+
var PID_DIR = path24.join(resolveHomeDir(), ".remnic");
|
|
11153
|
+
var LEGACY_PID_DIR = path24.join(resolveHomeDir(), ".engram");
|
|
11154
|
+
var PID_FILE = path24.join(PID_DIR, "server.pid");
|
|
11155
|
+
var LEGACY_PID_FILE = path24.join(LEGACY_PID_DIR, "server.pid");
|
|
11156
|
+
var LOG_FILE = path24.join(PID_DIR, "server.log");
|
|
11157
|
+
var LEGACY_LOG_FILE = path24.join(LEGACY_PID_DIR, "server.log");
|
|
11158
|
+
var CLI_MODULE_DIR = path24.dirname(fileURLToPath6(import.meta.url));
|
|
11159
|
+
var CLI_REPO_ROOT2 = path24.resolve(CLI_MODULE_DIR, "../../..");
|
|
11005
11160
|
var OPENCLAW_GATEWAY_LABEL = "ai.openclaw.gateway";
|
|
11006
11161
|
var CLI_SUCCESS_EXIT_GRACE_MS = 5e3;
|
|
11007
11162
|
var CLI_OUTPUT_FLUSH_GRACE_MS = 250;
|
|
@@ -11180,12 +11335,12 @@ async function resolveKnownBenchmarkIds() {
|
|
|
11180
11335
|
return knownIds;
|
|
11181
11336
|
}
|
|
11182
11337
|
function resolveBenchOutputDir() {
|
|
11183
|
-
return
|
|
11338
|
+
return path24.join(resolveHomeDir(), ".remnic", "bench", "results");
|
|
11184
11339
|
}
|
|
11185
11340
|
async function launchBenchUi(resultsDir) {
|
|
11186
|
-
const benchUiDir =
|
|
11341
|
+
const benchUiDir = path24.join(CLI_REPO_ROOT2, "packages", "bench-ui");
|
|
11187
11342
|
const pnpmCmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
11188
|
-
if (!fs32.existsSync(
|
|
11343
|
+
if (!fs32.existsSync(path24.join(benchUiDir, "package.json"))) {
|
|
11189
11344
|
console.error("ERROR: @remnic/bench-ui is not available in this checkout.");
|
|
11190
11345
|
process.exit(1);
|
|
11191
11346
|
}
|
|
@@ -11212,11 +11367,11 @@ async function launchBenchUi(resultsDir) {
|
|
|
11212
11367
|
});
|
|
11213
11368
|
}
|
|
11214
11369
|
function resolveDatasetDownloadScriptPath() {
|
|
11215
|
-
const bundled =
|
|
11370
|
+
const bundled = path24.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
|
|
11216
11371
|
if (fs32.existsSync(bundled)) {
|
|
11217
11372
|
return bundled;
|
|
11218
11373
|
}
|
|
11219
|
-
return
|
|
11374
|
+
return path24.join(CLI_REPO_ROOT2, "packages", "remnic-cli", "assets", "download-datasets.sh");
|
|
11220
11375
|
}
|
|
11221
11376
|
function runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, jsonMode) {
|
|
11222
11377
|
const stdio = jsonMode ? ["inherit", process.stderr, "inherit"] : "inherit";
|
|
@@ -11522,12 +11677,12 @@ async function exportBenchPackageResult(parsed) {
|
|
|
11522
11677
|
process.exit(1);
|
|
11523
11678
|
}
|
|
11524
11679
|
const result = await loadBenchmarkResult(summary.path);
|
|
11525
|
-
const reportCardProvenance = parsed.format === "html" ? await loadBenchmarkReportCardProvenance(
|
|
11680
|
+
const reportCardProvenance = parsed.format === "html" ? await loadBenchmarkReportCardProvenance(path24.dirname(summary.path), result.meta.id) : void 0;
|
|
11526
11681
|
const rendered = renderBenchmarkResultExport(result, parsed.format, {
|
|
11527
11682
|
...reportCardProvenance ? { reportCardProvenance } : {}
|
|
11528
11683
|
});
|
|
11529
11684
|
if (parsed.output) {
|
|
11530
|
-
fs32.mkdirSync(
|
|
11685
|
+
fs32.mkdirSync(path24.dirname(parsed.output), { recursive: true });
|
|
11531
11686
|
fs32.writeFileSync(parsed.output, rendered);
|
|
11532
11687
|
console.log(`Exported ${summary.id} as ${parsed.format} to ${parsed.output}`);
|
|
11533
11688
|
return;
|
|
@@ -11549,7 +11704,7 @@ async function manageBenchDatasets(parsed) {
|
|
|
11549
11704
|
return {
|
|
11550
11705
|
benchmark: benchmarkId,
|
|
11551
11706
|
downloaded: discovered !== void 0,
|
|
11552
|
-
path: discovered ? discovered.dir :
|
|
11707
|
+
path: discovered ? discovered.dir : path24.join(datasetRoot, benchmarkId),
|
|
11553
11708
|
source: discovered?.source ?? "canonical"
|
|
11554
11709
|
};
|
|
11555
11710
|
});
|
|
@@ -11584,7 +11739,7 @@ async function manageBenchDatasets(parsed) {
|
|
|
11584
11739
|
runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, parsed.json === true);
|
|
11585
11740
|
downloaded.push({
|
|
11586
11741
|
benchmark: benchmarkId,
|
|
11587
|
-
path:
|
|
11742
|
+
path: path24.join(datasetRoot, benchmarkId)
|
|
11588
11743
|
});
|
|
11589
11744
|
}
|
|
11590
11745
|
if (parsed.json) {
|
|
@@ -11723,10 +11878,10 @@ async function calibrateBenchJudges(parsed, rawArgs) {
|
|
|
11723
11878
|
}
|
|
11724
11879
|
const bench = await loadBenchModule();
|
|
11725
11880
|
const resultsDir = expandTilde(
|
|
11726
|
-
parsed.resultsDir ??
|
|
11881
|
+
parsed.resultsDir ?? path24.join(resolveHomeDir(), ".remnic", "bench", "results")
|
|
11727
11882
|
);
|
|
11728
11883
|
const calibrationDir = expandTilde(
|
|
11729
|
-
parsed.calibrationDir ??
|
|
11884
|
+
parsed.calibrationDir ?? path24.join(resolveHomeDir(), ".remnic", "bench", "calibration")
|
|
11730
11885
|
);
|
|
11731
11886
|
const stored = await bench.listBenchmarkResults(resultsDir);
|
|
11732
11887
|
const allForBenchmark = stored.filter((entry) => entry.benchmark === benchmarkId);
|
|
@@ -12286,7 +12441,7 @@ async function loadPublishedPromotionHelpers() {
|
|
|
12286
12441
|
return {
|
|
12287
12442
|
async promoteArtifactsToPublished(args) {
|
|
12288
12443
|
const { mkdirSync: mkdirSync2, readFileSync: readFileSync6, writeFileSync: writeFileSync2 } = await import("fs");
|
|
12289
|
-
const
|
|
12444
|
+
const path25 = await import("path");
|
|
12290
12445
|
mkdirSync2(args.publishedOutDir, { recursive: true });
|
|
12291
12446
|
if (args.artifactPaths.length === 0) {
|
|
12292
12447
|
console.warn(
|
|
@@ -12303,13 +12458,13 @@ async function loadPublishedPromotionHelpers() {
|
|
|
12303
12458
|
const modelSlug = args.model.replace(/[^a-zA-Z0-9_.-]/g, "-");
|
|
12304
12459
|
const rawProfile = parsedObj.config?.runtimeProfile;
|
|
12305
12460
|
const profileSlug = typeof rawProfile === "string" && rawProfile.length > 0 ? `-${rawProfile.replace(/[^a-zA-Z0-9_.-]/g, "-")}` : "";
|
|
12306
|
-
const target =
|
|
12461
|
+
const target = path25.join(
|
|
12307
12462
|
args.publishedOutDir,
|
|
12308
12463
|
`${today}-${args.benchmarkId}-${modelSlug}${profileSlug}-${gitShaShort}.json`
|
|
12309
12464
|
);
|
|
12310
12465
|
writeFileSync2(target, raw, "utf8");
|
|
12311
12466
|
console.log(
|
|
12312
|
-
`[bench published] Promoted ${
|
|
12467
|
+
`[bench published] Promoted ${path25.basename(artifactPath)} \u2192 ${target}`
|
|
12313
12468
|
);
|
|
12314
12469
|
}
|
|
12315
12470
|
void benchModule;
|
|
@@ -12416,7 +12571,7 @@ async function runBenchViaPackage(parsed, benchmarkId, runtimeProfile, benchStat
|
|
|
12416
12571
|
const previousCodexDiagnosticsDir = process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV];
|
|
12417
12572
|
const previousCodexDiagnosticsMode = process.env[CODEX_CLI_BENCH_DIAGNOSTICS_MODE_ENV];
|
|
12418
12573
|
if (!previousCodexDiagnosticsDir) {
|
|
12419
|
-
process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV] =
|
|
12574
|
+
process.env[CODEX_CLI_BENCH_DIAGNOSTICS_DIR_ENV] = path24.join(
|
|
12420
12575
|
outputDir,
|
|
12421
12576
|
"codex-cli-diagnostics"
|
|
12422
12577
|
);
|
|
@@ -12566,7 +12721,7 @@ async function preparePersistedJudgeCalibrationAttachment(benchModule, benchmark
|
|
|
12566
12721
|
);
|
|
12567
12722
|
}
|
|
12568
12723
|
const calibrationDir = expandTilde(
|
|
12569
|
-
calibrationBinding.calibrationDir ??
|
|
12724
|
+
calibrationBinding.calibrationDir ?? path24.join(resolveHomeDir(), ".remnic", "bench", "calibration")
|
|
12570
12725
|
);
|
|
12571
12726
|
const state = await benchModule.loadJudgeCalibrationState?.(benchmarkId, calibrationDir);
|
|
12572
12727
|
if (!state) {
|
|
@@ -13048,7 +13203,7 @@ async function resolvePackageBenchRuntime(benchModule, parsed, runtimeProfile) {
|
|
|
13048
13203
|
);
|
|
13049
13204
|
}
|
|
13050
13205
|
function normalizeMemoryDirPath(memoryDir) {
|
|
13051
|
-
return
|
|
13206
|
+
return path24.resolve(expandTilde(memoryDir));
|
|
13052
13207
|
}
|
|
13053
13208
|
function resolveMemoryDir() {
|
|
13054
13209
|
const configMemoryDir = (() => {
|
|
@@ -13061,9 +13216,9 @@ function resolveMemoryDir() {
|
|
|
13061
13216
|
return normalizeMemoryDirPath(remnicCfg.memoryDir);
|
|
13062
13217
|
}
|
|
13063
13218
|
const home = resolveHomeDir();
|
|
13064
|
-
const standalonePath =
|
|
13065
|
-
const legacyStandalonePath =
|
|
13066
|
-
const openclawPath =
|
|
13219
|
+
const standalonePath = path24.join(home, ".remnic", "memory");
|
|
13220
|
+
const legacyStandalonePath = path24.join(home, ".engram", "memory");
|
|
13221
|
+
const openclawPath = path24.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
13067
13222
|
if (fs32.existsSync(standalonePath)) return standalonePath;
|
|
13068
13223
|
if (fs32.existsSync(legacyStandalonePath)) return legacyStandalonePath;
|
|
13069
13224
|
return openclawPath;
|
|
@@ -13112,21 +13267,21 @@ function resolveFlagStrict(args, flag) {
|
|
|
13112
13267
|
var REMNIC_OPENCLAW_LEGACY_PLUGIN_ID = "openclaw-engram";
|
|
13113
13268
|
function resolveOpenclawStateDir() {
|
|
13114
13269
|
const configuredStateDir = process.env.OPENCLAW_STATE_DIR?.trim();
|
|
13115
|
-
return configuredStateDir ?
|
|
13270
|
+
return configuredStateDir ? path24.resolve(expandTilde(configuredStateDir)) : path24.join(resolveHomeDir(), ".openclaw");
|
|
13116
13271
|
}
|
|
13117
13272
|
var DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR = [
|
|
13118
13273
|
process.env.OPENCLAW_CONFIG_PATH,
|
|
13119
13274
|
process.env.OPENCLAW_ENGRAM_CONFIG_PATH,
|
|
13120
|
-
|
|
13275
|
+
path24.join(resolveOpenclawStateDir(), "openclaw.json")
|
|
13121
13276
|
].filter(Boolean);
|
|
13122
13277
|
function resolveOpenclawConfigPath(cliPath) {
|
|
13123
|
-
if (cliPath) return
|
|
13278
|
+
if (cliPath) return path24.resolve(expandTilde(cliPath));
|
|
13124
13279
|
const envPath = process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_ENGRAM_CONFIG_PATH;
|
|
13125
|
-
if (envPath) return
|
|
13280
|
+
if (envPath) return path24.resolve(expandTilde(envPath));
|
|
13126
13281
|
for (const candidate of DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR) {
|
|
13127
13282
|
if (fs32.existsSync(candidate)) return candidate;
|
|
13128
13283
|
}
|
|
13129
|
-
return
|
|
13284
|
+
return path24.join(resolveOpenclawStateDir(), "openclaw.json");
|
|
13130
13285
|
}
|
|
13131
13286
|
function readOpenclawConfig(configPath) {
|
|
13132
13287
|
if (!fs32.existsSync(configPath)) return {};
|
|
@@ -13185,10 +13340,10 @@ function buildRemnicOpenclawHooksPolicy(legacyHooks, existingHooks) {
|
|
|
13185
13340
|
function resolveOpenclawInstallMemoryDir(args) {
|
|
13186
13341
|
const existingMemoryDir = (typeof args.existingNewEntryConfig.memoryDir === "string" ? args.existingNewEntryConfig.memoryDir : void 0) || (args.migrateLegacy && typeof args.legacyConfigToMerge.memoryDir === "string" ? args.legacyConfigToMerge.memoryDir : void 0);
|
|
13187
13342
|
if (args.requestedMemoryDir) {
|
|
13188
|
-
return
|
|
13343
|
+
return path24.resolve(expandTilde(args.requestedMemoryDir));
|
|
13189
13344
|
}
|
|
13190
13345
|
if (existingMemoryDir) {
|
|
13191
|
-
return
|
|
13346
|
+
return path24.resolve(expandTilde(existingMemoryDir));
|
|
13192
13347
|
}
|
|
13193
13348
|
return args.fallbackMemoryDir;
|
|
13194
13349
|
}
|
|
@@ -13206,21 +13361,21 @@ function resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir) {
|
|
|
13206
13361
|
if (!config || typeof config !== "object" || Array.isArray(config)) continue;
|
|
13207
13362
|
const memoryDir = config.memoryDir;
|
|
13208
13363
|
if (typeof memoryDir === "string" && memoryDir.trim().length > 0) {
|
|
13209
|
-
return
|
|
13364
|
+
return path24.resolve(expandTilde(memoryDir));
|
|
13210
13365
|
}
|
|
13211
13366
|
}
|
|
13212
13367
|
return fallbackMemoryDir;
|
|
13213
13368
|
}
|
|
13214
13369
|
function resolveOpenclawPluginDir(cliPath) {
|
|
13215
|
-
if (cliPath) return
|
|
13370
|
+
if (cliPath) return path24.resolve(expandTilde(cliPath));
|
|
13216
13371
|
return resolveOpenclawManagedPluginDir();
|
|
13217
13372
|
}
|
|
13218
13373
|
function resolveOpenclawManagedPluginDir() {
|
|
13219
|
-
return
|
|
13374
|
+
return path24.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
|
|
13220
13375
|
}
|
|
13221
13376
|
function resolveOpenclawLegacyPluginDir(cliPath) {
|
|
13222
|
-
if (cliPath) return
|
|
13223
|
-
return
|
|
13377
|
+
if (cliPath) return path24.resolve(expandTilde(cliPath));
|
|
13378
|
+
return path24.join(resolveOpenclawStateDir(), "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID);
|
|
13224
13379
|
}
|
|
13225
13380
|
function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
|
|
13226
13381
|
const yyyy = now.getFullYear().toString();
|
|
@@ -13233,7 +13388,7 @@ function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
|
|
|
13233
13388
|
}
|
|
13234
13389
|
function backupPathIfPresent(sourcePath, backupPath) {
|
|
13235
13390
|
if (!fs32.existsSync(sourcePath)) return false;
|
|
13236
|
-
fs32.mkdirSync(
|
|
13391
|
+
fs32.mkdirSync(path24.dirname(backupPath), { recursive: true });
|
|
13237
13392
|
fs32.cpSync(sourcePath, backupPath, { recursive: true });
|
|
13238
13393
|
return true;
|
|
13239
13394
|
}
|
|
@@ -13252,7 +13407,7 @@ function restartOpenclawGateway() {
|
|
|
13252
13407
|
});
|
|
13253
13408
|
}
|
|
13254
13409
|
function cmdInit() {
|
|
13255
|
-
const configPath =
|
|
13410
|
+
const configPath = path24.join(process.cwd(), "remnic.config.json");
|
|
13256
13411
|
if (fs32.existsSync(configPath)) {
|
|
13257
13412
|
console.log(`Config already exists: ${configPath}`);
|
|
13258
13413
|
return;
|
|
@@ -13260,7 +13415,7 @@ function cmdInit() {
|
|
|
13260
13415
|
const template = {
|
|
13261
13416
|
remnic: {
|
|
13262
13417
|
openaiApiKey: "${OPENAI_API_KEY}",
|
|
13263
|
-
memoryDir:
|
|
13418
|
+
memoryDir: path24.join(process.cwd(), ".remnic", "memory"),
|
|
13264
13419
|
memoryOsPreset: "balanced"
|
|
13265
13420
|
},
|
|
13266
13421
|
server: {
|
|
@@ -13322,7 +13477,7 @@ async function cmdStatus(json) {
|
|
|
13322
13477
|
console.log(`Remnic server: running${pid ? ` (pid ${pid})` : ""}`);
|
|
13323
13478
|
await printHealthCheck(resolveDaemonBaseUrl(resolveConfigPath()), resolveStatusProbeToken());
|
|
13324
13479
|
}
|
|
13325
|
-
async function oauthFetch(method,
|
|
13480
|
+
async function oauthFetch(method, path25, token, body) {
|
|
13326
13481
|
const controller = new AbortController();
|
|
13327
13482
|
const timeoutId = setTimeout(() => controller.abort(), 5e3);
|
|
13328
13483
|
try {
|
|
@@ -13341,7 +13496,7 @@ async function oauthFetch(method, path24, token, body) {
|
|
|
13341
13496
|
if (body !== void 0) {
|
|
13342
13497
|
init.body = JSON.stringify(body);
|
|
13343
13498
|
}
|
|
13344
|
-
const response = await fetch(`${resolveDaemonBaseUrl(resolveConfigPath())}${
|
|
13499
|
+
const response = await fetch(`${resolveDaemonBaseUrl(resolveConfigPath())}${path25}`, init);
|
|
13345
13500
|
if (response.status === 401) {
|
|
13346
13501
|
throw new Error(
|
|
13347
13502
|
"operator token rejected by remnic-server (HTTP 401). Update `server.authToken` or `REMNIC_AUTH_TOKEN` to match the running daemon."
|
|
@@ -14035,7 +14190,7 @@ async function cmdVersions(rest) {
|
|
|
14035
14190
|
console.error("Usage: remnic versions list <page-path>");
|
|
14036
14191
|
process.exit(1);
|
|
14037
14192
|
}
|
|
14038
|
-
const absPath =
|
|
14193
|
+
const absPath = path24.resolve(pagePath);
|
|
14039
14194
|
const history = await listVersions(absPath, versioningConfig, memDir);
|
|
14040
14195
|
if (json) {
|
|
14041
14196
|
console.log(JSON.stringify(history, null, 2));
|
|
@@ -14060,7 +14215,7 @@ async function cmdVersions(rest) {
|
|
|
14060
14215
|
console.error("Usage: remnic versions show <page-path> <version-id>");
|
|
14061
14216
|
process.exit(1);
|
|
14062
14217
|
}
|
|
14063
|
-
const absPath =
|
|
14218
|
+
const absPath = path24.resolve(pagePath);
|
|
14064
14219
|
try {
|
|
14065
14220
|
const content = await getVersion(absPath, versionId, versioningConfig, memDir);
|
|
14066
14221
|
console.log(content);
|
|
@@ -14078,7 +14233,7 @@ async function cmdVersions(rest) {
|
|
|
14078
14233
|
console.error("Usage: remnic versions diff <page-path> <v1> <v2>");
|
|
14079
14234
|
process.exit(1);
|
|
14080
14235
|
}
|
|
14081
|
-
const absPath =
|
|
14236
|
+
const absPath = path24.resolve(pagePath);
|
|
14082
14237
|
try {
|
|
14083
14238
|
const diffOutput = await diffVersions(absPath, v1, v2, versioningConfig, memDir);
|
|
14084
14239
|
console.log(diffOutput);
|
|
@@ -14095,7 +14250,7 @@ async function cmdVersions(rest) {
|
|
|
14095
14250
|
console.error("Usage: remnic versions revert <page-path> <version-id>");
|
|
14096
14251
|
process.exit(1);
|
|
14097
14252
|
}
|
|
14098
|
-
const absPath =
|
|
14253
|
+
const absPath = path24.resolve(pagePath);
|
|
14099
14254
|
try {
|
|
14100
14255
|
const version = await revertToVersion(absPath, versionId, versioningConfig, void 0, memDir);
|
|
14101
14256
|
if (json) {
|
|
@@ -14135,7 +14290,7 @@ async function cmdEnrich(rest) {
|
|
|
14135
14290
|
const subcommand = rest[0];
|
|
14136
14291
|
if (subcommand === "audit") {
|
|
14137
14292
|
const memoryDir2 = expandTilde(config.memoryDir);
|
|
14138
|
-
const auditDir2 =
|
|
14293
|
+
const auditDir2 = path24.join(memoryDir2, "enrichment");
|
|
14139
14294
|
const sinceFlag = resolveFlag(rest.slice(1), "--since");
|
|
14140
14295
|
const entries = await readAuditLog(auditDir2, sinceFlag ?? void 0);
|
|
14141
14296
|
if (entries.length === 0) {
|
|
@@ -14260,7 +14415,7 @@ Registered providers:`);
|
|
|
14260
14415
|
return;
|
|
14261
14416
|
}
|
|
14262
14417
|
const memoryDir = expandTilde(config.memoryDir);
|
|
14263
|
-
const auditDir =
|
|
14418
|
+
const auditDir = path24.join(memoryDir, "enrichment");
|
|
14264
14419
|
let totalPersisted = 0;
|
|
14265
14420
|
for (const result of results) {
|
|
14266
14421
|
for (const candidate of result.acceptedCandidates) {
|
|
@@ -14383,7 +14538,7 @@ Root: ${root}`);
|
|
|
14383
14538
|
const validNames = new Set(extensions.map((e) => e.name));
|
|
14384
14539
|
let errors = 0;
|
|
14385
14540
|
for (const entry of entries) {
|
|
14386
|
-
const entryPath =
|
|
14541
|
+
const entryPath = path24.join(root, entry);
|
|
14387
14542
|
try {
|
|
14388
14543
|
if (!fs32.statSync(entryPath).isDirectory()) continue;
|
|
14389
14544
|
} catch {
|
|
@@ -14514,7 +14669,7 @@ ${section}
|
|
|
14514
14669
|
const saveDir = resolveBriefingSaveDir(config.briefing.saveDir);
|
|
14515
14670
|
fs32.mkdirSync(saveDir, { recursive: true });
|
|
14516
14671
|
const filename = briefingFilename(new Date(result.window.to), format);
|
|
14517
|
-
const filePath =
|
|
14672
|
+
const filePath = path24.join(saveDir, filename);
|
|
14518
14673
|
fs32.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
|
|
14519
14674
|
console.error(`Saved briefing: ${filePath}`);
|
|
14520
14675
|
} catch (err) {
|
|
@@ -14670,7 +14825,7 @@ async function cmdDoctor() {
|
|
|
14670
14825
|
const rawMemoryDir = entryConfig?.memoryDir;
|
|
14671
14826
|
const configuredMemoryDir = typeof rawMemoryDir === "string" ? rawMemoryDir : void 0;
|
|
14672
14827
|
if (configuredMemoryDir) {
|
|
14673
|
-
const resolvedMemDir =
|
|
14828
|
+
const resolvedMemDir = path24.resolve(expandTilde(configuredMemoryDir));
|
|
14674
14829
|
let memDirOk = false;
|
|
14675
14830
|
let memDirDetail = `${resolvedMemDir} (not found)`;
|
|
14676
14831
|
let memDirRemediation = `Run \`remnic openclaw install --memory-dir "${resolvedMemDir}"\` to create the directory.`;
|
|
@@ -14883,7 +15038,7 @@ async function cmdMigrate(json, rollback) {
|
|
|
14883
15038
|
console.log(` Rollback: ${result.rollbackCommand}`);
|
|
14884
15039
|
}
|
|
14885
15040
|
function cmdOnboard(dirPath, json) {
|
|
14886
|
-
const directory =
|
|
15041
|
+
const directory = path24.resolve(dirPath || process.cwd());
|
|
14887
15042
|
const result = onboard({ directory });
|
|
14888
15043
|
if (json) {
|
|
14889
15044
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -14902,7 +15057,7 @@ Suggested namespace: ${result.plan.suggestedNamespace}`);
|
|
|
14902
15057
|
async function cmdCurate(targetPath, json) {
|
|
14903
15058
|
const memoryDir = resolveMemoryDir();
|
|
14904
15059
|
const result = await curate({
|
|
14905
|
-
targetPath:
|
|
15060
|
+
targetPath: path24.resolve(targetPath),
|
|
14906
15061
|
memoryDir,
|
|
14907
15062
|
source: "curation",
|
|
14908
15063
|
checkDuplicates: true,
|
|
@@ -14940,7 +15095,7 @@ async function cmdReview(action, rest) {
|
|
|
14940
15095
|
console.error("Usage: remnic review <approve|dismiss|flag> <id>");
|
|
14941
15096
|
process.exit(1);
|
|
14942
15097
|
}
|
|
14943
|
-
const storage = new
|
|
15098
|
+
const storage = new StorageManager5(memoryDir);
|
|
14944
15099
|
const configPath = resolveConfigPath();
|
|
14945
15100
|
let tombstonesConfig = null;
|
|
14946
15101
|
try {
|
|
@@ -15032,7 +15187,7 @@ async function cmdSync(action, rest, json) {
|
|
|
15032
15187
|
}
|
|
15033
15188
|
function localOfflineSourceId(memoryDir) {
|
|
15034
15189
|
const host = os4.hostname() || "unknown-host";
|
|
15035
|
-
const dirHash = createHash6("sha256").update(
|
|
15190
|
+
const dirHash = createHash6("sha256").update(path24.resolve(memoryDir)).digest("hex").slice(0, 16);
|
|
15036
15191
|
return `remnic-local:${host}:${dirHash}`;
|
|
15037
15192
|
}
|
|
15038
15193
|
function normalizeOfflineRemoteUrl(raw) {
|
|
@@ -15224,7 +15379,8 @@ async function parseOfflineSnapshotStreamResponse(response) {
|
|
|
15224
15379
|
schemaVersion: parsed.schemaVersion,
|
|
15225
15380
|
createdAt: parsed.createdAt,
|
|
15226
15381
|
sourceId: parsed.sourceId,
|
|
15227
|
-
includeTranscripts: parsed.includeTranscripts
|
|
15382
|
+
includeTranscripts: parsed.includeTranscripts,
|
|
15383
|
+
...Array.isArray(parsed.omittedEmbeddingGenerationDirs) ? { omittedEmbeddingGenerationDirs: parsed.omittedEmbeddingGenerationDirs } : {}
|
|
15228
15384
|
};
|
|
15229
15385
|
return;
|
|
15230
15386
|
}
|
|
@@ -15257,7 +15413,8 @@ async function parseOfflineSnapshotStreamResponse(response) {
|
|
|
15257
15413
|
createdAt: finalHeader.createdAt,
|
|
15258
15414
|
sourceId: finalHeader.sourceId,
|
|
15259
15415
|
includeTranscripts: finalHeader.includeTranscripts,
|
|
15260
|
-
files
|
|
15416
|
+
files,
|
|
15417
|
+
...finalHeader.omittedEmbeddingGenerationDirs ? { omittedEmbeddingGenerationDirs: finalHeader.omittedEmbeddingGenerationDirs } : {}
|
|
15261
15418
|
});
|
|
15262
15419
|
return {
|
|
15263
15420
|
...finalHeader.namespace ? { namespace: finalHeader.namespace } : {},
|
|
@@ -15441,10 +15598,10 @@ var OFFLINE_SYNC_CONTENT_MISSING_RETRY_MAX = 3;
|
|
|
15441
15598
|
var OFFLINE_SYNC_CONTENT_MISSING_RETRY_DELAY_MS = 250;
|
|
15442
15599
|
var OfflineRemoteFileChangedError = class extends Error {
|
|
15443
15600
|
path;
|
|
15444
|
-
constructor(
|
|
15445
|
-
super(`remote file changed while fetching offline content: ${
|
|
15601
|
+
constructor(path25) {
|
|
15602
|
+
super(`remote file changed while fetching offline content: ${path25}`);
|
|
15446
15603
|
this.name = "OfflineRemoteFileChangedError";
|
|
15447
|
-
this.path =
|
|
15604
|
+
this.path = path25;
|
|
15448
15605
|
}
|
|
15449
15606
|
};
|
|
15450
15607
|
function isOfflineRemoteFileChangedError(error) {
|
|
@@ -15585,9 +15742,11 @@ function offlineSnapshotContentFilesForApply(options) {
|
|
|
15585
15742
|
const current = options.currentFiles ? offlineFileStateMap(options.currentFiles) : null;
|
|
15586
15743
|
const conflictContentMaxBytes = options.conflictContentMaxBytes ?? Number.POSITIVE_INFINITY;
|
|
15587
15744
|
const deferredPaths = new Set(options.deferredPaths ?? []);
|
|
15745
|
+
const skipPaths = options.skipPaths ?? /* @__PURE__ */ new Set();
|
|
15588
15746
|
const files = [];
|
|
15589
15747
|
for (const incoming of options.snapshot.files) {
|
|
15590
15748
|
if (deferredPaths.has(incoming.path)) continue;
|
|
15749
|
+
if (skipPaths.has(incoming.path)) continue;
|
|
15591
15750
|
const baseEntry = base.get(incoming.path);
|
|
15592
15751
|
const currentEntry = current?.get(incoming.path);
|
|
15593
15752
|
if (currentEntry?.sha256 === incoming.sha256) continue;
|
|
@@ -15613,6 +15772,7 @@ function offlineSnapshotContentFilesForApply(options) {
|
|
|
15613
15772
|
function shouldDirectHydrateOfflineFile(options) {
|
|
15614
15773
|
if (options.incoming.bytes < OFFLINE_SYNC_DIRECT_HYDRATE_MIN_BYTES) return false;
|
|
15615
15774
|
if (options.current?.sha256 === options.incoming.sha256) return false;
|
|
15775
|
+
if (embeddingGenerationMembership2(options.incoming.path)) return false;
|
|
15616
15776
|
if (shouldPreferIncomingOfflineRuntimeFile(options.incoming.path)) return true;
|
|
15617
15777
|
if (options.current && options.base && options.current.sha256 === options.base.sha256) {
|
|
15618
15778
|
return true;
|
|
@@ -15705,7 +15865,7 @@ async function pushOfflineFileContentFromChunkReader(args) {
|
|
|
15705
15865
|
}
|
|
15706
15866
|
const hash = createHash6("sha256");
|
|
15707
15867
|
const chunks = args.readFileChunks({
|
|
15708
|
-
root:
|
|
15868
|
+
root: path24.resolve(args.memoryDir),
|
|
15709
15869
|
path: args.file.path,
|
|
15710
15870
|
filePath,
|
|
15711
15871
|
chunkSize: OFFLINE_SYNC_FILE_CONTENT_UPLOAD_CHUNK_BYTES
|
|
@@ -15975,7 +16135,8 @@ async function hydrateOfflineSnapshotContent(args) {
|
|
|
15975
16135
|
baseFiles: args.baseFiles,
|
|
15976
16136
|
currentFiles: args.currentFiles,
|
|
15977
16137
|
conflictContentMaxBytes: OFFLINE_SYNC_FILES_CONTENT_MAX_BATCH_BYTES,
|
|
15978
|
-
deferredPaths: args.deferredPaths
|
|
16138
|
+
deferredPaths: args.deferredPaths,
|
|
16139
|
+
skipPaths: args.skipContentPaths
|
|
15979
16140
|
});
|
|
15980
16141
|
if (neededFiles.length === 0) return { ...args.snapshot, files: snapshot.files };
|
|
15981
16142
|
const expectedByPath = new Map(snapshot.files.map((file) => [file.path, file]));
|
|
@@ -16053,31 +16214,66 @@ function chunkOfflineChangesetApplyBatches(changeset, namespace, maxRequestBytes
|
|
|
16053
16214
|
if (!Number.isInteger(maxRequestBytes) || maxRequestBytes < 1) {
|
|
16054
16215
|
throw new Error("offline sync apply max request bytes must be a positive integer");
|
|
16055
16216
|
}
|
|
16056
|
-
const
|
|
16057
|
-
|
|
16058
|
-
const
|
|
16217
|
+
const items = [];
|
|
16218
|
+
const itemIndexByDir = /* @__PURE__ */ new Map();
|
|
16219
|
+
for (const change of changeset.changes) {
|
|
16220
|
+
const membership = embeddingGenerationMembership2(change.path);
|
|
16221
|
+
if (!membership) {
|
|
16222
|
+
items.push({ changes: [change], shardDir: null });
|
|
16223
|
+
continue;
|
|
16224
|
+
}
|
|
16225
|
+
const existing = itemIndexByDir.get(membership.shardDir);
|
|
16226
|
+
if (existing !== void 0) {
|
|
16227
|
+
items[existing].changes.push(change);
|
|
16228
|
+
continue;
|
|
16229
|
+
}
|
|
16230
|
+
itemIndexByDir.set(membership.shardDir, items.length);
|
|
16231
|
+
items.push({ changes: [change], shardDir: membership.shardDir });
|
|
16232
|
+
}
|
|
16233
|
+
const manifestFor = (dirs) => (changeset.embeddingGenerations ?? []).filter((generation) => dirs.has(generation.shardDir));
|
|
16234
|
+
const requestBytesFor = (changes, dirs) => Buffer.byteLength(JSON.stringify({
|
|
16059
16235
|
namespace,
|
|
16060
16236
|
changeset: {
|
|
16061
16237
|
...changeset,
|
|
16062
|
-
changes
|
|
16238
|
+
changes,
|
|
16239
|
+
embeddingGenerations: manifestFor(dirs)
|
|
16063
16240
|
}
|
|
16064
16241
|
}), "utf-8");
|
|
16065
|
-
|
|
16066
|
-
|
|
16067
|
-
|
|
16068
|
-
|
|
16069
|
-
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
16242
|
+
const chunks = [];
|
|
16243
|
+
let current = [];
|
|
16244
|
+
const currentDirs = /* @__PURE__ */ new Set();
|
|
16245
|
+
const flush = () => {
|
|
16246
|
+
chunks.push({ ...changeset, changes: current, embeddingGenerations: manifestFor(currentDirs) });
|
|
16247
|
+
current = [];
|
|
16248
|
+
currentDirs.clear();
|
|
16249
|
+
};
|
|
16250
|
+
for (const item of items) {
|
|
16251
|
+
if (current.length > 0) {
|
|
16252
|
+
const nextDirs = /* @__PURE__ */ new Set([...currentDirs, ...item.shardDir ? [item.shardDir] : []]);
|
|
16253
|
+
if (requestBytesFor([...current, ...item.changes], nextDirs) > maxRequestBytes) {
|
|
16254
|
+
flush();
|
|
16255
|
+
}
|
|
16256
|
+
}
|
|
16257
|
+
const singleDirs = new Set(item.shardDir ? [item.shardDir] : []);
|
|
16258
|
+
if (requestBytesFor(item.changes, singleDirs) > maxRequestBytes) {
|
|
16259
|
+
if (item.shardDir) {
|
|
16260
|
+
const generationBytes = item.changes.reduce(
|
|
16261
|
+
(total, change) => total + (change.type === "upsert" ? change.file.bytes : 0),
|
|
16262
|
+
0
|
|
16263
|
+
);
|
|
16264
|
+
throw new Error(
|
|
16265
|
+
`offline sync push aborted before any request: embedding generation ${item.shardDir} (${generationBytes} bytes of shards plus sync overhead) exceeds the apply request budget of ${maxRequestBytes} bytes and cannot be split without exposing a mixed generation. Oversized generations need the secure staged chunk transport (planned; chunks land in a private staging root and publish through the atomic generation swap), not final-path upload \u2014 retry after the index shrinks below the budget.`
|
|
16266
|
+
);
|
|
16267
|
+
}
|
|
16073
16268
|
throw new Error(
|
|
16074
|
-
`offline sync change for ${
|
|
16269
|
+
`offline sync change for ${item.changes[0].path} exceeds the apply request size budget; retry after direct-push threshold is lowered`
|
|
16075
16270
|
);
|
|
16076
16271
|
}
|
|
16077
|
-
current.push(
|
|
16272
|
+
current.push(...item.changes);
|
|
16273
|
+
if (item.shardDir) currentDirs.add(item.shardDir);
|
|
16078
16274
|
}
|
|
16079
16275
|
if (current.length > 0) {
|
|
16080
|
-
|
|
16276
|
+
flush();
|
|
16081
16277
|
}
|
|
16082
16278
|
return chunks;
|
|
16083
16279
|
}
|
|
@@ -16340,16 +16536,16 @@ async function runOfflineSyncOnce(options) {
|
|
|
16340
16536
|
conflicts: [...prior?.conflicts ?? [], ...result.conflicts]
|
|
16341
16537
|
});
|
|
16342
16538
|
pushed = buildPushedSummary(null);
|
|
16343
|
-
const stateWritePathsFor = (
|
|
16539
|
+
const stateWritePathsFor = (resolvedNamespace) => offlineStatePathsForNamespace({
|
|
16344
16540
|
memoryDir: options.memoryDir,
|
|
16345
16541
|
remoteUrl: options.remoteUrl,
|
|
16346
16542
|
requestedNamespace: options.namespace,
|
|
16347
|
-
resolvedNamespace
|
|
16543
|
+
resolvedNamespace,
|
|
16348
16544
|
explicitStatePath: options.statePathExplicit ? activeStatePath : void 0
|
|
16349
16545
|
});
|
|
16350
16546
|
const writePartialPushState = async (error, partial, checkpointChangeset = changeset) => {
|
|
16351
|
-
const
|
|
16352
|
-
const
|
|
16547
|
+
const resolvedNamespace = partial?.resolvedNamespace ?? resolvedOfflineSnapshotNamespace({ namespace: pushed?.namespace ?? "" }, syncNamespace);
|
|
16548
|
+
const stateWritePaths = stateWritePathsFor(resolvedNamespace);
|
|
16353
16549
|
const nextBaseFiles = advanceOfflineBaseFilesForSuccessfulPush({
|
|
16354
16550
|
baseFiles: syncBaseFiles,
|
|
16355
16551
|
currentFiles: currentSnapshotForPush.files,
|
|
@@ -16358,23 +16554,23 @@ async function runOfflineSyncOnce(options) {
|
|
|
16358
16554
|
changeset: checkpointChangeset,
|
|
16359
16555
|
conflicts: pushed?.conflicts ?? directPushConflicts
|
|
16360
16556
|
});
|
|
16361
|
-
const
|
|
16557
|
+
const state = {
|
|
16362
16558
|
version: 1,
|
|
16363
16559
|
remoteId: options.remoteUrl,
|
|
16364
|
-
...
|
|
16560
|
+
...resolvedNamespace ? { namespace: resolvedNamespace } : {},
|
|
16365
16561
|
includeTranscripts: options.includeTranscripts,
|
|
16366
16562
|
// Partial checkpoints do not recapture conflicted/deferred paths, so keep
|
|
16367
16563
|
// the original capture time for safe fast-base reuse on the next run.
|
|
16368
16564
|
lastSyncedAt: priorState?.lastSyncedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
16369
16565
|
baseFiles: nextBaseFiles
|
|
16370
16566
|
};
|
|
16371
|
-
for (const statePath of
|
|
16372
|
-
await writeOfflineSyncState(statePath,
|
|
16567
|
+
for (const statePath of stateWritePaths) {
|
|
16568
|
+
await writeOfflineSyncState(statePath, state);
|
|
16373
16569
|
}
|
|
16374
16570
|
const message = error instanceof Error ? error.message : String(error);
|
|
16375
16571
|
return {
|
|
16376
|
-
statePath:
|
|
16377
|
-
namespace:
|
|
16572
|
+
statePath: stateWritePaths[0] ?? activeStatePath,
|
|
16573
|
+
namespace: resolvedNamespace,
|
|
16378
16574
|
prepared: priorState === null,
|
|
16379
16575
|
pushed,
|
|
16380
16576
|
pull: null,
|
|
@@ -16581,18 +16777,26 @@ async function runOfflineSyncOnce(options) {
|
|
|
16581
16777
|
excludeNodeLocalState: false
|
|
16582
16778
|
});
|
|
16583
16779
|
const applyCurrentSnapshot = await buildCurrentSnapshotForApply();
|
|
16584
|
-
|
|
16780
|
+
const generationDeferrals = divergedEmbeddingGenerationDeferrals({
|
|
16781
|
+
incomingFiles: remoteSnapshotMetadata.files,
|
|
16782
|
+
baseFiles: syncBaseFiles,
|
|
16783
|
+
currentFiles: applyCurrentSnapshot.files
|
|
16784
|
+
});
|
|
16785
|
+
const pullDeferredPaths = [...remoteDeferredPaths, ...generationDeferrals];
|
|
16786
|
+
let stagedTransport;
|
|
16585
16787
|
try {
|
|
16586
|
-
|
|
16788
|
+
stagedTransport = await stageGenerationMembersForApply({
|
|
16789
|
+
memoryDir: options.memoryDir,
|
|
16587
16790
|
remoteUrl: options.remoteUrl,
|
|
16588
16791
|
token: options.token,
|
|
16589
16792
|
namespace: syncNamespace,
|
|
16590
16793
|
includeTranscripts: options.includeTranscripts,
|
|
16591
|
-
|
|
16592
|
-
baseFiles: syncBaseFiles,
|
|
16794
|
+
incomingFiles: remoteSnapshotMetadata.files,
|
|
16593
16795
|
currentFiles: applyCurrentSnapshot.files,
|
|
16594
|
-
deferredPaths:
|
|
16595
|
-
|
|
16796
|
+
deferredPaths: pullDeferredPaths,
|
|
16797
|
+
minBytes: options.generationStagedHydrateMinBytes ?? OFFLINE_SYNC_DIRECT_HYDRATE_MIN_BYTES,
|
|
16798
|
+
secureStoreEncryptOnWrite: options.secureStoreEncryptOnWrite,
|
|
16799
|
+
hydrateFileContent: hydrateOfflineFileContent
|
|
16596
16800
|
});
|
|
16597
16801
|
} catch (error) {
|
|
16598
16802
|
if (pushed || partialHydration.hydratedFiles.length > 0) {
|
|
@@ -16600,36 +16804,10 @@ async function runOfflineSyncOnce(options) {
|
|
|
16600
16804
|
}
|
|
16601
16805
|
throw error;
|
|
16602
16806
|
}
|
|
16603
|
-
const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshot, syncNamespace);
|
|
16604
|
-
let pull;
|
|
16605
16807
|
try {
|
|
16606
|
-
|
|
16607
|
-
pull = await applyOfflineSyncSnapshot({
|
|
16608
|
-
root: options.memoryDir,
|
|
16609
|
-
snapshot: remoteSnapshot,
|
|
16610
|
-
baseFiles: syncBaseFiles,
|
|
16611
|
-
currentFiles: latestApplySnapshot.files,
|
|
16612
|
-
deferredPaths: [...remoteDeferredPaths],
|
|
16613
|
-
allowMissingConflictContent: true,
|
|
16614
|
-
readFile: storageIo.readFile,
|
|
16615
|
-
readFileDigest: storageIo.readFileDigest,
|
|
16616
|
-
writeFile: storageIo.writeFile,
|
|
16617
|
-
deleteFile: storageIo.deleteFile,
|
|
16618
|
-
recordDeletionRevision: storageIo.recordDeletionRevision
|
|
16619
|
-
});
|
|
16620
|
-
} catch (error) {
|
|
16621
|
-
if (!isMissingOfflineContentError(error)) {
|
|
16622
|
-
if (pushed || partialHydration.hydratedFiles.length > 0) {
|
|
16623
|
-
return writePartialPushState(error, {
|
|
16624
|
-
...partialHydrationWithContext,
|
|
16625
|
-
resolvedNamespace
|
|
16626
|
-
});
|
|
16627
|
-
}
|
|
16628
|
-
throw error;
|
|
16629
|
-
}
|
|
16630
|
-
let retrySnapshot;
|
|
16808
|
+
let remoteSnapshot;
|
|
16631
16809
|
try {
|
|
16632
|
-
|
|
16810
|
+
remoteSnapshot = await hydrateOfflineSnapshotContent({
|
|
16633
16811
|
remoteUrl: options.remoteUrl,
|
|
16634
16812
|
token: options.token,
|
|
16635
16813
|
namespace: syncNamespace,
|
|
@@ -16637,69 +16815,126 @@ async function runOfflineSyncOnce(options) {
|
|
|
16637
16815
|
snapshot: remoteSnapshotMetadata,
|
|
16638
16816
|
baseFiles: syncBaseFiles,
|
|
16639
16817
|
currentFiles: applyCurrentSnapshot.files,
|
|
16640
|
-
deferredPaths:
|
|
16641
|
-
missingContentDeferredPaths: remoteDeferredPaths
|
|
16818
|
+
deferredPaths: pullDeferredPaths,
|
|
16819
|
+
missingContentDeferredPaths: remoteDeferredPaths,
|
|
16820
|
+
skipContentPaths: stagedTransport.stagedPaths
|
|
16642
16821
|
});
|
|
16643
|
-
} catch (
|
|
16822
|
+
} catch (error) {
|
|
16644
16823
|
if (pushed || partialHydration.hydratedFiles.length > 0) {
|
|
16645
|
-
return writePartialPushState(
|
|
16646
|
-
...partialHydrationWithContext,
|
|
16647
|
-
resolvedNamespace
|
|
16648
|
-
});
|
|
16824
|
+
return writePartialPushState(error, partialHydrationWithContext);
|
|
16649
16825
|
}
|
|
16650
|
-
throw
|
|
16826
|
+
throw error;
|
|
16651
16827
|
}
|
|
16828
|
+
const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshot, syncNamespace);
|
|
16829
|
+
let pull;
|
|
16652
16830
|
try {
|
|
16653
|
-
const
|
|
16831
|
+
const latestApplySnapshot = await buildCurrentSnapshotForApply();
|
|
16654
16832
|
pull = await applyOfflineSyncSnapshot({
|
|
16655
16833
|
root: options.memoryDir,
|
|
16656
|
-
snapshot:
|
|
16834
|
+
snapshot: remoteSnapshot,
|
|
16657
16835
|
baseFiles: syncBaseFiles,
|
|
16658
|
-
currentFiles:
|
|
16659
|
-
deferredPaths:
|
|
16836
|
+
currentFiles: latestApplySnapshot.files,
|
|
16837
|
+
deferredPaths: pullDeferredPaths,
|
|
16660
16838
|
allowMissingConflictContent: true,
|
|
16839
|
+
readIncomingFile: stagedTransport.readIncomingFile,
|
|
16661
16840
|
readFile: storageIo.readFile,
|
|
16662
16841
|
readFileDigest: storageIo.readFileDigest,
|
|
16663
16842
|
writeFile: storageIo.writeFile,
|
|
16843
|
+
writeStagingFile: storageIo.writeStagingFile,
|
|
16844
|
+
readStagingFile: storageIo.readStagingFile,
|
|
16664
16845
|
deleteFile: storageIo.deleteFile,
|
|
16665
16846
|
recordDeletionRevision: storageIo.recordDeletionRevision
|
|
16666
16847
|
});
|
|
16667
|
-
} catch (
|
|
16668
|
-
if (
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
|
|
16848
|
+
} catch (error) {
|
|
16849
|
+
if (!isMissingOfflineContentError(error)) {
|
|
16850
|
+
if (pushed || partialHydration.hydratedFiles.length > 0) {
|
|
16851
|
+
return writePartialPushState(error, {
|
|
16852
|
+
...partialHydrationWithContext,
|
|
16853
|
+
resolvedNamespace
|
|
16854
|
+
});
|
|
16855
|
+
}
|
|
16856
|
+
throw error;
|
|
16857
|
+
}
|
|
16858
|
+
let retrySnapshot;
|
|
16859
|
+
try {
|
|
16860
|
+
retrySnapshot = await hydrateOfflineSnapshotContent({
|
|
16861
|
+
remoteUrl: options.remoteUrl,
|
|
16862
|
+
token: options.token,
|
|
16863
|
+
namespace: syncNamespace,
|
|
16864
|
+
includeTranscripts: options.includeTranscripts,
|
|
16865
|
+
snapshot: remoteSnapshotMetadata,
|
|
16866
|
+
baseFiles: syncBaseFiles,
|
|
16867
|
+
currentFiles: applyCurrentSnapshot.files,
|
|
16868
|
+
deferredPaths: pullDeferredPaths,
|
|
16869
|
+
missingContentDeferredPaths: remoteDeferredPaths,
|
|
16870
|
+
skipContentPaths: stagedTransport.stagedPaths
|
|
16871
|
+
});
|
|
16872
|
+
} catch (retryError) {
|
|
16873
|
+
if (pushed || partialHydration.hydratedFiles.length > 0) {
|
|
16874
|
+
return writePartialPushState(retryError, {
|
|
16875
|
+
...partialHydrationWithContext,
|
|
16876
|
+
resolvedNamespace
|
|
16877
|
+
});
|
|
16878
|
+
}
|
|
16879
|
+
throw retryError;
|
|
16880
|
+
}
|
|
16881
|
+
try {
|
|
16882
|
+
const latestRetryApplySnapshot = await buildCurrentSnapshotForApply();
|
|
16883
|
+
pull = await applyOfflineSyncSnapshot({
|
|
16884
|
+
root: options.memoryDir,
|
|
16885
|
+
snapshot: retrySnapshot,
|
|
16886
|
+
baseFiles: syncBaseFiles,
|
|
16887
|
+
currentFiles: latestRetryApplySnapshot.files,
|
|
16888
|
+
deferredPaths: pullDeferredPaths,
|
|
16889
|
+
allowMissingConflictContent: true,
|
|
16890
|
+
readIncomingFile: stagedTransport.readIncomingFile,
|
|
16891
|
+
readFile: storageIo.readFile,
|
|
16892
|
+
readFileDigest: storageIo.readFileDigest,
|
|
16893
|
+
writeFile: storageIo.writeFile,
|
|
16894
|
+
writeStagingFile: storageIo.writeStagingFile,
|
|
16895
|
+
readStagingFile: storageIo.readStagingFile,
|
|
16896
|
+
deleteFile: storageIo.deleteFile,
|
|
16897
|
+
recordDeletionRevision: storageIo.recordDeletionRevision
|
|
16672
16898
|
});
|
|
16899
|
+
} catch (retryApplyError) {
|
|
16900
|
+
if (pushed || partialHydration.hydratedFiles.length > 0) {
|
|
16901
|
+
return writePartialPushState(retryApplyError, {
|
|
16902
|
+
...partialHydrationWithContext,
|
|
16903
|
+
resolvedNamespace
|
|
16904
|
+
});
|
|
16905
|
+
}
|
|
16906
|
+
throw retryApplyError;
|
|
16673
16907
|
}
|
|
16674
|
-
throw retryApplyError;
|
|
16675
16908
|
}
|
|
16676
|
-
|
|
16677
|
-
|
|
16678
|
-
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
await writeOfflineSyncState(statePath, state);
|
|
16686
|
-
}
|
|
16687
|
-
return {
|
|
16688
|
-
statePath: stateWritePaths[0] ?? activeStatePath,
|
|
16689
|
-
namespace: resolvedNamespace,
|
|
16690
|
-
prepared: priorState === null,
|
|
16691
|
-
pushed,
|
|
16692
|
-
pull,
|
|
16693
|
-
partial: false,
|
|
16694
|
-
pendingSummary,
|
|
16695
|
-
remoteFileCount: remoteSnapshot.files.length,
|
|
16696
|
-
largeFilePushFailures: [...directPushFailures],
|
|
16697
|
-
deferred: {
|
|
16698
|
-
localChangedDuringPush: [...directPushDeferredPaths].sort(),
|
|
16699
|
-
remoteChangedDuringHydrate: [...remoteDeferredPaths].sort(),
|
|
16700
|
-
total: directPushDeferredPaths.size + remoteDeferredPaths.size
|
|
16909
|
+
const state = offlineSyncStateFromSnapshot({
|
|
16910
|
+
remoteId: options.remoteUrl,
|
|
16911
|
+
namespace: resolvedNamespace,
|
|
16912
|
+
snapshot: remoteSnapshot,
|
|
16913
|
+
baseFiles: pull.nextBaseFiles
|
|
16914
|
+
});
|
|
16915
|
+
const stateWritePaths = stateWritePathsFor(resolvedNamespace);
|
|
16916
|
+
for (const statePath of stateWritePaths) {
|
|
16917
|
+
await writeOfflineSyncState(statePath, state);
|
|
16701
16918
|
}
|
|
16702
|
-
|
|
16919
|
+
return {
|
|
16920
|
+
statePath: stateWritePaths[0] ?? activeStatePath,
|
|
16921
|
+
namespace: resolvedNamespace,
|
|
16922
|
+
prepared: priorState === null,
|
|
16923
|
+
pushed,
|
|
16924
|
+
pull,
|
|
16925
|
+
partial: false,
|
|
16926
|
+
pendingSummary,
|
|
16927
|
+
remoteFileCount: remoteSnapshot.files.length,
|
|
16928
|
+
largeFilePushFailures: [...directPushFailures],
|
|
16929
|
+
deferred: {
|
|
16930
|
+
localChangedDuringPush: [...directPushDeferredPaths].sort(),
|
|
16931
|
+
remoteChangedDuringHydrate: [...remoteDeferredPaths].sort(),
|
|
16932
|
+
total: directPushDeferredPaths.size + remoteDeferredPaths.size
|
|
16933
|
+
}
|
|
16934
|
+
};
|
|
16935
|
+
} finally {
|
|
16936
|
+
await stagedTransport.cleanup();
|
|
16937
|
+
}
|
|
16703
16938
|
}
|
|
16704
16939
|
function sumOfflineFileBytes(files) {
|
|
16705
16940
|
return files.reduce((total, file) => total + file.bytes, 0);
|
|
@@ -16819,7 +17054,7 @@ Environment fallbacks:
|
|
|
16819
17054
|
REMNIC_OFFLINE_TOKEN > REMNIC_AUTH_TOKEN > ENGRAM_AUTH_TOKEN.`);
|
|
16820
17055
|
return;
|
|
16821
17056
|
}
|
|
16822
|
-
const memoryDir =
|
|
17057
|
+
const memoryDir = path24.resolve(expandTilde(resolveRequiredValueFlag(rest, "--memory-dir") ?? resolveMemoryDir()));
|
|
16823
17058
|
const namespace = resolveRequiredValueFlag(rest, "--namespace");
|
|
16824
17059
|
const includeTranscripts = !hasFlag(rest, "--no-transcripts");
|
|
16825
17060
|
const stateOverride = resolveRequiredValueFlag(rest, "--state");
|
|
@@ -16840,17 +17075,18 @@ Environment fallbacks:
|
|
|
16840
17075
|
const remoteUrl = needsRemote ? resolveOfflineRemoteUrl(rest) : resolveOptionalOfflineRemoteUrl(rest);
|
|
16841
17076
|
const knownAction = needsRemote || action === "status";
|
|
16842
17077
|
const token = knownAction ? resolveOfflineToken(rest) : void 0;
|
|
16843
|
-
const statePath = statePathExplicit ?
|
|
17078
|
+
const statePath = statePathExplicit ? path24.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
|
|
16844
17079
|
if (action === "prepare") {
|
|
16845
17080
|
if (!remoteUrl || !token || !statePath) throw new Error("offline prepare requires remote URL and token");
|
|
16846
17081
|
fs32.mkdirSync(memoryDir, { recursive: true });
|
|
16847
|
-
const
|
|
17082
|
+
const remoteSnapshotMetadata = await fetchOfflineSnapshot({
|
|
16848
17083
|
remoteUrl,
|
|
16849
17084
|
token,
|
|
16850
17085
|
namespace,
|
|
16851
|
-
includeTranscripts
|
|
17086
|
+
includeTranscripts,
|
|
17087
|
+
includeContent: false
|
|
16852
17088
|
});
|
|
16853
|
-
const resolvedNamespace = resolvedOfflineSnapshotNamespace(
|
|
17089
|
+
const resolvedNamespace = resolvedOfflineSnapshotNamespace(remoteSnapshotMetadata, namespace);
|
|
16854
17090
|
const stateWritePaths = offlineStatePathsForNamespace({
|
|
16855
17091
|
memoryDir,
|
|
16856
17092
|
remoteUrl,
|
|
@@ -16873,16 +17109,56 @@ Environment fallbacks:
|
|
|
16873
17109
|
memoryDir,
|
|
16874
17110
|
await createConfiguredOfflineStorage(memoryDir, config.secureStoreEncryptOnWrite)
|
|
16875
17111
|
);
|
|
16876
|
-
const
|
|
17112
|
+
const currentSnapshot = await buildOfflineSyncSnapshotFromBase2({
|
|
16877
17113
|
root: memoryDir,
|
|
16878
|
-
|
|
16879
|
-
|
|
17114
|
+
sourceId: "local",
|
|
17115
|
+
includeContent: false,
|
|
17116
|
+
includeTranscripts,
|
|
16880
17117
|
readFile: storageIo.readFile,
|
|
16881
17118
|
readFileDigest: storageIo.readFileDigest,
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
17119
|
+
excludeNodeLocalState: false
|
|
17120
|
+
});
|
|
17121
|
+
const stagedTransport = await stageGenerationMembersForApply({
|
|
17122
|
+
memoryDir,
|
|
17123
|
+
remoteUrl,
|
|
17124
|
+
token,
|
|
17125
|
+
namespace: resolvedNamespace,
|
|
17126
|
+
includeTranscripts,
|
|
17127
|
+
incomingFiles: remoteSnapshotMetadata.files,
|
|
17128
|
+
currentFiles: currentSnapshot.files,
|
|
17129
|
+
minBytes: OFFLINE_SYNC_DIRECT_HYDRATE_MIN_BYTES,
|
|
17130
|
+
secureStoreEncryptOnWrite: config.secureStoreEncryptOnWrite,
|
|
17131
|
+
hydrateFileContent: hydrateOfflineFileContent
|
|
16885
17132
|
});
|
|
17133
|
+
let remoteSnapshot;
|
|
17134
|
+
let pull;
|
|
17135
|
+
try {
|
|
17136
|
+
remoteSnapshot = await hydrateOfflineSnapshotContent({
|
|
17137
|
+
remoteUrl,
|
|
17138
|
+
token,
|
|
17139
|
+
namespace: resolvedNamespace,
|
|
17140
|
+
includeTranscripts,
|
|
17141
|
+
snapshot: remoteSnapshotMetadata,
|
|
17142
|
+
baseFiles: existingState?.state.baseFiles ?? [],
|
|
17143
|
+
currentFiles: currentSnapshot.files,
|
|
17144
|
+
skipContentPaths: stagedTransport.stagedPaths
|
|
17145
|
+
});
|
|
17146
|
+
pull = await applyOfflineSyncSnapshot({
|
|
17147
|
+
root: memoryDir,
|
|
17148
|
+
snapshot: remoteSnapshot,
|
|
17149
|
+
baseFiles: existingState?.state.baseFiles ?? [],
|
|
17150
|
+
readFile: storageIo.readFile,
|
|
17151
|
+
readFileDigest: storageIo.readFileDigest,
|
|
17152
|
+
writeFile: storageIo.writeFile,
|
|
17153
|
+
writeStagingFile: storageIo.writeStagingFile,
|
|
17154
|
+
readStagingFile: storageIo.readStagingFile,
|
|
17155
|
+
deleteFile: storageIo.deleteFile,
|
|
17156
|
+
recordDeletionRevision: storageIo.recordDeletionRevision,
|
|
17157
|
+
readIncomingFile: stagedTransport.readIncomingFile
|
|
17158
|
+
});
|
|
17159
|
+
} finally {
|
|
17160
|
+
await stagedTransport.cleanup();
|
|
17161
|
+
}
|
|
16886
17162
|
const state = offlineSyncStateFromSnapshot({
|
|
16887
17163
|
remoteId: remoteUrl,
|
|
16888
17164
|
namespace: resolvedNamespace,
|
|
@@ -17022,11 +17298,11 @@ Environment fallbacks:
|
|
|
17022
17298
|
failures: result.largeFilePushFailures
|
|
17023
17299
|
});
|
|
17024
17300
|
largeFileFailureCounts = advanced.counts;
|
|
17025
|
-
for (const
|
|
17026
|
-
if (skippedLargeFiles.has(
|
|
17027
|
-
skippedLargeFiles.add(
|
|
17301
|
+
for (const path25 of advanced.newlySkipped) {
|
|
17302
|
+
if (skippedLargeFiles.has(path25)) continue;
|
|
17303
|
+
skippedLargeFiles.add(path25);
|
|
17028
17304
|
console.warn(
|
|
17029
|
-
`offline sync: permanently skipping ${
|
|
17305
|
+
`offline sync: permanently skipping ${path25} 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)`
|
|
17030
17306
|
);
|
|
17031
17307
|
}
|
|
17032
17308
|
const pulled = result.pull ? result.pull.upserted + result.pull.deleted : 0;
|
|
@@ -17041,11 +17317,11 @@ Environment fallbacks:
|
|
|
17041
17317
|
failures: error.failures
|
|
17042
17318
|
});
|
|
17043
17319
|
largeFileFailureCounts = advanced.counts;
|
|
17044
|
-
for (const
|
|
17045
|
-
if (skippedLargeFiles.has(
|
|
17046
|
-
skippedLargeFiles.add(
|
|
17320
|
+
for (const path25 of advanced.newlySkipped) {
|
|
17321
|
+
if (skippedLargeFiles.has(path25)) continue;
|
|
17322
|
+
skippedLargeFiles.add(path25);
|
|
17047
17323
|
console.warn(
|
|
17048
|
-
`offline sync: permanently skipping ${
|
|
17324
|
+
`offline sync: permanently skipping ${path25} 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)`
|
|
17049
17325
|
);
|
|
17050
17326
|
}
|
|
17051
17327
|
}
|
|
@@ -17186,7 +17462,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
17186
17462
|
const connectorDaemonUrl = typeof effectiveConnectorConfig.remnicDaemonUrl === "string" && effectiveConnectorConfig.remnicDaemonUrl.trim().length > 0 ? effectiveConnectorConfig.remnicDaemonUrl.trim() : void 0;
|
|
17187
17463
|
const pubResult = await pub.publish({
|
|
17188
17464
|
config: { memoryDir, namespace: connectorNamespace, daemonUrl: connectorDaemonUrl },
|
|
17189
|
-
skillsRoot:
|
|
17465
|
+
skillsRoot: path24.join(memoryDir, "skills"),
|
|
17190
17466
|
rollbackTokenEntry: preInstallTokenEntry,
|
|
17191
17467
|
log: { info: console.log, warn: console.warn, error: console.error }
|
|
17192
17468
|
});
|
|
@@ -17546,15 +17822,15 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
|
|
|
17546
17822
|
}
|
|
17547
17823
|
const manifest = generateMarketplaceManifest();
|
|
17548
17824
|
await writeMarketplaceManifest(outputDir, manifest);
|
|
17549
|
-
const outPath =
|
|
17825
|
+
const outPath = path24.join(outputDir, "marketplace.json");
|
|
17550
17826
|
if (json) {
|
|
17551
17827
|
console.log(JSON.stringify({ status: "generated", path: outPath }, null, 2));
|
|
17552
17828
|
} else {
|
|
17553
17829
|
console.log(`Generated marketplace.json at ${outPath}`);
|
|
17554
17830
|
}
|
|
17555
17831
|
} else if (subAction === "validate") {
|
|
17556
|
-
const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ??
|
|
17557
|
-
const resolved =
|
|
17832
|
+
const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path24.join(process.cwd(), "marketplace.json");
|
|
17833
|
+
const resolved = path24.resolve(targetPath);
|
|
17558
17834
|
if (!fs32.existsSync(resolved)) {
|
|
17559
17835
|
console.error(`File not found: ${resolved}`);
|
|
17560
17836
|
process.exit(1);
|
|
@@ -17970,7 +18246,7 @@ async function cmdBench(rest) {
|
|
|
17970
18246
|
}
|
|
17971
18247
|
const completeCount = prevStatus.benchmarks.filter((b) => b.status === "complete").length;
|
|
17972
18248
|
const failedCount = prevStatus.benchmarks.filter((b) => b.status === "failed").length;
|
|
17973
|
-
printBenchStatusLine(parsed.json, `Resuming from: ${
|
|
18249
|
+
printBenchStatusLine(parsed.json, `Resuming from: ${path24.basename(latestStatusPath)}`);
|
|
17974
18250
|
printBenchStatusLine(parsed.json, ` Previous run: ${prevStatus.startedAt}`);
|
|
17975
18251
|
printBenchStatusLine(parsed.json, ` Benchmarks: ${prevStatus.benchmarks.length} total, ${completeCount} complete, ${failedCount} failed`);
|
|
17976
18252
|
const before = selectedBenchmarks.length;
|
|
@@ -18135,9 +18411,9 @@ Options:
|
|
|
18135
18411
|
);
|
|
18136
18412
|
process.exit(1);
|
|
18137
18413
|
} else {
|
|
18138
|
-
fixturePath =
|
|
18414
|
+
fixturePath = path24.resolve(expandTilde(fixturePathRaw));
|
|
18139
18415
|
}
|
|
18140
|
-
const outPath =
|
|
18416
|
+
const outPath = path24.resolve(expandTilde(outPathRaw));
|
|
18141
18417
|
const benchModule = await loadBenchModule();
|
|
18142
18418
|
const runner = benchModule.runProceduralAblationCli;
|
|
18143
18419
|
if (typeof runner !== "function") {
|
|
@@ -18156,7 +18432,7 @@ Options:
|
|
|
18156
18432
|
);
|
|
18157
18433
|
console.log(`wrote ${outPath}`);
|
|
18158
18434
|
}
|
|
18159
|
-
var LOGS_DIR =
|
|
18435
|
+
var LOGS_DIR = path24.join(PID_DIR, "logs");
|
|
18160
18436
|
var LAUNCHD_PLIST_PATHS = launchdPlistPaths(resolveHomeDir());
|
|
18161
18437
|
var [LAUNCHD_PLIST_PATH] = LAUNCHD_PLIST_PATHS;
|
|
18162
18438
|
var SYSTEMD_UNIT_PATHS = systemdUnitPaths(resolveHomeDir());
|
|
@@ -18233,7 +18509,7 @@ function selectLaunchdInspection(openclawPluginModeConfigured) {
|
|
|
18233
18509
|
for (const plistPath of LAUNCHD_PLIST_PATHS.slice(1)) {
|
|
18234
18510
|
const legacy = inspectLaunchdPlist(plistPath);
|
|
18235
18511
|
if (!legacy.installed) continue;
|
|
18236
|
-
const label =
|
|
18512
|
+
const label = path24.basename(plistPath, ".plist");
|
|
18237
18513
|
return legacy.ok ? {
|
|
18238
18514
|
...legacy,
|
|
18239
18515
|
warn: true,
|
|
@@ -18267,10 +18543,10 @@ function daemonInstall() {
|
|
|
18267
18543
|
const vars = { HOME: home, NODE_PATH: nodePath, REMNIC_SERVER_BIN: serverBin };
|
|
18268
18544
|
fs32.mkdirSync(LOGS_DIR, { recursive: true });
|
|
18269
18545
|
if (isMacOS()) {
|
|
18270
|
-
const templatePath =
|
|
18546
|
+
const templatePath = path24.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
|
|
18271
18547
|
const template = fs32.readFileSync(templatePath, "utf8");
|
|
18272
18548
|
const plist = renderTemplate(template, vars);
|
|
18273
|
-
fs32.mkdirSync(
|
|
18549
|
+
fs32.mkdirSync(path24.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
|
|
18274
18550
|
fs32.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
18275
18551
|
try {
|
|
18276
18552
|
launchdLoadPlist(LAUNCHD_PLIST_PATH);
|
|
@@ -18287,10 +18563,10 @@ function daemonInstall() {
|
|
|
18287
18563
|
console.log(` RunAtLoad: true, KeepAlive: true`);
|
|
18288
18564
|
console.log(` Logs: ${LOGS_DIR}/daemon.log`);
|
|
18289
18565
|
} else if (isLinux()) {
|
|
18290
|
-
const templatePath =
|
|
18566
|
+
const templatePath = path24.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
|
|
18291
18567
|
const template = fs32.readFileSync(templatePath, "utf8");
|
|
18292
18568
|
const unit = renderTemplate(template, vars);
|
|
18293
|
-
fs32.mkdirSync(
|
|
18569
|
+
fs32.mkdirSync(path24.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
|
|
18294
18570
|
fs32.writeFileSync(SYSTEMD_UNIT_PATH, unit);
|
|
18295
18571
|
try {
|
|
18296
18572
|
childProcess2.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
|
|
@@ -18789,7 +19065,7 @@ Clean complete: cleaned=${result.cleaned}`
|
|
|
18789
19065
|
}
|
|
18790
19066
|
async function cmdOpenclawInstall(opts) {
|
|
18791
19067
|
const configPath = resolveOpenclawConfigPath(opts.configPath);
|
|
18792
|
-
const fallbackMemoryDir =
|
|
19068
|
+
const fallbackMemoryDir = path24.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
18793
19069
|
console.log(`OpenClaw config: ${configPath}`);
|
|
18794
19070
|
const existingConfig = readOpenclawConfig(configPath);
|
|
18795
19071
|
const { plugins, entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
|
|
@@ -18892,7 +19168,7 @@ Remove it first and re-run, or choose a different path with --memory-dir.`
|
|
|
18892
19168
|
fs32.mkdirSync(memoryDir, { recursive: true });
|
|
18893
19169
|
console.log(`Created memory directory: ${memoryDir}`);
|
|
18894
19170
|
}
|
|
18895
|
-
const configDir =
|
|
19171
|
+
const configDir = path24.dirname(configPath);
|
|
18896
19172
|
if (!fs32.existsSync(configDir)) {
|
|
18897
19173
|
fs32.mkdirSync(configDir, { recursive: true });
|
|
18898
19174
|
}
|
|
@@ -18921,12 +19197,12 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
18921
19197
|
const pluginDir = resolveOpenclawPluginDir(opts.pluginDir);
|
|
18922
19198
|
const managedTargetDir = resolveOpenclawManagedPluginDir();
|
|
18923
19199
|
const legacyPluginDirForBackup = opts.legacyPluginDirForBackup ? resolveOpenclawLegacyPluginDir(opts.legacyPluginDirForBackup) : void 0;
|
|
18924
|
-
const fallbackMemoryDir =
|
|
19200
|
+
const fallbackMemoryDir = path24.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
18925
19201
|
const packageSpec = buildOpenclawManagedUpgradePackageSpec(opts.version);
|
|
18926
19202
|
const configExistedBefore = fs32.existsSync(configPath);
|
|
18927
19203
|
const existingConfig = readOpenclawConfig(configPath);
|
|
18928
19204
|
const { entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
|
|
18929
|
-
const preservedMemoryDir = opts.memoryDir ?
|
|
19205
|
+
const preservedMemoryDir = opts.memoryDir ? path24.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
|
|
18930
19206
|
console.log(`OpenClaw config: ${configPath}`);
|
|
18931
19207
|
console.log(`Plugin dir: ${pluginDir}`);
|
|
18932
19208
|
if (legacyPluginDirForBackup) {
|
|
@@ -18934,7 +19210,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
18934
19210
|
}
|
|
18935
19211
|
console.log(`Memory dir: ${preservedMemoryDir}`);
|
|
18936
19212
|
console.log(`Package spec: ${packageSpec}`);
|
|
18937
|
-
console.log(`Backup root: ${
|
|
19213
|
+
console.log(`Backup root: ${path24.join(resolveOpenclawStateDir(), "backups")}`);
|
|
18938
19214
|
const plannedActions = [
|
|
18939
19215
|
`backup openclaw.json and the existing ${REMNIC_OPENCLAW_PLUGIN_ID} extension`,
|
|
18940
19216
|
...legacyPluginDirForBackup ? [`backup the existing ${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID} extension without modifying it`] : [],
|
|
@@ -18972,9 +19248,9 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
18972
19248
|
assertDirectoryPathOrMissing(legacyPluginDirForBackup, "Legacy OpenClaw plugin dir");
|
|
18973
19249
|
}
|
|
18974
19250
|
const backupDir = createOpenclawUpgradeBackupDir();
|
|
18975
|
-
const configBackupPath =
|
|
18976
|
-
const pluginBackupDir =
|
|
18977
|
-
const legacyPluginBackupDir = legacyPluginDirForBackup ?
|
|
19251
|
+
const configBackupPath = path24.join(backupDir, "openclaw.json");
|
|
19252
|
+
const pluginBackupDir = path24.join(backupDir, "extensions", REMNIC_OPENCLAW_PLUGIN_ID);
|
|
19253
|
+
const legacyPluginBackupDir = legacyPluginDirForBackup ? path24.join(backupDir, "extensions", REMNIC_OPENCLAW_LEGACY_PLUGIN_ID) : void 0;
|
|
18978
19254
|
const backupNotes = [];
|
|
18979
19255
|
if (backupPathIfPresent(configPath, configBackupPath)) {
|
|
18980
19256
|
backupNotes.push(`+ Backed up config to ${configBackupPath}`);
|
|
@@ -19024,7 +19300,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
19024
19300
|
const managedRollbackDir = publishedInstallError ? publishedInstallError.managedRollbackDir : installResult?.managedRollbackDir;
|
|
19025
19301
|
const managedRollbackTargetDir = publishedInstallError?.managedRollbackTargetDir ?? installResult?.managedRollbackTargetDir ?? managedTargetDir;
|
|
19026
19302
|
const requiresHostManagedRestore = publishedInstallError?.requiresHostManagedRestore ?? installResult?.requiresHostManagedRestore ?? false;
|
|
19027
|
-
const managedRollbackSharesPluginDir = managedRollbackDir &&
|
|
19303
|
+
const managedRollbackSharesPluginDir = managedRollbackDir && path24.resolve(managedRollbackTargetDir) === path24.resolve(pluginDir);
|
|
19028
19304
|
const pluginRollbackDir = managedRollbackSharesPluginDir ? requiresHostManagedRestore ? rollbackDir : rollbackDir ?? managedRollbackDir : rollbackDir;
|
|
19029
19305
|
const shouldRestorePlugin = Boolean(
|
|
19030
19306
|
installResult && !requiresHostManagedRestore || pluginRollbackDir || publishedInstallError?.shouldRestoreBackup
|
|
@@ -19081,7 +19357,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
19081
19357
|
rollbackErrors.push(error);
|
|
19082
19358
|
}
|
|
19083
19359
|
if (pendingConfigRestoreError) rollbackErrors.push(pendingConfigRestoreError);
|
|
19084
|
-
if (managedRollbackDir &&
|
|
19360
|
+
if (managedRollbackDir && path24.resolve(managedRollbackTargetDir) !== path24.resolve(pluginDir) && !requiresHostManagedRestore) {
|
|
19085
19361
|
try {
|
|
19086
19362
|
rollbackNotes.push(
|
|
19087
19363
|
...rollbackOpenclawUpgrade({
|
|
@@ -19147,9 +19423,9 @@ async function cmdOpenclawMigrateEngram(opts) {
|
|
|
19147
19423
|
console.log(" - Re-apply any local source patches to the new package only after verifying the published build.");
|
|
19148
19424
|
}
|
|
19149
19425
|
function createOpenclawUpgradeBackupDir() {
|
|
19150
|
-
const backupsRoot =
|
|
19426
|
+
const backupsRoot = path24.join(resolveOpenclawStateDir(), "backups");
|
|
19151
19427
|
fs32.mkdirSync(backupsRoot, { recursive: true });
|
|
19152
|
-
return fs32.mkdtempSync(
|
|
19428
|
+
return fs32.mkdtempSync(path24.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
|
|
19153
19429
|
}
|
|
19154
19430
|
async function cmdTaxonomy(rest) {
|
|
19155
19431
|
initLogger5();
|
|
@@ -19191,8 +19467,8 @@ async function cmdTaxonomy(rest) {
|
|
|
19191
19467
|
const doc = generateResolverDocument(taxonomy);
|
|
19192
19468
|
console.log(doc);
|
|
19193
19469
|
if (config.taxonomyAutoGenResolver) {
|
|
19194
|
-
const resolverPath =
|
|
19195
|
-
fs32.mkdirSync(
|
|
19470
|
+
const resolverPath = path24.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
19471
|
+
fs32.mkdirSync(path24.dirname(resolverPath), { recursive: true });
|
|
19196
19472
|
fs32.writeFileSync(resolverPath, doc);
|
|
19197
19473
|
console.error(`Written: ${resolverPath}`);
|
|
19198
19474
|
}
|
|
@@ -19238,7 +19514,7 @@ async function cmdTaxonomy(rest) {
|
|
|
19238
19514
|
console.log(`Added category "${id}" (${name}).`);
|
|
19239
19515
|
if (config.taxonomyAutoGenResolver) {
|
|
19240
19516
|
const doc = generateResolverDocument(taxonomy);
|
|
19241
|
-
const resolverPath =
|
|
19517
|
+
const resolverPath = path24.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
19242
19518
|
fs32.writeFileSync(resolverPath, doc);
|
|
19243
19519
|
console.error(`Regenerated: ${resolverPath}`);
|
|
19244
19520
|
}
|
|
@@ -19269,7 +19545,7 @@ async function cmdTaxonomy(rest) {
|
|
|
19269
19545
|
console.log(`Removed category "${id}".`);
|
|
19270
19546
|
if (config.taxonomyAutoGenResolver) {
|
|
19271
19547
|
const doc = generateResolverDocument(taxonomy);
|
|
19272
|
-
const resolverPath =
|
|
19548
|
+
const resolverPath = path24.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
19273
19549
|
fs32.writeFileSync(resolverPath, doc);
|
|
19274
19550
|
console.error(`Regenerated: ${resolverPath}`);
|
|
19275
19551
|
}
|
|
@@ -19551,7 +19827,7 @@ async function runTrainingExport(args, stdout = process.stdout) {
|
|
|
19551
19827
|
);
|
|
19552
19828
|
}
|
|
19553
19829
|
const formatted = adapter.formatRecords(records);
|
|
19554
|
-
const outDir =
|
|
19830
|
+
const outDir = path24.dirname(args.output);
|
|
19555
19831
|
fs32.mkdirSync(outDir, { recursive: true });
|
|
19556
19832
|
const tmpPath = `${args.output}.tmp-${process.pid}-${Date.now()}`;
|
|
19557
19833
|
fs32.writeFileSync(tmpPath, formatted, "utf-8");
|
|
@@ -19680,7 +19956,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
19680
19956
|
case "tree": {
|
|
19681
19957
|
const subAction = rest[0];
|
|
19682
19958
|
const json = rest.includes("--json");
|
|
19683
|
-
const outputDir = resolveFlag(rest, "--output") ??
|
|
19959
|
+
const outputDir = resolveFlag(rest, "--output") ?? path24.join(process.cwd(), ".remnic", "context-tree");
|
|
19684
19960
|
const categoriesFlag = resolveFlag(rest, "--categories");
|
|
19685
19961
|
const categories = categoriesFlag ? categoriesFlag.split(",") : void 0;
|
|
19686
19962
|
const maxPerCategoryRaw = resolveFlag(rest, "--max-per-category");
|
|
@@ -19757,7 +20033,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
19757
20033
|
console.error(`Context tree not found at ${treeDir}. Run 'remnic tree generate' first.`);
|
|
19758
20034
|
process.exit(1);
|
|
19759
20035
|
}
|
|
19760
|
-
const indexPath =
|
|
20036
|
+
const indexPath = path24.join(treeDir, "INDEX.md");
|
|
19761
20037
|
if (!fs32.existsSync(indexPath)) {
|
|
19762
20038
|
console.error(`INDEX.md missing in ${treeDir}. Tree may be corrupt \u2014 regenerate.`);
|
|
19763
20039
|
process.exit(1);
|
|
@@ -20370,6 +20646,7 @@ export {
|
|
|
20370
20646
|
chunkOfflineChangesetApplyBatches,
|
|
20371
20647
|
chunkOfflineFileContentBatches,
|
|
20372
20648
|
directHydrateLargeOfflineFiles,
|
|
20649
|
+
divergedEmbeddingGenerationDeferrals2 as divergedEmbeddingGenerationDeferrals,
|
|
20373
20650
|
extractWhyRawArgs,
|
|
20374
20651
|
extractXrayRawArgs,
|
|
20375
20652
|
fetchOfflineSnapshot,
|
|
@@ -20377,6 +20654,7 @@ export {
|
|
|
20377
20654
|
formatOfflineRequestForError,
|
|
20378
20655
|
hasFlag,
|
|
20379
20656
|
hashCalibrationProviderConfig,
|
|
20657
|
+
hydrateOfflineFileContent,
|
|
20380
20658
|
hydrateOfflineSnapshotContent,
|
|
20381
20659
|
isOfflineMissingContentDeferrablePath,
|
|
20382
20660
|
isOfflineSnapshotPostFallbackError,
|