@bash0816/claude-code 2.1.248 → 2.1.251

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/README.md CHANGED
@@ -37,7 +37,7 @@ npm が `claude` bin link を管理する状態になれば、通常の `npm ins
37
37
  Latest audited version / 最新監査済み版:
38
38
 
39
39
  ```sh
40
- npm install -g @bash0816/claude-code@2.1.245
40
+ npm install -g @bash0816/claude-code@2.1.248
41
41
  ```
42
42
 
43
43
  ## Update / 更新
@@ -95,6 +95,51 @@ like `disable` or `Y` will silently turn protection off. Use exactly `0` to be s
95
95
  `1`/`true`/`yes`/`on`(大文字小文字を区別しません)以外の値は全て機能を再有効化してしまうため、
96
96
  `disable` や `Y` のような typo でも保護が黙って外れます。安全のため厳密に `0` を指定してください。
97
97
 
98
+ ### Tool Search Disabled by Default / Tool Search は既定で無効化
99
+
100
+ This Termux wrapper disables the upstream's automatic tool discovery feature (`ENABLE_TOOL_SEARCH=false`
101
+ by default) to prevent unnecessary dynamic tool loading in normal conversations. Without this setting,
102
+ the model may spontaneously activate `ToolSearch` and trigger `WebSearch`/`WebFetch` calls, consuming
103
+ your conversation turn limit (`--max-turns`).
104
+
105
+ この Termux wrapper は、upstream の自動 tool discovery 機能を既定で無効化しています
106
+ (`ENABLE_TOOL_SEARCH=false`)。この設定がないと、モデルが通常の会話で自発的に `ToolSearch` を活動化させ、
107
+ `WebSearch`/`WebFetch` を呼び出し、会話の turn 上限(`--max-turns`)を消費するおそれがあります。
108
+
109
+ If you want to re-enable tool search (for example, if you explicitly use `--tools` and want the model
110
+ to load additional tools dynamically), set the variable before launching:
111
+
112
+ tool search を再有効化したい場合(例えば `--tools` を明示的に指定して、モデルが追加の tool を
113
+ 動的にロードしてほしい場合)、起動前に環境変数を設定してください:
114
+
115
+ ```sh
116
+ ENABLE_TOOL_SEARCH=true claude
117
+ ```
118
+
119
+ or:
120
+
121
+ または:
122
+
123
+ ```sh
124
+ ENABLE_TOOL_SEARCH=auto claude
125
+ ```
126
+
127
+ **Note on `settings.json`:** If you want to configure this in `settings.json`, place `ENABLE_TOOL_SEARCH` in
128
+ the `env` block with the value `force`. The environment variable default (`false`) takes precedence over `true`,
129
+ so use the `env` block to force-enable it:
130
+
131
+ ```json
132
+ { "env": { "ENABLE_TOOL_SEARCH": "force" } }
133
+ ```
134
+
135
+ **`settings.json` を使う場合の注意:** `settings.json` で設定する場合、`env` ブロック内に `ENABLE_TOOL_SEARCH`
136
+ を置いて、値を `force` にしてください。環境変数の既定値(`false`)が `true` より優先されるため、
137
+ force-enable するには `env` ブロックを使う必要があります:
138
+
139
+ ```json
140
+ { "env": { "ENABLE_TOOL_SEARCH": "force" } }
141
+ ```
142
+
98
143
  ## Policy / 方針
99
144
 
100
145
  - Only audited versions in `config/claude-native-audited-versions.json` can run.
package/bin/claude CHANGED
@@ -19,10 +19,10 @@ fi
19
19
 
20
20
  if ! "$NODE" -e '
21
21
  const [major, minor] = process.versions.node.split(".").map(Number);
22
- const ok = major > 23 || (major === 23 && minor >= 5) || (major === 22 && minor >= 15);
22
+ const ok = major > 23 || (major === 23 && minor >= 8) || (major === 22 && minor >= 15);
23
23
  process.exit(ok ? 0 : 1);
24
24
  '; then
25
- echo "Error: claude-code requires Node.js >=22.15.0 <23.0.0 or >=23.5.0 (module.registerHooks() API). Detected: $("$NODE" --version)" >&2
25
+ echo "Error: claude-code requires Node.js >=22.15.0 <23.0.0 or >=23.8.0 (module.registerHooks() API + zlib zstd support). Detected: $("$NODE" --version)" >&2
26
26
  exit 1
27
27
  fi
28
28
 
@@ -786,19 +786,163 @@
786
786
  "entry_format": "esm-chunked",
787
787
  "tarball_integrity": "sha512-2qwjgGuzlVfkJC7UWUjl86hiv5Ok5vtVxAZ/5fpdhzQKuBLlxrJJu3z5tVI+VrO/x/hcqx5kJuy9/O9K4eT+Kg==",
788
788
  "tarball_sha256": "bd2e2b6ebace34039b073b0f586d521ec09c895fa2a39de8d1c86423ae5884ca",
789
- "status": "offset_discovered",
789
+ "status": "termux_verified",
790
790
  "num_modules": 1946,
791
791
  "byte_count": 136124175,
792
792
  "cycle_hoists": [
793
- { "file": "chunk-vmw9kxhv.js", "targetModule": "chunk-y0jj307t.js", "expectedOccurrences": 1, "assertProperties": [] },
794
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-ppd18hq1.js", "expectedOccurrences": 1, "assertProperties": ["MonitorTool"] },
795
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-830s9480.js", "expectedOccurrences": 1, "assertProperties": ["EndConversationTool"] },
796
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-m4hx5z9g.js", "expectedOccurrences": 1, "assertProperties": ["ArtifactTool"] },
797
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-eg121wbt.js", "expectedOccurrences": 1, "assertProperties": ["WorkflowTool"] },
798
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-prrm838s.js", "expectedOccurrences": 1, "assertProperties": [] },
799
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-exvwsc2a.js", "expectedOccurrences": 2, "assertProperties": [] },
800
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-s61yn21a.js", "expectedOccurrences": 1, "assertProperties": ["default"] },
801
- { "file": "chunk-9n7t2tbt.js", "targetModule": "chunk-040m9a9s.js", "expectedOccurrences": 3, "assertProperties": ["getWorkflowCommands", "invalidateWorkflowCache", "warmWorkflows"] }
793
+ {
794
+ "file": "chunk-vmw9kxhv.js",
795
+ "targetModule": "chunk-y0jj307t.js",
796
+ "expectedOccurrences": 1,
797
+ "assertProperties": []
798
+ },
799
+ {
800
+ "file": "chunk-9n7t2tbt.js",
801
+ "targetModule": "chunk-ppd18hq1.js",
802
+ "expectedOccurrences": 1,
803
+ "assertProperties": [
804
+ "MonitorTool"
805
+ ]
806
+ },
807
+ {
808
+ "file": "chunk-9n7t2tbt.js",
809
+ "targetModule": "chunk-830s9480.js",
810
+ "expectedOccurrences": 1,
811
+ "assertProperties": [
812
+ "EndConversationTool"
813
+ ]
814
+ },
815
+ {
816
+ "file": "chunk-9n7t2tbt.js",
817
+ "targetModule": "chunk-m4hx5z9g.js",
818
+ "expectedOccurrences": 1,
819
+ "assertProperties": [
820
+ "ArtifactTool"
821
+ ]
822
+ },
823
+ {
824
+ "file": "chunk-9n7t2tbt.js",
825
+ "targetModule": "chunk-eg121wbt.js",
826
+ "expectedOccurrences": 1,
827
+ "assertProperties": [
828
+ "WorkflowTool"
829
+ ]
830
+ },
831
+ {
832
+ "file": "chunk-9n7t2tbt.js",
833
+ "targetModule": "chunk-prrm838s.js",
834
+ "expectedOccurrences": 1,
835
+ "assertProperties": []
836
+ },
837
+ {
838
+ "file": "chunk-9n7t2tbt.js",
839
+ "targetModule": "chunk-exvwsc2a.js",
840
+ "expectedOccurrences": 2,
841
+ "assertProperties": []
842
+ },
843
+ {
844
+ "file": "chunk-9n7t2tbt.js",
845
+ "targetModule": "chunk-s61yn21a.js",
846
+ "expectedOccurrences": 1,
847
+ "assertProperties": [
848
+ "default"
849
+ ]
850
+ },
851
+ {
852
+ "file": "chunk-9n7t2tbt.js",
853
+ "targetModule": "chunk-040m9a9s.js",
854
+ "expectedOccurrences": 3,
855
+ "assertProperties": [
856
+ "getWorkflowCommands",
857
+ "invalidateWorkflowCache",
858
+ "warmWorkflows"
859
+ ]
860
+ }
861
+ ]
862
+ },
863
+ "2.1.251": {
864
+ "wrapper_spec": "@anthropic-ai/claude-code@2.1.251",
865
+ "native_spec": "@anthropic-ai/claude-code-linux-arm64@2.1.251",
866
+ "entry_format": "esm-chunked",
867
+ "tarball_integrity": "sha512-h4EXRyV25yJfez40cTIoBlJptJqccP8nIDPdDMO9TDPUzZ6e5Y3OO9AgrfdMRAgccaTRsKfJenh7lA2D40nzdw==",
868
+ "tarball_sha256": "50760f283bf289a8bfb6f25ab86276808fd038b8f724ba5eaffb9b195483846d",
869
+ "status": "offset_discovered",
870
+ "num_modules": 1971,
871
+ "byte_count": 126850982,
872
+ "cycle_hoists": [
873
+ {
874
+ "file": "chunk-5yrgn0qs.js",
875
+ "targetModule": "chunk-j108xzrz.js",
876
+ "expectedOccurrences": 1,
877
+ "assertProperties": []
878
+ },
879
+ {
880
+ "file": "chunk-82xr73g2.js",
881
+ "targetModule": "chunk-kqaa82qj.js",
882
+ "expectedOccurrences": 1,
883
+ "assertProperties": [
884
+ "MonitorTool"
885
+ ]
886
+ },
887
+ {
888
+ "file": "chunk-82xr73g2.js",
889
+ "targetModule": "chunk-q6fxy93d.js",
890
+ "expectedOccurrences": 1,
891
+ "assertProperties": [
892
+ "EndConversationTool"
893
+ ]
894
+ },
895
+ {
896
+ "file": "chunk-82xr73g2.js",
897
+ "targetModule": "chunk-dxpcqxe7.js",
898
+ "expectedOccurrences": 1,
899
+ "assertProperties": [
900
+ "ArtifactTool"
901
+ ]
902
+ },
903
+ {
904
+ "file": "chunk-82xr73g2.js",
905
+ "targetModule": "chunk-be1dqpgt.js",
906
+ "expectedOccurrences": 1,
907
+ "assertProperties": [
908
+ "WorkflowTool"
909
+ ]
910
+ },
911
+ {
912
+ "file": "chunk-82xr73g2.js",
913
+ "targetModule": "chunk-er5txax0.js",
914
+ "expectedOccurrences": 1,
915
+ "assertProperties": []
916
+ },
917
+ {
918
+ "file": "chunk-82xr73g2.js",
919
+ "targetModule": "chunk-nh8esxyc.js",
920
+ "expectedOccurrences": 2,
921
+ "assertProperties": []
922
+ },
923
+ {
924
+ "file": "chunk-82xr73g2.js",
925
+ "targetModule": "chunk-4agvbmxr.js",
926
+ "expectedOccurrences": 1,
927
+ "assertProperties": [
928
+ "default"
929
+ ]
930
+ },
931
+ {
932
+ "file": "chunk-82xr73g2.js",
933
+ "targetModule": "chunk-4sfywf4e.js",
934
+ "expectedOccurrences": 3,
935
+ "assertProperties": [
936
+ "getWorkflowCommands",
937
+ "invalidateWorkflowCache",
938
+ "warmWorkflows"
939
+ ]
940
+ }
941
+ ],
942
+ "cycle_hoists_skipped_assets": [
943
+ "chart.umd.min.js",
944
+ "hljsBundle.generated.min.js",
945
+ "mermaid.min.js"
802
946
  ]
803
947
  }
804
948
  }
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "manifest_version": 1,
3
3
  "package_name": "@bash0816/claude-code",
4
- "latest_audited_version": "2.1.245",
5
- "latest_candidate_version": "2.1.248",
6
- "previous_stable_version": "2.1.241",
4
+ "latest_audited_version": "2.1.248",
5
+ "latest_candidate_version": "2.1.251",
6
+ "previous_stable_version": "2.1.245",
7
7
  "stable_pinned_version": "2.1.220-2",
8
8
  "manifest_url": "https://raw.githubusercontent.com/bash0816/ClaudeCode-Termux/main/config/claude-termux-release-manifest.json"
9
9
  }
@@ -1,8 +1,10 @@
1
1
  import { pathToFileURL, fileURLToPath } from 'node:url';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
- import { createRequire } from 'node:module';
3
+ import { createRequire, syncBuiltinESMExports } from 'node:module';
4
4
  import path from 'node:path';
5
5
 
6
+ const require = createRequire(import.meta.url);
7
+
6
8
  let PROCESS_OWNED_DIR = null;
7
9
  let SOURCE_BIN = null;
8
10
  let CHILD_PROCESS_GUARD_PATH = null;
@@ -11,6 +13,45 @@ let WS_STUB_PATH = null;
11
13
 
12
14
  let CYCLE_HOISTS = [];
13
15
 
16
+ let REEXTRACT = null;
17
+ let reExtractConsecFailures = 0;
18
+ let lastReExtractMs = 0;
19
+ const MAX_CONSEC_FAILURES = 3;
20
+ const REEXTRACT_THROTTLE_MS = 3000;
21
+
22
+ function recoverMissing(realPath, now = Date.now()) {
23
+ if (existsSync(realPath)) return true;
24
+ if (!REEXTRACT || !SOURCE_BIN) return false;
25
+ if (reExtractConsecFailures >= MAX_CONSEC_FAILURES) return false;
26
+ if (now - lastReExtractMs < REEXTRACT_THROTTLE_MS) return existsSync(realPath);
27
+ lastReExtractMs = now;
28
+ try {
29
+ if (!existsSync(SOURCE_BIN)) { reExtractConsecFailures += 1; return false; }
30
+ REEXTRACT(SOURCE_BIN, PROCESS_OWNED_DIR);
31
+ console.error('[claude-code] recovered missing extracted module(s) by re-extracting from the native binary');
32
+ } catch (e) {
33
+ reExtractConsecFailures += 1;
34
+ console.error('[claude-code] re-extraction failed: ' + (e && e.message ? e.message : String(e)));
35
+ return false;
36
+ }
37
+ const ok = existsSync(realPath);
38
+ reExtractConsecFailures = ok ? 0 : reExtractConsecFailures + 1;
39
+ return ok;
40
+ }
41
+
42
+ function resolveBunfsPath(id) {
43
+ if (typeof id !== 'string' || !id.startsWith('/$bunfs/root/')) return null;
44
+ const rel = id.slice('/$bunfs/root/'.length);
45
+ if (rel.includes('..') || path.isAbsolute(rel)) {
46
+ throw new Error(`bunfs: rejected specifier ${id}`);
47
+ }
48
+ const real = path.resolve(PROCESS_OWNED_DIR, rel);
49
+ if (path.relative(PROCESS_OWNED_DIR, real).startsWith('..')) {
50
+ throw new Error(`bunfs: path escapes process-owned dir: ${id}`);
51
+ }
52
+ return real;
53
+ }
54
+
14
55
  export function initialize(data) {
15
56
  PROCESS_OWNED_DIR = data.processOwnedDir;
16
57
  SOURCE_BIN = data.sourceBin;
@@ -18,6 +59,12 @@ export function initialize(data) {
18
59
  VM_GUARD_PATH = data.vmGuardPath;
19
60
  WS_STUB_PATH = data.wsStubPath;
20
61
  CYCLE_HOISTS = Array.isArray(data.cycleHoists) ? data.cycleHoists : [];
62
+ REEXTRACT = typeof data.reExtract === 'function' ? data.reExtract : null;
63
+ globalThis.__bunfsRecoverMissing = recoverMissing;
64
+ globalThis.__bunfsResolvePath = resolveBunfsPath;
65
+ // 回復状態のリセット (テスト隔離・再 initialize 対応)
66
+ reExtractConsecFailures = 0;
67
+ lastReExtractMs = 0;
21
68
  }
22
69
 
23
70
  function tryHoistCycleBreakingImports(filePath, source) {
@@ -37,7 +84,7 @@ function tryHoistCycleBreakingImports(filePath, source) {
37
84
 
38
85
  const real = path.resolve(PROCESS_OWNED_DIR, record.targetModule);
39
86
  if (path.relative(PROCESS_OWNED_DIR, real).startsWith('..')) continue;
40
- if (!existsSync(real)) continue;
87
+ if (!existsSync(real) && !recoverMissing(real)) continue;
41
88
 
42
89
  let varName = targetToVar.get(record.targetModule);
43
90
  if (!varName) {
@@ -85,22 +132,34 @@ function buildImportMetaRequirePolyfillPrelude(anchorUrl) {
85
132
  ` if (id === "child_process" || id === "node:child_process") return __bunfsGuardedChildProcess;\n` +
86
133
  ` if (id === "vm" || id === "node:vm") return __bunfsGuardedVm;\n` +
87
134
  ` if (typeof id === "string" && id.startsWith("/$bunfs/root/")) {\n` +
88
- ` const rel = id.slice("/$bunfs/root/".length);\n` +
89
- ` if (rel.includes("..") || __bunfsMetaRequirePath.isAbsolute(rel)) {\n` +
90
- ` throw new Error("bunfs meta-require: rejected specifier " + id);\n` +
91
- ` }\n` +
92
- ` const real = __bunfsMetaRequirePath.resolve(__bunfsOwnedDir, rel);\n` +
93
- ` if (__bunfsMetaRequirePath.relative(__bunfsOwnedDir, real).startsWith("..")) {\n` +
94
- ` throw new Error("bunfs meta-require: path escapes process-owned dir: " + id);\n` +
135
+ ` let real;\n` +
136
+ ` try {\n` +
137
+ ` real = globalThis.__bunfsResolvePath(id);\n` +
138
+ ` } catch (_eResolve) {\n` +
139
+ ` throw new Error("bunfs meta-require: " + _eResolve.message);\n` +
95
140
  ` }\n` +
96
141
  ` if (!__bunfsMetaRequireExistsSync(real)) {\n` +
97
- ` throw new Error("bunfs meta-require: missing extracted module " + id + " -> " + real);\n` +
142
+ ` const _rec = (typeof globalThis.__bunfsRecoverMissing === "function") && globalThis.__bunfsRecoverMissing(real);\n` +
143
+ ` if (!_rec) throw new Error("bunfs meta-require: missing extracted module " + id + " -> " + real);\n` +
98
144
  ` }\n` +
99
145
  ` const ext = __bunfsMetaRequirePath.extname(real);\n` +
100
146
  ` if (ext === ".md" || ext === ".txt") {\n` +
101
- ` return __bunfsMetaRequireReadFileSync(real, "utf8");\n` +
147
+ ` try { return __bunfsMetaRequireReadFileSync(real, "utf8"); }\n` +
148
+ ` catch (_e2) {\n` +
149
+ ` if (_e2 && _e2.code === "ENOENT" && !__bunfsMetaRequireExistsSync(real) && typeof globalThis.__bunfsRecoverMissing === "function" && globalThis.__bunfsRecoverMissing(real)) {\n` +
150
+ ` return __bunfsMetaRequireReadFileSync(real, "utf8");\n` +
151
+ ` }\n` +
152
+ ` throw _e2;\n` +
153
+ ` }\n` +
154
+ ` }\n` +
155
+ ` try {\n` +
156
+ ` return __bunfsRealRequire(real);\n` +
157
+ ` } catch (_e) {\n` +
158
+ ` if (!__bunfsMetaRequireExistsSync(real) && typeof globalThis.__bunfsRecoverMissing === "function" && globalThis.__bunfsRecoverMissing(real)) {\n` +
159
+ ` return __bunfsRealRequire(real);\n` +
160
+ ` }\n` +
161
+ ` throw _e;\n` +
102
162
  ` }\n` +
103
- ` return __bunfsRealRequire(real);\n` +
104
163
  ` }\n` +
105
164
  ` return __bunfsRealRequire(id);\n` +
106
165
  `};\n`
@@ -124,15 +183,13 @@ export function resolve(specifier, context, nextResolve) {
124
183
  }
125
184
  }
126
185
  if (specifier.startsWith('/$bunfs/root/')) {
127
- const rel = specifier.slice('/$bunfs/root/'.length);
128
- if (rel.includes('..') || path.isAbsolute(rel)) {
129
- throw new Error(`bunfs resolve: rejected specifier ${specifier}`);
186
+ let real;
187
+ try {
188
+ real = resolveBunfsPath(specifier);
189
+ } catch (e) {
190
+ throw new Error(`bunfs resolve: ${e.message}`);
130
191
  }
131
- const real = path.resolve(PROCESS_OWNED_DIR, rel);
132
- if (path.relative(PROCESS_OWNED_DIR, real).startsWith('..')) {
133
- throw new Error(`bunfs resolve: path escapes process-owned dir: ${specifier}`);
134
- }
135
- if (!existsSync(real)) {
192
+ if (!existsSync(real) && !recoverMissing(real)) {
136
193
  throw new Error(`bunfs resolve: missing extracted module ${specifier} -> ${real}`);
137
194
  }
138
195
  return { url: pathToFileURL(real).href, shortCircuit: true, format: 'module' };
@@ -146,7 +203,17 @@ export function load(url, context, nextLoad) {
146
203
  return nextLoad(url, context);
147
204
  }
148
205
  const filePath = fileURLToPath(url);
149
- let source = readFileSync(filePath, 'utf8');
206
+ let source;
207
+ try {
208
+ source = readFileSync(filePath, 'utf8');
209
+ } catch (e) {
210
+ // filePath 自身が消えている場合のみ回復 (エラーコードだけに依存しない)
211
+ if (e && e.code === 'ENOENT' && !existsSync(filePath) && recoverMissing(filePath)) {
212
+ source = readFileSync(filePath, 'utf8');
213
+ } else {
214
+ throw e;
215
+ }
216
+ }
150
217
 
151
218
  let hoistedImportLine = '';
152
219
  const hoistResult = tryHoistCycleBreakingImports(filePath, source);
@@ -165,3 +232,56 @@ export function load(url, context, nextLoad) {
165
232
  }
166
233
  return { format: 'module', source, shortCircuit: true };
167
234
  }
235
+
236
+ let FS_PATCHED = false;
237
+ function installFsBunfsInterception() {
238
+ if (FS_PATCHED) return;
239
+ const fsMod = require('node:fs');
240
+ const zlib = require('node:zlib');
241
+ if (typeof zlib.zstdDecompressSync !== 'function' || typeof zlib.zstdDecompress !== 'function') {
242
+ throw new Error('bunfs: Node.js zlib zstd support not found. Please upgrade to Node.js >=23.8.0 or >=22.15.0 (LTS).');
243
+ }
244
+ const origReadFileSync = fsMod.readFileSync;
245
+ const origReadFile = fsMod.readFile;
246
+ const origPromisesReadFile = fsMod.promises.readFile;
247
+
248
+ function resolveOrRecover(p) {
249
+ const real = resolveBunfsPath(p);
250
+ if (real === null) return null;
251
+ if (!existsSync(real)) {
252
+ const recovered = (typeof globalThis.__bunfsRecoverMissing === 'function') && globalThis.__bunfsRecoverMissing(real);
253
+ if (!recovered) throw new Error(`bunfs fs-intercept: missing extracted asset ${p} -> ${real}`);
254
+ }
255
+ const realOwned = fsMod.realpathSync(PROCESS_OWNED_DIR);
256
+ const realTarget = fsMod.realpathSync(real);
257
+ if (path.relative(realOwned, realTarget).startsWith('..')) {
258
+ throw new Error(`bunfs fs-intercept: resolved path escapes owned dir via symlink: ${p}`);
259
+ }
260
+ return real;
261
+ }
262
+
263
+ try {
264
+ fsMod.readFileSync = function (p, ...rest) {
265
+ const real = typeof p === 'string' ? resolveOrRecover(p) : null;
266
+ return Reflect.apply(origReadFileSync, this, [real !== null ? real : p, ...rest]);
267
+ };
268
+ fsMod.readFile = function (p, ...rest) {
269
+ const real = typeof p === 'string' ? resolveOrRecover(p) : null;
270
+ return Reflect.apply(origReadFile, this, [real !== null ? real : p, ...rest]);
271
+ };
272
+ fsMod.promises.readFile = function (p, ...rest) {
273
+ const real = typeof p === 'string' ? resolveOrRecover(p) : null;
274
+ return Reflect.apply(origPromisesReadFile, this, [real !== null ? real : p, ...rest]);
275
+ };
276
+ syncBuiltinESMExports();
277
+ } catch (e) {
278
+ fsMod.readFileSync = origReadFileSync;
279
+ fsMod.readFile = origReadFile;
280
+ fsMod.promises.readFile = origPromisesReadFile;
281
+ try { syncBuiltinESMExports(); } catch { /* 復元目的、失敗しても re-throw を優先 */ }
282
+ throw e;
283
+ }
284
+ FS_PATCHED = true;
285
+ }
286
+
287
+ export { recoverMissing, resolveBunfsPath, installFsBunfsInterception };