@remnic/cli 9.66.1 → 9.66.2
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 +553 -249
- package/package.json +32 -32
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 fs28 from "fs";
|
|
22
22
|
import os3 from "os";
|
|
23
23
|
import path19 from "path";
|
|
24
24
|
import { createHash as createHash4 } from "crypto";
|
|
@@ -588,45 +588,9 @@ async function runJournalBinaryCommand(rest) {
|
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
-
// src/commands/
|
|
591
|
+
// src/commands/journal-vault.ts
|
|
592
592
|
import fs10 from "fs";
|
|
593
|
-
import {
|
|
594
|
-
async function runExternalWikiBinaryCommand(rest) {
|
|
595
|
-
let roots;
|
|
596
|
-
try {
|
|
597
|
-
const configPath = resolveConfigPath();
|
|
598
|
-
const raw = fs10.existsSync(configPath) ? JSON.parse(fs10.readFileSync(configPath, "utf8")) : {};
|
|
599
|
-
roots = parseConfig10(resolveRemnicConfigRecord10(raw)).externalWikis;
|
|
600
|
-
} catch {
|
|
601
|
-
console.error(
|
|
602
|
-
"external-wiki: failed to load the Remnic config - run `remnic doctor` and check the config file for errors"
|
|
603
|
-
);
|
|
604
|
-
process.exitCode = 1;
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
|
-
try {
|
|
608
|
-
const code = await runExternalWikiCliCommand(roots, rest, {
|
|
609
|
-
stdout: process.stdout,
|
|
610
|
-
stderr: process.stderr
|
|
611
|
-
});
|
|
612
|
-
if (code !== 0) process.exitCode = code;
|
|
613
|
-
} catch {
|
|
614
|
-
console.error("external-wiki: search failed");
|
|
615
|
-
process.exitCode = 1;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// src/commands/procedural.ts
|
|
620
|
-
import fs11 from "fs";
|
|
621
|
-
import {
|
|
622
|
-
StorageManager,
|
|
623
|
-
computeProcedureStats,
|
|
624
|
-
formatProcedureStatsText,
|
|
625
|
-
initLogger,
|
|
626
|
-
parseConfig as parseConfig11,
|
|
627
|
-
resolveRemnicConfigRecord as resolveRemnicConfigRecord11,
|
|
628
|
-
runProcedureLibraryMaintenance
|
|
629
|
-
} from "@remnic/core";
|
|
593
|
+
import { readVaultJournal } from "@remnic/core";
|
|
630
594
|
|
|
631
595
|
// src/cli-args.ts
|
|
632
596
|
function resolveFlag(args, flag) {
|
|
@@ -684,6 +648,236 @@ function parseTaxonomyResolveArgs(args, booleanFlags = TAXONOMY_RESOLVE_BOOLEAN_
|
|
|
684
648
|
return { textParts, values, booleans };
|
|
685
649
|
}
|
|
686
650
|
|
|
651
|
+
// src/commands/journal-vault.ts
|
|
652
|
+
var defaultIo = {
|
|
653
|
+
stdout: (line) => {
|
|
654
|
+
process.stdout.write(`${line}
|
|
655
|
+
`);
|
|
656
|
+
},
|
|
657
|
+
stderr: (line) => {
|
|
658
|
+
process.stderr.write(`${line}
|
|
659
|
+
`);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
function journalVaultHelp() {
|
|
663
|
+
return `Usage: remnic journal-vault show --file <path> --section <heading>
|
|
664
|
+
|
|
665
|
+
show Print the stripped journal section. Missing file or heading prints exists:false.
|
|
666
|
+
`;
|
|
667
|
+
}
|
|
668
|
+
function runJournalVaultCommand(rest, io = defaultIo) {
|
|
669
|
+
if (rest.length === 0 || rest[0] === "--help" || rest[0] === "-h" || rest[0] === "help") {
|
|
670
|
+
io.stdout(journalVaultHelp().trimEnd());
|
|
671
|
+
return 0;
|
|
672
|
+
}
|
|
673
|
+
if (rest[0] !== "show") {
|
|
674
|
+
io.stderr(`journal-vault: unknown action "${rest[0]}".`);
|
|
675
|
+
io.stderr(journalVaultHelp().trimEnd());
|
|
676
|
+
return 1;
|
|
677
|
+
}
|
|
678
|
+
const filePath = resolveFlag(rest, "--file");
|
|
679
|
+
const section = resolveFlag(rest, "--section");
|
|
680
|
+
if (filePath === void 0 || section === void 0) {
|
|
681
|
+
io.stderr("journal-vault: show requires --file <path> and --section <heading>");
|
|
682
|
+
return 1;
|
|
683
|
+
}
|
|
684
|
+
let fileText = null;
|
|
685
|
+
try {
|
|
686
|
+
fileText = fs10.readFileSync(filePath, "utf8");
|
|
687
|
+
} catch (err) {
|
|
688
|
+
if (err.code !== "ENOENT") {
|
|
689
|
+
io.stderr(err instanceof Error ? err.message : String(err));
|
|
690
|
+
return 1;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
const result = readVaultJournal({ fileText, journalSection: section });
|
|
694
|
+
if (!result.ok) {
|
|
695
|
+
io.stderr(`journal-vault: duplicate heading at lines ${result.lines.join(", ")}`);
|
|
696
|
+
return 1;
|
|
697
|
+
}
|
|
698
|
+
if (!result.exists) {
|
|
699
|
+
io.stdout("exists:false");
|
|
700
|
+
return 0;
|
|
701
|
+
}
|
|
702
|
+
io.stdout(result.text);
|
|
703
|
+
return 0;
|
|
704
|
+
}
|
|
705
|
+
async function runJournalVaultBinaryCommand(rest) {
|
|
706
|
+
const code = runJournalVaultCommand(rest);
|
|
707
|
+
if (code !== 0) process.exitCode = code;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// src/commands/activity-privacy.ts
|
|
711
|
+
import { parseFlexibleIsoTimestamp, shouldRetain } from "@remnic/core";
|
|
712
|
+
var defaultIo2 = {
|
|
713
|
+
stdout: (line) => {
|
|
714
|
+
process.stdout.write(`${line}
|
|
715
|
+
`);
|
|
716
|
+
},
|
|
717
|
+
stderr: (line) => {
|
|
718
|
+
process.stderr.write(`${line}
|
|
719
|
+
`);
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
function activityPrivacyHelp() {
|
|
723
|
+
return `Usage: remnic activity-privacy retain --captured <iso> --now <iso> --days <n> [--enabled <true|false>]
|
|
724
|
+
|
|
725
|
+
retain Print retain=true or retain=false. --days 0 keeps forever.
|
|
726
|
+
`;
|
|
727
|
+
}
|
|
728
|
+
function parseEnabled(rest, io) {
|
|
729
|
+
const raw = resolveFlag(rest, "--enabled");
|
|
730
|
+
if (raw === void 0) {
|
|
731
|
+
if (hasFlag(rest, "--enabled")) {
|
|
732
|
+
io.stderr("activity-privacy: --enabled requires true or false");
|
|
733
|
+
return void 0;
|
|
734
|
+
}
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
if (raw === "true") return true;
|
|
738
|
+
if (raw === "false") return false;
|
|
739
|
+
io.stderr("activity-privacy: --enabled must be true or false");
|
|
740
|
+
return void 0;
|
|
741
|
+
}
|
|
742
|
+
function runActivityPrivacyCommand(rest, io = defaultIo2) {
|
|
743
|
+
if (rest.length === 0 || rest[0] === "--help" || rest[0] === "-h" || rest[0] === "help") {
|
|
744
|
+
io.stdout(activityPrivacyHelp().trimEnd());
|
|
745
|
+
return 0;
|
|
746
|
+
}
|
|
747
|
+
if (rest[0] !== "retain") {
|
|
748
|
+
io.stderr(`activity-privacy: unknown action "${rest[0]}".`);
|
|
749
|
+
io.stderr(activityPrivacyHelp().trimEnd());
|
|
750
|
+
return 1;
|
|
751
|
+
}
|
|
752
|
+
const capturedRaw = resolveFlag(rest, "--captured");
|
|
753
|
+
const nowRaw = resolveFlag(rest, "--now");
|
|
754
|
+
const daysRaw = resolveFlag(rest, "--days");
|
|
755
|
+
if (capturedRaw === void 0 || nowRaw === void 0 || daysRaw === void 0) {
|
|
756
|
+
io.stderr("activity-privacy: retain requires --captured <iso>, --now <iso>, and --days <n>");
|
|
757
|
+
return 1;
|
|
758
|
+
}
|
|
759
|
+
const capturedAtMs = parseFlexibleIsoTimestamp(capturedRaw);
|
|
760
|
+
const nowMs = parseFlexibleIsoTimestamp(nowRaw);
|
|
761
|
+
if (capturedAtMs === null || nowMs === null) {
|
|
762
|
+
io.stderr("activity-privacy: --captured and --now must be ISO timestamps");
|
|
763
|
+
return 1;
|
|
764
|
+
}
|
|
765
|
+
const days = Number(daysRaw);
|
|
766
|
+
if (!Number.isInteger(days) || days < 0) {
|
|
767
|
+
io.stderr("activity-privacy: --days must be a non-negative integer");
|
|
768
|
+
return 1;
|
|
769
|
+
}
|
|
770
|
+
const enabled = parseEnabled(rest, io);
|
|
771
|
+
if (enabled === void 0) return 1;
|
|
772
|
+
io.stdout(`retain=${shouldRetain(capturedAtMs, nowMs, days, enabled)}`);
|
|
773
|
+
return 0;
|
|
774
|
+
}
|
|
775
|
+
async function runActivityPrivacyBinaryCommand(rest) {
|
|
776
|
+
const code = runActivityPrivacyCommand(rest);
|
|
777
|
+
if (code !== 0) process.exitCode = code;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// src/commands/vault-publish.ts
|
|
781
|
+
import fs11 from "fs";
|
|
782
|
+
import { applyManagedRegion } from "@remnic/core";
|
|
783
|
+
var defaultIo3 = {
|
|
784
|
+
stdout: (line) => {
|
|
785
|
+
process.stdout.write(`${line}
|
|
786
|
+
`);
|
|
787
|
+
},
|
|
788
|
+
stderr: (line) => {
|
|
789
|
+
process.stderr.write(`${line}
|
|
790
|
+
`);
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
function vaultPublishHelp() {
|
|
794
|
+
return `Usage: remnic vault-publish apply --file <path> --name <region> --content <text>
|
|
795
|
+
|
|
796
|
+
apply Replace the marked region. Missing markers print no_marker.
|
|
797
|
+
`;
|
|
798
|
+
}
|
|
799
|
+
function runVaultPublishCommand(rest, io = defaultIo3) {
|
|
800
|
+
if (rest.length === 0 || rest[0] === "--help" || rest[0] === "-h" || rest[0] === "help") {
|
|
801
|
+
io.stdout(vaultPublishHelp().trimEnd());
|
|
802
|
+
return 0;
|
|
803
|
+
}
|
|
804
|
+
if (rest[0] !== "apply") {
|
|
805
|
+
io.stderr(`vault-publish: unknown action "${rest[0]}".`);
|
|
806
|
+
io.stderr(vaultPublishHelp().trimEnd());
|
|
807
|
+
return 1;
|
|
808
|
+
}
|
|
809
|
+
const filePath = resolveFlag(rest, "--file");
|
|
810
|
+
const name = resolveFlag(rest, "--name");
|
|
811
|
+
const content = resolveFlag(rest, "--content");
|
|
812
|
+
if (filePath === void 0 || name === void 0 || content === void 0) {
|
|
813
|
+
io.stderr("vault-publish: apply requires --file <path>, --name <region>, and --content <text>");
|
|
814
|
+
return 1;
|
|
815
|
+
}
|
|
816
|
+
let fileText;
|
|
817
|
+
try {
|
|
818
|
+
fileText = fs11.readFileSync(filePath, "utf8");
|
|
819
|
+
} catch (err) {
|
|
820
|
+
if (err.code === "ENOENT") {
|
|
821
|
+
io.stderr("missing_file");
|
|
822
|
+
return 1;
|
|
823
|
+
}
|
|
824
|
+
io.stderr(err instanceof Error ? err.message : String(err));
|
|
825
|
+
return 1;
|
|
826
|
+
}
|
|
827
|
+
const applied = applyManagedRegion(fileText, { strategy: "markers", name, content });
|
|
828
|
+
if (!applied.ok) {
|
|
829
|
+
io.stderr(applied.reason);
|
|
830
|
+
return 1;
|
|
831
|
+
}
|
|
832
|
+
if (applied.text !== fileText) fs11.writeFileSync(filePath, applied.text);
|
|
833
|
+
io.stdout("ok");
|
|
834
|
+
return 0;
|
|
835
|
+
}
|
|
836
|
+
async function runVaultPublishBinaryCommand(rest) {
|
|
837
|
+
const code = runVaultPublishCommand(rest);
|
|
838
|
+
if (code !== 0) process.exitCode = code;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// src/commands/external-wiki.ts
|
|
842
|
+
import fs12 from "fs";
|
|
843
|
+
import { parseConfig as parseConfig10, resolveRemnicConfigRecord as resolveRemnicConfigRecord10, runExternalWikiCliCommand } from "@remnic/core";
|
|
844
|
+
async function runExternalWikiBinaryCommand(rest) {
|
|
845
|
+
let roots;
|
|
846
|
+
try {
|
|
847
|
+
const configPath = resolveConfigPath();
|
|
848
|
+
const raw = fs12.existsSync(configPath) ? JSON.parse(fs12.readFileSync(configPath, "utf8")) : {};
|
|
849
|
+
roots = parseConfig10(resolveRemnicConfigRecord10(raw)).externalWikis;
|
|
850
|
+
} catch {
|
|
851
|
+
console.error(
|
|
852
|
+
"external-wiki: failed to load the Remnic config - run `remnic doctor` and check the config file for errors"
|
|
853
|
+
);
|
|
854
|
+
process.exitCode = 1;
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
try {
|
|
858
|
+
const code = await runExternalWikiCliCommand(roots, rest, {
|
|
859
|
+
stdout: process.stdout,
|
|
860
|
+
stderr: process.stderr
|
|
861
|
+
});
|
|
862
|
+
if (code !== 0) process.exitCode = code;
|
|
863
|
+
} catch {
|
|
864
|
+
console.error("external-wiki: search failed");
|
|
865
|
+
process.exitCode = 1;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// src/commands/procedural.ts
|
|
870
|
+
import fs13 from "fs";
|
|
871
|
+
import {
|
|
872
|
+
StorageManager,
|
|
873
|
+
computeProcedureStats,
|
|
874
|
+
formatProcedureStatsText,
|
|
875
|
+
initLogger,
|
|
876
|
+
parseConfig as parseConfig11,
|
|
877
|
+
resolveRemnicConfigRecord as resolveRemnicConfigRecord11,
|
|
878
|
+
runProcedureLibraryMaintenance
|
|
879
|
+
} from "@remnic/core";
|
|
880
|
+
|
|
687
881
|
// src/path-utils.ts
|
|
688
882
|
function resolveHomeDir() {
|
|
689
883
|
return process.env.HOME ?? process.env.USERPROFILE ?? "~";
|
|
@@ -755,7 +949,7 @@ Shared with:
|
|
|
755
949
|
process.exit(1);
|
|
756
950
|
}
|
|
757
951
|
const configPath = resolveConfigPath();
|
|
758
|
-
const raw =
|
|
952
|
+
const raw = fs13.existsSync(configPath) ? JSON.parse(fs13.readFileSync(configPath, "utf8")) : {};
|
|
759
953
|
const config = parseConfig11(resolveRemnicConfigRecord11(raw));
|
|
760
954
|
const memoryDir = expandTilde(
|
|
761
955
|
typeof memoryDirOverride === "string" && memoryDirOverride.length > 0 ? memoryDirOverride : config.memoryDir ?? resolveMemoryDir()
|
|
@@ -811,7 +1005,7 @@ function formatProcedureMaintenanceText(report) {
|
|
|
811
1005
|
}
|
|
812
1006
|
|
|
813
1007
|
// src/commands/drift.ts
|
|
814
|
-
import
|
|
1008
|
+
import fs14 from "fs";
|
|
815
1009
|
import {
|
|
816
1010
|
Orchestrator as Orchestrator7,
|
|
817
1011
|
initLogger as initLogger2,
|
|
@@ -876,7 +1070,7 @@ Resolve a drifted item with the existing review surface:
|
|
|
876
1070
|
process.exit(1);
|
|
877
1071
|
}
|
|
878
1072
|
const configPath = resolveConfigPath();
|
|
879
|
-
const raw =
|
|
1073
|
+
const raw = fs14.existsSync(configPath) ? JSON.parse(fs14.readFileSync(configPath, "utf8")) : {};
|
|
880
1074
|
const config = parseConfig12(resolveRemnicConfigRecord12(raw));
|
|
881
1075
|
const memoryDirOverridden = typeof memoryDirOverride === "string" && memoryDirOverride.length > 0;
|
|
882
1076
|
const memoryDir = expandTilde(
|
|
@@ -940,6 +1134,104 @@ function formatPreferenceDriftText(report) {
|
|
|
940
1134
|
return lines.join("\n") + "\n";
|
|
941
1135
|
}
|
|
942
1136
|
|
|
1137
|
+
// src/commands/recall-navigate.ts
|
|
1138
|
+
import {
|
|
1139
|
+
expandRecallNode,
|
|
1140
|
+
traverseRecallLink
|
|
1141
|
+
} from "@remnic/core";
|
|
1142
|
+
var RECALL_NAV_UNAVAILABLE_TAG = "[unavailable] budget_off";
|
|
1143
|
+
function recallNavigateHelp() {
|
|
1144
|
+
return `Usage: remnic recall <expand|traverse> --node <json> [--budget <n>] [--type <linkType>]
|
|
1145
|
+
|
|
1146
|
+
expand Re-render one node at the next disclosure level
|
|
1147
|
+
traverse Follow typed links from a node
|
|
1148
|
+
|
|
1149
|
+
--budget 0 turns navigation off and prints ${RECALL_NAV_UNAVAILABLE_TAG}
|
|
1150
|
+
--type required for traverse: supports, contradicts, elaborates, supersedes, causes
|
|
1151
|
+
`;
|
|
1152
|
+
}
|
|
1153
|
+
function takeFlag5(rest, name) {
|
|
1154
|
+
const index = rest.indexOf(name);
|
|
1155
|
+
if (index < 0) return void 0;
|
|
1156
|
+
const value = rest[index + 1];
|
|
1157
|
+
if (value === void 0 || value.startsWith("-")) {
|
|
1158
|
+
throw new Error(`${name} requires a value`);
|
|
1159
|
+
}
|
|
1160
|
+
return value;
|
|
1161
|
+
}
|
|
1162
|
+
function parseBudget(rest) {
|
|
1163
|
+
if (!rest.includes("--budget")) return 1;
|
|
1164
|
+
const raw = takeFlag5(rest, "--budget");
|
|
1165
|
+
const budget = Number(raw);
|
|
1166
|
+
if (!Number.isFinite(budget)) {
|
|
1167
|
+
throw new Error(`--budget must be a number (got ${JSON.stringify(raw)})`);
|
|
1168
|
+
}
|
|
1169
|
+
return budget;
|
|
1170
|
+
}
|
|
1171
|
+
function parseNode(raw) {
|
|
1172
|
+
let value;
|
|
1173
|
+
try {
|
|
1174
|
+
value = JSON.parse(raw);
|
|
1175
|
+
} catch {
|
|
1176
|
+
throw new Error("--node must be JSON");
|
|
1177
|
+
}
|
|
1178
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1179
|
+
throw new Error("--node must be a JSON object");
|
|
1180
|
+
}
|
|
1181
|
+
const node = value;
|
|
1182
|
+
if (typeof node.id !== "string" || node.id.length === 0) {
|
|
1183
|
+
throw new Error("--node.id must be a non-empty string");
|
|
1184
|
+
}
|
|
1185
|
+
if (typeof node.disclosure !== "string") {
|
|
1186
|
+
throw new Error("--node.disclosure is required");
|
|
1187
|
+
}
|
|
1188
|
+
return node;
|
|
1189
|
+
}
|
|
1190
|
+
function emitUnavailable(io) {
|
|
1191
|
+
io.stdout(RECALL_NAV_UNAVAILABLE_TAG);
|
|
1192
|
+
return 0;
|
|
1193
|
+
}
|
|
1194
|
+
function runRecallNavigate(rest, io) {
|
|
1195
|
+
const action = rest[0];
|
|
1196
|
+
if (rest.length === 0 || action === "--help" || action === "-h" || action === "help") {
|
|
1197
|
+
io.stdout(recallNavigateHelp());
|
|
1198
|
+
return 0;
|
|
1199
|
+
}
|
|
1200
|
+
try {
|
|
1201
|
+
const budget = parseBudget(rest);
|
|
1202
|
+
const nodeRaw = takeFlag5(rest, "--node");
|
|
1203
|
+
if (nodeRaw === void 0) throw new Error("--node is required");
|
|
1204
|
+
const node = parseNode(nodeRaw);
|
|
1205
|
+
if (action === "expand") {
|
|
1206
|
+
const result = expandRecallNode(node, { budget });
|
|
1207
|
+
if (result.status === "unavailable") return emitUnavailable(io);
|
|
1208
|
+
io.stdout(JSON.stringify(result));
|
|
1209
|
+
return 0;
|
|
1210
|
+
}
|
|
1211
|
+
if (action === "traverse") {
|
|
1212
|
+
const linkType = takeFlag5(rest, "--type");
|
|
1213
|
+
if (linkType === void 0) throw new Error("traverse requires --type");
|
|
1214
|
+
const result = traverseRecallLink(node, linkType, { budget });
|
|
1215
|
+
if (result.status === "unavailable") return emitUnavailable(io);
|
|
1216
|
+
io.stdout(JSON.stringify(result));
|
|
1217
|
+
return 0;
|
|
1218
|
+
}
|
|
1219
|
+
io.stderr(`recall: unknown action "${action}".`);
|
|
1220
|
+
io.stderr(recallNavigateHelp());
|
|
1221
|
+
return 1;
|
|
1222
|
+
} catch (err) {
|
|
1223
|
+
io.stderr(err instanceof Error ? err.message : String(err));
|
|
1224
|
+
return 1;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
async function runRecallNavigateCommand(rest) {
|
|
1228
|
+
const code = runRecallNavigate(rest, {
|
|
1229
|
+
stdout: (line) => console.log(line),
|
|
1230
|
+
stderr: (line) => console.error(line)
|
|
1231
|
+
});
|
|
1232
|
+
if (code !== 0) process.exitCode = code;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
943
1235
|
// src/optional-module-loader.ts
|
|
944
1236
|
function isSpecifierNotFoundError(err, specifier) {
|
|
945
1237
|
if (!err || typeof err !== "object") {
|
|
@@ -990,7 +1282,7 @@ async function loadWecloneExportModule() {
|
|
|
990
1282
|
}
|
|
991
1283
|
|
|
992
1284
|
// src/converge.ts
|
|
993
|
-
import * as
|
|
1285
|
+
import * as fs16 from "fs";
|
|
994
1286
|
import { createHash as createHash3 } from "crypto";
|
|
995
1287
|
import * as path3 from "path";
|
|
996
1288
|
import {
|
|
@@ -1022,7 +1314,7 @@ import {
|
|
|
1022
1314
|
|
|
1023
1315
|
// src/offline-storage-io.ts
|
|
1024
1316
|
import { createDecipheriv, createHash } from "crypto";
|
|
1025
|
-
import
|
|
1317
|
+
import fs15 from "fs";
|
|
1026
1318
|
import { lstat, mkdtemp, readdir, rm } from "fs/promises";
|
|
1027
1319
|
import path2 from "path";
|
|
1028
1320
|
import {
|
|
@@ -1184,7 +1476,7 @@ async function* readOfflineSyncFileChunks(options) {
|
|
|
1184
1476
|
});
|
|
1185
1477
|
}
|
|
1186
1478
|
async function readFilePrefix(filePath, length) {
|
|
1187
|
-
const handle = await
|
|
1479
|
+
const handle = await fs15.promises.open(filePath, "r");
|
|
1188
1480
|
try {
|
|
1189
1481
|
const out = Buffer.alloc(length);
|
|
1190
1482
|
const { bytesRead } = await handle.read(out, 0, length, 0);
|
|
@@ -1194,7 +1486,7 @@ async function readFilePrefix(filePath, length) {
|
|
|
1194
1486
|
}
|
|
1195
1487
|
}
|
|
1196
1488
|
async function* readPlainOfflineFileChunks(filePath, chunkSize) {
|
|
1197
|
-
const stream =
|
|
1489
|
+
const stream = fs15.createReadStream(filePath, { highWaterMark: chunkSize });
|
|
1198
1490
|
for await (const chunk of stream) {
|
|
1199
1491
|
yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
1200
1492
|
}
|
|
@@ -1231,9 +1523,9 @@ async function* readEncryptedOfflineFileChunks(options) {
|
|
|
1231
1523
|
});
|
|
1232
1524
|
decipher.setAuthTag(authTag);
|
|
1233
1525
|
decipher.setAAD(Buffer.concat([secureStoreEnvelopeHeaderAad(salt), aad]));
|
|
1234
|
-
const output =
|
|
1526
|
+
const output = fs15.createWriteStream(tempPath, { mode: 384 });
|
|
1235
1527
|
try {
|
|
1236
|
-
const stream =
|
|
1528
|
+
const stream = fs15.createReadStream(options.filePath, {
|
|
1237
1529
|
start: MAGIC_HEADER_SIZE + ENVELOPE_HEADER_SIZE,
|
|
1238
1530
|
highWaterMark: options.chunkSize
|
|
1239
1531
|
});
|
|
@@ -1843,7 +2135,7 @@ async function readLocalTombstoneEvidence(rootDir) {
|
|
|
1843
2135
|
for (const relativePath of TOMBSTONE_PATHS) {
|
|
1844
2136
|
let content;
|
|
1845
2137
|
try {
|
|
1846
|
-
content = await
|
|
2138
|
+
content = await fs16.promises.readFile(path3.join(rootDir, relativePath), "utf-8");
|
|
1847
2139
|
} catch (error) {
|
|
1848
2140
|
if (error.code === "ENOENT") continue;
|
|
1849
2141
|
throw error;
|
|
@@ -1858,7 +2150,7 @@ async function discoverCursorNamespaces(memoryDir, peerUrl) {
|
|
|
1858
2150
|
const cursorDir = path3.join(path3.resolve(memoryDir), ".remnic", "state", "converge-cursors");
|
|
1859
2151
|
let entries;
|
|
1860
2152
|
try {
|
|
1861
|
-
entries = await
|
|
2153
|
+
entries = await fs16.promises.readdir(cursorDir, { withFileTypes: true });
|
|
1862
2154
|
} catch (error) {
|
|
1863
2155
|
if (error.code === "ENOENT") return [];
|
|
1864
2156
|
throw error;
|
|
@@ -2348,7 +2640,7 @@ async function executeConvergeApply(options = {}) {
|
|
|
2348
2640
|
if (current.sha256 !== entry.localSha256) {
|
|
2349
2641
|
throw new Error(`local file changed during push: ${localPath}`);
|
|
2350
2642
|
}
|
|
2351
|
-
const stat2 = await
|
|
2643
|
+
const stat2 = await fs16.promises.stat(filePath);
|
|
2352
2644
|
let chunks;
|
|
2353
2645
|
let chunkOffset = 0;
|
|
2354
2646
|
const resetChunks = async () => {
|
|
@@ -2831,7 +3123,7 @@ function renderReplayResult(result, targetNamespace, format) {
|
|
|
2831
3123
|
}
|
|
2832
3124
|
|
|
2833
3125
|
// src/quarantine-replay.ts
|
|
2834
|
-
import * as
|
|
3126
|
+
import * as fs17 from "fs";
|
|
2835
3127
|
import { EngramAccessService, Orchestrator as Orchestrator8, initLogger as initLogger3, parseConfig as parseConfig14, resolveRemnicConfigRecord as resolveRemnicConfigRecord13 } from "@remnic/core";
|
|
2836
3128
|
import { WriteQuarantineStore } from "@remnic/core/write-quarantine.js";
|
|
2837
3129
|
function valueFlag(args, flag) {
|
|
@@ -2880,7 +3172,7 @@ async function runQuarantineReplay(rest, format, resolveConfigPath2) {
|
|
|
2880
3172
|
let orchestrator;
|
|
2881
3173
|
try {
|
|
2882
3174
|
const configPath = resolveConfigPath2();
|
|
2883
|
-
const raw =
|
|
3175
|
+
const raw = fs17.existsSync(configPath) ? JSON.parse(fs17.readFileSync(configPath, "utf8")) : {};
|
|
2884
3176
|
const config = parseConfig14(resolveRemnicConfigRecord13(raw));
|
|
2885
3177
|
orchestrator = new Orchestrator8(config);
|
|
2886
3178
|
await orchestrator.initialize();
|
|
@@ -2912,7 +3204,7 @@ async function runQuarantineReplay(rest, format, resolveConfigPath2) {
|
|
|
2912
3204
|
}
|
|
2913
3205
|
|
|
2914
3206
|
// src/offline-impression-rotation.ts
|
|
2915
|
-
import
|
|
3207
|
+
import fs18 from "fs";
|
|
2916
3208
|
import { parseConfig as parseConfig15, resolveRemnicConfigRecord as resolveRemnicConfigRecord14, drainPendingImpressionsForOfflineSync } from "@remnic/core";
|
|
2917
3209
|
import { LastRecallStore } from "@remnic/core/recall-state";
|
|
2918
3210
|
function parseConfigQuietly(raw) {
|
|
@@ -2947,7 +3239,7 @@ function pickOfflineConfigRecord(raw) {
|
|
|
2947
3239
|
function resolveOfflineImpressionRotation(configPath) {
|
|
2948
3240
|
let raw;
|
|
2949
3241
|
try {
|
|
2950
|
-
raw =
|
|
3242
|
+
raw = fs18.existsSync(configPath) ? JSON.parse(fs18.readFileSync(configPath, "utf8")) : {};
|
|
2951
3243
|
} catch {
|
|
2952
3244
|
throw new Error(
|
|
2953
3245
|
`cannot read recall-impression rotation from ${configPath}: config file could not be read as JSON`
|
|
@@ -3205,7 +3497,7 @@ function assertBenchModuleFreshForDevelopment() {
|
|
|
3205
3497
|
}
|
|
3206
3498
|
|
|
3207
3499
|
// src/cmd-security.ts
|
|
3208
|
-
import
|
|
3500
|
+
import fs19 from "fs";
|
|
3209
3501
|
import {
|
|
3210
3502
|
Orchestrator as Orchestrator9,
|
|
3211
3503
|
parseConfig as parseConfig16,
|
|
@@ -3225,7 +3517,7 @@ async function cmdSecurity(rest) {
|
|
|
3225
3517
|
}
|
|
3226
3518
|
initLogger4();
|
|
3227
3519
|
const configPath = resolveConfigPath();
|
|
3228
|
-
const raw =
|
|
3520
|
+
const raw = fs19.existsSync(configPath) ? JSON.parse(fs19.readFileSync(configPath, "utf8")) : {};
|
|
3229
3521
|
const config = parseConfig16(resolveRemnicConfigRecord15(raw));
|
|
3230
3522
|
const orchestrator = new Orchestrator9(config);
|
|
3231
3523
|
await orchestrator.initialize();
|
|
@@ -3250,7 +3542,7 @@ async function cmdSecurity(rest) {
|
|
|
3250
3542
|
}
|
|
3251
3543
|
|
|
3252
3544
|
// src/daemon-service-candidates.ts
|
|
3253
|
-
import
|
|
3545
|
+
import fs20 from "fs";
|
|
3254
3546
|
import path6 from "path";
|
|
3255
3547
|
var LAUNCHD_LABEL = "ai.remnic.daemon";
|
|
3256
3548
|
var LEGACY_REMNIC_SERVER_LAUNCHD_LABEL = "ai.remnic.server";
|
|
@@ -3272,7 +3564,7 @@ function systemdUnitPaths(homeDir) {
|
|
|
3272
3564
|
function anyFileExists(paths) {
|
|
3273
3565
|
return paths.some((candidate) => {
|
|
3274
3566
|
try {
|
|
3275
|
-
return
|
|
3567
|
+
return fs20.statSync(candidate).isFile();
|
|
3276
3568
|
} catch {
|
|
3277
3569
|
return false;
|
|
3278
3570
|
}
|
|
@@ -3284,7 +3576,7 @@ function commandNames(command) {
|
|
|
3284
3576
|
}
|
|
3285
3577
|
function isRunnableNodeScript(filePath) {
|
|
3286
3578
|
try {
|
|
3287
|
-
const text =
|
|
3579
|
+
const text = fs20.readFileSync(filePath, "utf8").slice(0, 4096);
|
|
3288
3580
|
const firstLine = text.split(/\r?\n/, 1)[0] ?? "";
|
|
3289
3581
|
if (/^#!.*\bnode\b/.test(firstLine)) return true;
|
|
3290
3582
|
if (firstLine.startsWith("#!")) return false;
|
|
@@ -3297,7 +3589,7 @@ function isRunnableNodeScript(filePath) {
|
|
|
3297
3589
|
function resolveShimNodeScript(filePath) {
|
|
3298
3590
|
let text;
|
|
3299
3591
|
try {
|
|
3300
|
-
text =
|
|
3592
|
+
text = fs20.readFileSync(filePath, "utf8").slice(0, 16384);
|
|
3301
3593
|
} catch {
|
|
3302
3594
|
return void 0;
|
|
3303
3595
|
}
|
|
@@ -3309,8 +3601,8 @@ function resolveShimNodeScript(filePath) {
|
|
|
3309
3601
|
const candidate = raw.replaceAll("${basedir}", basedir).replaceAll("$basedir", basedir).replaceAll("\\ ", " ");
|
|
3310
3602
|
const resolved = path6.isAbsolute(candidate) ? candidate : path6.resolve(basedir, candidate);
|
|
3311
3603
|
try {
|
|
3312
|
-
if (
|
|
3313
|
-
return
|
|
3604
|
+
if (fs20.statSync(resolved).isFile() && isRunnableNodeScript(resolved)) {
|
|
3605
|
+
return fs20.realpathSync(resolved);
|
|
3314
3606
|
}
|
|
3315
3607
|
} catch {
|
|
3316
3608
|
}
|
|
@@ -3318,7 +3610,7 @@ function resolveShimNodeScript(filePath) {
|
|
|
3318
3610
|
return void 0;
|
|
3319
3611
|
}
|
|
3320
3612
|
function resolveRunnableNodeScript(filePath) {
|
|
3321
|
-
const realPath =
|
|
3613
|
+
const realPath = fs20.realpathSync(filePath);
|
|
3322
3614
|
if (isRunnableNodeScript(realPath)) return realPath;
|
|
3323
3615
|
return resolveShimNodeScript(realPath);
|
|
3324
3616
|
}
|
|
@@ -3328,9 +3620,9 @@ function findCommandOnPath(command, pathEnv = process.env.PATH ?? "") {
|
|
|
3328
3620
|
for (const name of commandNames(command)) {
|
|
3329
3621
|
const candidate = path6.join(dir, name);
|
|
3330
3622
|
try {
|
|
3331
|
-
const stat2 =
|
|
3623
|
+
const stat2 = fs20.statSync(candidate);
|
|
3332
3624
|
if (!stat2.isFile()) continue;
|
|
3333
|
-
if (process.platform !== "win32")
|
|
3625
|
+
if (process.platform !== "win32") fs20.accessSync(candidate, fs20.constants.X_OK);
|
|
3334
3626
|
const runnable = resolveRunnableNodeScript(candidate);
|
|
3335
3627
|
if (runnable) return runnable;
|
|
3336
3628
|
} catch {
|
|
@@ -4803,7 +5095,7 @@ function finalizeBenchStatus(filePath) {
|
|
|
4803
5095
|
}
|
|
4804
5096
|
|
|
4805
5097
|
// src/bench-fallback.ts
|
|
4806
|
-
import
|
|
5098
|
+
import fs21 from "fs";
|
|
4807
5099
|
import path10 from "path";
|
|
4808
5100
|
var FALLBACK_RESULTS_DIRNAME = "fallback-runs";
|
|
4809
5101
|
function buildBenchRunnerArgs(parsed, benchmarkId, outputDir) {
|
|
@@ -4875,7 +5167,7 @@ function createFallbackBenchOutputDir(resultsDir, benchmarkId, pid, startedAtMs
|
|
|
4875
5167
|
);
|
|
4876
5168
|
}
|
|
4877
5169
|
function resolveFallbackBenchResultPath(outputDir) {
|
|
4878
|
-
const entries =
|
|
5170
|
+
const entries = fs21.readdirSync(outputDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name).sort();
|
|
4879
5171
|
if (entries.length === 0) {
|
|
4880
5172
|
throw new Error(`Fallback benchmark runner did not write a JSON result artifact in ${outputDir}`);
|
|
4881
5173
|
}
|
|
@@ -4883,7 +5175,7 @@ function resolveFallbackBenchResultPath(outputDir) {
|
|
|
4883
5175
|
}
|
|
4884
5176
|
|
|
4885
5177
|
// src/openclaw-upgrade-swap.ts
|
|
4886
|
-
import
|
|
5178
|
+
import fs22 from "fs";
|
|
4887
5179
|
import path11 from "path";
|
|
4888
5180
|
function describeError(error) {
|
|
4889
5181
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -4895,7 +5187,7 @@ function createSiblingTempFilePath(targetPath, label) {
|
|
|
4895
5187
|
function resolveAtomicWriteMode(targetPath, explicitMode) {
|
|
4896
5188
|
if (explicitMode !== void 0) return explicitMode;
|
|
4897
5189
|
try {
|
|
4898
|
-
return
|
|
5190
|
+
return fs22.statSync(targetPath).mode & 4095;
|
|
4899
5191
|
} catch (error) {
|
|
4900
5192
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
4901
5193
|
return 384;
|
|
@@ -4905,8 +5197,8 @@ function resolveAtomicWriteMode(targetPath, explicitMode) {
|
|
|
4905
5197
|
}
|
|
4906
5198
|
function resolveAtomicReplacementPath(targetPath) {
|
|
4907
5199
|
try {
|
|
4908
|
-
if (
|
|
4909
|
-
return
|
|
5200
|
+
if (fs22.lstatSync(targetPath).isSymbolicLink()) {
|
|
5201
|
+
return fs22.realpathSync(targetPath);
|
|
4910
5202
|
}
|
|
4911
5203
|
} catch (error) {
|
|
4912
5204
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -4923,7 +5215,7 @@ function createSiblingSwapPath(targetDir, label) {
|
|
|
4923
5215
|
function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
4924
5216
|
if (!displacedDir) return void 0;
|
|
4925
5217
|
try {
|
|
4926
|
-
|
|
5218
|
+
fs22.rmSync(displacedDir, { recursive: true, force: true });
|
|
4927
5219
|
return void 0;
|
|
4928
5220
|
} catch (error) {
|
|
4929
5221
|
return `Warning: ${context}, but failed to remove the displaced plugin copy at ${displacedDir}: ${describeError(error)}`;
|
|
@@ -4931,43 +5223,43 @@ function cleanupDisplacedDirectoryBestEffort(displacedDir, context) {
|
|
|
4931
5223
|
}
|
|
4932
5224
|
function atomicWriteFileSync(targetPath, data, options = {}) {
|
|
4933
5225
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
4934
|
-
|
|
5226
|
+
fs22.mkdirSync(path11.dirname(resolvedTargetPath), { recursive: true });
|
|
4935
5227
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "write");
|
|
4936
5228
|
const mode = resolveAtomicWriteMode(resolvedTargetPath, options.mode);
|
|
4937
5229
|
try {
|
|
4938
5230
|
if (options.hooks?.writeTempFileSync) {
|
|
4939
5231
|
options.hooks.writeTempFileSync(tempPath);
|
|
4940
5232
|
} else {
|
|
4941
|
-
|
|
5233
|
+
fs22.writeFileSync(tempPath, data, { mode });
|
|
4942
5234
|
}
|
|
4943
|
-
|
|
4944
|
-
const renameTempFileSync = options.hooks?.renameTempFileSync ??
|
|
5235
|
+
fs22.chmodSync(tempPath, mode);
|
|
5236
|
+
const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs22.renameSync;
|
|
4945
5237
|
renameTempFileSync(tempPath, resolvedTargetPath);
|
|
4946
5238
|
} catch (error) {
|
|
4947
|
-
|
|
5239
|
+
fs22.rmSync(tempPath, { force: true });
|
|
4948
5240
|
throw error;
|
|
4949
5241
|
}
|
|
4950
5242
|
}
|
|
4951
5243
|
function atomicCopyFileSync(sourcePath, targetPath, options = {}) {
|
|
4952
|
-
if (!
|
|
5244
|
+
if (!fs22.existsSync(sourcePath)) return;
|
|
4953
5245
|
const resolvedTargetPath = resolveAtomicReplacementPath(targetPath);
|
|
4954
|
-
|
|
5246
|
+
fs22.mkdirSync(path11.dirname(resolvedTargetPath), { recursive: true });
|
|
4955
5247
|
const tempPath = createSiblingTempFilePath(resolvedTargetPath, "copy");
|
|
4956
|
-
const mode =
|
|
5248
|
+
const mode = fs22.statSync(sourcePath).mode & 4095;
|
|
4957
5249
|
try {
|
|
4958
|
-
const copyTempFileSync = options.hooks?.copyTempFileSync ??
|
|
5250
|
+
const copyTempFileSync = options.hooks?.copyTempFileSync ?? fs22.copyFileSync;
|
|
4959
5251
|
copyTempFileSync(sourcePath, tempPath);
|
|
4960
|
-
|
|
4961
|
-
const renameTempFileSync = options.hooks?.renameTempFileSync ??
|
|
5252
|
+
fs22.chmodSync(tempPath, mode);
|
|
5253
|
+
const renameTempFileSync = options.hooks?.renameTempFileSync ?? fs22.renameSync;
|
|
4962
5254
|
renameTempFileSync(tempPath, resolvedTargetPath);
|
|
4963
5255
|
} catch (error) {
|
|
4964
|
-
|
|
5256
|
+
fs22.rmSync(tempPath, { force: true });
|
|
4965
5257
|
throw error;
|
|
4966
5258
|
}
|
|
4967
5259
|
}
|
|
4968
5260
|
function cleanupRollbackDirectory(rollbackDir) {
|
|
4969
5261
|
if (!rollbackDir) return;
|
|
4970
|
-
|
|
5262
|
+
fs22.rmSync(rollbackDir, { recursive: true, force: true });
|
|
4971
5263
|
}
|
|
4972
5264
|
function cleanupRollbackDirectoryBestEffort(rollbackDir) {
|
|
4973
5265
|
if (!rollbackDir) return void 0;
|
|
@@ -4979,20 +5271,20 @@ function cleanupRollbackDirectoryBestEffort(rollbackDir) {
|
|
|
4979
5271
|
}
|
|
4980
5272
|
}
|
|
4981
5273
|
function restoreDirectoryFromRollback(targetDir, rollbackDir) {
|
|
4982
|
-
if (!
|
|
5274
|
+
if (!fs22.existsSync(rollbackDir)) {
|
|
4983
5275
|
throw new Error(`Rollback directory is missing: ${rollbackDir}`);
|
|
4984
5276
|
}
|
|
4985
|
-
|
|
4986
|
-
const displacedDir =
|
|
5277
|
+
fs22.mkdirSync(path11.dirname(targetDir), { recursive: true });
|
|
5278
|
+
const displacedDir = fs22.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "rollback-restore") : void 0;
|
|
4987
5279
|
if (displacedDir) {
|
|
4988
|
-
|
|
5280
|
+
fs22.renameSync(targetDir, displacedDir);
|
|
4989
5281
|
}
|
|
4990
5282
|
try {
|
|
4991
|
-
|
|
5283
|
+
fs22.renameSync(rollbackDir, targetDir);
|
|
4992
5284
|
} catch (restoreError) {
|
|
4993
|
-
if (displacedDir &&
|
|
5285
|
+
if (displacedDir && fs22.existsSync(displacedDir)) {
|
|
4994
5286
|
try {
|
|
4995
|
-
|
|
5287
|
+
fs22.renameSync(displacedDir, targetDir);
|
|
4996
5288
|
} catch (revertError) {
|
|
4997
5289
|
throw new AggregateError(
|
|
4998
5290
|
[restoreError, revertError],
|
|
@@ -5008,23 +5300,23 @@ function restoreDirectoryFromRollback(targetDir, rollbackDir) {
|
|
|
5008
5300
|
return cleanupDisplacedDirectoryBestEffort(displacedDir, `restored the previous plugin copy into ${targetDir}`);
|
|
5009
5301
|
}
|
|
5010
5302
|
function restoreDirectoryFromBackup(targetDir, backupDir) {
|
|
5011
|
-
if (!
|
|
5303
|
+
if (!fs22.existsSync(backupDir)) {
|
|
5012
5304
|
throw new Error(`Plugin backup directory is missing: ${backupDir}`);
|
|
5013
5305
|
}
|
|
5014
|
-
|
|
5306
|
+
fs22.mkdirSync(path11.dirname(targetDir), { recursive: true });
|
|
5015
5307
|
const stagedDir = createSiblingSwapPath(targetDir, "backup-restore");
|
|
5016
|
-
const displacedDir =
|
|
5017
|
-
|
|
5308
|
+
const displacedDir = fs22.existsSync(targetDir) ? createSiblingSwapPath(targetDir, "pre-backup-restore") : void 0;
|
|
5309
|
+
fs22.cpSync(backupDir, stagedDir, { recursive: true });
|
|
5018
5310
|
if (displacedDir) {
|
|
5019
|
-
|
|
5311
|
+
fs22.renameSync(targetDir, displacedDir);
|
|
5020
5312
|
}
|
|
5021
5313
|
try {
|
|
5022
|
-
|
|
5314
|
+
fs22.renameSync(stagedDir, targetDir);
|
|
5023
5315
|
} catch (restoreError) {
|
|
5024
|
-
|
|
5025
|
-
if (displacedDir &&
|
|
5316
|
+
fs22.rmSync(targetDir, { recursive: true, force: true });
|
|
5317
|
+
if (displacedDir && fs22.existsSync(displacedDir)) {
|
|
5026
5318
|
try {
|
|
5027
|
-
|
|
5319
|
+
fs22.renameSync(displacedDir, targetDir);
|
|
5028
5320
|
} catch (revertError) {
|
|
5029
5321
|
throw new AggregateError(
|
|
5030
5322
|
[restoreError, revertError],
|
|
@@ -5032,7 +5324,7 @@ function restoreDirectoryFromBackup(targetDir, backupDir) {
|
|
|
5032
5324
|
);
|
|
5033
5325
|
}
|
|
5034
5326
|
}
|
|
5035
|
-
|
|
5327
|
+
fs22.rmSync(stagedDir, { recursive: true, force: true });
|
|
5036
5328
|
throw new Error(
|
|
5037
5329
|
`Failed to restore the plugin backup into ${targetDir}. The durable backup remains preserved at ${backupDir}.`,
|
|
5038
5330
|
{ cause: restoreError }
|
|
@@ -5057,7 +5349,7 @@ function rollbackOpenclawUpgrade({
|
|
|
5057
5349
|
let configRemovalAttempted = false;
|
|
5058
5350
|
let pluginRestored = false;
|
|
5059
5351
|
try {
|
|
5060
|
-
if (rollbackDir &&
|
|
5352
|
+
if (rollbackDir && fs22.existsSync(rollbackDir)) {
|
|
5061
5353
|
const cleanupWarning = restoreDirectoryFromRollback(pluginDir, rollbackDir);
|
|
5062
5354
|
notes.push(`Restored previous plugin from rollback copy at ${rollbackDir}`);
|
|
5063
5355
|
if (cleanupWarning) notes.push(cleanupWarning);
|
|
@@ -5067,7 +5359,7 @@ function rollbackOpenclawUpgrade({
|
|
|
5067
5359
|
rollbackRestoreError = error instanceof Error ? error.message : String(error);
|
|
5068
5360
|
}
|
|
5069
5361
|
try {
|
|
5070
|
-
if (!pluginRestored && pluginBackupDir &&
|
|
5362
|
+
if (!pluginRestored && pluginBackupDir && fs22.existsSync(pluginBackupDir)) {
|
|
5071
5363
|
const cleanupWarning = restoreDirectoryFromBackup(pluginDir, pluginBackupDir);
|
|
5072
5364
|
if (rollbackRestoreError) {
|
|
5073
5365
|
notes.push(`Rollback copy restore failed; restored previous plugin from durable backup at ${pluginBackupDir}`);
|
|
@@ -5092,12 +5384,12 @@ function rollbackOpenclawUpgrade({
|
|
|
5092
5384
|
notes.push("No previous plugin copy was available for automatic restore");
|
|
5093
5385
|
}
|
|
5094
5386
|
try {
|
|
5095
|
-
if (configBackupPath &&
|
|
5387
|
+
if (configBackupPath && fs22.existsSync(configBackupPath)) {
|
|
5096
5388
|
restoreFileFromBackup(configPath, configBackupPath);
|
|
5097
5389
|
notes.push(`Restored OpenClaw config from backup at ${configBackupPath}`);
|
|
5098
|
-
} else if (removeConfigIfUnbacked &&
|
|
5390
|
+
} else if (removeConfigIfUnbacked && fs22.existsSync(configPath)) {
|
|
5099
5391
|
configRemovalAttempted = true;
|
|
5100
|
-
|
|
5392
|
+
fs22.rmSync(configPath, { force: true });
|
|
5101
5393
|
notes.push("Removed OpenClaw config created during the failed upgrade");
|
|
5102
5394
|
}
|
|
5103
5395
|
} catch (error) {
|
|
@@ -5150,7 +5442,7 @@ Run this manually when you're ready:
|
|
|
5150
5442
|
|
|
5151
5443
|
// src/openclaw-managed-upgrade-loader.ts
|
|
5152
5444
|
import { execFileSync } from "child_process";
|
|
5153
|
-
import
|
|
5445
|
+
import fs23 from "fs";
|
|
5154
5446
|
import os from "os";
|
|
5155
5447
|
import path12 from "path";
|
|
5156
5448
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "url";
|
|
@@ -5226,7 +5518,7 @@ function buildOpenclawManagedUpgradePackageSpec(version = "latest") {
|
|
|
5226
5518
|
function readCliAdapterRange() {
|
|
5227
5519
|
const moduleDir = path12.dirname(fileURLToPath3(import.meta.url));
|
|
5228
5520
|
const manifestPath = path12.resolve(moduleDir, "../package.json");
|
|
5229
|
-
const manifest = JSON.parse(
|
|
5521
|
+
const manifest = JSON.parse(fs23.readFileSync(manifestPath, "utf8"));
|
|
5230
5522
|
if (manifest.name !== "@remnic/cli") {
|
|
5231
5523
|
throw new Error(`Invalid @remnic/cli package manifest at ${manifestPath}.`);
|
|
5232
5524
|
}
|
|
@@ -5270,7 +5562,7 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
5270
5562
|
const adapterMissing = isSpecifierNotFoundError(error, OPENCLAW_PLUGIN_PACKAGE) || isSpecifierNotFoundError(error, MANAGED_UPGRADE_SPECIFIER) || isManagedUpgradeSubpathMissing(error);
|
|
5271
5563
|
if (!adapterMissing) throw error;
|
|
5272
5564
|
}
|
|
5273
|
-
const temporaryRoot =
|
|
5565
|
+
const temporaryRoot = fs23.mkdtempSync(path12.join(os.tmpdir(), "remnic-openclaw-upgrade-"));
|
|
5274
5566
|
try {
|
|
5275
5567
|
const toolingPackageSpec = `${OPENCLAW_PLUGIN_PACKAGE}@${readCliAdapterRange()}`;
|
|
5276
5568
|
const installArgs = [
|
|
@@ -5285,12 +5577,12 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
5285
5577
|
];
|
|
5286
5578
|
(hooks.runNpmInstall ?? runNpmInstall)(installArgs);
|
|
5287
5579
|
const resolverPath = path12.join(temporaryRoot, "load-managed-upgrade.mjs");
|
|
5288
|
-
|
|
5580
|
+
fs23.writeFileSync(resolverPath, `export * from ${JSON.stringify(MANAGED_UPGRADE_SPECIFIER)};
|
|
5289
5581
|
`, "utf8");
|
|
5290
5582
|
return await importModule(pathToFileURL2(resolverPath).href);
|
|
5291
5583
|
} finally {
|
|
5292
5584
|
try {
|
|
5293
|
-
|
|
5585
|
+
fs23.rmSync(temporaryRoot, { recursive: true, force: true });
|
|
5294
5586
|
} catch (error) {
|
|
5295
5587
|
const detail = error instanceof Error ? error.message : String(error);
|
|
5296
5588
|
console.warn(`Could not remove temporary managed upgrade project at ${temporaryRoot}: ${detail}`);
|
|
@@ -5299,13 +5591,13 @@ async function loadOpenclawManagedUpgradeModule(packageSpec, hooks = {}) {
|
|
|
5299
5591
|
}
|
|
5300
5592
|
|
|
5301
5593
|
// src/remote-daemon.ts
|
|
5302
|
-
import
|
|
5594
|
+
import fs24 from "fs";
|
|
5303
5595
|
function readCompatEnv(primary, legacy) {
|
|
5304
5596
|
return process.env[primary] ?? process.env[legacy];
|
|
5305
5597
|
}
|
|
5306
5598
|
function readRemnicConfigRecord(configPath) {
|
|
5307
5599
|
try {
|
|
5308
|
-
const parsed = JSON.parse(
|
|
5600
|
+
const parsed = JSON.parse(fs24.readFileSync(configPath, "utf8"));
|
|
5309
5601
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
5310
5602
|
return parsed;
|
|
5311
5603
|
}
|
|
@@ -5534,7 +5826,7 @@ async function remoteRecallXray(daemon, request) {
|
|
|
5534
5826
|
}
|
|
5535
5827
|
|
|
5536
5828
|
// src/daemon-service.ts
|
|
5537
|
-
import
|
|
5829
|
+
import fs25 from "fs";
|
|
5538
5830
|
import path13 from "path";
|
|
5539
5831
|
import * as childProcess from "child_process";
|
|
5540
5832
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -5546,7 +5838,7 @@ function launchdUnloadPlist(plistPath, processApi = childProcess) {
|
|
|
5546
5838
|
processApi.execFileSync("launchctl", ["unload", plistPath], { stdio: "pipe" });
|
|
5547
5839
|
}
|
|
5548
5840
|
function resolveServerBinDetails(options = {}) {
|
|
5549
|
-
const existsSync4 = options.existsSync ??
|
|
5841
|
+
const existsSync4 = options.existsSync ?? fs25.existsSync;
|
|
5550
5842
|
const findCommandOnPath2 = options.findCommandOnPath ?? findCommandOnPath;
|
|
5551
5843
|
const moduleDir = options.moduleDir ?? thisModuleDir;
|
|
5552
5844
|
const packageResolve = options.packageResolve ?? resolveImportSpecifier;
|
|
@@ -5605,8 +5897,8 @@ function resolveServerBin(options = {}) {
|
|
|
5605
5897
|
return resolveServerBinDetails(options).path;
|
|
5606
5898
|
}
|
|
5607
5899
|
function readVerifiedDaemonPid(options) {
|
|
5608
|
-
const readFileSync4 = options.readFileSync ??
|
|
5609
|
-
const unlinkSync = options.unlinkSync ??
|
|
5900
|
+
const readFileSync4 = options.readFileSync ?? fs25.readFileSync;
|
|
5901
|
+
const unlinkSync = options.unlinkSync ?? fs25.unlinkSync;
|
|
5610
5902
|
const processKill = options.processKill ?? process.kill;
|
|
5611
5903
|
const platform = options.platform ?? process.platform;
|
|
5612
5904
|
const execFileSync4 = options.execFileSync ?? ((command, args, execOptions) => childProcess.execFileSync(command, args, execOptions));
|
|
@@ -5706,8 +5998,8 @@ function removePidFileBestEffort(file, unlinkSync) {
|
|
|
5706
5998
|
}
|
|
5707
5999
|
}
|
|
5708
6000
|
function inspectLaunchdPlist(plistPath, options = {}) {
|
|
5709
|
-
const existsSync4 = options.existsSync ??
|
|
5710
|
-
const readFileSync4 = options.readFileSync ??
|
|
6001
|
+
const existsSync4 = options.existsSync ?? fs25.existsSync;
|
|
6002
|
+
const readFileSync4 = options.readFileSync ?? fs25.readFileSync;
|
|
5711
6003
|
if (!existsSync4(plistPath)) {
|
|
5712
6004
|
return {
|
|
5713
6005
|
installed: false,
|
|
@@ -5885,7 +6177,7 @@ function stripConfigArgv(args) {
|
|
|
5885
6177
|
}
|
|
5886
6178
|
|
|
5887
6179
|
// src/import-dispatch.ts
|
|
5888
|
-
import
|
|
6180
|
+
import fs26 from "fs";
|
|
5889
6181
|
import {
|
|
5890
6182
|
runImporter,
|
|
5891
6183
|
validateImportBatchSize,
|
|
@@ -6405,7 +6697,7 @@ async function cmdImport(rest, targetFactory, disposeTarget, ioOverrides = {}) {
|
|
|
6405
6697
|
let materializedTarget;
|
|
6406
6698
|
let materializePromise;
|
|
6407
6699
|
const io = {
|
|
6408
|
-
readFile: ioOverrides.readFile ?? (async (p) =>
|
|
6700
|
+
readFile: ioOverrides.readFile ?? (async (p) => fs26.promises.readFile(p, "utf-8")),
|
|
6409
6701
|
loadAdapter: ioOverrides.loadAdapter ?? (async (name) => (await loadImporterModule(name)).adapter),
|
|
6410
6702
|
runImporter: ioOverrides.runImporter ?? runImporter,
|
|
6411
6703
|
getWriteTarget: async () => {
|
|
@@ -6518,7 +6810,7 @@ async function cmdCapture(rest, io) {
|
|
|
6518
6810
|
}
|
|
6519
6811
|
|
|
6520
6812
|
// src/import-lossless-claw-cmd.ts
|
|
6521
|
-
import
|
|
6813
|
+
import fs27 from "fs";
|
|
6522
6814
|
import path15 from "path";
|
|
6523
6815
|
import {
|
|
6524
6816
|
applyLcmSchema,
|
|
@@ -6630,15 +6922,15 @@ async function loadImportLosslessClawModule() {
|
|
|
6630
6922
|
|
|
6631
6923
|
// src/import-lossless-claw-cmd.ts
|
|
6632
6924
|
function assertDirectoryOrAbsent(p, label) {
|
|
6633
|
-
if (
|
|
6925
|
+
if (fs27.existsSync(p) && !fs27.statSync(p).isDirectory()) {
|
|
6634
6926
|
throw new Error(`${label} is not a directory: ${p}`);
|
|
6635
6927
|
}
|
|
6636
6928
|
}
|
|
6637
6929
|
function assertFile(p, label) {
|
|
6638
|
-
if (!
|
|
6930
|
+
if (!fs27.existsSync(p)) {
|
|
6639
6931
|
throw new Error(`${label} does not exist: ${p}`);
|
|
6640
6932
|
}
|
|
6641
|
-
if (!
|
|
6933
|
+
if (!fs27.statSync(p).isFile()) {
|
|
6642
6934
|
throw new Error(`${label} is not a file: ${p}`);
|
|
6643
6935
|
}
|
|
6644
6936
|
}
|
|
@@ -6670,7 +6962,7 @@ async function cmdImportLosslessClaw(argv, io, deps = {}) {
|
|
|
6670
6962
|
try {
|
|
6671
6963
|
if (parsed.dryRun) {
|
|
6672
6964
|
const lcmPath = path15.join(memoryDir, "state", "lcm.sqlite");
|
|
6673
|
-
if (
|
|
6965
|
+
if (fs27.existsSync(lcmPath)) {
|
|
6674
6966
|
destDb = mod.openExistingLcmDatabaseReadOnly(lcmPath);
|
|
6675
6967
|
} else {
|
|
6676
6968
|
destDb = mod.openInMemoryDestinationDatabase();
|
|
@@ -8022,7 +8314,7 @@ async function resolveAllBenchmarks() {
|
|
|
8022
8314
|
if (packageBenchmarks) {
|
|
8023
8315
|
return packageBenchmarks.filter((entry) => entry.runnerAvailable).map((entry) => entry.id);
|
|
8024
8316
|
}
|
|
8025
|
-
if (!
|
|
8317
|
+
if (!fs28.existsSync(EVAL_RUNNER_PATH)) {
|
|
8026
8318
|
return [];
|
|
8027
8319
|
}
|
|
8028
8320
|
return BENCHMARK_CATALOG.filter((entry) => entry.category !== "ingestion").map((entry) => entry.id);
|
|
@@ -8070,7 +8362,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
|
|
|
8070
8362
|
`Fallback benchmark runner does not support provider-backed, gateway, or thinking/timeout flags (${unsupportedOptions.join(", ")}). Build/install @remnic/bench to use those options.`
|
|
8071
8363
|
);
|
|
8072
8364
|
}
|
|
8073
|
-
if (!
|
|
8365
|
+
if (!fs28.existsSync(EVAL_RUNNER_PATH)) {
|
|
8074
8366
|
console.error(
|
|
8075
8367
|
"Benchmark runner not found. Expected eval runner at evals/run.ts or a phase-1 @remnic/bench runtime export."
|
|
8076
8368
|
);
|
|
@@ -8080,7 +8372,7 @@ async function runBenchViaFallback(parsed, benchmarkId, runtimeProfile) {
|
|
|
8080
8372
|
path19.join(CLI_REPO_ROOT, "node_modules", ".bin", "tsx"),
|
|
8081
8373
|
path19.join(CLI_REPO_ROOT, "packages", "remnic-cli", "node_modules", ".bin", "tsx")
|
|
8082
8374
|
];
|
|
8083
|
-
const tsxCmd = tsxCandidates.find((candidate) =>
|
|
8375
|
+
const tsxCmd = tsxCandidates.find((candidate) => fs28.existsSync(candidate)) ?? "tsx";
|
|
8084
8376
|
const fallbackOutputDir = createFallbackBenchOutputDir(
|
|
8085
8377
|
parsed.resultsDir ?? resolveBenchOutputDir(),
|
|
8086
8378
|
benchmarkId,
|
|
@@ -8225,9 +8517,9 @@ var PERSONAMEM_COMPLETION_MARKER = path19.join(
|
|
|
8225
8517
|
);
|
|
8226
8518
|
function resolveRealpathWithinDataset(datasetPath, relativePath) {
|
|
8227
8519
|
try {
|
|
8228
|
-
const datasetRoot =
|
|
8520
|
+
const datasetRoot = fs28.realpathSync(datasetPath);
|
|
8229
8521
|
const candidatePath = path19.resolve(datasetRoot, relativePath);
|
|
8230
|
-
const candidateRealPath =
|
|
8522
|
+
const candidateRealPath = fs28.realpathSync(candidatePath);
|
|
8231
8523
|
const relativeToRoot = path19.relative(datasetRoot, candidateRealPath);
|
|
8232
8524
|
if (relativeToRoot.startsWith("..") || path19.isAbsolute(relativeToRoot)) {
|
|
8233
8525
|
return null;
|
|
@@ -8286,14 +8578,14 @@ function parseCsvRows(raw) {
|
|
|
8286
8578
|
function isPersonaMemDatasetComplete(datasetPath) {
|
|
8287
8579
|
try {
|
|
8288
8580
|
const completionMarkerPath = path19.join(datasetPath, PERSONAMEM_COMPLETION_MARKER);
|
|
8289
|
-
if (
|
|
8581
|
+
if (fs28.statSync(completionMarkerPath).isFile()) {
|
|
8290
8582
|
return true;
|
|
8291
8583
|
}
|
|
8292
8584
|
} catch {
|
|
8293
8585
|
}
|
|
8294
8586
|
const datasetFile = PERSONAMEM_DATASET_FILE_CANDIDATES.find((candidate) => {
|
|
8295
8587
|
try {
|
|
8296
|
-
return
|
|
8588
|
+
return fs28.statSync(path19.join(datasetPath, candidate)).isFile();
|
|
8297
8589
|
} catch {
|
|
8298
8590
|
return false;
|
|
8299
8591
|
}
|
|
@@ -8302,7 +8594,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
8302
8594
|
return false;
|
|
8303
8595
|
}
|
|
8304
8596
|
try {
|
|
8305
|
-
const rows = parseCsvRows(
|
|
8597
|
+
const rows = parseCsvRows(fs28.readFileSync(path19.join(datasetPath, datasetFile), "utf8"));
|
|
8306
8598
|
if (rows.length < 2) {
|
|
8307
8599
|
return false;
|
|
8308
8600
|
}
|
|
@@ -8317,7 +8609,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
8317
8609
|
}
|
|
8318
8610
|
return historyPaths.every((relativePath) => {
|
|
8319
8611
|
const resolvedPath = resolveRealpathWithinDataset(datasetPath, relativePath);
|
|
8320
|
-
return resolvedPath !== null &&
|
|
8612
|
+
return resolvedPath !== null && fs28.statSync(resolvedPath).isFile();
|
|
8321
8613
|
});
|
|
8322
8614
|
} catch {
|
|
8323
8615
|
return false;
|
|
@@ -8325,7 +8617,7 @@ function isPersonaMemDatasetComplete(datasetPath) {
|
|
|
8325
8617
|
}
|
|
8326
8618
|
function hasDatasetFile(datasetPath, relativePath) {
|
|
8327
8619
|
try {
|
|
8328
|
-
return
|
|
8620
|
+
return fs28.statSync(path19.join(datasetPath, relativePath)).isFile();
|
|
8329
8621
|
} catch {
|
|
8330
8622
|
return false;
|
|
8331
8623
|
}
|
|
@@ -8345,10 +8637,10 @@ function memoryAgentBenchDatasetHasRecSysSamples(datasetPath) {
|
|
|
8345
8637
|
return candidateFilenames.some((filename) => {
|
|
8346
8638
|
const filePath = path19.join(datasetPath, filename);
|
|
8347
8639
|
try {
|
|
8348
|
-
if (!
|
|
8640
|
+
if (!fs28.statSync(filePath).isFile()) {
|
|
8349
8641
|
return false;
|
|
8350
8642
|
}
|
|
8351
|
-
const raw =
|
|
8643
|
+
const raw = fs28.readFileSync(filePath, "utf8");
|
|
8352
8644
|
return /"source"\s*:\s*"recsys[_-]/i.test(raw);
|
|
8353
8645
|
} catch {
|
|
8354
8646
|
return false;
|
|
@@ -8364,7 +8656,7 @@ function isMemoryAgentBenchDatasetComplete(datasetPath) {
|
|
|
8364
8656
|
function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
8365
8657
|
let stats;
|
|
8366
8658
|
try {
|
|
8367
|
-
stats =
|
|
8659
|
+
stats = fs28.statSync(datasetPath);
|
|
8368
8660
|
} catch {
|
|
8369
8661
|
return false;
|
|
8370
8662
|
}
|
|
@@ -8374,7 +8666,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8374
8666
|
const marker = DOWNLOADED_DATASET_MARKERS[benchmarkId];
|
|
8375
8667
|
if (!marker) {
|
|
8376
8668
|
try {
|
|
8377
|
-
return
|
|
8669
|
+
return fs28.readdirSync(datasetPath).length > 0;
|
|
8378
8670
|
} catch {
|
|
8379
8671
|
return false;
|
|
8380
8672
|
}
|
|
@@ -8382,7 +8674,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8382
8674
|
if (marker.allOf) {
|
|
8383
8675
|
const hasAllRequiredFiles = marker.allOf.every((name) => {
|
|
8384
8676
|
try {
|
|
8385
|
-
return
|
|
8677
|
+
return fs28.statSync(path19.join(datasetPath, name)).isFile();
|
|
8386
8678
|
} catch {
|
|
8387
8679
|
return false;
|
|
8388
8680
|
}
|
|
@@ -8394,7 +8686,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8394
8686
|
if (marker.anyOf) {
|
|
8395
8687
|
const hasMarkerFile = marker.anyOf.some((name) => {
|
|
8396
8688
|
try {
|
|
8397
|
-
return
|
|
8689
|
+
return fs28.statSync(path19.join(datasetPath, name)).isFile();
|
|
8398
8690
|
} catch {
|
|
8399
8691
|
return false;
|
|
8400
8692
|
}
|
|
@@ -8412,7 +8704,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8412
8704
|
}
|
|
8413
8705
|
if (marker.ext) {
|
|
8414
8706
|
try {
|
|
8415
|
-
return
|
|
8707
|
+
return fs28.readdirSync(datasetPath).some(
|
|
8416
8708
|
(name) => name.endsWith(marker.ext) && !marker.exclude?.includes(name)
|
|
8417
8709
|
);
|
|
8418
8710
|
} catch {
|
|
@@ -8424,7 +8716,7 @@ function isDatasetDownloaded(datasetPath, benchmarkId) {
|
|
|
8424
8716
|
async function launchBenchUi(resultsDir) {
|
|
8425
8717
|
const benchUiDir = path19.join(CLI_REPO_ROOT, "packages", "bench-ui");
|
|
8426
8718
|
const pnpmCmd = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
|
8427
|
-
if (!
|
|
8719
|
+
if (!fs28.existsSync(path19.join(benchUiDir, "package.json"))) {
|
|
8428
8720
|
console.error("ERROR: @remnic/bench-ui is not available in this checkout.");
|
|
8429
8721
|
process.exit(1);
|
|
8430
8722
|
}
|
|
@@ -8462,13 +8754,13 @@ function listDownloadableBenchmarks() {
|
|
|
8462
8754
|
}
|
|
8463
8755
|
function resolveDatasetDownloadScriptPath() {
|
|
8464
8756
|
const bundled = path19.join(CLI_MODULE_DIR, "assets", "download-datasets.sh");
|
|
8465
|
-
if (
|
|
8757
|
+
if (fs28.existsSync(bundled)) {
|
|
8466
8758
|
return bundled;
|
|
8467
8759
|
}
|
|
8468
8760
|
return path19.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh");
|
|
8469
8761
|
}
|
|
8470
8762
|
function isRepoCheckout() {
|
|
8471
|
-
return
|
|
8763
|
+
return fs28.existsSync(path19.join(CLI_REPO_ROOT, "pnpm-workspace.yaml")) && fs28.existsSync(path19.join(CLI_REPO_ROOT, "evals", "scripts", "download-datasets.sh"));
|
|
8472
8764
|
}
|
|
8473
8765
|
function runDatasetDownloadScript(scriptPath, benchmarkId, datasetRoot, jsonMode) {
|
|
8474
8766
|
const stdio = jsonMode ? ["inherit", process.stderr, "inherit"] : "inherit";
|
|
@@ -8781,8 +9073,8 @@ async function exportBenchPackageResult(parsed) {
|
|
|
8781
9073
|
...reportCardProvenance ? { reportCardProvenance } : {}
|
|
8782
9074
|
});
|
|
8783
9075
|
if (parsed.output) {
|
|
8784
|
-
|
|
8785
|
-
|
|
9076
|
+
fs28.mkdirSync(path19.dirname(parsed.output), { recursive: true });
|
|
9077
|
+
fs28.writeFileSync(parsed.output, rendered);
|
|
8786
9078
|
console.log(`Exported ${summary.id} as ${parsed.format} to ${parsed.output}`);
|
|
8787
9079
|
return;
|
|
8788
9080
|
}
|
|
@@ -8827,7 +9119,7 @@ async function manageBenchDatasets(parsed) {
|
|
|
8827
9119
|
process.exit(1);
|
|
8828
9120
|
}
|
|
8829
9121
|
const scriptPath = resolveDatasetDownloadScriptPath();
|
|
8830
|
-
if (!
|
|
9122
|
+
if (!fs28.existsSync(scriptPath)) {
|
|
8831
9123
|
console.error(`ERROR: dataset download script not found: ${scriptPath}`);
|
|
8832
9124
|
process.exit(1);
|
|
8833
9125
|
}
|
|
@@ -9027,7 +9319,7 @@ async function calibrateBenchJudges(parsed, rawArgs) {
|
|
|
9027
9319
|
);
|
|
9028
9320
|
process.exit(1);
|
|
9029
9321
|
}
|
|
9030
|
-
const sourceResultSha256 = createHash4("sha256").update(
|
|
9322
|
+
const sourceResultSha256 = createHash4("sha256").update(fs28.readFileSync(latest.path)).digest("hex");
|
|
9031
9323
|
const expandedManifestPath = expandTilde(manifestPath);
|
|
9032
9324
|
if (!bench.resolveLocalLabJudgeProviderConfig) {
|
|
9033
9325
|
console.error(
|
|
@@ -9442,7 +9734,7 @@ function loadPinnedLoCoMoTaskSelector(parsed) {
|
|
|
9442
9734
|
}
|
|
9443
9735
|
let decoded;
|
|
9444
9736
|
try {
|
|
9445
|
-
decoded = JSON.parse(
|
|
9737
|
+
decoded = JSON.parse(fs28.readFileSync(parsed.taskIdsFile, "utf8"));
|
|
9446
9738
|
} catch (error) {
|
|
9447
9739
|
throw new Error(
|
|
9448
9740
|
`Unable to read --task-ids-file ${parsed.taskIdsFile}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -10117,7 +10409,7 @@ function resolveBenchReproDatasetDir(datasetDir) {
|
|
|
10117
10409
|
return void 0;
|
|
10118
10410
|
}
|
|
10119
10411
|
try {
|
|
10120
|
-
return
|
|
10412
|
+
return fs28.realpathSync(datasetDir);
|
|
10121
10413
|
} catch {
|
|
10122
10414
|
return datasetDir;
|
|
10123
10415
|
}
|
|
@@ -10171,7 +10463,7 @@ async function writeBenchReproManifestForPackageRun(args) {
|
|
|
10171
10463
|
}
|
|
10172
10464
|
function loadStandaloneConvergeCommandConfig() {
|
|
10173
10465
|
const configPath = resolveConfigPath();
|
|
10174
|
-
const raw =
|
|
10466
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
10175
10467
|
return parseConfig17(resolveRemnicConfigRecord16(raw));
|
|
10176
10468
|
}
|
|
10177
10469
|
function parseConvergePluginConfig(value) {
|
|
@@ -10200,13 +10492,13 @@ function resolveConfigPath(cliPath) {
|
|
|
10200
10492
|
path19.join(resolveHomeDir(), ".config", "engram", "config.json")
|
|
10201
10493
|
];
|
|
10202
10494
|
for (const candidate of candidates) {
|
|
10203
|
-
if (
|
|
10495
|
+
if (fs28.existsSync(candidate)) return candidate;
|
|
10204
10496
|
}
|
|
10205
10497
|
return path19.join(resolveHomeDir(), ".config", "remnic", "config.json");
|
|
10206
10498
|
}
|
|
10207
10499
|
function resolveExistingBenchRemnicConfigPath(cliPath) {
|
|
10208
10500
|
const configPath = resolveConfigPath(cliPath);
|
|
10209
|
-
if (
|
|
10501
|
+
if (fs28.existsSync(configPath)) {
|
|
10210
10502
|
return configPath;
|
|
10211
10503
|
}
|
|
10212
10504
|
if (cliPath) {
|
|
@@ -10216,7 +10508,7 @@ function resolveExistingBenchRemnicConfigPath(cliPath) {
|
|
|
10216
10508
|
}
|
|
10217
10509
|
function resolveExistingBenchOpenclawConfigPath(cliPath) {
|
|
10218
10510
|
const configPath = resolveOpenclawConfigPath(cliPath);
|
|
10219
|
-
if (
|
|
10511
|
+
if (fs28.existsSync(configPath)) {
|
|
10220
10512
|
return configPath;
|
|
10221
10513
|
}
|
|
10222
10514
|
if (cliPath) {
|
|
@@ -10323,7 +10615,7 @@ function resolveMemoryDir() {
|
|
|
10323
10615
|
const envMemoryDir = readCompatEnv("REMNIC_MEMORY_DIR", "ENGRAM_MEMORY_DIR");
|
|
10324
10616
|
if (envMemoryDir) return normalizeMemoryDirPath(envMemoryDir);
|
|
10325
10617
|
const configPath = resolveConfigPath();
|
|
10326
|
-
const raw =
|
|
10618
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
10327
10619
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
10328
10620
|
if (typeof remnicCfg.memoryDir === "string" && remnicCfg.memoryDir.length > 0) {
|
|
10329
10621
|
return normalizeMemoryDirPath(remnicCfg.memoryDir);
|
|
@@ -10332,18 +10624,18 @@ function resolveMemoryDir() {
|
|
|
10332
10624
|
const standalonePath = path19.join(home, ".remnic", "memory");
|
|
10333
10625
|
const legacyStandalonePath = path19.join(home, ".engram", "memory");
|
|
10334
10626
|
const openclawPath = path19.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
10335
|
-
if (
|
|
10336
|
-
if (
|
|
10627
|
+
if (fs28.existsSync(standalonePath)) return standalonePath;
|
|
10628
|
+
if (fs28.existsSync(legacyStandalonePath)) return legacyStandalonePath;
|
|
10337
10629
|
return openclawPath;
|
|
10338
10630
|
})();
|
|
10339
10631
|
const manifestPath = getManifestPath();
|
|
10340
|
-
if (
|
|
10632
|
+
if (fs28.existsSync(manifestPath)) {
|
|
10341
10633
|
try {
|
|
10342
10634
|
const active = getActiveSpace();
|
|
10343
10635
|
if (active?.memoryDir) {
|
|
10344
10636
|
const activeMemoryDir = normalizeMemoryDirPath(active.memoryDir);
|
|
10345
|
-
if (!
|
|
10346
|
-
|
|
10637
|
+
if (!fs28.existsSync(activeMemoryDir)) {
|
|
10638
|
+
fs28.mkdirSync(activeMemoryDir, { recursive: true });
|
|
10347
10639
|
}
|
|
10348
10640
|
return activeMemoryDir;
|
|
10349
10641
|
}
|
|
@@ -10392,13 +10684,13 @@ function resolveOpenclawConfigPath(cliPath) {
|
|
|
10392
10684
|
const envPath = process.env.OPENCLAW_CONFIG_PATH || process.env.OPENCLAW_ENGRAM_CONFIG_PATH;
|
|
10393
10685
|
if (envPath) return path19.resolve(expandTilde(envPath));
|
|
10394
10686
|
for (const candidate of DEFAULT_OPENCLAW_CONFIG_PATHS_FOR_DOCTOR) {
|
|
10395
|
-
if (
|
|
10687
|
+
if (fs28.existsSync(candidate)) return candidate;
|
|
10396
10688
|
}
|
|
10397
10689
|
return path19.join(resolveOpenclawStateDir(), "openclaw.json");
|
|
10398
10690
|
}
|
|
10399
10691
|
function readOpenclawConfig(configPath) {
|
|
10400
|
-
if (!
|
|
10401
|
-
const raw =
|
|
10692
|
+
if (!fs28.existsSync(configPath)) return {};
|
|
10693
|
+
const raw = fs28.readFileSync(configPath, "utf-8");
|
|
10402
10694
|
let parsed;
|
|
10403
10695
|
try {
|
|
10404
10696
|
parsed = JSON.parse(raw);
|
|
@@ -10500,9 +10792,9 @@ function formatOpenclawUpgradeStamp(now = /* @__PURE__ */ new Date()) {
|
|
|
10500
10792
|
return `${yyyy}${mm}${dd}-${hh}${min}${ss}`;
|
|
10501
10793
|
}
|
|
10502
10794
|
function backupPathIfPresent(sourcePath, backupPath) {
|
|
10503
|
-
if (!
|
|
10504
|
-
|
|
10505
|
-
|
|
10795
|
+
if (!fs28.existsSync(sourcePath)) return false;
|
|
10796
|
+
fs28.mkdirSync(path19.dirname(backupPath), { recursive: true });
|
|
10797
|
+
fs28.cpSync(sourcePath, backupPath, { recursive: true });
|
|
10506
10798
|
return true;
|
|
10507
10799
|
}
|
|
10508
10800
|
function restartOpenclawGateway() {
|
|
@@ -10521,7 +10813,7 @@ function restartOpenclawGateway() {
|
|
|
10521
10813
|
}
|
|
10522
10814
|
function cmdInit() {
|
|
10523
10815
|
const configPath = path19.join(process.cwd(), "remnic.config.json");
|
|
10524
|
-
if (
|
|
10816
|
+
if (fs28.existsSync(configPath)) {
|
|
10525
10817
|
console.log(`Config already exists: ${configPath}`);
|
|
10526
10818
|
return;
|
|
10527
10819
|
}
|
|
@@ -10537,7 +10829,7 @@ function cmdInit() {
|
|
|
10537
10829
|
authToken: "${REMNIC_AUTH_TOKEN}"
|
|
10538
10830
|
}
|
|
10539
10831
|
};
|
|
10540
|
-
|
|
10832
|
+
fs28.writeFileSync(configPath, JSON.stringify(template, null, 2) + "\n");
|
|
10541
10833
|
console.log(`Created ${configPath}`);
|
|
10542
10834
|
console.log("\nSet these environment variables:");
|
|
10543
10835
|
console.log(" export OPENAI_API_KEY=sk-...");
|
|
@@ -10959,7 +11251,7 @@ async function cmdQuery(queryText, json, explain) {
|
|
|
10959
11251
|
}
|
|
10960
11252
|
initLogger5();
|
|
10961
11253
|
const configPath = resolveConfigPath();
|
|
10962
|
-
const raw =
|
|
11254
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
10963
11255
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
10964
11256
|
const config = parseConfig17(remnicCfg);
|
|
10965
11257
|
const orchestrator = new Orchestrator10(config);
|
|
@@ -11139,7 +11431,7 @@ async function cmdXray(rest) {
|
|
|
11139
11431
|
}
|
|
11140
11432
|
initLogger5();
|
|
11141
11433
|
const configPath = resolveConfigPath();
|
|
11142
|
-
const raw =
|
|
11434
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
11143
11435
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
11144
11436
|
const config = parseConfig17(remnicCfg);
|
|
11145
11437
|
const orchestrator = new Orchestrator10(config);
|
|
@@ -11172,7 +11464,7 @@ async function runWhoKnowsCommand(rest, io) {
|
|
|
11172
11464
|
async function withLocalService(fn) {
|
|
11173
11465
|
initLogger5();
|
|
11174
11466
|
const configPath = resolveConfigPath();
|
|
11175
|
-
const raw =
|
|
11467
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
11176
11468
|
const orchestrator = new Orchestrator10(parseConfig17(resolveRemnicConfigRecord16(raw)));
|
|
11177
11469
|
await orchestrator.initialize();
|
|
11178
11470
|
await orchestrator.deferredReady;
|
|
@@ -11205,7 +11497,7 @@ async function cmdPromotionCandidates(rest) {
|
|
|
11205
11497
|
async function cmdVersions(rest) {
|
|
11206
11498
|
initLogger5();
|
|
11207
11499
|
const configPath = resolveConfigPath();
|
|
11208
|
-
const raw =
|
|
11500
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
11209
11501
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
11210
11502
|
const config = parseConfig17(remnicCfg);
|
|
11211
11503
|
if (!config.versioningEnabled) {
|
|
@@ -11321,7 +11613,7 @@ Options:
|
|
|
11321
11613
|
async function cmdEnrich(rest) {
|
|
11322
11614
|
initLogger5();
|
|
11323
11615
|
const configPath = resolveConfigPath();
|
|
11324
|
-
const raw =
|
|
11616
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
11325
11617
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
11326
11618
|
const config = parseConfig17(remnicCfg);
|
|
11327
11619
|
const subcommand = rest[0];
|
|
@@ -11515,7 +11807,7 @@ Registered providers:`);
|
|
|
11515
11807
|
async function cmdExtensions(action, rest) {
|
|
11516
11808
|
initLogger5();
|
|
11517
11809
|
const configPath = resolveConfigPath();
|
|
11518
|
-
const raw =
|
|
11810
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
11519
11811
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
11520
11812
|
const config = parseConfig17(remnicCfg);
|
|
11521
11813
|
const root = resolveExtensionsRoot(config);
|
|
@@ -11566,7 +11858,7 @@ Root: ${root}`);
|
|
|
11566
11858
|
const extensions = await discoverMemoryExtensions(root, warnLog);
|
|
11567
11859
|
let entries = [];
|
|
11568
11860
|
try {
|
|
11569
|
-
entries =
|
|
11861
|
+
entries = fs28.readdirSync(root);
|
|
11570
11862
|
} catch {
|
|
11571
11863
|
console.log(`Extensions root does not exist: ${root}`);
|
|
11572
11864
|
process.exitCode = 0;
|
|
@@ -11577,7 +11869,7 @@ Root: ${root}`);
|
|
|
11577
11869
|
for (const entry of entries) {
|
|
11578
11870
|
const entryPath = path19.join(root, entry);
|
|
11579
11871
|
try {
|
|
11580
|
-
if (!
|
|
11872
|
+
if (!fs28.statSync(entryPath).isDirectory()) continue;
|
|
11581
11873
|
} catch {
|
|
11582
11874
|
continue;
|
|
11583
11875
|
}
|
|
@@ -11609,7 +11901,7 @@ Root: ${root}`);
|
|
|
11609
11901
|
async function cmdBriefing(rest) {
|
|
11610
11902
|
initLogger5();
|
|
11611
11903
|
const configPath = resolveConfigPath();
|
|
11612
|
-
const raw =
|
|
11904
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
11613
11905
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
11614
11906
|
const config = parseConfig17(remnicCfg);
|
|
11615
11907
|
if (!config.briefing.enabled) {
|
|
@@ -11689,10 +11981,10 @@ async function cmdBriefing(rest) {
|
|
|
11689
11981
|
if (save) {
|
|
11690
11982
|
try {
|
|
11691
11983
|
const saveDir = resolveBriefingSaveDir(config.briefing.saveDir);
|
|
11692
|
-
|
|
11984
|
+
fs28.mkdirSync(saveDir, { recursive: true });
|
|
11693
11985
|
const filename = briefingFilename(new Date(result.window.to), format);
|
|
11694
11986
|
const filePath = path19.join(saveDir, filename);
|
|
11695
|
-
|
|
11987
|
+
fs28.writeFileSync(filePath, payload + (payload.endsWith("\n") ? "" : "\n"));
|
|
11696
11988
|
console.error(`Saved briefing: ${filePath}`);
|
|
11697
11989
|
} catch (err) {
|
|
11698
11990
|
console.error(`Failed to save briefing: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -11710,7 +12002,7 @@ async function cmdDoctor() {
|
|
|
11710
12002
|
detail: `${nodeVersion} (requires >= 22.12.0)`
|
|
11711
12003
|
});
|
|
11712
12004
|
const configPath = resolveConfigPath();
|
|
11713
|
-
const configExists =
|
|
12005
|
+
const configExists = fs28.existsSync(configPath);
|
|
11714
12006
|
checks.push({ name: "Config file", ok: configExists, detail: configPath });
|
|
11715
12007
|
let standaloneConfig;
|
|
11716
12008
|
let standaloneConfigError;
|
|
@@ -11718,7 +12010,7 @@ async function cmdDoctor() {
|
|
|
11718
12010
|
let configuredNs = { invalid: false };
|
|
11719
12011
|
if (configExists) {
|
|
11720
12012
|
try {
|
|
11721
|
-
const raw = JSON.parse(
|
|
12013
|
+
const raw = JSON.parse(fs28.readFileSync(configPath, "utf8"));
|
|
11722
12014
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
11723
12015
|
standaloneOpenaiApiKeyExplicitlyFalse = isOpenaiApiKeyDisabled(remnicCfg.openaiApiKey);
|
|
11724
12016
|
configuredNs = readConfiguredNamespace(remnicCfg);
|
|
@@ -11734,7 +12026,7 @@ async function cmdDoctor() {
|
|
|
11734
12026
|
memoryDir = parseConfig17({}).memoryDir;
|
|
11735
12027
|
}
|
|
11736
12028
|
try {
|
|
11737
|
-
|
|
12029
|
+
fs28.mkdirSync(memoryDir, { recursive: true });
|
|
11738
12030
|
checks.push({ name: "Memory directory", ok: true, detail: memoryDir });
|
|
11739
12031
|
} catch {
|
|
11740
12032
|
checks.push({ name: "Memory directory", ok: false, detail: `cannot create ${memoryDir}` });
|
|
@@ -11763,7 +12055,7 @@ async function cmdDoctor() {
|
|
|
11763
12055
|
});
|
|
11764
12056
|
if (nsPolicyCheck) checks.push(nsPolicyCheck);
|
|
11765
12057
|
const openclawConfigPath = resolveOpenclawConfigPath();
|
|
11766
|
-
const openclawConfigExists =
|
|
12058
|
+
const openclawConfigExists = fs28.existsSync(openclawConfigPath);
|
|
11767
12059
|
let openclawConfig = {};
|
|
11768
12060
|
let openclawConfigValid = false;
|
|
11769
12061
|
let openclawPluginModeConfigured = false;
|
|
@@ -11771,7 +12063,7 @@ async function cmdDoctor() {
|
|
|
11771
12063
|
let activeOpenclawEntryConfig = null;
|
|
11772
12064
|
if (openclawConfigExists) {
|
|
11773
12065
|
try {
|
|
11774
|
-
const parsed = JSON.parse(
|
|
12066
|
+
const parsed = JSON.parse(fs28.readFileSync(openclawConfigPath, "utf-8"));
|
|
11775
12067
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
11776
12068
|
openclawConfig = parsed;
|
|
11777
12069
|
openclawConfigValid = true;
|
|
@@ -11851,9 +12143,9 @@ async function cmdDoctor() {
|
|
|
11851
12143
|
let memDirOk = false;
|
|
11852
12144
|
let memDirDetail = `${resolvedMemDir} (not found)`;
|
|
11853
12145
|
let memDirRemediation = `Run \`remnic openclaw install --memory-dir "${resolvedMemDir}"\` to create the directory.`;
|
|
11854
|
-
if (
|
|
12146
|
+
if (fs28.existsSync(resolvedMemDir)) {
|
|
11855
12147
|
try {
|
|
11856
|
-
const stat2 =
|
|
12148
|
+
const stat2 = fs28.statSync(resolvedMemDir);
|
|
11857
12149
|
if (stat2.isDirectory()) {
|
|
11858
12150
|
memDirOk = true;
|
|
11859
12151
|
memDirDetail = resolvedMemDir;
|
|
@@ -12008,12 +12300,12 @@ async function cmdDoctor() {
|
|
|
12008
12300
|
}
|
|
12009
12301
|
function cmdConfig() {
|
|
12010
12302
|
const configPath = resolveConfigPath();
|
|
12011
|
-
if (!
|
|
12303
|
+
if (!fs28.existsSync(configPath)) {
|
|
12012
12304
|
console.log("No config file found. Run `remnic init` to create one.");
|
|
12013
12305
|
return;
|
|
12014
12306
|
}
|
|
12015
12307
|
console.log(`Config: ${configPath}`);
|
|
12016
|
-
const rawConfig =
|
|
12308
|
+
const rawConfig = fs28.readFileSync(configPath, "utf8");
|
|
12017
12309
|
const redacted = rawConfig.replace(
|
|
12018
12310
|
/("(?:openaiApiKey|localLlmApiKey|authToken|apiKey|remoteSearchApiKey|meilisearchApiKey|opikApiKey)"\s*:\s*")([^"]*)(")/g,
|
|
12019
12311
|
"$1[REDACTED]$3"
|
|
@@ -12121,7 +12413,7 @@ async function cmdReview(action, rest) {
|
|
|
12121
12413
|
const configPath = resolveConfigPath();
|
|
12122
12414
|
let tombstonesConfig = null;
|
|
12123
12415
|
try {
|
|
12124
|
-
const rawCfg =
|
|
12416
|
+
const rawCfg = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
12125
12417
|
const remnicCfg = resolveRemnicConfigRecord16(rawCfg);
|
|
12126
12418
|
const config = parseConfig17(remnicCfg);
|
|
12127
12419
|
tombstonesConfig = {
|
|
@@ -12865,7 +13157,7 @@ async function pushOfflineFileContent(args) {
|
|
|
12865
13157
|
}
|
|
12866
13158
|
async function pushOfflineFileContentFromChunkReader(args) {
|
|
12867
13159
|
const filePath = resolveOfflineDirectHydrationPath(args.memoryDir, args.file.path);
|
|
12868
|
-
const stat2 =
|
|
13160
|
+
const stat2 = fs28.statSync(filePath);
|
|
12869
13161
|
if (stat2.mtimeMs !== args.file.mtimeMs) {
|
|
12870
13162
|
throw new Error(`local file changed while pushing offline content: ${args.file.path}`);
|
|
12871
13163
|
}
|
|
@@ -13356,7 +13648,7 @@ function advanceOfflineBaseFilesForSuccessfulPush(options) {
|
|
|
13356
13648
|
return [...next.values()].sort((left, right) => left.path.localeCompare(right.path));
|
|
13357
13649
|
}
|
|
13358
13650
|
async function runOfflineSyncOnce(options) {
|
|
13359
|
-
|
|
13651
|
+
fs28.mkdirSync(options.memoryDir, { recursive: true });
|
|
13360
13652
|
let activeStatePath = options.statePath;
|
|
13361
13653
|
let priorState = await readOfflineSyncState(activeStatePath);
|
|
13362
13654
|
let syncNamespace = options.namespace ?? priorState?.namespace;
|
|
@@ -13989,7 +14281,7 @@ Environment fallbacks:
|
|
|
13989
14281
|
const configPath = resolveConfigPath();
|
|
13990
14282
|
let config;
|
|
13991
14283
|
try {
|
|
13992
|
-
const rawConfig =
|
|
14284
|
+
const rawConfig = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
13993
14285
|
config = parseConfigQuietly(pickOfflineConfigRecord(rawConfig));
|
|
13994
14286
|
} catch {
|
|
13995
14287
|
throw new Error(
|
|
@@ -14004,7 +14296,7 @@ Environment fallbacks:
|
|
|
14004
14296
|
const statePath = statePathExplicit ? path19.resolve(expandTilde(stateOverride)) : remoteUrl !== void 0 ? defaultOfflineSyncStatePath(memoryDir, remoteUrl, namespace) : void 0;
|
|
14005
14297
|
if (action === "prepare") {
|
|
14006
14298
|
if (!remoteUrl || !token || !statePath) throw new Error("offline prepare requires remote URL and token");
|
|
14007
|
-
|
|
14299
|
+
fs28.mkdirSync(memoryDir, { recursive: true });
|
|
14008
14300
|
const remoteSnapshot = await fetchOfflineSnapshot({
|
|
14009
14301
|
remoteUrl,
|
|
14010
14302
|
token,
|
|
@@ -14103,7 +14395,7 @@ Environment fallbacks:
|
|
|
14103
14395
|
return;
|
|
14104
14396
|
}
|
|
14105
14397
|
if (action === "status") {
|
|
14106
|
-
|
|
14398
|
+
fs28.mkdirSync(memoryDir, { recursive: true });
|
|
14107
14399
|
const state = statePath ? await readOfflineSyncState(statePath) : null;
|
|
14108
14400
|
if (state && remoteUrl && statePath) {
|
|
14109
14401
|
assertOfflineStateMatches({
|
|
@@ -14241,7 +14533,7 @@ function cmdDedup(json) {
|
|
|
14241
14533
|
function readInstalledConnectorConfig(configPath, fallback) {
|
|
14242
14534
|
if (!configPath) return fallback;
|
|
14243
14535
|
try {
|
|
14244
|
-
const parsed = JSON.parse(
|
|
14536
|
+
const parsed = JSON.parse(fs28.readFileSync(configPath, "utf8"));
|
|
14245
14537
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return fallback;
|
|
14246
14538
|
const { token: _token, ...config } = parsed;
|
|
14247
14539
|
return config;
|
|
@@ -14419,7 +14711,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
14419
14711
|
const pub = factory();
|
|
14420
14712
|
const available = await pub.isHostAvailable();
|
|
14421
14713
|
const extRoot = available ? await pub.resolveExtensionRoot() : "(host not installed)";
|
|
14422
|
-
const extensionExists = available && extRoot ?
|
|
14714
|
+
const extensionExists = available && extRoot ? fs28.existsSync(extRoot) : false;
|
|
14423
14715
|
publisherChecks.push({
|
|
14424
14716
|
name: `Publisher: ${targetHostId}`,
|
|
14425
14717
|
ok: !available || extensionExists,
|
|
@@ -14493,7 +14785,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
14493
14785
|
let connectorsCfg;
|
|
14494
14786
|
const configPath = resolveConfigPath();
|
|
14495
14787
|
try {
|
|
14496
|
-
const raw =
|
|
14788
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
14497
14789
|
connectorsCfg = parseConfigQuietly(raw).connectors;
|
|
14498
14790
|
} catch {
|
|
14499
14791
|
process.stderr.write(
|
|
@@ -14569,7 +14861,7 @@ async function cmdConnectors(action, rest, json) {
|
|
|
14569
14861
|
}
|
|
14570
14862
|
initLogger5();
|
|
14571
14863
|
const configPath = resolveConfigPath();
|
|
14572
|
-
const raw =
|
|
14864
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
14573
14865
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
14574
14866
|
const config = parseConfig17(remnicCfg);
|
|
14575
14867
|
const orchestrator = new Orchestrator10(config);
|
|
@@ -14694,7 +14986,7 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
|
|
|
14694
14986
|
console.error(`connectors marketplace: ${err instanceof Error ? err.message : String(err)}`);
|
|
14695
14987
|
process.exit(1);
|
|
14696
14988
|
}
|
|
14697
|
-
const rawConfig =
|
|
14989
|
+
const rawConfig = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
14698
14990
|
const pluginConfig = resolveRemnicConfigRecord16(rawConfig);
|
|
14699
14991
|
const config = parseConfig17(pluginConfig);
|
|
14700
14992
|
if (subAction === "generate") {
|
|
@@ -14716,13 +15008,13 @@ async function cmdConnectorsMarketplace(subAction, rest, json) {
|
|
|
14716
15008
|
} else if (subAction === "validate") {
|
|
14717
15009
|
const targetPath = rest.filter((a) => !a.startsWith("--"))[0] ?? path19.join(process.cwd(), "marketplace.json");
|
|
14718
15010
|
const resolved = path19.resolve(targetPath);
|
|
14719
|
-
if (!
|
|
15011
|
+
if (!fs28.existsSync(resolved)) {
|
|
14720
15012
|
console.error(`File not found: ${resolved}`);
|
|
14721
15013
|
process.exit(1);
|
|
14722
15014
|
}
|
|
14723
15015
|
let parsed;
|
|
14724
15016
|
try {
|
|
14725
|
-
parsed = JSON.parse(
|
|
15017
|
+
parsed = JSON.parse(fs28.readFileSync(resolved, "utf8"));
|
|
14726
15018
|
} catch {
|
|
14727
15019
|
console.error(`Invalid JSON in ${resolved}`);
|
|
14728
15020
|
process.exit(1);
|
|
@@ -14925,7 +15217,7 @@ async function cmdSpace(action, rest, json) {
|
|
|
14925
15217
|
async function cmdLegacyBenchmark(action, rest, json) {
|
|
14926
15218
|
initLogger5();
|
|
14927
15219
|
const configPath = resolveConfigPath();
|
|
14928
|
-
const raw =
|
|
15220
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
14929
15221
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
14930
15222
|
const config = parseConfig17(remnicCfg);
|
|
14931
15223
|
const orchestrator = new Orchestrator10(config);
|
|
@@ -15330,7 +15622,7 @@ function readPid() {
|
|
|
15330
15622
|
function inferPort() {
|
|
15331
15623
|
try {
|
|
15332
15624
|
const configPath = resolveConfigPath();
|
|
15333
|
-
const raw = JSON.parse(
|
|
15625
|
+
const raw = JSON.parse(fs28.readFileSync(configPath, "utf8"));
|
|
15334
15626
|
return raw.server?.port ?? 4318;
|
|
15335
15627
|
} catch {
|
|
15336
15628
|
return 4318;
|
|
@@ -15425,13 +15717,13 @@ function daemonInstall() {
|
|
|
15425
15717
|
process.exit(1);
|
|
15426
15718
|
}
|
|
15427
15719
|
const vars = { HOME: home, NODE_PATH: nodePath, REMNIC_SERVER_BIN: serverBin };
|
|
15428
|
-
|
|
15720
|
+
fs28.mkdirSync(LOGS_DIR, { recursive: true });
|
|
15429
15721
|
if (isMacOS()) {
|
|
15430
15722
|
const templatePath = path19.resolve(import.meta.dirname, "../templates/launchd/ai.remnic.daemon.plist");
|
|
15431
|
-
const template =
|
|
15723
|
+
const template = fs28.readFileSync(templatePath, "utf8");
|
|
15432
15724
|
const plist = renderTemplate(template, vars);
|
|
15433
|
-
|
|
15434
|
-
|
|
15725
|
+
fs28.mkdirSync(path19.dirname(LAUNCHD_PLIST_PATH), { recursive: true });
|
|
15726
|
+
fs28.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
15435
15727
|
try {
|
|
15436
15728
|
launchdLoadPlist(LAUNCHD_PLIST_PATH);
|
|
15437
15729
|
} catch (err) {
|
|
@@ -15448,10 +15740,10 @@ function daemonInstall() {
|
|
|
15448
15740
|
console.log(` Logs: ${LOGS_DIR}/daemon.log`);
|
|
15449
15741
|
} else if (isLinux()) {
|
|
15450
15742
|
const templatePath = path19.resolve(import.meta.dirname, "../templates/systemd/remnic.service");
|
|
15451
|
-
const template =
|
|
15743
|
+
const template = fs28.readFileSync(templatePath, "utf8");
|
|
15452
15744
|
const unit = renderTemplate(template, vars);
|
|
15453
|
-
|
|
15454
|
-
|
|
15745
|
+
fs28.mkdirSync(path19.dirname(SYSTEMD_UNIT_PATH), { recursive: true });
|
|
15746
|
+
fs28.writeFileSync(SYSTEMD_UNIT_PATH, unit);
|
|
15455
15747
|
try {
|
|
15456
15748
|
childProcess2.execSync("systemctl --user daemon-reload", { stdio: "pipe" });
|
|
15457
15749
|
} catch (err) {
|
|
@@ -15487,7 +15779,7 @@ function daemonUninstall() {
|
|
|
15487
15779
|
} catch {
|
|
15488
15780
|
}
|
|
15489
15781
|
try {
|
|
15490
|
-
|
|
15782
|
+
fs28.unlinkSync(plistPath);
|
|
15491
15783
|
removed = true;
|
|
15492
15784
|
console.log(`Removed launchd service: ${plistPath}`);
|
|
15493
15785
|
} catch {
|
|
@@ -15507,7 +15799,7 @@ function daemonUninstall() {
|
|
|
15507
15799
|
let removed = false;
|
|
15508
15800
|
for (const unitPath of SYSTEMD_UNIT_PATHS) {
|
|
15509
15801
|
try {
|
|
15510
|
-
|
|
15802
|
+
fs28.unlinkSync(unitPath);
|
|
15511
15803
|
removed = true;
|
|
15512
15804
|
console.log(`Removed systemd service: ${unitPath}`);
|
|
15513
15805
|
} catch {
|
|
@@ -15574,11 +15866,11 @@ async function daemonStatus() {
|
|
|
15574
15866
|
console.log(` Port: ${port}`);
|
|
15575
15867
|
console.log(` Service: ${serviceInstalled ? "installed" : "not installed"}`);
|
|
15576
15868
|
console.log(` Platform: ${process.platform}`);
|
|
15577
|
-
console.log(` PID file: ${
|
|
15578
|
-
console.log(` Log file: ${
|
|
15869
|
+
console.log(` PID file: ${fs28.existsSync(PID_FILE) ? PID_FILE : LEGACY_PID_FILE}`);
|
|
15870
|
+
console.log(` Log file: ${fs28.existsSync(LOG_FILE) ? LOG_FILE : LEGACY_LOG_FILE}`);
|
|
15579
15871
|
try {
|
|
15580
15872
|
const configPath = resolveConfigPath();
|
|
15581
|
-
const raw =
|
|
15873
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
15582
15874
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
15583
15875
|
const config = parseConfig17(remnicCfg);
|
|
15584
15876
|
const extRoot = resolveExtensionsRoot(config);
|
|
@@ -15619,9 +15911,9 @@ function daemonStart() {
|
|
|
15619
15911
|
return;
|
|
15620
15912
|
}
|
|
15621
15913
|
}
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
const logStream =
|
|
15914
|
+
fs28.mkdirSync(PID_DIR, { recursive: true });
|
|
15915
|
+
fs28.mkdirSync(LOGS_DIR, { recursive: true });
|
|
15916
|
+
const logStream = fs28.openSync(LOG_FILE, "a");
|
|
15625
15917
|
const serverBin = resolveServerBin();
|
|
15626
15918
|
const isSource = serverBin.endsWith(".ts");
|
|
15627
15919
|
let cmd;
|
|
@@ -15643,7 +15935,7 @@ function daemonStart() {
|
|
|
15643
15935
|
}
|
|
15644
15936
|
});
|
|
15645
15937
|
child.unref();
|
|
15646
|
-
|
|
15938
|
+
fs28.writeFileSync(PID_FILE, String(child.pid));
|
|
15647
15939
|
console.log(`Started remnic server (pid ${child.pid})`);
|
|
15648
15940
|
console.log(` Log: ${LOG_FILE}`);
|
|
15649
15941
|
}
|
|
@@ -15677,11 +15969,11 @@ function daemonStop() {
|
|
|
15677
15969
|
console.log("Process not found (cleaning up PID file)");
|
|
15678
15970
|
}
|
|
15679
15971
|
try {
|
|
15680
|
-
|
|
15972
|
+
fs28.unlinkSync(PID_FILE);
|
|
15681
15973
|
} catch {
|
|
15682
15974
|
}
|
|
15683
15975
|
try {
|
|
15684
|
-
|
|
15976
|
+
fs28.unlinkSync(LEGACY_PID_FILE);
|
|
15685
15977
|
} catch {
|
|
15686
15978
|
}
|
|
15687
15979
|
}
|
|
@@ -15809,7 +16101,7 @@ async function promptYesNo(question, defaultYes = true) {
|
|
|
15809
16101
|
async function cmdBinary(rest) {
|
|
15810
16102
|
initLogger5();
|
|
15811
16103
|
const configPath = resolveConfigPath();
|
|
15812
|
-
const raw =
|
|
16104
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
15813
16105
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
15814
16106
|
const config = parseConfig17(remnicCfg);
|
|
15815
16107
|
const memoryDir = resolveMemoryDir();
|
|
@@ -16000,7 +16292,7 @@ async function cmdOpenclawInstall(opts) {
|
|
|
16000
16292
|
} else if (slotIsActiveLegacy) {
|
|
16001
16293
|
changes.push(` Slot left as "${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID}" \u2014 re-run with --yes to activate the new entry`);
|
|
16002
16294
|
}
|
|
16003
|
-
if (!
|
|
16295
|
+
if (!fs28.existsSync(memoryDir)) changes.push(`+ Will create memory directory: ${memoryDir}`);
|
|
16004
16296
|
if (hasLegacy && migrateLegacy) {
|
|
16005
16297
|
changes.push(`~ Legacy '${REMNIC_OPENCLAW_LEGACY_PLUGIN_ID}' entry retained (safe to remove after verifying hooks fire)`);
|
|
16006
16298
|
}
|
|
@@ -16020,8 +16312,8 @@ async function cmdOpenclawInstall(opts) {
|
|
|
16020
16312
|
Resulting plugins.slots.memory: ${dryRunPlugins.slots?.memory ?? "(unset)"}`);
|
|
16021
16313
|
return;
|
|
16022
16314
|
}
|
|
16023
|
-
if (
|
|
16024
|
-
const st =
|
|
16315
|
+
if (fs28.existsSync(memoryDir)) {
|
|
16316
|
+
const st = fs28.statSync(memoryDir);
|
|
16025
16317
|
if (!st.isDirectory()) {
|
|
16026
16318
|
throw new Error(
|
|
16027
16319
|
`Cannot use ${memoryDir} as the memory directory \u2014 a file already exists at that path.
|
|
@@ -16029,12 +16321,12 @@ Remove it first and re-run, or choose a different path with --memory-dir.`
|
|
|
16029
16321
|
);
|
|
16030
16322
|
}
|
|
16031
16323
|
} else {
|
|
16032
|
-
|
|
16324
|
+
fs28.mkdirSync(memoryDir, { recursive: true });
|
|
16033
16325
|
console.log(`Created memory directory: ${memoryDir}`);
|
|
16034
16326
|
}
|
|
16035
16327
|
const configDir = path19.dirname(configPath);
|
|
16036
|
-
if (!
|
|
16037
|
-
|
|
16328
|
+
if (!fs28.existsSync(configDir)) {
|
|
16329
|
+
fs28.mkdirSync(configDir, { recursive: true });
|
|
16038
16330
|
}
|
|
16039
16331
|
atomicWriteFileSync(configPath, JSON.stringify(updatedConfig, null, 2) + "\n");
|
|
16040
16332
|
console.log("\nDone! Summary of changes:");
|
|
@@ -16063,7 +16355,7 @@ async function cmdOpenclawUpgrade(opts) {
|
|
|
16063
16355
|
const legacyPluginDirForBackup = opts.legacyPluginDirForBackup ? resolveOpenclawLegacyPluginDir(opts.legacyPluginDirForBackup) : void 0;
|
|
16064
16356
|
const fallbackMemoryDir = path19.join(resolveOpenclawStateDir(), "workspace", "memory", "local");
|
|
16065
16357
|
const packageSpec = buildOpenclawManagedUpgradePackageSpec(opts.version);
|
|
16066
|
-
const configExistedBefore =
|
|
16358
|
+
const configExistedBefore = fs28.existsSync(configPath);
|
|
16067
16359
|
const existingConfig = readOpenclawConfig(configPath);
|
|
16068
16360
|
const { entries, slots } = parseOpenclawPluginState(existingConfig, configPath);
|
|
16069
16361
|
const preservedMemoryDir = opts.memoryDir ? path19.resolve(expandTilde(opts.memoryDir)) : resolveCurrentOpenclawMemoryDir(entries, slots, fallbackMemoryDir);
|
|
@@ -16288,13 +16580,13 @@ async function cmdOpenclawMigrateEngram(opts) {
|
|
|
16288
16580
|
}
|
|
16289
16581
|
function createOpenclawUpgradeBackupDir() {
|
|
16290
16582
|
const backupsRoot = path19.join(resolveOpenclawStateDir(), "backups");
|
|
16291
|
-
|
|
16292
|
-
return
|
|
16583
|
+
fs28.mkdirSync(backupsRoot, { recursive: true });
|
|
16584
|
+
return fs28.mkdtempSync(path19.join(backupsRoot, `remnic-openclaw-upgrade-${formatOpenclawUpgradeStamp()}-`));
|
|
16293
16585
|
}
|
|
16294
16586
|
async function cmdTaxonomy(rest) {
|
|
16295
16587
|
initLogger5();
|
|
16296
16588
|
const configPath = resolveConfigPath();
|
|
16297
|
-
const raw =
|
|
16589
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
16298
16590
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
16299
16591
|
const config = parseConfig17(remnicCfg);
|
|
16300
16592
|
if (!config.taxonomyEnabled) {
|
|
@@ -16332,8 +16624,8 @@ async function cmdTaxonomy(rest) {
|
|
|
16332
16624
|
console.log(doc);
|
|
16333
16625
|
if (config.taxonomyAutoGenResolver) {
|
|
16334
16626
|
const resolverPath = path19.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
16335
|
-
|
|
16336
|
-
|
|
16627
|
+
fs28.mkdirSync(path19.dirname(resolverPath), { recursive: true });
|
|
16628
|
+
fs28.writeFileSync(resolverPath, doc);
|
|
16337
16629
|
console.error(`Written: ${resolverPath}`);
|
|
16338
16630
|
}
|
|
16339
16631
|
break;
|
|
@@ -16379,7 +16671,7 @@ async function cmdTaxonomy(rest) {
|
|
|
16379
16671
|
if (config.taxonomyAutoGenResolver) {
|
|
16380
16672
|
const doc = generateResolverDocument(taxonomy);
|
|
16381
16673
|
const resolverPath = path19.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
16382
|
-
|
|
16674
|
+
fs28.writeFileSync(resolverPath, doc);
|
|
16383
16675
|
console.error(`Regenerated: ${resolverPath}`);
|
|
16384
16676
|
}
|
|
16385
16677
|
break;
|
|
@@ -16410,7 +16702,7 @@ async function cmdTaxonomy(rest) {
|
|
|
16410
16702
|
if (config.taxonomyAutoGenResolver) {
|
|
16411
16703
|
const doc = generateResolverDocument(taxonomy);
|
|
16412
16704
|
const resolverPath = path19.join(config.memoryDir, ".taxonomy", "RESOLVER.md");
|
|
16413
|
-
|
|
16705
|
+
fs28.writeFileSync(resolverPath, doc);
|
|
16414
16706
|
console.error(`Regenerated: ${resolverPath}`);
|
|
16415
16707
|
}
|
|
16416
16708
|
break;
|
|
@@ -16601,12 +16893,12 @@ async function runTrainingExport(args, stdout = process.stdout) {
|
|
|
16601
16893
|
`Unknown training-export format "${args.format}". ${validList}`
|
|
16602
16894
|
);
|
|
16603
16895
|
}
|
|
16604
|
-
if (!
|
|
16896
|
+
if (!fs28.existsSync(args.memoryDir)) {
|
|
16605
16897
|
throw new Error(
|
|
16606
16898
|
`--memory-dir "${args.memoryDir}" does not exist. Provide the path to an existing memory directory.`
|
|
16607
16899
|
);
|
|
16608
16900
|
}
|
|
16609
|
-
if (!
|
|
16901
|
+
if (!fs28.statSync(args.memoryDir).isDirectory()) {
|
|
16610
16902
|
throw new Error(
|
|
16611
16903
|
`--memory-dir "${args.memoryDir}" is not a directory. Provide the path to a memory directory, not a file.`
|
|
16612
16904
|
);
|
|
@@ -16692,10 +16984,10 @@ async function runTrainingExport(args, stdout = process.stdout) {
|
|
|
16692
16984
|
}
|
|
16693
16985
|
const formatted = adapter.formatRecords(records);
|
|
16694
16986
|
const outDir = path19.dirname(args.output);
|
|
16695
|
-
|
|
16987
|
+
fs28.mkdirSync(outDir, { recursive: true });
|
|
16696
16988
|
const tmpPath = `${args.output}.tmp-${process.pid}-${Date.now()}`;
|
|
16697
|
-
|
|
16698
|
-
|
|
16989
|
+
fs28.writeFileSync(tmpPath, formatted, "utf-8");
|
|
16990
|
+
fs28.renameSync(tmpPath, args.output);
|
|
16699
16991
|
stdout.write(
|
|
16700
16992
|
`Exported ${records.length} records to ${args.output} (${adapter.name} format)
|
|
16701
16993
|
`
|
|
@@ -16738,6 +17030,9 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
16738
17030
|
await cmdQuery(queryText, json, explain);
|
|
16739
17031
|
break;
|
|
16740
17032
|
}
|
|
17033
|
+
case "recall":
|
|
17034
|
+
await runRecallNavigateCommand(rest);
|
|
17035
|
+
break;
|
|
16741
17036
|
case "action-confidence":
|
|
16742
17037
|
await cmdActionConfidence(rest);
|
|
16743
17038
|
break;
|
|
@@ -16873,7 +17168,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
16873
17168
|
}
|
|
16874
17169
|
}, 500);
|
|
16875
17170
|
};
|
|
16876
|
-
|
|
17171
|
+
fs28.watch(memoryDir, { recursive: true }, (_event, filename) => {
|
|
16877
17172
|
if (filename && filename.startsWith(".")) return;
|
|
16878
17173
|
rebuild();
|
|
16879
17174
|
});
|
|
@@ -16881,12 +17176,12 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
16881
17176
|
});
|
|
16882
17177
|
} else if (subAction === "validate") {
|
|
16883
17178
|
const treeDir = outputDir;
|
|
16884
|
-
if (!
|
|
17179
|
+
if (!fs28.existsSync(treeDir)) {
|
|
16885
17180
|
console.error(`Context tree not found at ${treeDir}. Run 'remnic tree generate' first.`);
|
|
16886
17181
|
process.exit(1);
|
|
16887
17182
|
}
|
|
16888
17183
|
const indexPath = path19.join(treeDir, "INDEX.md");
|
|
16889
|
-
if (!
|
|
17184
|
+
if (!fs28.existsSync(indexPath)) {
|
|
16890
17185
|
console.error(`INDEX.md missing in ${treeDir}. Tree may be corrupt \u2014 regenerate.`);
|
|
16891
17186
|
process.exit(1);
|
|
16892
17187
|
}
|
|
@@ -17092,6 +17387,15 @@ Other:
|
|
|
17092
17387
|
case "journal":
|
|
17093
17388
|
await runJournalBinaryCommand(rest);
|
|
17094
17389
|
break;
|
|
17390
|
+
case "journal-vault":
|
|
17391
|
+
await runJournalVaultBinaryCommand(rest);
|
|
17392
|
+
break;
|
|
17393
|
+
case "activity-privacy":
|
|
17394
|
+
await runActivityPrivacyBinaryCommand(rest);
|
|
17395
|
+
break;
|
|
17396
|
+
case "vault-publish":
|
|
17397
|
+
await runVaultPublishBinaryCommand(rest);
|
|
17398
|
+
break;
|
|
17095
17399
|
case "codegraph":
|
|
17096
17400
|
await runCodegraphBinaryCommand(rest);
|
|
17097
17401
|
break;
|
|
@@ -17108,7 +17412,7 @@ Other:
|
|
|
17108
17412
|
const targetFactory = async () => {
|
|
17109
17413
|
if (!orchestratorSingleton) {
|
|
17110
17414
|
const configPath = resolveConfigPath();
|
|
17111
|
-
const raw =
|
|
17415
|
+
const raw = fs28.existsSync(configPath) ? JSON.parse(fs28.readFileSync(configPath, "utf8")) : {};
|
|
17112
17416
|
const remnicCfg = resolveRemnicConfigRecord16(raw);
|
|
17113
17417
|
const config = parseConfig17(remnicCfg);
|
|
17114
17418
|
orchestratorSingleton = new Orchestrator10(config);
|