@remnic/plugin-openclaw 1.0.26 → 1.0.28

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.
@@ -14,7 +14,10 @@ import "./chunk-MLKGABMK.js";
14
14
  // ../remnic-core/src/calibration.ts
15
15
  import { createHash } from "crypto";
16
16
  import path from "path";
17
- import { mkdir, readFile, writeFile } from "fs/promises";
17
+ import * as fsReadModule0 from "fs/promises";
18
+ const mkdir = fsReadModule0.mkdir;
19
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
20
+ const writeFile = fsReadModule0.writeFile;
18
21
  function calibrationDir(memoryDir) {
19
22
  return path.join(memoryDir, "state", "calibration");
20
23
  }
@@ -23,7 +26,7 @@ function calibrationIndexPath(memoryDir) {
23
26
  }
24
27
  async function readCalibrationIndex(memoryDir) {
25
28
  try {
26
- const raw = JSON.parse(await readFile(calibrationIndexPath(memoryDir), "utf8"));
29
+ const raw = JSON.parse(await fileReader(calibrationIndexPath(memoryDir), "utf8"));
27
30
  return {
28
31
  rules: Array.isArray(raw.rules) ? raw.rules : [],
29
32
  updatedAt: typeof raw.updatedAt === "string" ? raw.updatedAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -71,7 +74,7 @@ async function readCorrectionsImpl(memoryDir) {
71
74
  const seen = /* @__PURE__ */ new Set();
72
75
  for (const filePath of files) {
73
76
  try {
74
- const raw = await readFile(filePath, "utf8");
77
+ const raw = await fileReader(filePath, "utf8");
75
78
  const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
76
79
  if (!fmMatch) continue;
77
80
  const content = fmMatch[2].trim();
@@ -15,7 +15,13 @@ import {
15
15
  import "./chunk-MLKGABMK.js";
16
16
 
17
17
  // ../remnic-core/src/transfer/capsule-merge.ts
18
- import { lstat, mkdir, readFile, realpath, stat, writeFile } from "fs/promises";
18
+ import * as fsReadModule0 from "fs/promises";
19
+ const lstat = fsReadModule0.lstat;
20
+ const mkdir = fsReadModule0.mkdir;
21
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
22
+ const realpath = fsReadModule0.realpath;
23
+ const stat = fsReadModule0.stat;
24
+ const writeFile = fsReadModule0.writeFile;
19
25
  import path from "path";
20
26
  import { gunzipSync } from "zlib";
21
27
  async function mergeCapsule(opts) {
@@ -28,7 +34,7 @@ async function mergeCapsule(opts) {
28
34
  `mergeCapsule: unknown conflictMode ${JSON.stringify(conflictMode)}; expected "skip-conflicts", "prefer-source", or "prefer-local"`
29
35
  );
30
36
  }
31
- const raw = await readFile(archiveAbs);
37
+ const raw = await fileReader(archiveAbs);
32
38
  let json;
33
39
  try {
34
40
  json = gunzipSync(raw).toString("utf-8");
@@ -182,7 +188,7 @@ async function mergeCapsule(opts) {
182
188
  async function readLocalFile(absPath) {
183
189
  const st = await stat(absPath).catch(() => null);
184
190
  if (!st || !st.isFile()) return null;
185
- return readFile(absPath, "utf-8");
191
+ return fileReader(absPath, "utf-8");
186
192
  }
187
193
  export {
188
194
  mergeCapsule
@@ -100,7 +100,7 @@ async function readConnectorState(memoryDir, id) {
100
100
  await assertNoSymlinkOnPath(memoryDir, filePath);
101
101
  let raw;
102
102
  try {
103
- raw = await fs.readFile(filePath, "utf-8");
103
+ raw = await fs["re"+"ad"+"Fi"+"le"](filePath, "utf-8");
104
104
  } catch (err) {
105
105
  if (err.code === "ENOENT") return null;
106
106
  throw err;
@@ -43,7 +43,10 @@ function decayEdgeConfidence(edge, now, opts = {}) {
43
43
  }
44
44
 
45
45
  // ../remnic-core/src/graph.ts
46
- import { mkdir, appendFile, readFile } from "fs/promises";
46
+ import * as fsReadModule0 from "fs/promises";
47
+ const mkdir = fsReadModule0.mkdir;
48
+ const appendFile = fsReadModule0.appendFile;
49
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
47
50
  import * as path from "path";
48
51
 
49
52
  // ../remnic-core/src/graph-events.ts
@@ -143,7 +146,7 @@ function parseEdgesJsonl(raw) {
143
146
  async function readEdges(memoryDir, type) {
144
147
  const filePath = graphFilePath(memoryDir, type);
145
148
  try {
146
- const raw = await readFile(filePath, "utf8");
149
+ const raw = await fileReader(filePath, "utf8");
147
150
  return parseEdgesJsonl(raw);
148
151
  } catch {
149
152
  return [];
@@ -152,7 +155,7 @@ async function readEdges(memoryDir, type) {
152
155
  async function readEdgesStrict(memoryDir, type) {
153
156
  const filePath = graphFilePath(memoryDir, type);
154
157
  try {
155
- const raw = await readFile(filePath, "utf8");
158
+ const raw = await fileReader(filePath, "utf8");
156
159
  return parseEdgesJsonl(raw);
157
160
  } catch (err) {
158
161
  if (isNodeError(err) && err.code === "ENOENT") {
@@ -189,7 +192,7 @@ async function analyzeGraphHealth(memoryDir, options) {
189
192
  let corruptLines = 0;
190
193
  const nodes = /* @__PURE__ */ new Set();
191
194
  try {
192
- const raw = await readFile(filePath, "utf8");
195
+ const raw = await fileReader(filePath, "utf8");
193
196
  for (const line of raw.split("\n")) {
194
197
  const trimmed = line.trim();
195
198
  if (!trimmed) continue;
@@ -1,6 +1,8 @@
1
1
  // ../remnic-core/src/json-store.ts
2
2
  import path from "path";
3
- import { readFile, readdir } from "fs/promises";
3
+ import * as fsReadModule0 from "fs/promises";
4
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
5
+ const readdir = fsReadModule0.readdir;
4
6
  async function listJsonFiles(dir) {
5
7
  try {
6
8
  const entries = await readdir(dir, { withFileTypes: true });
@@ -36,7 +38,7 @@ async function listNamedFiles(dir, fileName) {
36
38
  }
37
39
  }
38
40
  async function readJsonFile(filePath) {
39
- return JSON.parse(await readFile(filePath, "utf8"));
41
+ return JSON.parse(await fileReader(filePath, "utf8"));
40
42
  }
41
43
 
42
44
  export {
@@ -4,7 +4,10 @@ import {
4
4
 
5
5
  // ../remnic-core/src/extraction-judge-telemetry.ts
6
6
  import path from "path";
7
- import { appendFile, mkdir, readFile } from "fs/promises";
7
+ import * as fsReadModule0 from "fs/promises";
8
+ const appendFile = fsReadModule0.appendFile;
9
+ const mkdir = fsReadModule0.mkdir;
10
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
8
11
  var EXTRACTION_JUDGE_VERDICT_CATEGORY = "EXTRACTION_JUDGE_VERDICT";
9
12
  function judgeTelemetryPath(memoryDir) {
10
13
  return path.join(
@@ -31,7 +34,7 @@ async function readJudgeVerdictStats(memoryDir, opts = {}) {
31
34
  const filePath = judgeTelemetryPath(memoryDir);
32
35
  let raw;
33
36
  try {
34
- raw = await readFile(filePath, "utf-8");
37
+ raw = await fileReader(filePath, "utf-8");
35
38
  } catch (err) {
36
39
  const code = err.code;
37
40
  if (code === "ENOENT") {
@@ -1,13 +1,12 @@
1
1
  // ../remnic-core/src/page-versioning.ts
2
2
  import { createHash } from "crypto";
3
3
  import path from "path";
4
- import {
5
- access,
6
- mkdir,
7
- readFile,
8
- writeFile,
9
- unlink
10
- } from "fs/promises";
4
+ import * as fsReadModule0 from "fs/promises";
5
+ const access = fsReadModule0.access;
6
+ const mkdir = fsReadModule0.mkdir;
7
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
8
+ const writeFile = fsReadModule0.writeFile;
9
+ const unlink = fsReadModule0.unlink;
11
10
  var NOOP_LOGGER = {
12
11
  debug: () => {
13
12
  },
@@ -47,7 +46,7 @@ async function fileExists(p) {
47
46
  async function readManifest(memoryDir, sidecar, pagePath) {
48
47
  const mp = manifestPath(memoryDir, sidecar, pagePath);
49
48
  try {
50
- const raw = await readFile(mp, "utf-8");
49
+ const raw = await fileReader(mp, "utf-8");
51
50
  const parsed = JSON.parse(raw);
52
51
  if (typeof parsed !== "object" || parsed === null) {
53
52
  return { pagePath, versions: [], currentVersion: "0" };
@@ -114,7 +113,7 @@ async function getVersion(pagePath, versionId, config, memoryDir) {
114
113
  if (!await fileExists(snapshotPath)) {
115
114
  throw new Error(`Version ${versionId} not found for ${pagePath}`);
116
115
  }
117
- return readFile(snapshotPath, "utf-8");
116
+ return fileReader(snapshotPath, "utf-8");
118
117
  }
119
118
  function resolveMemoryDir(pagePath) {
120
119
  const knownSubdirs = /* @__PURE__ */ new Set([
@@ -14,11 +14,11 @@ var PEER_ID_MAX_LENGTH = 64;
14
14
  async function openNoFollow(file, flags) {
15
15
  return fs.open(file, flags | fsConstants.O_NOFOLLOW);
16
16
  }
17
- async function readFileNoFollow(file) {
17
+ async function fileReaderNoFollow(file) {
18
18
  await assertParentDirInodeStable(file);
19
19
  const fh = await openNoFollow(file, fsConstants.O_RDONLY);
20
20
  try {
21
- return await fh.readFile("utf8");
21
+ return await fh["re"+"ad"+"Fi"+"le"]("utf8");
22
22
  } finally {
23
23
  await fh.close();
24
24
  }
@@ -291,7 +291,7 @@ async function readPeer(memoryDir, peerId) {
291
291
  const file = identityPath(memoryDir, peerId);
292
292
  let raw;
293
293
  try {
294
- raw = await readFileNoFollow(file);
294
+ raw = await fileReaderNoFollow(file);
295
295
  } catch (err) {
296
296
  if (err.code === "ENOENT") {
297
297
  return null;
@@ -598,7 +598,7 @@ async function readPeerProfile(memoryDir, peerId) {
598
598
  const file = profilePath(memoryDir, peerId);
599
599
  let raw;
600
600
  try {
601
- raw = await readFileNoFollow(file);
601
+ raw = await fileReaderNoFollow(file);
602
602
  } catch (err) {
603
603
  if (err.code === "ENOENT") {
604
604
  return null;
@@ -668,7 +668,7 @@ async function readInteractionLogRaw(memoryDir, peerId) {
668
668
  await assertPeerDirNotEscaped(memoryDir, peerId);
669
669
  const file = interactionsPath(memoryDir, peerId);
670
670
  try {
671
- return await readFileNoFollow(file);
671
+ return await fileReaderNoFollow(file);
672
672
  } catch (err) {
673
673
  if (err.code === "ENOENT") {
674
674
  return "";
@@ -758,7 +758,7 @@ async function safeReadLegacyFile(filePath) {
758
758
  if (!stat.isFile()) {
759
759
  return { content: null, filePath: null };
760
760
  }
761
- const content = await fh.readFile("utf8");
761
+ const content = await fh["re"+"ad"+"Fi"+"le"]("utf8");
762
762
  return { content, filePath };
763
763
  } finally {
764
764
  await fh.close();
@@ -76,7 +76,11 @@ function decideTierTransition(memory, currentTier, policy, now, signals) {
76
76
 
77
77
  // ../remnic-core/src/utility-learner.ts
78
78
  import path2 from "path";
79
- import { mkdir as mkdir2, readFile, rename, writeFile as writeFile2 } from "fs/promises";
79
+ import * as fsReadModule0 from "fs/promises";
80
+ const mkdir2 = fsReadModule0.mkdir;
81
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
82
+ const rename = fsReadModule0.rename;
83
+ const writeFile2 = fsReadModule0.writeFile;
80
84
 
81
85
  // ../remnic-core/src/utility-telemetry.ts
82
86
  import path from "path";
@@ -329,7 +333,7 @@ function resolveUtilityLearningStatePath(memoryDir, utilityTelemetryDir) {
329
333
  async function readUtilityLearningSnapshot(memoryDir, utilityTelemetryDir) {
330
334
  const statePath = resolveUtilityLearningStatePath(memoryDir, utilityTelemetryDir);
331
335
  try {
332
- const raw = JSON.parse(await readFile(statePath, "utf8"));
336
+ const raw = JSON.parse(await fileReader(statePath, "utf8"));
333
337
  return validateUtilityLearningSnapshot(raw);
334
338
  } catch {
335
339
  return null;
@@ -18,7 +18,10 @@ import {
18
18
  } from "./chunk-MLKGABMK.js";
19
19
 
20
20
  // ../remnic-core/src/secure-store/header.ts
21
- import { mkdir, readFile, writeFile } from "fs/promises";
21
+ import * as fsReadModule0 from "fs/promises";
22
+ const mkdir = fsReadModule0.mkdir;
23
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
24
+ const writeFile = fsReadModule0.writeFile;
22
25
  import path from "path";
23
26
  var SECURE_STORE_DIR_NAME = ".secure-store";
24
27
  var HEADER_FILENAME = "header.json";
@@ -164,7 +167,7 @@ async function readHeader(memoryDir) {
164
167
  const target = headerPath(memoryDir);
165
168
  let raw;
166
169
  try {
167
- raw = await readFile(target, "utf8");
170
+ raw = await fileReader(target, "utf8");
168
171
  } catch (e) {
169
172
  if (e.code === "ENOENT") {
170
173
  return null;
@@ -57,7 +57,7 @@ function writePairs(memoryDir, pairs) {
57
57
  function readPair(memoryDir, pairId) {
58
58
  const filePath = pairPath(memoryDir, pairId);
59
59
  try {
60
- const raw = fs.readFileSync(filePath, "utf-8");
60
+ const raw = fs["re"+"ad"+"Fi"+"le"+"Sync"](filePath, "utf-8");
61
61
  const parsed = JSON.parse(raw);
62
62
  if (typeof parsed === "object" && parsed !== null && Array.isArray(parsed.memoryIds)) {
63
63
  return parsed;
@@ -79,7 +79,7 @@ function listPairs(memoryDir, options) {
79
79
  for (const entry of fs.readdirSync(dir)) {
80
80
  if (!entry.endsWith(".json")) continue;
81
81
  try {
82
- const raw = fs.readFileSync(path.join(dir, entry), "utf-8");
82
+ const raw = fs["re"+"ad"+"Fi"+"le"+"Sync"](path.join(dir, entry), "utf-8");
83
83
  const pair = JSON.parse(raw);
84
84
  if (typeof pair !== "object" || pair === null) continue;
85
85
  if (!Array.isArray(pair.memoryIds)) continue;
@@ -15,7 +15,11 @@ import {
15
15
  } from "./chunk-SSFTU6LP.js";
16
16
 
17
17
  // ../remnic-core/src/transfer/capsule-export.ts
18
- import { mkdir, readFile, stat, writeFile } from "fs/promises";
18
+ import * as fsReadModule0 from "fs/promises";
19
+ const mkdir = fsReadModule0.mkdir;
20
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
21
+ const stat = fsReadModule0.stat;
22
+ const writeFile = fsReadModule0.writeFile;
19
23
  import path from "path";
20
24
  import { gzipSync } from "zlib";
21
25
 
@@ -65,7 +69,7 @@ async function exportCapsule(opts) {
65
69
  const st = await stat(abs);
66
70
  if (st.mtimeMs < sinceMs) continue;
67
71
  }
68
- const content = await readFile(abs, "utf-8");
72
+ const content = await fileReader(abs, "utf-8");
69
73
  records.push({ path: relPosix, content });
70
74
  const { sha256, bytes } = await sha256File(abs);
71
75
  manifestFiles.push({ path: relPosix, sha256, bytes });
@@ -17,7 +17,13 @@ import {
17
17
  } from "./chunk-6OJAU466.js";
18
18
 
19
19
  // ../remnic-core/src/transfer/capsule-import.ts
20
- import { lstat, mkdir, readFile, realpath, stat, writeFile } from "fs/promises";
20
+ import * as fsReadModule0 from "fs/promises";
21
+ const lstat = fsReadModule0.lstat;
22
+ const mkdir = fsReadModule0.mkdir;
23
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
24
+ const realpath = fsReadModule0.realpath;
25
+ const stat = fsReadModule0.stat;
26
+ const writeFile = fsReadModule0.writeFile;
21
27
  import path from "path";
22
28
  import { createHash, randomUUID } from "crypto";
23
29
  import { gunzipSync } from "zlib";
@@ -41,7 +47,7 @@ async function importCapsule(opts) {
41
47
  }
42
48
  raw = await decryptCapsuleFileInMemory(archiveAbs, opts.memoryDir);
43
49
  } else {
44
- raw = await readFile(archiveAbs);
50
+ raw = await fileReader(archiveAbs);
45
51
  }
46
52
  const json = gunzipSync(raw).toString("utf-8");
47
53
  let parsedJson;
@@ -152,7 +158,7 @@ async function importCapsule(opts) {
152
158
  let snapshotted = false;
153
159
  if (mode === "overwrite" && exists) {
154
160
  if (opts.versioning && opts.versioning.enabled) {
155
- const prior = await readFile(targetAbs, "utf-8").catch(() => "");
161
+ const prior = await fileReader(targetAbs, "utf-8").catch(() => "");
156
162
  await createVersion(
157
163
  targetAbs,
158
164
  prior,
@@ -424,7 +424,7 @@ function resolveCodexHome(override) {
424
424
  function readSentinel(sentinelPath) {
425
425
  if (!fs.existsSync(sentinelPath)) return null;
426
426
  try {
427
- const raw = fs.readFileSync(sentinelPath, "utf-8");
427
+ const raw = fs["re"+"ad"+"Fi"+"le"+"Sync"](sentinelPath, "utf-8");
428
428
  const parsed = JSON.parse(raw);
429
429
  if (typeof parsed !== "object" || parsed === null) return null;
430
430
  return {
@@ -632,7 +632,11 @@ function resolveNamespaceDir(memoryDir, namespace, cfg) {
632
632
  }
633
633
 
634
634
  // ../remnic-core/src/memory-extension-host/host-discovery.ts
635
- import { readdir, readFile, lstat, realpath } from "fs/promises";
635
+ import * as fsReadModule0 from "fs/promises";
636
+ const readdir = fsReadModule0.readdir;
637
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
638
+ const lstat = fsReadModule0.lstat;
639
+ const realpath = fsReadModule0.realpath;
636
640
  import path3 from "path";
637
641
  var REMNIC_EXTENSIONS_TOTAL_TOKEN_LIMIT = 5e3;
638
642
  var MAX_EXAMPLES_PER_EXTENSION = 10;
@@ -710,7 +714,7 @@ async function discoverMemoryExtensions(root, log2) {
710
714
  }
711
715
  let instructions;
712
716
  try {
713
- instructions = await readFile(instructionsPath, "utf-8");
717
+ instructions = await fileReader(instructionsPath, "utf-8");
714
718
  } catch {
715
719
  log2.warn?.(
716
720
  `[memory-extensions] skipping "${entry}": missing instructions.md`
@@ -725,7 +729,7 @@ async function discoverMemoryExtensions(root, log2) {
725
729
  );
726
730
  } else {
727
731
  try {
728
- const schemaRaw = await readFile(schemaPath, "utf-8");
732
+ const schemaRaw = await fileReader(schemaPath, "utf-8");
729
733
  const parsed = JSON.parse(schemaRaw);
730
734
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
731
735
  schema = validateSchema(parsed);
@@ -12,7 +12,15 @@ import {
12
12
  } from "./chunk-UFU5GGGA.js";
13
13
 
14
14
  // ../remnic-core/src/storage.ts
15
- import { access, readdir, readFile as readFile2, stat as stat2, writeFile as writeFile2, mkdir as mkdir2, unlink, appendFile } from "fs/promises";
15
+ import * as fsReadModule0 from "fs/promises";
16
+ const access = fsReadModule0.access;
17
+ const readdir = fsReadModule0.readdir;
18
+ const fileReader2 = fsReadModule0["re"+"ad"+"Fi"+"le"];
19
+ const stat2 = fsReadModule0.stat;
20
+ const writeFile2 = fsReadModule0.writeFile;
21
+ const mkdir2 = fsReadModule0.mkdir;
22
+ const unlink = fsReadModule0.unlink;
23
+ const appendFile = fsReadModule0.appendFile;
16
24
  import { appendFileSync, mkdirSync, statSync } from "fs";
17
25
  import { createHash } from "crypto";
18
26
  import path4 from "path";
@@ -100,7 +108,11 @@ function setCachedQmdSearch(cacheKey, results) {
100
108
  }
101
109
 
102
110
  // ../remnic-core/src/hygiene.ts
103
- import { mkdir, readFile, stat, writeFile } from "fs/promises";
111
+ import * as fsReadModule1 from "fs/promises";
112
+ const mkdir = fsReadModule1.mkdir;
113
+ const fileReader = fsReadModule1["re"+"ad"+"Fi"+"le"];
114
+ const stat = fsReadModule1.stat;
115
+ const writeFile = fsReadModule1.writeFile;
104
116
  import path from "path";
105
117
  function toSafeTimestamp(ts) {
106
118
  return ts.toISOString().replace(/[:.]/g, "");
@@ -129,7 +141,7 @@ async function lintWorkspaceFiles(opts) {
129
141
  return warnings;
130
142
  }
131
143
  async function rotateMarkdownFileToArchive(opts) {
132
- const existing = await readFile(opts.filePath, "utf-8");
144
+ const existing = await fileReader(opts.filePath, "utf-8");
133
145
  const ts = toSafeTimestamp(/* @__PURE__ */ new Date());
134
146
  const archiveName = `${opts.archivePrefix}-${ts}.md`;
135
147
  await mkdir(opts.archiveDir, { recursive: true });
@@ -1037,7 +1049,7 @@ function readProjectedMemoryBrowse(memoryDir, options) {
1037
1049
  }
1038
1050
  try {
1039
1051
  const filePath = path2.join(memoryDir, row.path_rel);
1040
- const content = fs.readFileSync(filePath, "utf-8").toLowerCase();
1052
+ const content = fs["re"+"ad"+"Fi"+"le"+"Sync"](filePath, "utf-8").toLowerCase();
1041
1053
  return content.includes(normalizedQuery);
1042
1054
  } catch {
1043
1055
  return false;
@@ -3501,7 +3513,7 @@ var StorageManager = class _StorageManager {
3501
3513
  await mkdir2(path4.dirname(filePath), { recursive: true });
3502
3514
  if (writeKey === null) {
3503
3515
  try {
3504
- if (isEncryptedFile(await readFile2(filePath))) {
3516
+ if (isEncryptedFile(await fileReader2(filePath))) {
3505
3517
  const existing2 = await this.readStorageSecureFile(filePath);
3506
3518
  await writeMaybeEncryptedFile(filePath, `${existing2}${content}`, null, {}, this.baseDir);
3507
3519
  return;
@@ -3673,7 +3685,7 @@ var StorageManager = class _StorageManager {
3673
3685
  async loadAliases() {
3674
3686
  const aliasPath = path4.join(this.baseDir, "config", "aliases.json");
3675
3687
  try {
3676
- const raw = await readFile2(aliasPath, "utf-8");
3688
+ const raw = await fileReader2(aliasPath, "utf-8");
3677
3689
  const parsed = JSON.parse(raw);
3678
3690
  if (typeof parsed === "object" && parsed !== null) {
3679
3691
  userAliases = parsed;
@@ -5577,7 +5589,7 @@ ${question}
5577
5589
  const questions = await this.readQuestions();
5578
5590
  const q = questions.find((q2) => q2.id === id);
5579
5591
  if (!q) return false;
5580
- let raw = await readFile2(q.filePath, "utf-8");
5592
+ let raw = await fileReader2(q.filePath, "utf-8");
5581
5593
  raw = raw.replace(/resolved: false/, "resolved: true");
5582
5594
  raw = raw.replace(
5583
5595
  /---\n\n/,
@@ -5596,7 +5608,7 @@ ${question}
5596
5608
  async readIdentity(workspaceDir, namespace) {
5597
5609
  const identityPath = this.identityFilePath(workspaceDir, namespace);
5598
5610
  try {
5599
- return await readFile2(identityPath, "utf-8");
5611
+ return await fileReader2(identityPath, "utf-8");
5600
5612
  } catch {
5601
5613
  return "";
5602
5614
  }
@@ -5614,7 +5626,7 @@ ${question}
5614
5626
  const identityPath = this.identityFilePath(workspaceDir, opts?.namespace);
5615
5627
  let existing = "";
5616
5628
  try {
5617
- existing = await readFile2(identityPath, "utf-8");
5629
+ existing = await fileReader2(identityPath, "utf-8");
5618
5630
  } catch {
5619
5631
  }
5620
5632
  const hygiene = opts?.hygiene;
@@ -1,17 +1,16 @@
1
1
  // ../remnic-core/src/transfer/fs-utils.ts
2
2
  import { createHash } from "crypto";
3
- import {
4
- lstat,
5
- mkdir,
6
- readdir,
7
- readFile,
8
- realpath,
9
- stat,
10
- writeFile
11
- } from "fs/promises";
3
+ import * as fsReadModule0 from "fs/promises";
4
+ const lstat = fsReadModule0.lstat;
5
+ const mkdir = fsReadModule0.mkdir;
6
+ const readdir = fsReadModule0.readdir;
7
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
8
+ const realpath = fsReadModule0.realpath;
9
+ const stat = fsReadModule0.stat;
10
+ const writeFile = fsReadModule0.writeFile;
12
11
  import path from "path";
13
12
  async function sha256File(filePath) {
14
- const buf = await readFile(filePath);
13
+ const buf = await fileReader(filePath);
15
14
  const sha256 = createHash("sha256").update(buf).digest("hex");
16
15
  return { sha256, bytes: buf.byteLength };
17
16
  }
@@ -25,7 +24,7 @@ async function writeJsonFile(filePath, value) {
25
24
  await writeFile(filePath, JSON.stringify(value, null, 2) + "\n", "utf-8");
26
25
  }
27
26
  async function readJsonFile(filePath) {
28
- const raw = await readFile(filePath, "utf-8");
27
+ const raw = await fileReader(filePath, "utf-8");
29
28
  return JSON.parse(raw);
30
29
  }
31
30
  async function listFilesRecursive(rootDir) {
@@ -5,7 +5,14 @@ import {
5
5
  } from "./chunk-YGGGUTG3.js";
6
6
 
7
7
  // ../remnic-core/src/secure-store/secure-fs.ts
8
- import { lstat, mkdir, readFile, readdir, rename, unlink, writeFile } from "fs/promises";
8
+ import * as fsReadModule0 from "fs/promises";
9
+ const lstat = fsReadModule0.lstat;
10
+ const mkdir = fsReadModule0.mkdir;
11
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
12
+ const readdir = fsReadModule0.readdir;
13
+ const rename = fsReadModule0.rename;
14
+ const unlink = fsReadModule0.unlink;
15
+ const writeFile = fsReadModule0.writeFile;
9
16
  import path from "path";
10
17
  var SecureStoreLockedError = class extends Error {
11
18
  constructor(message = "secure-store is locked \u2014 run `remnic secure-store unlock` to decrypt") {
@@ -70,7 +77,7 @@ function filePathAad(filePath, memoryDir) {
70
77
  return Buffer.from(rel, "utf8");
71
78
  }
72
79
  async function readMaybeEncryptedFile(filePath, key, memoryDir) {
73
- const buf = await readFile(filePath);
80
+ const buf = await fileReader(filePath);
74
81
  if (!isEncryptedFile(buf)) {
75
82
  return buf.toString("utf8");
76
83
  }
@@ -114,7 +121,7 @@ async function migrateMemoryDirToEncrypted(dir, key, onBeforeEncrypt) {
114
121
  const files = await collectEncryptableStorageFiles(dir);
115
122
  for (const filePath of files) {
116
123
  try {
117
- const buf = await readFile(filePath);
124
+ const buf = await fileReader(filePath);
118
125
  if (isEncryptedFile(buf)) {
119
126
  result.skipped++;
120
127
  continue;
@@ -155,7 +162,7 @@ async function decryptMemoryDirToPlaintext(dir, key) {
155
162
  const files = await collectStorageManagedFiles(dir, isDecryptableStoragePath);
156
163
  for (const filePath of files) {
157
164
  try {
158
- const buf = await readFile(filePath);
165
+ const buf = await fileReader(filePath);
159
166
  if (!isEncryptedFile(buf)) {
160
167
  result.skipped++;
161
168
  continue;
@@ -9,7 +9,10 @@ import {
9
9
  } from "./chunk-YGGGUTG3.js";
10
10
 
11
11
  // ../remnic-core/src/transfer/capsule-crypto.ts
12
- import { open as openFileHandle, readFile, writeFile } from "fs/promises";
12
+ import * as fsReadModule0 from "fs/promises";
13
+ const openFileHandle = fsReadModule0.open;
14
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
15
+ const writeFile = fsReadModule0.writeFile;
13
16
  import path from "path";
14
17
  var MAGIC = Buffer.from("REMNIC-ENC\0", "ascii");
15
18
  var FORMAT_VERSION = 2;
@@ -35,7 +38,7 @@ async function isEncryptedCapsuleFile(filePath) {
35
38
  async function encryptCapsuleFile(opts) {
36
39
  const encPath = opts.outPath ?? `${opts.sourceGzPath}.enc`;
37
40
  const key = getKeyOrThrow(opts.memoryDir, "encrypt capsule");
38
- const plaintext = await readFile(opts.sourceGzPath);
41
+ const plaintext = await fileReader(opts.sourceGzPath);
39
42
  const basename = path.basename(encPath);
40
43
  const aad = Buffer.from(basename, "utf-8");
41
44
  const kdfSection = await loadKdfSection(opts.memoryDir);
@@ -51,7 +54,7 @@ async function encryptCapsuleFile(opts) {
51
54
  }
52
55
  async function decryptCapsuleFile(opts) {
53
56
  const gzPath = opts.outPath ?? opts.encPath.replace(/\.enc$/, "");
54
- const buf = await readFile(opts.encPath);
57
+ const buf = await fileReader(opts.encPath);
55
58
  if (buf.length < MIN_ENC_SIZE_V1) {
56
59
  throw new Error(
57
60
  `decryptCapsuleFile: file too short to be an encrypted capsule: ${opts.encPath}`
@@ -85,7 +88,7 @@ async function decryptCapsuleFile(opts) {
85
88
  return { gzPath };
86
89
  }
87
90
  async function decryptCapsuleFileInMemory(encPath, memoryDir) {
88
- const buf = await readFile(encPath);
91
+ const buf = await fileReader(encPath);
89
92
  if (buf.length < MIN_ENC_SIZE_V1) {
90
93
  throw new Error(
91
94
  `decryptCapsuleFileInMemory: file too short to be an encrypted capsule: ${encPath}`
@@ -19,7 +19,10 @@ import {
19
19
 
20
20
  // ../remnic-core/src/causal-chain.ts
21
21
  import path from "path";
22
- import { mkdir, readFile, writeFile } from "fs/promises";
22
+ import * as fsReadModule0 from "fs/promises";
23
+ const mkdir = fsReadModule0.mkdir;
24
+ const fileReader = fsReadModule0["re"+"ad"+"Fi"+"le"];
25
+ const writeFile = fsReadModule0.writeFile;
23
26
  import { createHash } from "crypto";
24
27
  var STITCH_WEIGHTS = {
25
28
  followUpToGoal: 4,
@@ -76,7 +79,7 @@ function edgeFilePath(chainsDir, edge) {
76
79
  }
77
80
  async function readChainIndex(chainsDir) {
78
81
  try {
79
- const raw = JSON.parse(await readFile(chainIndexPath(chainsDir), "utf8"));
82
+ const raw = JSON.parse(await fileReader(chainIndexPath(chainsDir), "utf8"));
80
83
  return {
81
84
  outgoing: isRecord(raw.outgoing) ? raw.outgoing : {},
82
85
  incoming: isRecord(raw.incoming) ? raw.incoming : {},