@remnic/cli 9.54.7 → 9.55.0
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 +303 -255
- package/package.json +31 -31
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ async function persistEnrichmentCandidate(storage, entityName, candidate) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
import
|
|
21
|
+
import fs15 from "fs";
|
|
22
22
|
import os3 from "os";
|
|
23
23
|
import path17 from "path";
|
|
24
24
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -26,13 +26,13 @@ import * as childProcess2 from "child_process";
|
|
|
26
26
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
27
27
|
import { gzipSync } from "zlib";
|
|
28
28
|
import {
|
|
29
|
-
parseConfig as
|
|
29
|
+
parseConfig as parseConfig7,
|
|
30
30
|
isOpenaiApiKeyDisabled,
|
|
31
31
|
resolveEnvVars,
|
|
32
|
-
resolveRemnicConfigRecord as
|
|
33
|
-
Orchestrator as
|
|
32
|
+
resolveRemnicConfigRecord as resolveRemnicConfigRecord6,
|
|
33
|
+
Orchestrator as Orchestrator4,
|
|
34
34
|
EngramAccessService as EngramAccessService2,
|
|
35
|
-
initLogger as
|
|
35
|
+
initLogger as initLogger3,
|
|
36
36
|
onboard,
|
|
37
37
|
curate,
|
|
38
38
|
listReviewItems,
|
|
@@ -2466,8 +2466,53 @@ function assertBenchModuleFreshForDevelopment() {
|
|
|
2466
2466
|
assertLocalBenchBuildFreshForDevelopment(import.meta.url);
|
|
2467
2467
|
}
|
|
2468
2468
|
|
|
2469
|
-
// src/
|
|
2469
|
+
// src/cmd-security.ts
|
|
2470
2470
|
import fs7 from "fs";
|
|
2471
|
+
import {
|
|
2472
|
+
Orchestrator as Orchestrator3,
|
|
2473
|
+
parseConfig as parseConfig6,
|
|
2474
|
+
initLogger as initLogger2,
|
|
2475
|
+
resolveRemnicConfigRecord as resolveRemnicConfigRecord5,
|
|
2476
|
+
runAuditMemoryCliCommand,
|
|
2477
|
+
formatAuditMemoryReport
|
|
2478
|
+
} from "@remnic/core";
|
|
2479
|
+
async function cmdSecurity(rest) {
|
|
2480
|
+
const action = rest[0] ?? "help";
|
|
2481
|
+
if (action !== "audit-memory") {
|
|
2482
|
+
console.error(
|
|
2483
|
+
"Unknown security subcommand. Usage: remnic security audit-memory [--since <iso-date>] [--quarantine] [--json]"
|
|
2484
|
+
);
|
|
2485
|
+
process.exitCode = 1;
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
initLogger2();
|
|
2489
|
+
const configPath = resolveConfigPath();
|
|
2490
|
+
const raw = fs7.existsSync(configPath) ? JSON.parse(fs7.readFileSync(configPath, "utf8")) : {};
|
|
2491
|
+
const config = parseConfig6(resolveRemnicConfigRecord5(raw));
|
|
2492
|
+
const orchestrator = new Orchestrator3(config);
|
|
2493
|
+
await orchestrator.initialize();
|
|
2494
|
+
try {
|
|
2495
|
+
const sinceFlag = rest.indexOf("--since");
|
|
2496
|
+
if (sinceFlag >= 0 && !rest[sinceFlag + 1]) {
|
|
2497
|
+
console.error("--since requires a value");
|
|
2498
|
+
process.exitCode = 1;
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2501
|
+
const json = rest.includes("--json");
|
|
2502
|
+
const report = await runAuditMemoryCliCommand({
|
|
2503
|
+
memoryDir: config.memoryDir,
|
|
2504
|
+
storage: orchestrator.storage,
|
|
2505
|
+
since: sinceFlag >= 0 ? rest[sinceFlag + 1] : void 0,
|
|
2506
|
+
quarantine: rest.includes("--quarantine")
|
|
2507
|
+
});
|
|
2508
|
+
console.log(json ? JSON.stringify(report, null, 2) : formatAuditMemoryReport(report));
|
|
2509
|
+
} finally {
|
|
2510
|
+
orchestrator.abortDeferredInit();
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
// src/daemon-service-candidates.ts
|
|
2515
|
+
import fs8 from "fs";
|
|
2471
2516
|
import path5 from "path";
|
|
2472
2517
|
var LAUNCHD_LABEL = "ai.remnic.daemon";
|
|
2473
2518
|
var LEGACY_REMNIC_SERVER_LAUNCHD_LABEL = "ai.remnic.server";
|
|
@@ -2489,7 +2534,7 @@ function systemdUnitPaths(homeDir) {
|
|
|
2489
2534
|
function anyFileExists(paths) {
|
|
2490
2535
|
return paths.some((candidate) => {
|
|
2491
2536
|
try {
|
|
2492
|
-
return
|
|
2537
|
+
return fs8.statSync(candidate).isFile();
|
|
2493
2538
|
} catch {
|
|
2494
2539
|
return false;
|
|
2495
2540
|
}
|
|
@@ -2501,7 +2546,7 @@ function commandNames(command) {
|
|
|
2501
2546
|
}
|
|
2502
2547
|
function isRunnableNodeScript(filePath) {
|
|
2503
2548
|
try {
|
|
2504
|
-
const text =
|
|
2549
|
+
const text = fs8.readFileSync(filePath, "utf8").slice(0, 4096);
|
|
2505
2550
|
const firstLine = text.split(/\r?\n/, 1)[0] ?? "";
|
|
2506
2551
|
if (/^#!.*\bnode\b/.test(firstLine)) return true;
|
|
2507
2552
|
if (firstLine.startsWith("#!")) return false;
|
|
@@ -2514,7 +2559,7 @@ function isRunnableNodeScript(filePath) {
|
|
|
2514
2559
|
function resolveShimNodeScript(filePath) {
|
|
2515
2560
|
let text;
|
|
2516
2561
|
try {
|
|
2517
|
-
text =
|
|
2562
|
+
text = fs8.readFileSync(filePath, "utf8").slice(0, 16384);
|
|
2518
2563
|
} catch {
|
|
2519
2564
|
return void 0;
|
|
2520
2565
|
}
|
|
@@ -2526,8 +2571,8 @@ function resolveShimNodeScript(filePath) {
|
|
|
2526
2571
|
const candidate = raw.replaceAll("${basedir}", basedir).replaceAll("$basedir", basedir).replaceAll("\\ ", " ");
|
|
2527
2572
|
const resolved = path5.isAbsolute(candidate) ? candidate : path5.resolve(basedir, candidate);
|
|
2528
2573
|
try {
|
|
2529
|
-
if (
|
|
2530
|
-
return
|
|
2574
|
+
if (fs8.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
|
|
2575
|
+
return fs8.realpathSync(resolved);
|
|
2531
2576
|
}
|
|
2532
2577
|
} catch {
|
|
2533
2578
|
}
|
|
@@ -2535,7 +2580,7 @@ function resolveShimNodeScript(filePath) {
|
|
|
2535
2580
|
return void 0;
|
|
2536
2581
|
}
|
|
2537
2582
|
function resolveRunnableNodeScript(filePath) {
|
|
2538
|
-
const realPath =
|
|
2583
|
+
const realPath = fs8.realpathSync(filePath);
|
|
2539
2584
|
if (isRunnableNodeScript(realPath)) return realPath;
|
|
2540
2585
|
return resolveShimNodeScript(realPath);
|
|
2541
2586
|
}
|
|
@@ -2545,9 +2590,9 @@ function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
|
|
|
2545
2590
|
for (const name of commandNames(command)) {
|
|
2546
2591
|
const candidate = path5.join(dir, name);
|
|
2547
2592
|
try {
|
|
2548
|
-
const stat2 =
|
|
2593
|
+
const stat2 = fs8.statSync(candidate);
|
|
2549
2594
|
if (!stat2.isFile()) continue;
|
|
2550
|
-
if (process.platform !== "win32")
|
|
2595
|
+
if (process.platform !== "win32") fs8.accessSync(candidate, fs8.constants.X_OK);
|
|
2551
2596
|
const runnable = resolveRunnableNodeScript(candidate);
|
|
2552
2597
|
if (runnable) return runnable;
|
|
2553
2598
|
} catch {
|
|
@@ -4038,7 +4083,7 @@ function finalizeBenchStatus(filePath) {
|
|
|
4038
4083
|
}
|
|
4039
4084
|
|
|
4040
4085
|
// src/bench-fallback.ts
|
|
4041
|
-
import
|
|
4086
|
+
import fs9 from "fs";
|
|
4042
4087
|
import path9 from "path";
|
|
4043
4088
|
var FALLBACK_RESULTS_DIRNAME = "fallback-runs";
|
|
4044
4089
|
function buildBenchRunnerArgs(parsed, benchmarkId, outputDir) {
|
|
@@ -4110,7 +4155,7 @@ function createFallbackBenchOutputDir(resultsDir, benchmarkId, pid, startedAtMs
|
|
|
4110
4155
|
);
|
|
4111
4156
|
}
|
|
4112
4157
|
function resolveFallbackBenchResultPath(outputDir) {
|
|
4113
|
-
const entries =
|
|
4158
|
+
const entries = fs9.readdirSync(outputDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name).sort();
|
|
4114
4159
|
if (entries.length === 0) {
|
|
4115
4160
|
throw new Error(`Fallback benchmark runner did not write a JSON result artifact in ${outputDir}`);
|
|
4116
4161
|
}
|
|
@@ -4118,7 +4163,7 @@ function resolveFallbackBenchResultPath(outputDir) {
|
|
|
4118
4163
|
}
|
|
4119
4164
|
|
|
4120
4165
|
// src/openclaw-upgrade-swap.ts
|
|
4121
|
-
import
|
|
4166
|
+
import fs10 from "fs";
|
|
4122
4167
|
import path10 from "path";
|
|
4123
4168
|
function describeError(error) {
|
|
4124
4169
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -4130,7 +4175,7 @@ function createSiblingTempFilePath(targetPath, label) {
|
|
|
4130
4175
|
function resolveAtomicWriteMode(targetPath, explicitMode) {
|
|
4131
4176
|
if (explicitMode !== void 0) return explicitMode;
|
|
4132
4177
|
try {
|
|
4133
|
-
return
|
|
4178
|
+
return fs10.statSync(targetPath).mode & 4095;
|
|
4134
4179
|
} catch (error) {
|
|
4135
4180
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
4136
4181
|
return 384;
|
|
@@ -4140,8 +4185,8 @@ function resolveAtomicWriteMode(targetPath, explicitMode) {
|
|
|
4140
4185
|
}
|
|
4141
4186
|
function resolveAtomicReplacementPath(targetPath) {
|
|
4142
4187
|
try {
|
|
4143
|
-
if (
|
|
4144
|
-
return
|
|
4188
|
+
if (fs10.lstatSync(targetPath).isSymbolicLink()) {
|
|
4189
|
+
return fs10.realpathSync(targetPath);
|
|
4145
4190
|
}
|
|
4146
4191
|
} catch (error) {
|
|
4147
4192
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -4158,7 +4203,7 @@ function createSiblingSwapPath(targetDir, label) {
|
|
|
4158
4203
|
function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
4159
4204
|
if (!displacedDir) return void 0;
|
|
4160
4205
|
try {
|
|
4161
|
-
|
|
4206
|
+
fs10.rmSync(displacedDir, { recursive: true, force: true });
|
|
4162
4207
|
return void 0;
|
|
4163
4208
|
} catch (error) {
|
|
4164
4209
|
return `Warning: ${context}, but failed to remove the displaced plugin copy at ${displacedDir}: ${describeError(error)}`;
|
|
@@ -4166,43 +4211,43 @@ function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
|
4166
4211
|
}
|
|
4167
4212
|
function atomicWriteFileSync(targetPath, data, options = {}) {
|
|
4168
4213
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
4169
|
-
|
|
4214
|
+
fs10.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
|
|
4170
4215
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "write");
|
|
4171
4216
|
const mode = resolveAtomicWriteMode(resolvedTargetPath, options.mode);
|
|
4172
4217
|
try {
|
|
4173
4218
|
if (options.hooks?.writeTempFileSync) {
|
|
4174
4219
|
options.hooks.writeTempFileSync(tempPath);
|
|
4175
4220
|
} else {
|
|
4176
|
-
|
|
4221
|
+
fs10.writeFileSync(tempPath, data, { mode });
|
|
4177
4222
|
}
|
|
4178
|
-
|
|
4179
|
-
const renameTempFileSync = options.hooks?.renameTempFileSync ??
|
|
4223
|
+
fs10.chmodSync(tempPath, mode);
|
|
4224
|
+
const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs10.renameSync;
|
|
4180
4225
|
renameTempFileSync(tempPath, resolvedTargetPath);
|
|
4181
4226
|
} catch (error) {
|
|
4182
|
-
|
|
4227
|
+
fs10.rmSync(tempPath, { force: true });
|
|
4183
4228
|
throw error;
|
|
4184
4229
|
}
|
|
4185
4230
|
}
|
|
4186
4231
|
function atomicCopyFileSync(sourcePath, targetPath, options = {}) {
|
|
4187
|
-
if (!
|
|
4232
|
+
if (!fs10.existsSync(sourcePath)) return;
|
|
4188
4233
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
4189
|
-
|
|
4234
|
+
fs10.mkdirSync(path10.dirname(resolvedTargetPath), { recursive: true });
|
|
4190
4235
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "copy");
|
|
4191
|
-
const mode =
|
|
4236
|
+
const mode = fs10.statSync(sourcePath).mode & 4095;
|
|
4192
4237
|
try {
|
|
4193
|
-
const copyTempFileSync = options.hooks?.copyTempFileSync ??
|
|
4238
|
+
const copyTempFileSync = options.hooks?.copyTempFileSync ?? fs10.copyFileSync;
|
|
4194
4239
|
copyTempFileSync(sourcePath, tempPath);
|
|
4195
|
-
|
|
4196
|
-
const renameTempFileSync = options.hooks?.renameTempFileSync ??
|
|
4240
|
+
fs10.chmodSync(tempPath, mode);
|
|
4241
|
+
const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs10.renameSync;
|
|
4197
4242
|
renameTempFileSync(tempPath, resolvedTargetPath);
|
|
4198
4243
|
} catch (error) {
|
|
4199
|
-
|
|
4244
|
+
fs10.rmSync(tempPath, { force: true });
|
|
4200
4245
|
throw error;
|
|
4201
4246
|
}
|
|
4202
4247
|
}
|
|
4203
4248
|
function cleanupRollbackDirectory(rollbackDir) {
|
|
4204
4249
|
if (!rollbackDir) return;
|
|
4205
|
-
|
|
4250
|
+
fs10.rmSync(rollbackDir, { recursive: true, force: true });
|
|
4206
4251
|
}
|
|
4207
4252
|
function cleanupRollbackDirectoryBestEffort(rollbackDir) {
|
|
4208
4253
|
if (!rollbackDir) return void 0;
|
|
@@ -4214,20 +4259,20 @@ function cleanupRollbackDirectoryBestEffort(rollbackDir) {
|
|
|
4214
4259
|
}
|
|
4215
4260
|
}
|
|
4216
4261
|
function restoreDirectoryFromRollback(targetDir, rollbackDir) {
|
|
4217
|
-
if (!
|
|
4262
|
+
if (!fs10.existsSync(rollbackDir)) {
|
|
4218
4263
|
throw new Error(`Rollback directory is missing: ${rollbackDir}`);
|
|
4219
4264
|
}
|
|
4220
|
-
|
|
4221
|
-
const displacedDir =
|
|
4265
|
+
fs10.mkdirSync(path10.dirname(targetDir), { recursive: true });
|
|
4266
|
+
const displacedDir = fs10.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
|
|
4222
4267
|
if (displacedDir) {
|
|
4223
|
-
|
|
4268
|
+
fs10.renameSync(targetDir, displacedDir);
|
|
4224
4269
|
}
|
|
4225
4270
|
try {
|
|
4226
|
-
|
|
4271
|
+
fs10.renameSync(rollbackDir, targetDir);
|
|
4227
4272
|
} catch (restoreError) {
|
|
4228
|
-
if (displacedDir &&
|
|
4273
|
+
if (displacedDir && fs10.existsSync(displacedDir)) {
|
|
4229
4274
|
try {
|
|
4230
|
-
|
|
4275
|
+
fs10.renameSync(displacedDir, targetDir);
|
|
4231
4276
|
} catch (revertError) {
|
|
4232
4277
|
throw new AggregateError(
|
|
4233
4278
|
[restoreError, revertError],
|
|
@@ -4243,23 +4288,23 @@ function restoreDirectoryFromRollback(targetDir, rollbackDir) {
|
|
|
4243
4288
|
return cleanupDisplacedDirectoryBestEffort(displacedDir, `restored the previous plugin copy into ${targetDir}`);
|
|
4244
4289
|
}
|
|
4245
4290
|
function restoreDirectoryFromBackup(targetDir, backupDir) {
|
|
4246
|
-
if (!
|
|
4291
|
+
if (!fs10.existsSync(backupDir)) {
|
|
4247
4292
|
throw new Error(`Plugin backup directory is missing: ${backupDir}`);
|
|
4248
4293
|
}
|
|
4249
|
-
|
|
4294
|
+
fs10.mkdirSync(path10.dirname(targetDir), { recursive: true });
|
|
4250
4295
|
const stagedDir = createSiblingSwapPath(targetDir, "backup-restore");
|
|
4251
|
-
const displacedDir =
|
|
4252
|
-
|
|
4296
|
+
const displacedDir = fs10.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
|
|
4297
|
+
fs10.cpSync(backupDir, stagedDir, { recursive: true });
|
|
4253
4298
|
if (displacedDir) {
|
|
4254
|
-
|
|
4299
|
+
fs10.renameSync(targetDir, displacedDir);
|
|
4255
4300
|
}
|
|
4256
4301
|
try {
|
|
4257
|
-
|
|
4302
|
+
fs10.renameSync(stagedDir, targetDir);
|
|
4258
4303
|
} catch (restoreError) {
|
|
4259
|
-
|
|
4260
|
-
if (displacedDir &&
|
|
4304
|
+
fs10.rmSync(targetDir, { recursive: true, force: true });
|
|
4305
|
+
if (displacedDir && fs10.existsSync(displacedDir)) {
|
|
4261
4306
|
try {
|
|
4262
|
-
|
|
4307
|
+
fs10.renameSync(displacedDir, targetDir);
|
|
4263
4308
|
} catch (revertError) {
|
|
4264
4309
|
throw new AggregateError(
|
|
4265
4310
|
[restoreError, revertError],
|
|
@@ -4267,7 +4312,7 @@ function restoreDirectoryFromBackup(targetDir, backupDir) {
|
|
|
4267
4312
|
);
|
|
4268
4313
|
}
|
|
4269
4314
|
}
|
|
4270
|
-
|
|
4315
|
+
fs10.rmSync(stagedDir, { recursive: true, force: true });
|
|
4271
4316
|
throw new Error(
|
|
4272
4317
|
`Failed to restore the plugin backup into ${targetDir}. The durable backup remains preserved at ${backupDir}.`,
|
|
4273
4318
|
{ cause: restoreError }
|
|
@@ -4292,7 +4337,7 @@ function rollbackOpenclawUpgrade({
|
|
|
4292
4337
|
let configRemovalAttempted = false;
|
|
4293
4338
|
let pluginRestored = false;
|
|
4294
4339
|
try {
|
|
4295
|
-
if (rollbackDir &&
|
|
4340
|
+
if (rollbackDir && fs10.existsSync(rollbackDir)) {
|
|
4296
4341
|
const cleanupWarning = restoreDirectoryFromRollback(pluginDir, rollbackDir);
|
|
4297
4342
|
notes.push(`Restored previous plugin from rollback copy at ${rollbackDir}`);
|
|
4298
4343
|
if (cleanupWarning) notes.push(cleanupWarning);
|
|
@@ -4302,7 +4347,7 @@ function rollbackOpenclawUpgrade({
|
|
|
4302
4347
|
rollbackRestoreError = error instanceof Error ? error.message : String(error);
|
|
4303
4348
|
}
|
|
4304
4349
|
try {
|
|
4305
|
-
if (!pluginRestored && pluginBackupDir &&
|
|
4350
|
+
if (!pluginRestored && pluginBackupDir && fs10.existsSync(pluginBackupDir)) {
|
|
4306
4351
|
const cleanupWarning = restoreDirectoryFromBackup(pluginDir, pluginBackupDir);
|
|
4307
4352
|
if (rollbackRestoreError) {
|
|
4308
4353
|
notes.push(`Rollback copy restore failed; restored previous plugin from durable backup at ${pluginBackupDir}`);
|
|
@@ -4327,12 +4372,12 @@ function rollbackOpenclawUpgrade({
|
|
|
4327
4372
|
notes.push("No previous plugin copy was available for automatic restore");
|
|
4328
4373
|
}
|
|
4329
4374
|
try {
|
|
4330
|
-
if (configBackupPath &&
|
|
4375
|
+
if (configBackupPath && fs10.existsSync(configBackupPath)) {
|
|
4331
4376
|
restoreFileFromBackup(configPath, configBackupPath);
|
|
4332
4377
|
notes.push(`Restored OpenClaw config from backup at ${configBackupPath}`);
|
|
4333
|
-
} else if (removeConfigIfUnbacked &&
|
|
4378
|
+
} else if (removeConfigIfUnbacked && fs10.existsSync(configPath)) {
|
|
4334
4379
|
configRemovalAttempted = true;
|
|
4335
|
-
|
|
4380
|
+
fs10.rmSync(configPath, { force: true });
|
|
4336
4381
|
notes.push("Removed OpenClaw config created during the failed upgrade");
|
|
4337
4382
|
}
|
|
4338
4383
|
} catch (error) {
|
|
@@ -4385,7 +4430,7 @@ Run this manually when you're ready:
|
|
|
4385
4430
|
|
|
4386
4431
|
// src/openclaw-managed-upgrade-loader.ts
|
|
4387
4432
|
import { execFileSync } from "child_process";
|
|
4388
|
-
import
|
|
4433
|
+
import fs11 from "fs";
|
|
4389
4434
|
import os from "os";
|
|
4390
4435
|
import path11 from "path";
|
|
4391
4436
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "url";
|
|
@@ -4461,7 +4506,7 @@ function buildOpenclawManagedUpgradePackageSpec(version = "latest") {
|
|
|
4461
4506
|
function readCliAdapterRange() {
|
|
4462
4507
|
const moduleDir = path11.dirname(fileURLToPath3(import.meta.url));
|
|
4463
4508
|
const manifestPath = path11.resolve(moduleDir, "../package.json");
|
|
4464
|
-
const manifest = JSON.parse(
|
|
4509
|
+
const manifest = JSON.parse(fs11.readFileSync(manifestPath, "utf8"));
|
|
4465
4510
|
if (manifest.name !== "@remnic/cli") {
|
|
4466
4511
|
throw new Error(`Invalid @remnic/cli package manifest at ${manifestPath}.`);
|
|
4467
4512
|
}
|
|
@@ -4505,7 +4550,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
4505
4550
|
const adapterMissing = isSpecifierNotFoundError(error, OPENCLAW_PLUGIN_PACKAGE) || isSpecifierNotFoundError(error, MANAGED_UPGRADE_SPECIFIER) || isManagedUpgradeSubpathMissing(error);
|
|
4506
4551
|
if (!adapterMissing) throw error;
|
|
4507
4552
|
}
|
|
4508
|
-
const temporaryRoot =
|
|
4553
|
+
const temporaryRoot = fs11.mkdtempSync(path11.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
|
|
4509
4554
|
try {
|
|
4510
4555
|
const toolingPackageSpec = `${OPENCLAW_PLUGIN_PACKAGE}@${readCliAdapterRange()}`;
|
|
4511
4556
|
const installArgs = [
|
|
@@ -4520,12 +4565,12 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
4520
4565
|
];
|
|
4521
4566
|
(hooks.runNpmInstall ?? runNpmInstall)(installArgs);
|
|
4522
4567
|
const resolverPath = path11.join(temporaryRoot, "load-managed-upgrade.mjs");
|
|
4523
|
-
|
|
4568
|
+
fs11.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
|
|
4524
4569
|
`, "utf8");
|
|
4525
4570
|
return await importModule(pathToFileURL2(resolverPath).href);
|
|
4526
4571
|
} finally {
|
|
4527
4572
|
try {
|
|
4528
|
-
|
|
4573
|
+
fs11.rmSync(temporaryRoot, { recursive: true, force: true });
|
|
4529
4574
|
} catch (error) {
|
|
4530
4575
|
const detail = error instanceof Error ? error.message : String(error);
|
|
4531
4576
|
console.warn(`Could not remove temporary managed upgrade project at ${temporaryRoot}: ${detail}`);
|
|
@@ -4534,7 +4579,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
4534
4579
|
}
|
|
4535
4580
|
|
|
4536
4581
|
// src/daemon-service.ts
|
|
4537
|
-
import
|
|
4582
|
+
import fs12 from "fs";
|
|
4538
4583
|
import path12 from "path";
|
|
4539
4584
|
import * as childProcess from "child_process";
|
|
4540
4585
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -4546,7 +4591,7 @@ function launchdUnloadPlist(plistPath, processApi = childProcess) {
|
|
|
4546
4591
|
processApi.execFileSync("launchctl", ["unload", plistPath], { stdio: "pipe" });
|
|
4547
4592
|
}
|
|
4548
4593
|
function resolveServerBinDetails(options = {}) {
|
|
4549
|
-
const existsSync4 = options.existsSync ??
|
|
4594
|
+
const existsSync4 = options.existsSync ?? fs12.existsSync;
|
|
4550
4595
|
const findCommandOnPath2 = options.findCommandOnPath ?? findCommandOnPath;
|
|
4551
4596
|
const moduleDir = options.moduleDir ?? thisModuleDir;
|
|
4552
4597
|
const packageResolve = options.packageResolve ?? resolveImportSpecifier;
|
|
@@ -4605,8 +4650,8 @@ function resolveServerBin(options = {}) {
|
|
|
4605
4650
|
return resolveServerBinDetails(options).path;
|
|
4606
4651
|
}
|
|
4607
4652
|
function readVerifiedDaemonPid(options) {
|
|
4608
|
-
const readFileSync4 = options.readFileSync ??
|
|
4609
|
-
const unlinkSync = options.unlinkSync ??
|
|
4653
|
+
const readFileSync4 = options.readFileSync ?? fs12.readFileSync;
|
|
4654
|
+
const unlinkSync = options.unlinkSync ?? fs12.unlinkSync;
|
|
4610
4655
|
const processKill = options.processKill ?? process.kill;
|
|
4611
4656
|
const platform = options.platform ?? process.platform;
|
|
4612
4657
|
const execFileSync4 = options.execFileSync ?? ((command, args, execOptions) => childProcess.execFileSync(command, args, execOptions));
|
|
@@ -4706,8 +4751,8 @@ function removePidFileBestEffort(file, unlinkSync) {
|
|
|
4706
4751
|
}
|
|
4707
4752
|
}
|
|
4708
4753
|
function inspectLaunchdPlist(plistPath, options = {}) {
|
|
4709
|
-
const existsSync4 = options.existsSync ??
|
|
4710
|
-
const readFileSync4 = options.readFileSync ??
|
|
4754
|
+
const existsSync4 = options.existsSync ?? fs12.existsSync;
|
|
4755
|
+
const readFileSync4 = options.readFileSync ?? fs12.readFileSync;
|
|
4711
4756
|
if (!existsSync4(plistPath)) {
|
|
4712
4757
|
return {
|
|
4713
4758
|
installed: false,
|
|
@@ -4941,7 +4986,7 @@ function stripConfigArgv(args) {
|
|
|
4941
4986
|
}
|
|
4942
4987
|
|
|
4943
4988
|
// src/import-dispatch.ts
|
|
4944
|
-
import
|
|
4989
|
+
import fs13 from "fs";
|
|
4945
4990
|
import {
|
|
4946
4991
|
runImporter,
|
|
4947
4992
|
validateImportBatchSize,
|
|
@@ -5455,7 +5500,7 @@ async function cmdImport(rest, targetFactory, disposeTarget, ioOverrides = {}) {
|
|
|
5455
5500
|
let materializedTarget;
|
|
5456
5501
|
let materializePromise;
|
|
5457
5502
|
const io = {
|
|
5458
|
-
readFile: ioOverrides.readFile ?? (async (p) =>
|
|
5503
|
+
readFile: ioOverrides.readFile ?? (async (p) => fs13.promises.readFile(p, "utf-8")),
|
|
5459
5504
|
loadAdapter: ioOverrides.loadAdapter ?? (async (name) => (await loadImporterModule(name)).adapter),
|
|
5460
5505
|
runImporter: ioOverrides.runImporter ?? runImporter,
|
|
5461
5506
|
getWriteTarget: async () => {
|
|
@@ -5568,7 +5613,7 @@ async function cmdCapture(rest, io) {
|
|
|
5568
5613
|
}
|
|
5569
5614
|
|
|
5570
5615
|
// src/import-lossless-claw-cmd.ts
|
|
5571
|
-
import
|
|
5616
|
+
import fs14 from "fs";
|
|
5572
5617
|
import path14 from "path";
|
|
5573
5618
|
import {
|
|
5574
5619
|
applyLcmSchema,
|
|
@@ -5680,15 +5725,15 @@ async function loadImportLosslessClawModule() {
|
|
|
5680
5725
|
|
|
5681
5726
|
// src/import-lossless-claw-cmd.ts
|
|
5682
5727
|
function assertDirectoryOrAbsent(p, label) {
|
|
5683
|
-
if (
|
|
5728
|
+
if (fs14.existsSync(p) && !fs14.statSync(p).isDirectory()) {
|
|
5684
5729
|
throw new Error(`${label} is not a directory: ${p}`);
|
|
5685
5730
|
}
|
|
5686
5731
|
}
|
|
5687
5732
|
function assertFile(p, label) {
|
|
5688
|
-
if (!
|
|
5733
|
+
if (!fs14.existsSync(p)) {
|
|
5689
5734
|
throw new Error(`${label} does not exist: ${p}`);
|
|
5690
5735
|
}
|
|
5691
|
-
if (!
|
|
5736
|
+
if (!fs14.statSync(p).isFile()) {
|
|
5692
5737
|
throw new Error(`${label} is not a file: ${p}`);
|
|
5693
5738
|
}
|
|
5694
5739
|
}
|
|
@@ -5720,7 +5765,7 @@ async function cmdImportLosslessClaw(argv, io, deps = {}) {
|
|
|
5720
5765
|
try {
|
|
5721
5766
|
if (parsed.dryRun) {
|
|
5722
5767
|
const lcmPath = path14.join(memoryDir, "state", "lcm.sqlite");
|
|
5723
|
-
if (
|
|
5768
|
+
if (fs14.existsSync(lcmPath)) {
|
|
5724
5769
|
destDb = mod.openExistingLcmDatabaseReadOnly(lcmPath);
|
|
5725
5770
|
} else {
|
|
5726
5771
|
destDb = mod.openInMemoryDestinationDatabase();
|
|
@@ -6921,7 +6966,7 @@ async function resolveAllBenchmarks() {
|
|
|
6921
6966
|
if (packageBenchmarks) {
|
|
6922
6967
|
return packageBenchmarks.filter((entry) => entry.runnerAvailable).map((entry) => entry.id);
|
|
6923
6968
|
}
|
|
6924
|
-
if (!
|
|
6969
|
+
if (!fs15.existsSync(EVAL_RUNNER_PATH)) {
|
|
6925
6970
|
return [];
|
|
6926
6971
|
}
|
|
6927
6972
|
return BENCHMARK_CATALOG.filter((entry) => entry.category !== "ingestion").map((entry) => entry.id);
|
|
@@ -6969,7 +7014,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
|
|
|
6969
7014
|
`Fallback benchmark runner does not support provider-backed, gateway, or thinking/timeout flags (${unsupportedOptions.join(", ")}). Build/install @remnic/bench to use those options.`
|
|
6970
7015
|
);
|
|
6971
7016
|
}
|
|
6972
|
-
if (!
|
|
7017
|
+
if (!fs15.existsSync(EVAL_RUNNER_PATH)) {
|
|
6973
7018
|
console.error(
|
|
6974
7019
|
"Benchmark runner not found. Expected eval runner at evals/run.ts or a phase-1 @remnic/bench runtime export."
|
|
6975
7020
|
);
|
|
@@ -6979,7 +7024,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
|
|
|
6979
7024
|
path17.join(CLI_REPO_ROOT, "node_modules", ".bin", "tsx"),
|
|
6980
7025
|
path17.join(CLI_REPO_ROOT, "packages", "remnic-cli", "node_modules", ".bin", "tsx")
|
|
6981
7026
|
];
|
|
6982
|
-
const tsxCmd = tsxCandidates.find((candidate) =>
|
|
7027
|
+
const tsxCmd = tsxCandidates.find((candidate) => fs15.existsSync(candidate)) ?? "tsx";
|
|
6983
7028
|
const fallbackOutputDir = createFallbackBenchOutputDir(
|
|
6984
7029
|
parsed.resultsDir ?? resolveBenchOutputDir(),
|
|
6985
7030
|
benchmarkId,
|
|
@@ -7124,9 +7169,9 @@ var PERSONAMEM_COMPLETION_MARKER = path17.join(
|
|
|
7124
7169
|
);
|
|
7125
7170
|
function resolveRealpathWithinDataset(datasetPath, relativePath) {
|
|
7126
7171
|
try {
|
|
7127
|
-
const datasetRoot =
|
|
7172
|
+
const datasetRoot = fs15.realpathSync(datasetPath);
|
|
7128
7173
|
const candidatePath = path17.resolve(datasetRoot, relativePath);
|
|
7129
|
-
const candidateRealPath =
|
|
7174
|
+
const candidateRealPath = fs15.realpathSync(candidatePath);
|
|
7130
7175
|
const relativeToRoot = path17.relative(datasetRoot, candidateRealPath);
|
|
7131
7176
|
if (relativeToRoot.startsWith("..") || path17.isAbsolute(relativeToRoot)) {
|
|
7132
7177
|
return null;
|
|
@@ -7185,14 +7230,14 @@ function parseCsvRows(raw) {
|
|
|
7185
7230
|
function isPersonaMemDatasetComplete(datasetPath) {
|
|
7186
7231
|
try {
|
|
7187
7232
|
const completionMarkerPath = path17.join(datasetPath, PERSONAMEM_COMPLETION_MARKER);
|
|
7188
|
-
if (
|
|
7233
|
+
if (fs15.statSync(completionMarkerPath).isFile()) {
|
|
7189
7234
|
return true;
|
|
7190
7235
|
}
|
|
7191
7236
|
} catch {
|
|
7192
7237
|
}
|
|
7193
7238
|
const datasetFile = PERSONAMEM_DATASET_FILE_CANDIDATES.find((candidate) => {
|
|
7194
7239
|
try {
|
|
7195
|
-
return
|
|
7240
|
+
return fs15.statSync(path17.join(datasetPath, candidate)).isFile();
|
|
7196
7241
|
} catch {
|
|
7197
7242
|
return false;
|
|
7198
7243
|
}
|
|
@@ -7201,7 +7246,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
7201
7246
|
return false;
|
|
7202
7247
|
}
|
|
7203
7248
|
try {
|
|
7204
|
-
const rows = parseCsvRows(
|
|
7249
|
+
const rows = parseCsvRows(fs15.readFileSync(path17.join(datasetPath, datasetFile), "utf8"));
|
|
7205
7250
|
if (rows.length < 2) {
|
|
7206
7251
|
return false;
|
|
7207
7252
|
}
|
|
@@ -7216,7 +7261,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
7216
7261
|
}
|
|
7217
7262
|
return historyPaths.every((relativePath) => {
|
|
7218
7263
|
const resolvedPath = resolveRealpathWithinDataset(datasetPath, relativePath);
|
|
7219
|
-
return resolvedPath !== null &&
|
|
7264
|
+
return resolvedPath !== null && fs15.statSync(resolvedPath).isFile();
|
|
7220
7265
|
});
|
|
7221
7266
|
} catch {
|
|
7222
7267
|
return false;
|
|
@@ -7224,7 +7269,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
7224
7269
|
}
|
|
7225
7270
|
function hasDatasetFile(datasetPath, relativePath) {
|
|
7226
7271
|
try {
|
|
7227
|
-
return
|
|
7272
|
+
return fs15.statSync(path17.join(datasetPath, relativePath)).isFile();
|
|
7228
7273
|
} catch {
|
|
7229
7274
|
return false;
|
|
7230
7275
|
}
|
|
@@ -7244,10 +7289,10 @@ function memoryAgentBenchDatasetHasRecSysSamples(datasetPath) {
|
|
|
7244
7289
|
return candidateFilenames.some((filename) => {
|
|
7245
7290
|
const filePath = path17.join(datasetPath, filename);
|
|
7246
7291
|
try {
|
|
7247
|
-
if (!
|
|
7292
|
+
if (!fs15.statSync(filePath).isFile()) {
|
|
7248
7293
|
return false;
|
|
7249
7294
|
}
|
|
7250
|
-
const raw =
|
|
7295
|
+
const raw = fs15.readFileSync(filePath, "utf8");
|
|
7251
7296
|
return /"source"\s*:\s*"recsys[_-]/i.test(raw);
|
|
7252
7297
|
} catch {
|
|
7253
7298
|
return false;
|
|
@@ -7263,7 +7308,7 @@ function isMemoryAgentBenchDatasetComplete(datasetPath) {
|
|
|
7263
7308
|
function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
7264
7309
|
let stats;
|
|
7265
7310
|
try {
|
|
7266
|
-
stats =
|
|
7311
|
+
stats = fs15.statSync(datasetPath);
|
|
7267
7312
|
} catch {
|
|
7268
7313
|
return false;
|
|
7269
7314
|
}
|
|
@@ -7273,7 +7318,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
7273
7318
|
const marker = DOWNLOADED_DATASET_MARKERS[benchmarkId];
|
|
7274
7319
|
if (!marker) {
|
|
7275
7320
|
try {
|
|
7276
|
-
return
|
|
7321
|
+
return fs15.readdirSync(datasetPath).length > 0;
|
|
7277
7322
|
} catch {
|
|
7278
7323
|
return false;
|
|
7279
7324
|
}
|
|
@@ -7281,7 +7326,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
7281
7326
|
if (marker.allOf) {
|
|
7282
7327
|
const hasAllRequiredFiles = marker.allOf.every((name) => {
|
|
7283
7328
|
try {
|
|
7284
|
-
return
|
|
7329
|
+
return fs15.statSync(path17.join(datasetPath, name)).isFile();
|
|
7285
7330
|
} catch {
|
|
7286
7331
|
return false;
|
|
7287
7332
|
}
|
|
@@ -7293,7 +7338,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
7293
7338
|
if (marker.anyOf) {
|
|
7294
7339
|
const hasMarkerFile = marker.anyOf.some((name) => {
|
|
7295
7340
|
try {
|
|
7296
|
-
return
|
|
7341
|
+
return fs15.statSync(path17.join(datasetPath, name)).isFile();
|
|
7297
7342
|
} catch {
|
|
7298
7343
|
return false;
|
|
7299
7344
|
}
|
|
@@ -7311,7 +7356,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
7311
7356
|
}
|
|
7312
7357
|
if (marker.ext) {
|
|
7313
7358
|
try {
|
|
7314
|
-
return
|
|
7359
|
+
return fs15.readdirSync(datasetPath).some(
|
|
7315
7360
|
(name) => name.endsWith(marker.ext) && !marker.exclude?.includes(name)
|
|
7316
7361
|
);
|
|
7317
7362
|
} catch {
|
|
@@ -7323,7 +7368,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
7323
7368
|
async function launchBenchUi(resultsDir) {
|
|
7324
7369
|
const benchUiDir = path17.join(CLI_REPO_ROOT, "packages", "bench-ui");
|
|
7325
7370
|
const pnpmCmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
7326
|
-
if (!
|
|
7371
|
+
if (!fs15.existsSync(path17.join(benchUiDir, "package.json"))) {
|
|
7327
7372
|
console.error("ERROR: @remnic/bench-ui is not available in this checkout.");
|
|
7328
7373
|
process.exit(1);
|
|
7329
7374
|
}
|
|
@@ -7361,13 +7406,13 @@ function listDownloadableBenchmarks() {
|
|
|
7361
7406
|
}
|
|
7362
7407
|
function resolveDatasetDownloadScriptPath() {
|
|
7363
7408
|
const bundled = path17.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
|
|
7364
|
-
if (
|
|
7409
|
+
if (fs15.existsSync(bundled)) {
|
|
7365
7410
|
return bundled;
|
|
7366
7411
|
}
|
|
7367
7412
|
return path17.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh");
|
|
7368
7413
|
}
|
|
7369
7414
|
function isRepoCheckout() {
|
|
7370
|
-
return
|
|
7415
|
+
return fs15.existsSync(path17.join(CLI_REPO_ROOT, "pnpm-workspace.yaml")) && fs15.existsSync(path17.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh"));
|
|
7371
7416
|
}
|
|
7372
7417
|
function runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, jsonMode) {
|
|
7373
7418
|
const stdio = jsonMode ? ["inherit", process.stderr, "inherit"] : "inherit";
|
|
@@ -7680,8 +7725,8 @@ async function exportBenchPackageResult(parsed) {
|
|
|
7680
7725
|
...reportCardProvenance ? { reportCardProvenance } : {}
|
|
7681
7726
|
});
|
|
7682
7727
|
if (parsed.output) {
|
|
7683
|
-
|
|
7684
|
-
|
|
7728
|
+
fs15.mkdirSync(path17.dirname(parsed.output), { recursive: true });
|
|
7729
|
+
fs15.writeFileSync(parsed.output, rendered);
|
|
7685
7730
|
console.log(`Exported ${summary.id} as ${parsed.format} to ${parsed.output}`);
|
|
7686
7731
|
return;
|
|
7687
7732
|
}
|
|
@@ -7726,7 +7771,7 @@ async function manageBenchDatasets(parsed) {
|
|
|
7726
7771
|
process.exit(1);
|
|
7727
7772
|
}
|
|
7728
7773
|
const scriptPath = resolveDatasetDownloadScriptPath();
|
|
7729
|
-
if (!
|
|
7774
|
+
if (!fs15.existsSync(scriptPath)) {
|
|
7730
7775
|
console.error(`ERROR: dataset download script not found: ${scriptPath}`);
|
|
7731
7776
|
process.exit(1);
|
|
7732
7777
|
}
|
|
@@ -7926,7 +7971,7 @@ async function calibrateBenchJudges(parsed, rawArgs) {
|
|
|
7926
7971
|
);
|
|
7927
7972
|
process.exit(1);
|
|
7928
7973
|
}
|
|
7929
|
-
const sourceResultSha256 = createHash4("sha256").update(
|
|
7974
|
+
const sourceResultSha256 = createHash4("sha256").update(fs15.readFileSync(latest.path)).digest("hex");
|
|
7930
7975
|
const expandedManifestPath = expandTilde(manifestPath);
|
|
7931
7976
|
if (!bench.resolveLocalLabJudgeProviderConfig) {
|
|
7932
7977
|
console.error(
|
|
@@ -8341,7 +8386,7 @@ function loadPinnedLoCoMoTaskSelector(parsed) {
|
|
|
8341
8386
|
}
|
|
8342
8387
|
let decoded;
|
|
8343
8388
|
try {
|
|
8344
|
-
decoded = JSON.parse(
|
|
8389
|
+
decoded = JSON.parse(fs15.readFileSync(parsed.taskIdsFile, "utf8"));
|
|
8345
8390
|
} catch (error) {
|
|
8346
8391
|
throw new Error(
|
|
8347
8392
|
`Unable to read --task-ids-file ${parsed.taskIdsFile}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -9016,7 +9061,7 @@ function resolveBenchReproDatasetDir(datasetDir) {
|
|
|
9016
9061
|
return void 0;
|
|
9017
9062
|
}
|
|
9018
9063
|
try {
|
|
9019
|
-
return
|
|
9064
|
+
return fs15.realpathSync(datasetDir);
|
|
9020
9065
|
} catch {
|
|
9021
9066
|
return datasetDir;
|
|
9022
9067
|
}
|
|
@@ -9070,13 +9115,13 @@ async function writeBenchReproManifestForPackageRun(args) {
|
|
|
9070
9115
|
}
|
|
9071
9116
|
function loadStandaloneConvergeCommandConfig() {
|
|
9072
9117
|
const configPath = resolveConfigPath();
|
|
9073
|
-
const raw =
|
|
9074
|
-
return
|
|
9118
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
9119
|
+
return parseConfig7(resolveRemnicConfigRecord6(raw));
|
|
9075
9120
|
}
|
|
9076
9121
|
function parseConvergePluginConfig(value) {
|
|
9077
9122
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
9078
9123
|
if (Object.keys(value).length === 0) return void 0;
|
|
9079
|
-
return
|
|
9124
|
+
return parseConfig7(resolveRemnicConfigRecord6(value));
|
|
9080
9125
|
}
|
|
9081
9126
|
function loadConvergeCommandConfig() {
|
|
9082
9127
|
if (readCompatEnv("REMNIC_CONFIG_PATH", "ENGRAM_CONFIG_PATH")) {
|
|
@@ -9099,13 +9144,13 @@ function resolveConfigPath(cliPath) {
|
|
|
9099
9144
|
path17.join(resolveHomeDir(), ".config", "engram", "config.json")
|
|
9100
9145
|
];
|
|
9101
9146
|
for (const candidate of candidates) {
|
|
9102
|
-
if (
|
|
9147
|
+
if (fs15.existsSync(candidate)) return candidate;
|
|
9103
9148
|
}
|
|
9104
9149
|
return path17.join(resolveHomeDir(), ".config", "remnic", "config.json");
|
|
9105
9150
|
}
|
|
9106
9151
|
function resolveExistingBenchRemnicConfigPath(cliPath) {
|
|
9107
9152
|
const configPath = resolveConfigPath(cliPath);
|
|
9108
|
-
if (
|
|
9153
|
+
if (fs15.existsSync(configPath)) {
|
|
9109
9154
|
return configPath;
|
|
9110
9155
|
}
|
|
9111
9156
|
if (cliPath) {
|
|
@@ -9115,7 +9160,7 @@ function resolveExistingBenchRemnicConfigPath(cliPath) {
|
|
|
9115
9160
|
}
|
|
9116
9161
|
function resolveExistingBenchOpenclawConfigPath(cliPath) {
|
|
9117
9162
|
const configPath = resolveOpenclawConfigPath(cliPath);
|
|
9118
|
-
if (
|
|
9163
|
+
if (fs15.existsSync(configPath)) {
|
|
9119
9164
|
return configPath;
|
|
9120
9165
|
}
|
|
9121
9166
|
if (cliPath) {
|
|
@@ -9222,8 +9267,8 @@ function resolveMemoryDir() {
|
|
|
9222
9267
|
const envMemoryDir = readCompatEnv("REMNIC_MEMORY_DIR", "ENGRAM_MEMORY_DIR");
|
|
9223
9268
|
if (envMemoryDir) return normalizeMemoryDirPath(envMemoryDir);
|
|
9224
9269
|
const configPath = resolveConfigPath();
|
|
9225
|
-
const raw =
|
|
9226
|
-
const remnicCfg =
|
|
9270
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
9271
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
9227
9272
|
if (typeof remnicCfg.memoryDir === "string" && remnicCfg.memoryDir.length > 0) {
|
|
9228
9273
|
return normalizeMemoryDirPath(remnicCfg.memoryDir);
|
|
9229
9274
|
}
|
|
@@ -9231,18 +9276,18 @@ function resolveMemoryDir() {
|
|
|
9231
9276
|
const standalonePath = path17.join(home, ".remnic", "memory");
|
|
9232
9277
|
const legacyStandalonePath = path17.join(home, ".engram", "memory");
|
|
9233
9278
|
const openclawPath = path17.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
9234
|
-
if (
|
|
9235
|
-
if (
|
|
9279
|
+
if (fs15.existsSync(standalonePath)) return standalonePath;
|
|
9280
|
+
if (fs15.existsSync(legacyStandalonePath)) return legacyStandalonePath;
|
|
9236
9281
|
return openclawPath;
|
|
9237
9282
|
})();
|
|
9238
9283
|
const manifestPath = getManifestPath();
|
|
9239
|
-
if (
|
|
9284
|
+
if (fs15.existsSync(manifestPath)) {
|
|
9240
9285
|
try {
|
|
9241
9286
|
const active = getActiveSpace();
|
|
9242
9287
|
if (active?.memoryDir) {
|
|
9243
9288
|
const activeMemoryDir = normalizeMemoryDirPath(active.memoryDir);
|
|
9244
|
-
if (!
|
|
9245
|
-
|
|
9289
|
+
if (!fs15.existsSync(activeMemoryDir)) {
|
|
9290
|
+
fs15.mkdirSync(activeMemoryDir, { recursive: true });
|
|
9246
9291
|
}
|
|
9247
9292
|
return activeMemoryDir;
|
|
9248
9293
|
}
|
|
@@ -9291,13 +9336,13 @@ function resolveOpenclawConfigPath(cliPath) {
|
|
|
9291
9336
|
const envPath = process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_ENGRAM_CONFIG_PATH;
|
|
9292
9337
|
if (envPath) return path17.resolve(expandTilde(envPath));
|
|
9293
9338
|
for (const candidate of DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR) {
|
|
9294
|
-
if (
|
|
9339
|
+
if (fs15.existsSync(candidate)) return candidate;
|
|
9295
9340
|
}
|
|
9296
9341
|
return path17.join(resolveOpenclawStateDir(), "openclaw.json");
|
|
9297
9342
|
}
|
|
9298
9343
|
function readOpenclawConfig(configPath) {
|
|
9299
|
-
if (!
|
|
9300
|
-
const raw =
|
|
9344
|
+
if (!fs15.existsSync(configPath)) return {};
|
|
9345
|
+
const raw = fs15.readFileSync(configPath, "utf-8");
|
|
9301
9346
|
let parsed;
|
|
9302
9347
|
try {
|
|
9303
9348
|
parsed = JSON.parse(raw);
|
|
@@ -9399,9 +9444,9 @@ function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
|
|
|
9399
9444
|
return `${yyyy}${mm}${dd}-${hh}${min}${ss}`;
|
|
9400
9445
|
}
|
|
9401
9446
|
function backupPathIfPresent(sourcePath, backupPath) {
|
|
9402
|
-
if (!
|
|
9403
|
-
|
|
9404
|
-
|
|
9447
|
+
if (!fs15.existsSync(sourcePath)) return false;
|
|
9448
|
+
fs15.mkdirSync(path17.dirname(backupPath), { recursive: true });
|
|
9449
|
+
fs15.cpSync(sourcePath, backupPath, { recursive: true });
|
|
9405
9450
|
return true;
|
|
9406
9451
|
}
|
|
9407
9452
|
function restartOpenclawGateway() {
|
|
@@ -9420,7 +9465,7 @@ function restartOpenclawGateway() {
|
|
|
9420
9465
|
}
|
|
9421
9466
|
function cmdInit() {
|
|
9422
9467
|
const configPath = path17.join(process.cwd(), "remnic.config.json");
|
|
9423
|
-
if (
|
|
9468
|
+
if (fs15.existsSync(configPath)) {
|
|
9424
9469
|
console.log(`Config already exists: ${configPath}`);
|
|
9425
9470
|
return;
|
|
9426
9471
|
}
|
|
@@ -9436,7 +9481,7 @@ function cmdInit() {
|
|
|
9436
9481
|
authToken: "${REMNIC_AUTH_TOKEN}"
|
|
9437
9482
|
}
|
|
9438
9483
|
};
|
|
9439
|
-
|
|
9484
|
+
fs15.writeFileSync(configPath, JSON.stringify(template, null, 2) + "\n");
|
|
9440
9485
|
console.log(`Created ${configPath}`);
|
|
9441
9486
|
console.log("\nSet these environment variables:");
|
|
9442
9487
|
console.log(" export OPENAI_API_KEY=sk-...");
|
|
@@ -9506,7 +9551,7 @@ async function cmdStatus(json) {
|
|
|
9506
9551
|
}
|
|
9507
9552
|
function oauthReadConfigRecord(configPath) {
|
|
9508
9553
|
try {
|
|
9509
|
-
const parsed = JSON.parse(
|
|
9554
|
+
const parsed = JSON.parse(fs15.readFileSync(configPath, "utf8"));
|
|
9510
9555
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
9511
9556
|
return parsed;
|
|
9512
9557
|
}
|
|
@@ -9920,12 +9965,12 @@ async function cmdQuery(queryText, json, explain) {
|
|
|
9920
9965
|
console.error("Usage: remnic query <text>");
|
|
9921
9966
|
process.exit(1);
|
|
9922
9967
|
}
|
|
9923
|
-
|
|
9968
|
+
initLogger3();
|
|
9924
9969
|
const configPath = resolveConfigPath();
|
|
9925
|
-
const raw =
|
|
9926
|
-
const remnicCfg =
|
|
9927
|
-
const config =
|
|
9928
|
-
const orchestrator = new
|
|
9970
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
9971
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
9972
|
+
const config = parseConfig7(remnicCfg);
|
|
9973
|
+
const orchestrator = new Orchestrator4(config);
|
|
9929
9974
|
await orchestrator.initialize();
|
|
9930
9975
|
const service = new EngramAccessService2(orchestrator);
|
|
9931
9976
|
const recallRequest = buildQueryRecallRequest(queryText);
|
|
@@ -10091,12 +10136,12 @@ async function runXrayCommand(rest, io) {
|
|
|
10091
10136
|
async function cmdXray(rest) {
|
|
10092
10137
|
const { rawQuery, options } = extractXrayRawArgs(rest);
|
|
10093
10138
|
parseXrayCliOptions(rawQuery, options);
|
|
10094
|
-
|
|
10139
|
+
initLogger3();
|
|
10095
10140
|
const configPath = resolveConfigPath();
|
|
10096
|
-
const raw =
|
|
10097
|
-
const remnicCfg =
|
|
10098
|
-
const config =
|
|
10099
|
-
const orchestrator = new
|
|
10141
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
10142
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10143
|
+
const config = parseConfig7(remnicCfg);
|
|
10144
|
+
const orchestrator = new Orchestrator4(config);
|
|
10100
10145
|
await orchestrator.initialize();
|
|
10101
10146
|
await orchestrator.deferredReady;
|
|
10102
10147
|
const service = new EngramAccessService2(orchestrator);
|
|
@@ -10114,11 +10159,11 @@ async function cmdXray(rest) {
|
|
|
10114
10159
|
}
|
|
10115
10160
|
}
|
|
10116
10161
|
async function cmdVersions(rest) {
|
|
10117
|
-
|
|
10162
|
+
initLogger3();
|
|
10118
10163
|
const configPath = resolveConfigPath();
|
|
10119
|
-
const raw =
|
|
10120
|
-
const remnicCfg =
|
|
10121
|
-
const config =
|
|
10164
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
10165
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10166
|
+
const config = parseConfig7(remnicCfg);
|
|
10122
10167
|
if (!config.versioningEnabled) {
|
|
10123
10168
|
console.error("Page versioning is disabled (versioningEnabled = false).");
|
|
10124
10169
|
process.exit(1);
|
|
@@ -10230,11 +10275,11 @@ Options:
|
|
|
10230
10275
|
}
|
|
10231
10276
|
}
|
|
10232
10277
|
async function cmdEnrich(rest) {
|
|
10233
|
-
|
|
10278
|
+
initLogger3();
|
|
10234
10279
|
const configPath = resolveConfigPath();
|
|
10235
|
-
const raw =
|
|
10236
|
-
const remnicCfg =
|
|
10237
|
-
const config =
|
|
10280
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
10281
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10282
|
+
const config = parseConfig7(remnicCfg);
|
|
10238
10283
|
const subcommand = rest[0];
|
|
10239
10284
|
if (subcommand === "audit") {
|
|
10240
10285
|
const memoryDir2 = expandTilde(config.memoryDir);
|
|
@@ -10262,7 +10307,7 @@ async function cmdEnrich(rest) {
|
|
|
10262
10307
|
pipelineConfig2.providers = [
|
|
10263
10308
|
{ id: "web-search", enabled: true, costTier: "cheap" }
|
|
10264
10309
|
];
|
|
10265
|
-
const orchestrator2 = new
|
|
10310
|
+
const orchestrator2 = new Orchestrator4(config);
|
|
10266
10311
|
await orchestrator2.initialize();
|
|
10267
10312
|
await orchestrator2.deferredReady;
|
|
10268
10313
|
const searchBackend2 = orchestrator2.qmd;
|
|
@@ -10298,7 +10343,7 @@ Registered providers:`);
|
|
|
10298
10343
|
console.error("Usage: remnic enrich <entity-name> | --all | --dry-run | audit | providers");
|
|
10299
10344
|
process.exit(1);
|
|
10300
10345
|
}
|
|
10301
|
-
const orchestrator = new
|
|
10346
|
+
const orchestrator = new Orchestrator4(config);
|
|
10302
10347
|
await orchestrator.initialize();
|
|
10303
10348
|
await orchestrator.deferredReady;
|
|
10304
10349
|
const storage = await orchestrator.getStorage(config.defaultNamespace);
|
|
@@ -10424,7 +10469,7 @@ Registered providers:`);
|
|
|
10424
10469
|
}
|
|
10425
10470
|
}
|
|
10426
10471
|
async function cmdProcedural(rest) {
|
|
10427
|
-
|
|
10472
|
+
initLogger3();
|
|
10428
10473
|
const subcommand = rest[0];
|
|
10429
10474
|
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
10430
10475
|
console.log(`remnic procedural \u2014 Procedural memory operations (issue #567)
|
|
@@ -10477,9 +10522,9 @@ Shared with:
|
|
|
10477
10522
|
process.exit(1);
|
|
10478
10523
|
}
|
|
10479
10524
|
const configPath = resolveConfigPath();
|
|
10480
|
-
const raw =
|
|
10481
|
-
const remnicCfg =
|
|
10482
|
-
const config =
|
|
10525
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
10526
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10527
|
+
const config = parseConfig7(remnicCfg);
|
|
10483
10528
|
const memoryDir = expandTilde(
|
|
10484
10529
|
typeof memoryDirOverride === "string" && memoryDirOverride.length > 0 ? memoryDirOverride : config.memoryDir ?? resolveMemoryDir()
|
|
10485
10530
|
);
|
|
@@ -10492,11 +10537,11 @@ Shared with:
|
|
|
10492
10537
|
process.stdout.write(formatProcedureStatsText(report));
|
|
10493
10538
|
}
|
|
10494
10539
|
async function cmdExtensions(action, rest) {
|
|
10495
|
-
|
|
10540
|
+
initLogger3();
|
|
10496
10541
|
const configPath = resolveConfigPath();
|
|
10497
|
-
const raw =
|
|
10498
|
-
const remnicCfg =
|
|
10499
|
-
const config =
|
|
10542
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
10543
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10544
|
+
const config = parseConfig7(remnicCfg);
|
|
10500
10545
|
const root = resolveExtensionsRoot(config);
|
|
10501
10546
|
const noopLog = { warn: () => {
|
|
10502
10547
|
}, debug: () => {
|
|
@@ -10545,7 +10590,7 @@ Root: ${root}`);
|
|
|
10545
10590
|
const extensions = await discoverMemoryExtensions(root, warnLog);
|
|
10546
10591
|
let entries = [];
|
|
10547
10592
|
try {
|
|
10548
|
-
entries =
|
|
10593
|
+
entries = fs15.readdirSync(root);
|
|
10549
10594
|
} catch {
|
|
10550
10595
|
console.log(`Extensions root does not exist: ${root}`);
|
|
10551
10596
|
process.exitCode = 0;
|
|
@@ -10556,7 +10601,7 @@ Root: ${root}`);
|
|
|
10556
10601
|
for (const entry of entries) {
|
|
10557
10602
|
const entryPath = path17.join(root, entry);
|
|
10558
10603
|
try {
|
|
10559
|
-
if (!
|
|
10604
|
+
if (!fs15.statSync(entryPath).isDirectory()) continue;
|
|
10560
10605
|
} catch {
|
|
10561
10606
|
continue;
|
|
10562
10607
|
}
|
|
@@ -10586,11 +10631,11 @@ Root: ${root}`);
|
|
|
10586
10631
|
}
|
|
10587
10632
|
}
|
|
10588
10633
|
async function cmdBriefing(rest) {
|
|
10589
|
-
|
|
10634
|
+
initLogger3();
|
|
10590
10635
|
const configPath = resolveConfigPath();
|
|
10591
|
-
const raw =
|
|
10592
|
-
const remnicCfg =
|
|
10593
|
-
const config =
|
|
10636
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
10637
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10638
|
+
const config = parseConfig7(remnicCfg);
|
|
10594
10639
|
if (!config.briefing.enabled) {
|
|
10595
10640
|
console.error("Briefing is disabled in config (briefing.enabled = false).");
|
|
10596
10641
|
process.exit(1);
|
|
@@ -10643,7 +10688,7 @@ async function cmdBriefing(rest) {
|
|
|
10643
10688
|
process.exit(1);
|
|
10644
10689
|
}
|
|
10645
10690
|
const format = effectiveFormatFlag === "json" ? "json" : effectiveFormatFlag === "markdown" ? "markdown" : config.briefing.defaultFormat;
|
|
10646
|
-
const orchestrator = new
|
|
10691
|
+
const orchestrator = new Orchestrator4(config);
|
|
10647
10692
|
await orchestrator.initialize();
|
|
10648
10693
|
const storage = await orchestrator.getStorage(config.defaultNamespace);
|
|
10649
10694
|
const calendarSource = config.briefing.calendarSource ? new FileCalendarSource(config.briefing.calendarSource) : void 0;
|
|
@@ -10668,10 +10713,10 @@ async function cmdBriefing(rest) {
|
|
|
10668
10713
|
if (save) {
|
|
10669
10714
|
try {
|
|
10670
10715
|
const saveDir = resolveBriefingSaveDir(config.briefing.saveDir);
|
|
10671
|
-
|
|
10716
|
+
fs15.mkdirSync(saveDir, { recursive: true });
|
|
10672
10717
|
const filename = briefingFilename(new Date(result.window.to), format);
|
|
10673
10718
|
const filePath = path17.join(saveDir, filename);
|
|
10674
|
-
|
|
10719
|
+
fs15.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
|
|
10675
10720
|
console.error(`Saved briefing: ${filePath}`);
|
|
10676
10721
|
} catch (err) {
|
|
10677
10722
|
console.error(`Failed to save briefing: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -10689,7 +10734,7 @@ async function cmdDoctor() {
|
|
|
10689
10734
|
detail: `${nodeVersion} (requires >= 22.12.0)`
|
|
10690
10735
|
});
|
|
10691
10736
|
const configPath = resolveConfigPath();
|
|
10692
|
-
const configExists =
|
|
10737
|
+
const configExists = fs15.existsSync(configPath);
|
|
10693
10738
|
checks.push({ name: "Config file", ok: configExists, detail: configPath });
|
|
10694
10739
|
let standaloneConfig;
|
|
10695
10740
|
let standaloneConfigError;
|
|
@@ -10697,11 +10742,11 @@ async function cmdDoctor() {
|
|
|
10697
10742
|
let configuredNs = { invalid: false };
|
|
10698
10743
|
if (configExists) {
|
|
10699
10744
|
try {
|
|
10700
|
-
const raw = JSON.parse(
|
|
10701
|
-
const remnicCfg =
|
|
10745
|
+
const raw = JSON.parse(fs15.readFileSync(configPath, "utf8"));
|
|
10746
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
10702
10747
|
standaloneOpenaiApiKeyExplicitlyFalse = isOpenaiApiKeyDisabled(remnicCfg.openaiApiKey);
|
|
10703
10748
|
configuredNs = readConfiguredNamespace(remnicCfg);
|
|
10704
|
-
standaloneConfig =
|
|
10749
|
+
standaloneConfig = parseConfig7(remnicCfg);
|
|
10705
10750
|
} catch (err) {
|
|
10706
10751
|
standaloneConfigError = err instanceof Error ? err.message : String(err);
|
|
10707
10752
|
}
|
|
@@ -10710,10 +10755,10 @@ async function cmdDoctor() {
|
|
|
10710
10755
|
try {
|
|
10711
10756
|
memoryDir = resolveMemoryDir();
|
|
10712
10757
|
} catch {
|
|
10713
|
-
memoryDir =
|
|
10758
|
+
memoryDir = parseConfig7({}).memoryDir;
|
|
10714
10759
|
}
|
|
10715
10760
|
try {
|
|
10716
|
-
|
|
10761
|
+
fs15.mkdirSync(memoryDir, { recursive: true });
|
|
10717
10762
|
checks.push({ name: "Memory directory", ok: true, detail: memoryDir });
|
|
10718
10763
|
} catch {
|
|
10719
10764
|
checks.push({ name: "Memory directory", ok: false, detail: `cannot create ${memoryDir}` });
|
|
@@ -10742,7 +10787,7 @@ async function cmdDoctor() {
|
|
|
10742
10787
|
});
|
|
10743
10788
|
if (nsPolicyCheck) checks.push(nsPolicyCheck);
|
|
10744
10789
|
const openclawConfigPath = resolveOpenclawConfigPath();
|
|
10745
|
-
const openclawConfigExists =
|
|
10790
|
+
const openclawConfigExists = fs15.existsSync(openclawConfigPath);
|
|
10746
10791
|
let openclawConfig = {};
|
|
10747
10792
|
let openclawConfigValid = false;
|
|
10748
10793
|
let openclawPluginModeConfigured = false;
|
|
@@ -10750,7 +10795,7 @@ async function cmdDoctor() {
|
|
|
10750
10795
|
let activeOpenclawEntryConfig = null;
|
|
10751
10796
|
if (openclawConfigExists) {
|
|
10752
10797
|
try {
|
|
10753
|
-
const parsed = JSON.parse(
|
|
10798
|
+
const parsed = JSON.parse(fs15.readFileSync(openclawConfigPath, "utf-8"));
|
|
10754
10799
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
10755
10800
|
openclawConfig = parsed;
|
|
10756
10801
|
openclawConfigValid = true;
|
|
@@ -10830,9 +10875,9 @@ async function cmdDoctor() {
|
|
|
10830
10875
|
let memDirOk = false;
|
|
10831
10876
|
let memDirDetail = `${resolvedMemDir} (not found)`;
|
|
10832
10877
|
let memDirRemediation = `Run \`remnic openclaw install --memory-dir "${resolvedMemDir}"\` to create the directory.`;
|
|
10833
|
-
if (
|
|
10878
|
+
if (fs15.existsSync(resolvedMemDir)) {
|
|
10834
10879
|
try {
|
|
10835
|
-
const stat2 =
|
|
10880
|
+
const stat2 = fs15.statSync(resolvedMemDir);
|
|
10836
10881
|
if (stat2.isDirectory()) {
|
|
10837
10882
|
memDirOk = true;
|
|
10838
10883
|
memDirDetail = resolvedMemDir;
|
|
@@ -10974,12 +11019,12 @@ async function cmdDoctor() {
|
|
|
10974
11019
|
}
|
|
10975
11020
|
function cmdConfig() {
|
|
10976
11021
|
const configPath = resolveConfigPath();
|
|
10977
|
-
if (!
|
|
11022
|
+
if (!fs15.existsSync(configPath)) {
|
|
10978
11023
|
console.log("No config file found. Run `remnic init` to create one.");
|
|
10979
11024
|
return;
|
|
10980
11025
|
}
|
|
10981
11026
|
console.log(`Config: ${configPath}`);
|
|
10982
|
-
const rawConfig =
|
|
11027
|
+
const rawConfig = fs15.readFileSync(configPath, "utf8");
|
|
10983
11028
|
const redacted = rawConfig.replace(
|
|
10984
11029
|
/("(?:openaiApiKey|localLlmApiKey|authToken|apiKey|remoteSearchApiKey|meilisearchApiKey|opikApiKey)"\s*:\s*")([^"]*)(")/g,
|
|
10985
11030
|
"$1[REDACTED]$3"
|
|
@@ -11087,9 +11132,9 @@ async function cmdReview(action, rest) {
|
|
|
11087
11132
|
const configPath = resolveConfigPath();
|
|
11088
11133
|
let tombstonesConfig = null;
|
|
11089
11134
|
try {
|
|
11090
|
-
const rawCfg =
|
|
11091
|
-
const remnicCfg =
|
|
11092
|
-
const config =
|
|
11135
|
+
const rawCfg = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
11136
|
+
const remnicCfg = resolveRemnicConfigRecord6(rawCfg);
|
|
11137
|
+
const config = parseConfig7(remnicCfg);
|
|
11093
11138
|
tombstonesConfig = {
|
|
11094
11139
|
enabled: config.tombstonesEnabled,
|
|
11095
11140
|
semanticMatch: config.tombstonesSemanticMatch,
|
|
@@ -11831,7 +11876,7 @@ async function pushOfflineFileContent(args) {
|
|
|
11831
11876
|
}
|
|
11832
11877
|
async function pushOfflineFileContentFromChunkReader(args) {
|
|
11833
11878
|
const filePath = resolveOfflineDirectHydrationPath(args.memoryDir, args.file.path);
|
|
11834
|
-
const stat2 =
|
|
11879
|
+
const stat2 = fs15.statSync(filePath);
|
|
11835
11880
|
if (stat2.mtimeMs !== args.file.mtimeMs) {
|
|
11836
11881
|
throw new Error(`local file changed while pushing offline content: ${args.file.path}`);
|
|
11837
11882
|
}
|
|
@@ -12322,7 +12367,7 @@ function advanceOfflineBaseFilesForSuccessfulPush(options) {
|
|
|
12322
12367
|
return [...next.values()].sort((left, right) => left.path.localeCompare(right.path));
|
|
12323
12368
|
}
|
|
12324
12369
|
async function runOfflineSyncOnce(options) {
|
|
12325
|
-
|
|
12370
|
+
fs15.mkdirSync(options.memoryDir, { recursive: true });
|
|
12326
12371
|
let activeStatePath = options.statePath;
|
|
12327
12372
|
let priorState = await readOfflineSyncState(activeStatePath);
|
|
12328
12373
|
let syncNamespace = options.namespace ?? priorState?.namespace;
|
|
@@ -12955,7 +13000,7 @@ Environment fallbacks:
|
|
|
12955
13000
|
const configPath = resolveConfigPath();
|
|
12956
13001
|
let config;
|
|
12957
13002
|
try {
|
|
12958
|
-
const rawConfig =
|
|
13003
|
+
const rawConfig = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
12959
13004
|
config = parseConfigQuietly(pickOfflineConfigRecord(rawConfig));
|
|
12960
13005
|
} catch {
|
|
12961
13006
|
throw new Error(
|
|
@@ -12970,7 +13015,7 @@ Environment fallbacks:
|
|
|
12970
13015
|
const statePath = statePathExplicit ? path17.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
|
|
12971
13016
|
if (action === "prepare") {
|
|
12972
13017
|
if (!remoteUrl || !token || !statePath) throw new Error("offline prepare requires remote URL and token");
|
|
12973
|
-
|
|
13018
|
+
fs15.mkdirSync(memoryDir, { recursive: true });
|
|
12974
13019
|
const remoteSnapshot = await fetchOfflineSnapshot({
|
|
12975
13020
|
remoteUrl,
|
|
12976
13021
|
token,
|
|
@@ -13069,7 +13114,7 @@ Environment fallbacks:
|
|
|
13069
13114
|
return;
|
|
13070
13115
|
}
|
|
13071
13116
|
if (action === "status") {
|
|
13072
|
-
|
|
13117
|
+
fs15.mkdirSync(memoryDir, { recursive: true });
|
|
13073
13118
|
const state = statePath ? await readOfflineSyncState(statePath) : null;
|
|
13074
13119
|
if (state && remoteUrl && statePath) {
|
|
13075
13120
|
assertOfflineStateMatches({
|
|
@@ -13207,7 +13252,7 @@ function cmdDedup(json) {
|
|
|
13207
13252
|
function readInstalledConnectorConfig(configPath, fallback) {
|
|
13208
13253
|
if (!configPath) return fallback;
|
|
13209
13254
|
try {
|
|
13210
|
-
const parsed = JSON.parse(
|
|
13255
|
+
const parsed = JSON.parse(fs15.readFileSync(configPath, "utf8"));
|
|
13211
13256
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return fallback;
|
|
13212
13257
|
const { token: _token, ...config } = parsed;
|
|
13213
13258
|
return config;
|
|
@@ -13385,7 +13430,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
13385
13430
|
const pub = factory();
|
|
13386
13431
|
const available = await pub.isHostAvailable();
|
|
13387
13432
|
const extRoot = available ? await pub.resolveExtensionRoot() : "(host not installed)";
|
|
13388
|
-
const extensionExists = available && extRoot ?
|
|
13433
|
+
const extensionExists = available && extRoot ? fs15.existsSync(extRoot) : false;
|
|
13389
13434
|
publisherChecks.push({
|
|
13390
13435
|
name: `Publisher: ${targetHostId}`,
|
|
13391
13436
|
ok: !available || extensionExists,
|
|
@@ -13459,7 +13504,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
13459
13504
|
let connectorsCfg;
|
|
13460
13505
|
const configPath = resolveConfigPath();
|
|
13461
13506
|
try {
|
|
13462
|
-
const raw =
|
|
13507
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
13463
13508
|
connectorsCfg = parseConfigQuietly(raw).connectors;
|
|
13464
13509
|
} catch {
|
|
13465
13510
|
process.stderr.write(
|
|
@@ -13533,12 +13578,12 @@ async function cmdConnectors(action, rest, json) {
|
|
|
13533
13578
|
process.exitCode = 2;
|
|
13534
13579
|
return;
|
|
13535
13580
|
}
|
|
13536
|
-
|
|
13581
|
+
initLogger3();
|
|
13537
13582
|
const configPath = resolveConfigPath();
|
|
13538
|
-
const raw =
|
|
13539
|
-
const remnicCfg =
|
|
13540
|
-
const config =
|
|
13541
|
-
const orchestrator = new
|
|
13583
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
13584
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
13585
|
+
const config = parseConfig7(remnicCfg);
|
|
13586
|
+
const orchestrator = new Orchestrator4(config);
|
|
13542
13587
|
try {
|
|
13543
13588
|
await orchestrator.initialize();
|
|
13544
13589
|
await orchestrator.deferredReady;
|
|
@@ -13660,9 +13705,9 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
|
|
|
13660
13705
|
console.error(`connectors marketplace: ${err instanceof Error ? err.message : String(err)}`);
|
|
13661
13706
|
process.exit(1);
|
|
13662
13707
|
}
|
|
13663
|
-
const rawConfig =
|
|
13664
|
-
const pluginConfig =
|
|
13665
|
-
const config =
|
|
13708
|
+
const rawConfig = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
13709
|
+
const pluginConfig = resolveRemnicConfigRecord6(rawConfig);
|
|
13710
|
+
const config = parseConfig7(pluginConfig);
|
|
13666
13711
|
if (subAction === "generate") {
|
|
13667
13712
|
let outputDir;
|
|
13668
13713
|
try {
|
|
@@ -13682,13 +13727,13 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
|
|
|
13682
13727
|
} else if (subAction === "validate") {
|
|
13683
13728
|
const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path17.join(process.cwd(), "marketplace.json");
|
|
13684
13729
|
const resolved = path17.resolve(targetPath);
|
|
13685
|
-
if (!
|
|
13730
|
+
if (!fs15.existsSync(resolved)) {
|
|
13686
13731
|
console.error(`File not found: ${resolved}`);
|
|
13687
13732
|
process.exit(1);
|
|
13688
13733
|
}
|
|
13689
13734
|
let parsed;
|
|
13690
13735
|
try {
|
|
13691
|
-
parsed = JSON.parse(
|
|
13736
|
+
parsed = JSON.parse(fs15.readFileSync(resolved, "utf8"));
|
|
13692
13737
|
} catch {
|
|
13693
13738
|
console.error(`Invalid JSON in ${resolved}`);
|
|
13694
13739
|
process.exit(1);
|
|
@@ -13887,12 +13932,12 @@ async function cmdSpace(action, rest, json) {
|
|
|
13887
13932
|
}
|
|
13888
13933
|
}
|
|
13889
13934
|
async function cmdLegacyBenchmark(action, rest, json) {
|
|
13890
|
-
|
|
13935
|
+
initLogger3();
|
|
13891
13936
|
const configPath = resolveConfigPath();
|
|
13892
|
-
const raw =
|
|
13893
|
-
const remnicCfg =
|
|
13894
|
-
const config =
|
|
13895
|
-
const orchestrator = new
|
|
13937
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
13938
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
13939
|
+
const config = parseConfig7(remnicCfg);
|
|
13940
|
+
const orchestrator = new Orchestrator4(config);
|
|
13896
13941
|
const service = new EngramAccessService2(orchestrator);
|
|
13897
13942
|
const { runBenchSuite, loadBaseline, checkRegression } = await loadBenchModule();
|
|
13898
13943
|
const benchConfig = {
|
|
@@ -14293,7 +14338,7 @@ function readPid() {
|
|
|
14293
14338
|
function inferPort() {
|
|
14294
14339
|
try {
|
|
14295
14340
|
const configPath = resolveConfigPath();
|
|
14296
|
-
const raw = JSON.parse(
|
|
14341
|
+
const raw = JSON.parse(fs15.readFileSync(configPath, "utf8"));
|
|
14297
14342
|
return raw.server?.port ?? 4318;
|
|
14298
14343
|
} catch {
|
|
14299
14344
|
return 4318;
|
|
@@ -14388,13 +14433,13 @@ function daemonInstall() {
|
|
|
14388
14433
|
process.exit(1);
|
|
14389
14434
|
}
|
|
14390
14435
|
const vars = { HOME: home, NODE_PATH: nodePath, REMNIC_SERVER_BIN: serverBin };
|
|
14391
|
-
|
|
14436
|
+
fs15.mkdirSync(LOGS_DIR, { recursive: true });
|
|
14392
14437
|
if (isMacOS()) {
|
|
14393
14438
|
const templatePath = path17.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
|
|
14394
|
-
const template =
|
|
14439
|
+
const template = fs15.readFileSync(templatePath, "utf8");
|
|
14395
14440
|
const plist = renderTemplate(template, vars);
|
|
14396
|
-
|
|
14397
|
-
|
|
14441
|
+
fs15.mkdirSync(path17.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
|
|
14442
|
+
fs15.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
14398
14443
|
try {
|
|
14399
14444
|
launchdLoadPlist(LAUNCHD_PLIST_PATH);
|
|
14400
14445
|
} catch (err) {
|
|
@@ -14411,10 +14456,10 @@ function daemonInstall() {
|
|
|
14411
14456
|
console.log(` Logs: ${LOGS_DIR}/daemon.log`);
|
|
14412
14457
|
} else if (isLinux()) {
|
|
14413
14458
|
const templatePath = path17.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
|
|
14414
|
-
const template =
|
|
14459
|
+
const template = fs15.readFileSync(templatePath, "utf8");
|
|
14415
14460
|
const unit = renderTemplate(template, vars);
|
|
14416
|
-
|
|
14417
|
-
|
|
14461
|
+
fs15.mkdirSync(path17.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
|
|
14462
|
+
fs15.writeFileSync(SYSTEMD_UNIT_PATH, unit);
|
|
14418
14463
|
try {
|
|
14419
14464
|
childProcess2.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
|
|
14420
14465
|
} catch (err) {
|
|
@@ -14450,7 +14495,7 @@ function daemonUninstall() {
|
|
|
14450
14495
|
} catch {
|
|
14451
14496
|
}
|
|
14452
14497
|
try {
|
|
14453
|
-
|
|
14498
|
+
fs15.unlinkSync(plistPath);
|
|
14454
14499
|
removed = true;
|
|
14455
14500
|
console.log(`Removed launchd service: ${plistPath}`);
|
|
14456
14501
|
} catch {
|
|
@@ -14470,7 +14515,7 @@ function daemonUninstall() {
|
|
|
14470
14515
|
let removed = false;
|
|
14471
14516
|
for (const unitPath of SYSTEMD_UNIT_PATHS) {
|
|
14472
14517
|
try {
|
|
14473
|
-
|
|
14518
|
+
fs15.unlinkSync(unitPath);
|
|
14474
14519
|
removed = true;
|
|
14475
14520
|
console.log(`Removed systemd service: ${unitPath}`);
|
|
14476
14521
|
} catch {
|
|
@@ -14537,13 +14582,13 @@ async function daemonStatus() {
|
|
|
14537
14582
|
console.log(` Port: ${port}`);
|
|
14538
14583
|
console.log(` Service: ${serviceInstalled ? "installed" : "not installed"}`);
|
|
14539
14584
|
console.log(` Platform: ${process.platform}`);
|
|
14540
|
-
console.log(` PID file: ${
|
|
14541
|
-
console.log(` Log file: ${
|
|
14585
|
+
console.log(` PID file: ${fs15.existsSync(PID_FILE) ? PID_FILE : LEGACY_PID_FILE}`);
|
|
14586
|
+
console.log(` Log file: ${fs15.existsSync(LOG_FILE) ? LOG_FILE : LEGACY_LOG_FILE}`);
|
|
14542
14587
|
try {
|
|
14543
14588
|
const configPath = resolveConfigPath();
|
|
14544
|
-
const raw =
|
|
14545
|
-
const remnicCfg =
|
|
14546
|
-
const config =
|
|
14589
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
14590
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
14591
|
+
const config = parseConfig7(remnicCfg);
|
|
14547
14592
|
const extRoot = resolveExtensionsRoot(config);
|
|
14548
14593
|
const noopLog = { warn: () => {
|
|
14549
14594
|
}, debug: () => {
|
|
@@ -14582,9 +14627,9 @@ function daemonStart() {
|
|
|
14582
14627
|
return;
|
|
14583
14628
|
}
|
|
14584
14629
|
}
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
const logStream =
|
|
14630
|
+
fs15.mkdirSync(PID_DIR, { recursive: true });
|
|
14631
|
+
fs15.mkdirSync(LOGS_DIR, { recursive: true });
|
|
14632
|
+
const logStream = fs15.openSync(LOG_FILE, "a");
|
|
14588
14633
|
const serverBin = resolveServerBin();
|
|
14589
14634
|
const isSource = serverBin.endsWith(".ts");
|
|
14590
14635
|
let cmd;
|
|
@@ -14606,7 +14651,7 @@ function daemonStart() {
|
|
|
14606
14651
|
}
|
|
14607
14652
|
});
|
|
14608
14653
|
child.unref();
|
|
14609
|
-
|
|
14654
|
+
fs15.writeFileSync(PID_FILE, String(child.pid));
|
|
14610
14655
|
console.log(`Started remnic server (pid ${child.pid})`);
|
|
14611
14656
|
console.log(` Log: ${LOG_FILE}`);
|
|
14612
14657
|
}
|
|
@@ -14640,11 +14685,11 @@ function daemonStop() {
|
|
|
14640
14685
|
console.log("Process not found (cleaning up PID file)");
|
|
14641
14686
|
}
|
|
14642
14687
|
try {
|
|
14643
|
-
|
|
14688
|
+
fs15.unlinkSync(PID_FILE);
|
|
14644
14689
|
} catch {
|
|
14645
14690
|
}
|
|
14646
14691
|
try {
|
|
14647
|
-
|
|
14692
|
+
fs15.unlinkSync(LEGACY_PID_FILE);
|
|
14648
14693
|
} catch {
|
|
14649
14694
|
}
|
|
14650
14695
|
}
|
|
@@ -14770,11 +14815,11 @@ async function promptYesNo(question, defaultYes = true) {
|
|
|
14770
14815
|
});
|
|
14771
14816
|
}
|
|
14772
14817
|
async function cmdBinary(rest) {
|
|
14773
|
-
|
|
14818
|
+
initLogger3();
|
|
14774
14819
|
const configPath = resolveConfigPath();
|
|
14775
|
-
const raw =
|
|
14776
|
-
const remnicCfg =
|
|
14777
|
-
const config =
|
|
14820
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
14821
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
14822
|
+
const config = parseConfig7(remnicCfg);
|
|
14778
14823
|
const memoryDir = resolveMemoryDir();
|
|
14779
14824
|
const blConfig = {
|
|
14780
14825
|
enabled: config.binaryLifecycleEnabled,
|
|
@@ -14963,7 +15008,7 @@ async function cmdOpenclawInstall(opts) {
|
|
|
14963
15008
|
} else if (slotIsActiveLegacy) {
|
|
14964
15009
|
changes.push(` Slot left as "${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID}" \u2014 re-run with --yes to activate the new entry`);
|
|
14965
15010
|
}
|
|
14966
|
-
if (!
|
|
15011
|
+
if (!fs15.existsSync(memoryDir)) changes.push(`+ Will create memory directory: ${memoryDir}`);
|
|
14967
15012
|
if (hasLegacy && migrateLegacy) {
|
|
14968
15013
|
changes.push(`~ Legacy '${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID}' entry retained (safe to remove after verifying hooks fire)`);
|
|
14969
15014
|
}
|
|
@@ -14983,8 +15028,8 @@ async function cmdOpenclawInstall(opts) {
|
|
|
14983
15028
|
Resulting plugins.slots.memory: ${dryRunPlugins.slots?.memory ?? "(unset)"}`);
|
|
14984
15029
|
return;
|
|
14985
15030
|
}
|
|
14986
|
-
if (
|
|
14987
|
-
const st =
|
|
15031
|
+
if (fs15.existsSync(memoryDir)) {
|
|
15032
|
+
const st = fs15.statSync(memoryDir);
|
|
14988
15033
|
if (!st.isDirectory()) {
|
|
14989
15034
|
throw new Error(
|
|
14990
15035
|
`Cannot use ${memoryDir} as the memory directory \u2014 a file already exists at that path.
|
|
@@ -14992,12 +15037,12 @@ Remove it first and re-run, or choose a different path with --memory-dir.`
|
|
|
14992
15037
|
);
|
|
14993
15038
|
}
|
|
14994
15039
|
} else {
|
|
14995
|
-
|
|
15040
|
+
fs15.mkdirSync(memoryDir, { recursive: true });
|
|
14996
15041
|
console.log(`Created memory directory: ${memoryDir}`);
|
|
14997
15042
|
}
|
|
14998
15043
|
const configDir = path17.dirname(configPath);
|
|
14999
|
-
if (!
|
|
15000
|
-
|
|
15044
|
+
if (!fs15.existsSync(configDir)) {
|
|
15045
|
+
fs15.mkdirSync(configDir, { recursive: true });
|
|
15001
15046
|
}
|
|
15002
15047
|
atomicWriteFileSync(configPath, JSON.stringify(updatedConfig, null, 2) + "\n");
|
|
15003
15048
|
console.log("\nDone! Summary of changes:");
|
|
@@ -15026,7 +15071,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
15026
15071
|
const legacyPluginDirForBackup = opts.legacyPluginDirForBackup ? resolveOpenclawLegacyPluginDir(opts.legacyPluginDirForBackup) : void 0;
|
|
15027
15072
|
const fallbackMemoryDir = path17.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
15028
15073
|
const packageSpec = buildOpenclawManagedUpgradePackageSpec(opts.version);
|
|
15029
|
-
const configExistedBefore =
|
|
15074
|
+
const configExistedBefore = fs15.existsSync(configPath);
|
|
15030
15075
|
const existingConfig = readOpenclawConfig(configPath);
|
|
15031
15076
|
const { entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
|
|
15032
15077
|
const preservedMemoryDir = opts.memoryDir ? path17.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
|
|
@@ -15251,15 +15296,15 @@ async function cmdOpenclawMigrateEngram(opts) {
|
|
|
15251
15296
|
}
|
|
15252
15297
|
function createOpenclawUpgradeBackupDir() {
|
|
15253
15298
|
const backupsRoot = path17.join(resolveOpenclawStateDir(), "backups");
|
|
15254
|
-
|
|
15255
|
-
return
|
|
15299
|
+
fs15.mkdirSync(backupsRoot, { recursive: true });
|
|
15300
|
+
return fs15.mkdtempSync(path17.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
|
|
15256
15301
|
}
|
|
15257
15302
|
async function cmdTaxonomy(rest) {
|
|
15258
|
-
|
|
15303
|
+
initLogger3();
|
|
15259
15304
|
const configPath = resolveConfigPath();
|
|
15260
|
-
const raw =
|
|
15261
|
-
const remnicCfg =
|
|
15262
|
-
const config =
|
|
15305
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
15306
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
15307
|
+
const config = parseConfig7(remnicCfg);
|
|
15263
15308
|
if (!config.taxonomyEnabled) {
|
|
15264
15309
|
console.error(
|
|
15265
15310
|
"Taxonomy is disabled in config (taxonomyEnabled = false). Enable it to use taxonomy commands."
|
|
@@ -15295,8 +15340,8 @@ async function cmdTaxonomy(rest) {
|
|
|
15295
15340
|
console.log(doc);
|
|
15296
15341
|
if (config.taxonomyAutoGenResolver) {
|
|
15297
15342
|
const resolverPath = path17.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
15298
|
-
|
|
15299
|
-
|
|
15343
|
+
fs15.mkdirSync(path17.dirname(resolverPath), { recursive: true });
|
|
15344
|
+
fs15.writeFileSync(resolverPath, doc);
|
|
15300
15345
|
console.error(`Written: ${resolverPath}`);
|
|
15301
15346
|
}
|
|
15302
15347
|
break;
|
|
@@ -15342,7 +15387,7 @@ async function cmdTaxonomy(rest) {
|
|
|
15342
15387
|
if (config.taxonomyAutoGenResolver) {
|
|
15343
15388
|
const doc = generateResolverDocument(taxonomy);
|
|
15344
15389
|
const resolverPath = path17.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
15345
|
-
|
|
15390
|
+
fs15.writeFileSync(resolverPath, doc);
|
|
15346
15391
|
console.error(`Regenerated: ${resolverPath}`);
|
|
15347
15392
|
}
|
|
15348
15393
|
break;
|
|
@@ -15373,7 +15418,7 @@ async function cmdTaxonomy(rest) {
|
|
|
15373
15418
|
if (config.taxonomyAutoGenResolver) {
|
|
15374
15419
|
const doc = generateResolverDocument(taxonomy);
|
|
15375
15420
|
const resolverPath = path17.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
15376
|
-
|
|
15421
|
+
fs15.writeFileSync(resolverPath, doc);
|
|
15377
15422
|
console.error(`Regenerated: ${resolverPath}`);
|
|
15378
15423
|
}
|
|
15379
15424
|
break;
|
|
@@ -15564,12 +15609,12 @@ async function runTrainingExport(args, stdout = process.stdout) {
|
|
|
15564
15609
|
`Unknown training-export format "${args.format}". ${validList}`
|
|
15565
15610
|
);
|
|
15566
15611
|
}
|
|
15567
|
-
if (!
|
|
15612
|
+
if (!fs15.existsSync(args.memoryDir)) {
|
|
15568
15613
|
throw new Error(
|
|
15569
15614
|
`--memory-dir "${args.memoryDir}" does not exist. Provide the path to an existing memory directory.`
|
|
15570
15615
|
);
|
|
15571
15616
|
}
|
|
15572
|
-
if (!
|
|
15617
|
+
if (!fs15.statSync(args.memoryDir).isDirectory()) {
|
|
15573
15618
|
throw new Error(
|
|
15574
15619
|
`--memory-dir "${args.memoryDir}" is not a directory. Provide the path to a memory directory, not a file.`
|
|
15575
15620
|
);
|
|
@@ -15655,10 +15700,10 @@ async function runTrainingExport(args, stdout = process.stdout) {
|
|
|
15655
15700
|
}
|
|
15656
15701
|
const formatted = adapter.formatRecords(records);
|
|
15657
15702
|
const outDir = path17.dirname(args.output);
|
|
15658
|
-
|
|
15703
|
+
fs15.mkdirSync(outDir, { recursive: true });
|
|
15659
15704
|
const tmpPath = `${args.output}.tmp-${process.pid}-${Date.now()}`;
|
|
15660
|
-
|
|
15661
|
-
|
|
15705
|
+
fs15.writeFileSync(tmpPath, formatted, "utf-8");
|
|
15706
|
+
fs15.renameSync(tmpPath, args.output);
|
|
15662
15707
|
stdout.write(
|
|
15663
15708
|
`Exported ${records.length} records to ${args.output} (${adapter.name} format)
|
|
15664
15709
|
`
|
|
@@ -15707,6 +15752,9 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
15707
15752
|
case "xray":
|
|
15708
15753
|
await cmdXray(rest);
|
|
15709
15754
|
break;
|
|
15755
|
+
case "security":
|
|
15756
|
+
await cmdSecurity(rest);
|
|
15757
|
+
break;
|
|
15710
15758
|
case "doctor":
|
|
15711
15759
|
await cmdDoctor();
|
|
15712
15760
|
break;
|
|
@@ -15827,7 +15875,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
15827
15875
|
}
|
|
15828
15876
|
}, 500);
|
|
15829
15877
|
};
|
|
15830
|
-
|
|
15878
|
+
fs15.watch(memoryDir, { recursive: true }, (_event, filename) => {
|
|
15831
15879
|
if (filename && filename.startsWith(".")) return;
|
|
15832
15880
|
rebuild();
|
|
15833
15881
|
});
|
|
@@ -15835,12 +15883,12 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
15835
15883
|
});
|
|
15836
15884
|
} else if (subAction === "validate") {
|
|
15837
15885
|
const treeDir = outputDir;
|
|
15838
|
-
if (!
|
|
15886
|
+
if (!fs15.existsSync(treeDir)) {
|
|
15839
15887
|
console.error(`Context tree not found at ${treeDir}. Run 'remnic tree generate' first.`);
|
|
15840
15888
|
process.exit(1);
|
|
15841
15889
|
}
|
|
15842
15890
|
const indexPath = path17.join(treeDir, "INDEX.md");
|
|
15843
|
-
if (!
|
|
15891
|
+
if (!fs15.existsSync(indexPath)) {
|
|
15844
15892
|
console.error(`INDEX.md missing in ${treeDir}. Tree may be corrupt \u2014 regenerate.`);
|
|
15845
15893
|
process.exit(1);
|
|
15846
15894
|
}
|
|
@@ -16022,10 +16070,10 @@ Other:
|
|
|
16022
16070
|
let wearablesService;
|
|
16023
16071
|
try {
|
|
16024
16072
|
const configPath = resolveConfigPath();
|
|
16025
|
-
const raw =
|
|
16026
|
-
const remnicCfg =
|
|
16027
|
-
const config =
|
|
16028
|
-
wearablesOrchestrator = new
|
|
16073
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
16074
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
16075
|
+
const config = parseConfig7(remnicCfg);
|
|
16076
|
+
wearablesOrchestrator = new Orchestrator4(config);
|
|
16029
16077
|
await wearablesOrchestrator.initialize();
|
|
16030
16078
|
await wearablesOrchestrator.deferredReady;
|
|
16031
16079
|
wearablesService = wearablesOrchestrator.getWearablesService();
|
|
@@ -16077,10 +16125,10 @@ Other:
|
|
|
16077
16125
|
const targetFactory = async () => {
|
|
16078
16126
|
if (!orchestratorSingleton) {
|
|
16079
16127
|
const configPath = resolveConfigPath();
|
|
16080
|
-
const raw =
|
|
16081
|
-
const remnicCfg =
|
|
16082
|
-
const config =
|
|
16083
|
-
orchestratorSingleton = new
|
|
16128
|
+
const raw = fs15.existsSync(configPath) ? JSON.parse(fs15.readFileSync(configPath, "utf8")) : {};
|
|
16129
|
+
const remnicCfg = resolveRemnicConfigRecord6(raw);
|
|
16130
|
+
const config = parseConfig7(remnicCfg);
|
|
16131
|
+
orchestratorSingleton = new Orchestrator4(config);
|
|
16084
16132
|
await orchestratorSingleton.initialize();
|
|
16085
16133
|
await orchestratorSingleton.deferredReady;
|
|
16086
16134
|
}
|