@kamilio/wire 0.1.9 → 0.1.11

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.
Files changed (1453) hide show
  1. package/dist/adapters/root.d.ts +2 -1
  2. package/dist/adapters/root.d.ts.map +1 -1
  3. package/dist/adapters/root.js +30 -18
  4. package/dist/adapters/root.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +10 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/executable.d.ts.map +1 -1
  9. package/dist/executable.js +2 -1
  10. package/dist/executable.js.map +1 -1
  11. package/dist/mcp.d.ts +2 -3
  12. package/dist/mcp.d.ts.map +1 -1
  13. package/node_modules/provider-slack/dist/index.d.ts +1 -1
  14. package/node_modules/provider-slack/dist/index.d.ts.map +1 -1
  15. package/node_modules/provider-slack/dist/index.js +1 -1
  16. package/node_modules/provider-slack/dist/index.js.map +1 -1
  17. package/node_modules/provider-slack/dist/slack.d.ts +10 -0
  18. package/node_modules/provider-slack/dist/slack.d.ts.map +1 -1
  19. package/node_modules/provider-slack/dist/slack.js +415 -22
  20. package/node_modules/provider-slack/dist/slack.js.map +1 -1
  21. package/node_modules/provider-slack/package.json +10 -4
  22. package/node_modules/provider-slack/src/index.ts +1 -1
  23. package/node_modules/provider-slack/src/slack.ts +330 -20
  24. package/node_modules/toolcraft/LICENSE +21 -0
  25. package/node_modules/toolcraft/README.md +268 -23
  26. package/node_modules/toolcraft/composition.json +165 -0
  27. package/node_modules/toolcraft/dist/agent-defs.d.ts +1 -0
  28. package/node_modules/toolcraft/dist/agent-defs.js +1 -0
  29. package/node_modules/toolcraft/dist/agent-mcp-config.d.ts +1 -0
  30. package/node_modules/toolcraft/dist/agent-mcp-config.js +1 -0
  31. package/node_modules/toolcraft/dist/applied-default.d.ts +3 -0
  32. package/node_modules/toolcraft/dist/applied-default.js +16 -0
  33. package/node_modules/toolcraft/dist/auth-store.d.ts +1 -0
  34. package/node_modules/toolcraft/dist/auth-store.js +1 -0
  35. package/node_modules/toolcraft/dist/cli.compile-check.js +20 -2
  36. package/node_modules/toolcraft/dist/cli.d.ts +97 -4
  37. package/node_modules/toolcraft/dist/cli.js +1322 -412
  38. package/node_modules/toolcraft/dist/composition.d.ts +15 -0
  39. package/node_modules/toolcraft/dist/composition.js +10 -0
  40. package/node_modules/toolcraft/dist/composition.json +165 -0
  41. package/node_modules/toolcraft/dist/config-mutations.d.ts +1 -0
  42. package/node_modules/toolcraft/dist/config-mutations.js +1 -0
  43. package/node_modules/toolcraft/dist/design/help-formatter.d.ts +2 -2
  44. package/node_modules/toolcraft/dist/design/help-formatter.js +1 -1
  45. package/node_modules/toolcraft/dist/design/render-markdown-plaintext.d.ts +2 -0
  46. package/node_modules/toolcraft/dist/design/render-markdown-plaintext.js +1 -0
  47. package/node_modules/toolcraft/dist/design/render-markdown.d.ts +2 -0
  48. package/node_modules/toolcraft/dist/design/render-markdown.js +1 -0
  49. package/node_modules/toolcraft/dist/discriminator.d.ts +9 -0
  50. package/node_modules/toolcraft/dist/discriminator.js +32 -0
  51. package/node_modules/toolcraft/dist/error-report.d.ts +12 -17
  52. package/node_modules/toolcraft/dist/error-report.js +25 -16
  53. package/node_modules/toolcraft/dist/file-change-renderer.d.ts +9 -0
  54. package/node_modules/toolcraft/dist/file-change-renderer.js +10 -0
  55. package/node_modules/toolcraft/dist/frontmatter.d.ts +1 -0
  56. package/node_modules/toolcraft/dist/frontmatter.js +1 -0
  57. package/node_modules/toolcraft/dist/http-hosted-oauth.compile-check.js +60 -0
  58. package/node_modules/toolcraft/dist/http-hosted-oauth.d.ts +124 -0
  59. package/node_modules/toolcraft/dist/http-hosted-oauth.js +473 -0
  60. package/node_modules/toolcraft/dist/http.compile-check.js +31 -0
  61. package/node_modules/toolcraft/dist/http.d.ts +31 -0
  62. package/node_modules/toolcraft/dist/http.js +161 -0
  63. package/node_modules/toolcraft/dist/human-in-loop/approval-tasks.d.ts +8 -2
  64. package/node_modules/toolcraft/dist/human-in-loop/approval-tasks.js +33 -19
  65. package/node_modules/toolcraft/dist/human-in-loop/approvals-commands.d.ts +3 -3
  66. package/node_modules/toolcraft/dist/human-in-loop/approvals-commands.js +27 -33
  67. package/node_modules/toolcraft/dist/human-in-loop/config.js +3 -0
  68. package/node_modules/toolcraft/dist/human-in-loop/gate.d.ts +7 -3
  69. package/node_modules/toolcraft/dist/human-in-loop/gate.js +33 -31
  70. package/node_modules/toolcraft/dist/human-in-loop/index.d.ts +4 -1
  71. package/node_modules/toolcraft/dist/human-in-loop/index.js +2 -0
  72. package/node_modules/toolcraft/dist/human-in-loop/plan-hash.d.ts +13 -0
  73. package/node_modules/toolcraft/dist/human-in-loop/plan-hash.js +78 -0
  74. package/node_modules/toolcraft/dist/human-in-loop/runner.d.ts +1 -1
  75. package/node_modules/toolcraft/dist/human-in-loop/runner.js +45 -32
  76. package/node_modules/toolcraft/dist/human-in-loop/runtime-options.d.ts +19 -0
  77. package/node_modules/toolcraft/dist/human-in-loop/runtime.d.ts +2 -0
  78. package/node_modules/toolcraft/dist/human-in-loop/runtime.js +14 -0
  79. package/node_modules/toolcraft/dist/human-in-loop/spawn.d.ts +2 -2
  80. package/node_modules/toolcraft/dist/human-in-loop/types.d.ts +14 -14
  81. package/node_modules/toolcraft/dist/human-in-loop/wiring.d.ts +11 -0
  82. package/node_modules/toolcraft/dist/human-in-loop/wiring.js +36 -0
  83. package/node_modules/toolcraft/dist/index.compile-check.js +50 -1
  84. package/node_modules/toolcraft/dist/index.d.ts +1 -210
  85. package/node_modules/toolcraft/dist/index.js +1 -475
  86. package/node_modules/toolcraft/dist/json-schema-converter.d.ts +14 -6
  87. package/node_modules/toolcraft/dist/json-schema-converter.js +150 -20
  88. package/node_modules/toolcraft/dist/mcp-proxy-metadata.d.ts +2 -0
  89. package/node_modules/toolcraft/dist/mcp-proxy-metadata.js +13 -0
  90. package/node_modules/toolcraft/dist/mcp-proxy.d.ts +2 -1
  91. package/node_modules/toolcraft/dist/mcp-proxy.js +69 -64
  92. package/node_modules/toolcraft/dist/mcp-result.d.ts +3 -0
  93. package/node_modules/toolcraft/dist/mcp-result.js +10 -0
  94. package/node_modules/toolcraft/dist/mcp.compile-check.js +4 -1
  95. package/node_modules/toolcraft/dist/mcp.d.ts +13 -3
  96. package/node_modules/toolcraft/dist/mcp.js +391 -217
  97. package/node_modules/toolcraft/dist/node-require-shim.js +4 -0
  98. package/node_modules/toolcraft/dist/package-metadata.js +9 -2
  99. package/node_modules/toolcraft/dist/process-runner.d.ts +1 -0
  100. package/node_modules/toolcraft/dist/process-runner.js +1 -0
  101. package/node_modules/toolcraft/dist/project-root.d.ts +1 -0
  102. package/node_modules/toolcraft/dist/project-root.js +15 -0
  103. package/node_modules/toolcraft/dist/redaction.js +26 -17
  104. package/node_modules/toolcraft/dist/renderer.d.ts +1 -1
  105. package/node_modules/toolcraft/dist/renderer.js +43 -42
  106. package/node_modules/toolcraft/dist/runtime/io.d.ts +5 -0
  107. package/node_modules/toolcraft/dist/runtime/io.js +59 -0
  108. package/node_modules/toolcraft/dist/runtime-platform.d.ts +2 -0
  109. package/node_modules/toolcraft/dist/runtime-platform.js +2 -0
  110. package/node_modules/toolcraft/dist/runtime-platform.workerd.d.ts +3 -0
  111. package/node_modules/toolcraft/dist/runtime-platform.workerd.js +10 -0
  112. package/node_modules/toolcraft/dist/runtime.d.ts +266 -0
  113. package/node_modules/toolcraft/dist/runtime.js +576 -0
  114. package/node_modules/toolcraft/dist/safe-bash-capabilities.compile-check.js +11 -0
  115. package/node_modules/toolcraft/dist/safe-bash.compile-check.js +16 -0
  116. package/node_modules/toolcraft/dist/safe-bash.d.ts +75 -0
  117. package/node_modules/toolcraft/dist/safe-bash.js +226 -0
  118. package/node_modules/toolcraft/dist/schema-member-names.d.ts +2 -0
  119. package/node_modules/toolcraft/dist/schema-member-names.js +39 -0
  120. package/node_modules/toolcraft/dist/schema-scope.d.ts +1 -0
  121. package/node_modules/toolcraft/dist/schema-scope.js +29 -16
  122. package/node_modules/toolcraft/dist/schema-standard.compile-check.js +4 -0
  123. package/node_modules/toolcraft/dist/schema.d.ts +2 -0
  124. package/node_modules/toolcraft/dist/schema.js +1 -0
  125. package/node_modules/toolcraft/dist/sdk.compile-check.js +31 -1
  126. package/node_modules/toolcraft/dist/sdk.d.ts +22 -13
  127. package/node_modules/toolcraft/dist/sdk.js +237 -108
  128. package/node_modules/toolcraft/dist/stream.d.ts +19 -0
  129. package/node_modules/toolcraft/dist/stream.js +93 -0
  130. package/node_modules/toolcraft/dist/testing/diagnostic-value.d.ts +1 -0
  131. package/node_modules/toolcraft/dist/testing/diagnostic-value.js +57 -0
  132. package/node_modules/toolcraft/dist/testing/fakes.d.ts +20 -0
  133. package/node_modules/toolcraft/dist/testing/fakes.js +84 -0
  134. package/node_modules/toolcraft/dist/testing/fixtures.d.ts +8 -0
  135. package/node_modules/toolcraft/dist/testing/fixtures.js +248 -0
  136. package/node_modules/toolcraft/dist/testing/harness.d.ts +97 -0
  137. package/node_modules/toolcraft/dist/testing/harness.js +490 -0
  138. package/node_modules/toolcraft/dist/testing/hosted-oauth-storage.d.ts +6 -0
  139. package/node_modules/toolcraft/dist/testing/hosted-oauth-storage.js +140 -0
  140. package/node_modules/toolcraft/dist/testing/index.d.ts +5 -0
  141. package/node_modules/toolcraft/dist/testing/index.js +4 -0
  142. package/node_modules/toolcraft/dist/testing/memory-fs.d.ts +11 -0
  143. package/node_modules/toolcraft/dist/testing/memory-fs.js +102 -0
  144. package/node_modules/toolcraft/dist/testing/parity.d.ts +25 -0
  145. package/node_modules/toolcraft/dist/testing/parity.js +428 -0
  146. package/node_modules/toolcraft/dist/testing/render-capture.d.ts +6 -0
  147. package/node_modules/toolcraft/dist/testing/render-capture.js +55 -0
  148. package/node_modules/toolcraft/dist/tiny-mcp-client.d.ts +1 -0
  149. package/node_modules/toolcraft/dist/tiny-mcp-client.js +1 -0
  150. package/node_modules/toolcraft/dist/union-validation.d.ts +5 -0
  151. package/node_modules/toolcraft/dist/union-validation.js +36 -0
  152. package/node_modules/toolcraft/dist/user-error.d.ts +8 -0
  153. package/node_modules/toolcraft/dist/user-error.js +10 -0
  154. package/node_modules/toolcraft/node_modules/@noble/hashes/LICENSE +21 -0
  155. package/node_modules/toolcraft/node_modules/@noble/hashes/README.md +478 -0
  156. package/node_modules/toolcraft/node_modules/@noble/hashes/_blake.d.ts +20 -0
  157. package/node_modules/toolcraft/node_modules/@noble/hashes/_blake.js +59 -0
  158. package/node_modules/toolcraft/node_modules/@noble/hashes/_md.d.ts +95 -0
  159. package/node_modules/toolcraft/node_modules/@noble/hashes/_md.js +209 -0
  160. package/node_modules/toolcraft/node_modules/@noble/hashes/_u64.d.ts +36 -0
  161. package/node_modules/toolcraft/node_modules/@noble/hashes/_u64.js +77 -0
  162. package/node_modules/toolcraft/node_modules/@noble/hashes/argon2.d.ts +148 -0
  163. package/node_modules/toolcraft/node_modules/@noble/hashes/argon2.js +577 -0
  164. package/node_modules/toolcraft/node_modules/@noble/hashes/blake1.d.ts +162 -0
  165. package/node_modules/toolcraft/node_modules/@noble/hashes/blake1.js +630 -0
  166. package/node_modules/toolcraft/node_modules/@noble/hashes/blake2.d.ts +203 -0
  167. package/node_modules/toolcraft/node_modules/@noble/hashes/blake2.js +573 -0
  168. package/node_modules/toolcraft/node_modules/@noble/hashes/blake3.d.ts +68 -0
  169. package/node_modules/toolcraft/node_modules/@noble/hashes/blake3.js +310 -0
  170. package/node_modules/toolcraft/node_modules/@noble/hashes/eskdf.d.ts +91 -0
  171. package/node_modules/toolcraft/node_modules/@noble/hashes/eskdf.js +225 -0
  172. package/node_modules/toolcraft/node_modules/@noble/hashes/hkdf.d.ts +70 -0
  173. package/node_modules/toolcraft/node_modules/@noble/hashes/hkdf.js +152 -0
  174. package/node_modules/toolcraft/node_modules/@noble/hashes/hmac.d.ts +50 -0
  175. package/node_modules/toolcraft/node_modules/@noble/hashes/hmac.js +93 -0
  176. package/node_modules/toolcraft/node_modules/@noble/hashes/index.js +34 -0
  177. package/node_modules/toolcraft/node_modules/@noble/hashes/legacy.d.ts +107 -0
  178. package/node_modules/toolcraft/node_modules/@noble/hashes/legacy.js +348 -0
  179. package/node_modules/toolcraft/node_modules/@noble/hashes/package.json +91 -0
  180. package/node_modules/toolcraft/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
  181. package/node_modules/toolcraft/node_modules/@noble/hashes/pbkdf2.js +176 -0
  182. package/node_modules/toolcraft/node_modules/@noble/hashes/scrypt.d.ts +98 -0
  183. package/node_modules/toolcraft/node_modules/@noble/hashes/scrypt.js +304 -0
  184. package/node_modules/toolcraft/node_modules/@noble/hashes/sha2.d.ts +176 -0
  185. package/node_modules/toolcraft/node_modules/@noble/hashes/sha2.js +446 -0
  186. package/node_modules/toolcraft/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
  187. package/node_modules/toolcraft/node_modules/@noble/hashes/sha3-addons.js +973 -0
  188. package/node_modules/toolcraft/node_modules/@noble/hashes/sha3.d.ts +208 -0
  189. package/node_modules/toolcraft/node_modules/@noble/hashes/sha3.js +475 -0
  190. package/node_modules/toolcraft/node_modules/@noble/hashes/src/_blake.ts +67 -0
  191. package/node_modules/toolcraft/node_modules/@noble/hashes/src/_md.ts +227 -0
  192. package/node_modules/toolcraft/node_modules/@noble/hashes/src/_u64.ts +111 -0
  193. package/node_modules/toolcraft/node_modules/@noble/hashes/src/argon2.ts +693 -0
  194. package/node_modules/toolcraft/node_modules/@noble/hashes/src/blake1.ts +677 -0
  195. package/node_modules/toolcraft/node_modules/@noble/hashes/src/blake2.ts +648 -0
  196. package/node_modules/toolcraft/node_modules/@noble/hashes/src/blake3.ts +344 -0
  197. package/node_modules/toolcraft/node_modules/@noble/hashes/src/eskdf.ts +265 -0
  198. package/node_modules/toolcraft/node_modules/@noble/hashes/src/hkdf.ts +161 -0
  199. package/node_modules/toolcraft/node_modules/@noble/hashes/src/hmac.ts +130 -0
  200. package/node_modules/toolcraft/node_modules/@noble/hashes/src/index.ts +33 -0
  201. package/node_modules/toolcraft/node_modules/@noble/hashes/src/legacy.ts +361 -0
  202. package/node_modules/toolcraft/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
  203. package/node_modules/toolcraft/node_modules/@noble/hashes/src/scrypt.ts +375 -0
  204. package/node_modules/toolcraft/node_modules/@noble/hashes/src/sha2.ts +486 -0
  205. package/node_modules/toolcraft/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
  206. package/node_modules/toolcraft/node_modules/@noble/hashes/src/sha3.ts +525 -0
  207. package/node_modules/toolcraft/node_modules/@noble/hashes/src/utils.ts +978 -0
  208. package/node_modules/toolcraft/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
  209. package/node_modules/toolcraft/node_modules/@noble/hashes/utils.d.ts +560 -0
  210. package/node_modules/toolcraft/node_modules/@noble/hashes/utils.js +687 -0
  211. package/node_modules/toolcraft/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
  212. package/node_modules/toolcraft/node_modules/@noble/hashes/webcrypto.js +228 -0
  213. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/LICENSE +21 -0
  214. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/README.md +15 -2
  215. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +2 -1
  216. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +1 -0
  217. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/codex.js +2 -1
  218. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +1 -0
  219. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.js +2 -1
  220. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/goose.js +1 -0
  221. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +1 -1
  222. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/index.js +1 -1
  223. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +2 -1
  224. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/{kimi.d.ts → pi.d.ts} +1 -1
  225. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/pi.js +15 -0
  226. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +1 -0
  227. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/capabilities.d.ts +14 -0
  228. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/capabilities.js +63 -0
  229. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/index.d.ts +3 -2
  230. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/index.js +2 -1
  231. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/registry.js +5 -2
  232. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/types.d.ts +8 -1
  233. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/package.json +11 -5
  234. package/node_modules/toolcraft/node_modules/@poe-code/agent-human-in-loop/LICENSE +21 -0
  235. package/node_modules/toolcraft/node_modules/@poe-code/agent-human-in-loop/README.md +12 -2
  236. package/node_modules/toolcraft/node_modules/@poe-code/agent-human-in-loop/package.json +10 -4
  237. package/node_modules/toolcraft/node_modules/@poe-code/agent-mcp-config/LICENSE +21 -0
  238. package/node_modules/toolcraft/node_modules/@poe-code/agent-mcp-config/README.md +7 -7
  239. package/node_modules/toolcraft/node_modules/@poe-code/agent-mcp-config/dist/apply.js +23 -9
  240. package/node_modules/toolcraft/node_modules/@poe-code/agent-mcp-config/dist/configs.js +0 -6
  241. package/node_modules/toolcraft/node_modules/@poe-code/agent-mcp-config/package.json +9 -6
  242. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/LICENSE +21 -0
  243. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/README.md +17 -8
  244. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +17 -19
  245. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -3
  246. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +4 -4
  247. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/formats/json.js +1 -3
  248. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/formats/toml.js +1 -3
  249. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +1 -3
  250. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
  251. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +2 -2
  252. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +3 -6
  253. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/types.d.ts +5 -1
  254. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/dist/types.js +1 -1
  255. package/node_modules/toolcraft/node_modules/@poe-code/config-mutations/package.json +9 -8
  256. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/LICENSE +21 -0
  257. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/README.md +7 -2
  258. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/dist/index.d.ts +1 -1
  259. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/dist/index.js +1 -1
  260. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/dist/parse.d.ts +9 -0
  261. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/dist/parse.js +16 -0
  262. package/node_modules/toolcraft/node_modules/@poe-code/frontmatter/package.json +7 -5
  263. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/LICENSE +21 -0
  264. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/README.md +5 -2
  265. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/docker/build-context.js +2 -3
  266. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/docker/docker-execution-env.js +66 -34
  267. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/host/host-execution-env.js +1 -0
  268. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/transfer-filesystem.d.ts +1 -0
  269. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/transfer-filesystem.js +1 -0
  270. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.d.ts +2 -0
  271. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.js +1 -0
  272. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/types.d.ts +12 -5
  273. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/workspace-transfer.d.ts +6 -5
  274. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +67 -29
  275. package/node_modules/toolcraft/node_modules/@poe-code/process-runner/package.json +22 -7
  276. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/LICENSE +21 -0
  277. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/PROVENANCE.json +428 -0
  278. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/README.md +453 -0
  279. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/confinement.d.ts +3 -0
  280. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/confinement.js +171 -0
  281. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.d.ts +93 -0
  282. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.js +453 -0
  283. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/index.d.ts +7 -0
  284. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/index.js +19 -0
  285. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/stats.d.ts +4 -0
  286. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/stats.js +37 -0
  287. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/types.d.ts +81 -0
  288. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/values.d.ts +6 -0
  289. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/bridge/values.js +65 -0
  290. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config/memory.d.ts +3 -0
  291. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config/memory.js +7 -0
  292. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config/real.d.ts +5 -0
  293. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config/real.js +16 -0
  294. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config/registry.d.ts +2 -0
  295. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config/registry.js +15 -0
  296. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config.d.ts +15 -0
  297. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config.js +46 -0
  298. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config.node.d.ts +2 -0
  299. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config.node.js +11 -0
  300. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config.portable.d.ts +3 -0
  301. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/config.portable.js +9 -0
  302. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/abort.d.ts +5 -0
  303. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/abort.js +34 -0
  304. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.d.ts +1 -0
  305. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.js +9 -0
  306. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.d.ts +38 -0
  307. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.js +1 -0
  308. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/errors.d.ts +53 -0
  309. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/errors.js +99 -0
  310. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.d.ts +411 -0
  311. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.js +1 -0
  312. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/index.d.ts +6 -0
  313. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/index.js +6 -0
  314. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/io.d.ts +12 -0
  315. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/io.js +321 -0
  316. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/object.d.ts +134 -0
  317. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/object.js +97 -0
  318. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/path.d.ts +3 -0
  319. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/path.js +2 -0
  320. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.d.ts +21 -0
  321. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.js +78 -0
  322. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.d.ts +15 -0
  323. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.js +162 -0
  324. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/core.d.ts +21 -0
  325. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/core.js +19 -0
  326. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/capabilities.d.ts +10 -0
  327. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/capabilities.js +223 -0
  328. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.d.ts +7 -0
  329. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.js +19 -0
  330. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/descriptor.d.ts +21 -0
  331. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/descriptor.js +279 -0
  332. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/index.d.ts +62 -0
  333. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/index.js +926 -0
  334. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/path.d.ts +7 -0
  335. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/path.js +256 -0
  336. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/plain-path.d.ts +2 -0
  337. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/plain-path.js +3 -0
  338. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.d.ts +6 -0
  339. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.js +136 -0
  340. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.d.ts +3 -0
  341. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.js +14 -0
  342. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.d.ts +12 -0
  343. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.js +13 -0
  344. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/index.d.ts +190 -0
  345. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/index.js +3862 -0
  346. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.d.ts +27 -0
  347. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.js +90 -0
  348. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.d.ts +13 -0
  349. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.js +26 -0
  350. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.d.ts +15 -0
  351. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.js +144 -0
  352. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.d.ts +19 -0
  353. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.js +118 -0
  354. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.d.ts +6 -0
  355. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.js +29 -0
  356. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/mount/index.d.ts +79 -0
  357. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/mount/index.js +1490 -0
  358. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/object-authority.d.ts +27 -0
  359. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/object-authority.js +287 -0
  360. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +46 -0
  361. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +536 -0
  362. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.d.ts +91 -0
  363. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.js +1305 -0
  364. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.d.ts +43 -0
  365. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.js +583 -0
  366. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.d.ts +4 -0
  367. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.js +63 -0
  368. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/quota/index.d.ts +12 -0
  369. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/quota/index.js +525 -0
  370. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/read-file-stream.d.ts +7 -0
  371. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/read-file-stream.js +103 -0
  372. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.d.ts +38 -0
  373. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.js +218 -0
  374. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.d.ts +1 -0
  375. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.js +8 -0
  376. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/real/index.d.ts +109 -0
  377. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/real/index.js +1393 -0
  378. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.d.ts +7 -0
  379. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.js +38 -0
  380. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.d.ts +131 -0
  381. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.js +1176 -0
  382. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.d.ts +1 -0
  383. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.js +9 -0
  384. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
  385. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.js +1 -0
  386. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.d.ts +15 -0
  387. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.js +74 -0
  388. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.d.ts +4 -0
  389. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.js +111 -0
  390. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.d.ts +17 -0
  391. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.js +89 -0
  392. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
  393. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.js +76 -0
  394. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
  395. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.js +478 -0
  396. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
  397. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.js +1 -0
  398. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.d.ts +14 -0
  399. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.js +192 -0
  400. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/index.d.ts +8 -0
  401. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/index.js +4 -0
  402. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.d.ts +2 -0
  403. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.js +11 -0
  404. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.d.ts +8 -0
  405. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.js +167 -0
  406. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.d.ts +48 -0
  407. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.js +249 -0
  408. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.d.ts +13 -0
  409. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.js +400 -0
  410. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.d.ts +10 -0
  411. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.js +73 -0
  412. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.d.ts +103 -0
  413. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.js +28 -0
  414. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/scoped.d.ts +20 -0
  415. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/scoped.js +668 -0
  416. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.d.ts +8 -0
  417. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.js +115 -0
  418. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.d.ts +5 -0
  419. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.js +63 -0
  420. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.d.ts +2 -0
  421. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.js +1 -0
  422. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
  423. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.js +109 -0
  424. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.d.ts +141 -0
  425. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.js +1377 -0
  426. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
  427. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.js +59 -0
  428. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/index.d.ts +26 -0
  429. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/index.js +22 -0
  430. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/native/fs-seek/linux-x64-glibc.node +0 -0
  431. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.d.ts +5 -0
  432. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.mjs +120 -0
  433. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/native/fs-seek/manifest.json +46 -0
  434. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/filesystem.d.ts +19 -0
  435. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/filesystem.js +30 -0
  436. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/host.d.ts +3 -0
  437. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/host.js +78 -0
  438. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/index.d.ts +3 -0
  439. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/index.js +2 -0
  440. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.d.ts +1 -0
  441. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.js +5 -0
  442. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/native-seek.d.ts +3 -0
  443. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/native-seek.js +54 -0
  444. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/stats.d.ts +1 -0
  445. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/stats.js +1 -0
  446. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/values.d.ts +1 -0
  447. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node/values.js +1 -0
  448. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node-host.d.ts +1 -0
  449. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node-host.js +1 -0
  450. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node-unavailable.d.ts +1 -0
  451. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/node-unavailable.js +1 -0
  452. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/package.json +29 -0
  453. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/browser-path.d.ts +1 -0
  454. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/browser-path.js +1 -0
  455. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/browser.d.ts +26 -0
  456. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/browser.js +58 -0
  457. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/node-path.d.ts +1 -0
  458. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/node-path.js +1 -0
  459. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/node.d.ts +26 -0
  460. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/node.js +64 -0
  461. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.d.ts +9 -0
  462. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.js +17 -0
  463. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/directory.d.ts +9 -0
  464. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/directory.js +38 -0
  465. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/emscripten.d.ts +15 -0
  466. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/emscripten.js +372 -0
  467. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/filesystem.d.ts +51 -0
  468. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/filesystem.js +258 -0
  469. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/flags.d.ts +3 -0
  470. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/flags.js +14 -0
  471. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/index.d.ts +9 -0
  472. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/index.js +5 -0
  473. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/native.d.ts +18 -0
  474. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/native.js +477 -0
  475. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/request.d.ts +2 -0
  476. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/request.js +62 -0
  477. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/stat.d.ts +8 -0
  478. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/python/stat.js +34 -0
  479. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/runtime-core.d.ts +28 -0
  480. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/runtime-core.js +58 -0
  481. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/storage.d.ts +81 -0
  482. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/storage.js +430 -0
  483. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.d.ts +16 -0
  484. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.js +496 -0
  485. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.d.ts +23 -0
  486. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.js +39 -0
  487. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.d.ts +31 -0
  488. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.js +144 -0
  489. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/object-publication.d.ts +19 -0
  490. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/testing/object-publication.js +209 -0
  491. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/xml.d.ts +1 -0
  492. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/dist/xml.js +1 -0
  493. package/node_modules/toolcraft/node_modules/@poe-code/safe-fs/package.json +196 -0
  494. package/node_modules/toolcraft/node_modules/@poe-code/task-list/LICENSE +21 -0
  495. package/node_modules/toolcraft/node_modules/@poe-code/task-list/README.md +28 -3
  496. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +1 -1
  497. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +15 -4
  498. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +3 -4
  499. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/backends/utils.js +36 -43
  500. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +2 -5
  501. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/default-host.d.ts +2 -0
  502. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/default-host.js +2 -0
  503. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/default-host.workerd.d.ts +4 -0
  504. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/default-host.workerd.js +6 -0
  505. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/filesystem.d.ts +3 -0
  506. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/filesystem.js +32 -0
  507. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/move.js +3 -3
  508. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/open.js +2 -5
  509. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/paths.d.ts +12 -0
  510. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/paths.js +7 -0
  511. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/schema/ids.d.ts +2 -0
  512. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/schema/ids.js +6 -0
  513. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/types.d.ts +7 -5
  514. package/node_modules/toolcraft/node_modules/@poe-code/task-list/package.json +16 -5
  515. package/node_modules/toolcraft/node_modules/@poe-code/terminal-text/LICENSE +21 -0
  516. package/node_modules/toolcraft/node_modules/@poe-code/terminal-text/README.md +12 -0
  517. package/node_modules/toolcraft/node_modules/@poe-code/terminal-text/dist/index.d.ts +2 -0
  518. package/node_modules/toolcraft/node_modules/@poe-code/terminal-text/dist/index.js +20 -0
  519. package/node_modules/toolcraft/node_modules/@poe-code/terminal-text/package.json +22 -0
  520. package/node_modules/toolcraft/node_modules/@poe-code/user-error/README.md +56 -0
  521. package/node_modules/toolcraft/node_modules/@poe-code/user-error/dist/index.d.ts +17 -0
  522. package/node_modules/toolcraft/node_modules/@poe-code/user-error/dist/index.js +21 -0
  523. package/node_modules/toolcraft/node_modules/{mcp-oauth → @poe-code/user-error}/package.json +4 -10
  524. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/LICENSE +21 -0
  525. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/README.md +139 -0
  526. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/attributes.d.ts +69 -0
  527. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/attributes.js +62 -0
  528. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/characters.d.ts +3 -0
  529. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/characters.js +53 -0
  530. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/errors.d.ts +4 -0
  531. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/errors.js +7 -0
  532. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/frames.d.ts +67 -0
  533. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/frames.js +87 -0
  534. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/index.d.ts +101 -0
  535. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/index.js +945 -0
  536. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/source.d.ts +28 -0
  537. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/source.js +71 -0
  538. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/stream.d.ts +32 -0
  539. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/dist/stream.js +179 -0
  540. package/node_modules/toolcraft/node_modules/@poe-code/xml-ast/package.json +25 -0
  541. package/node_modules/toolcraft/node_modules/auth-store/LICENSE +21 -0
  542. package/node_modules/toolcraft/node_modules/auth-store/README.md +77 -0
  543. package/node_modules/toolcraft/node_modules/auth-store/dist/create-secret-store.d.ts +3 -1
  544. package/node_modules/toolcraft/node_modules/auth-store/dist/create-secret-store.js +3 -2
  545. package/node_modules/toolcraft/node_modules/auth-store/dist/encrypted-file-store.d.ts +6 -0
  546. package/node_modules/toolcraft/node_modules/auth-store/dist/encrypted-file-store.js +16 -0
  547. package/node_modules/toolcraft/node_modules/auth-store/dist/index.browser.d.ts +4 -0
  548. package/node_modules/toolcraft/node_modules/auth-store/dist/index.browser.js +2 -0
  549. package/node_modules/toolcraft/node_modules/auth-store/dist/index.d.ts +2 -1
  550. package/node_modules/toolcraft/node_modules/auth-store/dist/index.js +1 -1
  551. package/node_modules/toolcraft/node_modules/auth-store/dist/keychain-store.d.ts +8 -0
  552. package/node_modules/toolcraft/node_modules/auth-store/dist/keychain-store.js +13 -0
  553. package/node_modules/toolcraft/node_modules/auth-store/dist/provider-store.d.ts +1 -1
  554. package/node_modules/toolcraft/node_modules/auth-store/dist/provider-store.js +3 -0
  555. package/node_modules/toolcraft/node_modules/auth-store/dist/safe-fs-secret-store.d.ts +21 -0
  556. package/node_modules/toolcraft/node_modules/auth-store/dist/safe-fs-secret-store.js +119 -0
  557. package/node_modules/toolcraft/node_modules/auth-store/dist/secret-store.d.ts +12 -0
  558. package/node_modules/toolcraft/node_modules/auth-store/dist/secret-store.js +1 -0
  559. package/node_modules/toolcraft/node_modules/auth-store/dist/transaction-lock.d.ts +22 -0
  560. package/node_modules/toolcraft/node_modules/auth-store/dist/transaction-lock.js +153 -0
  561. package/node_modules/toolcraft/node_modules/auth-store/dist/types.d.ts +2 -7
  562. package/node_modules/toolcraft/node_modules/auth-store/package.json +21 -6
  563. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/dist/index.d.ts +4 -0
  564. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  565. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/dist/types.d.ts +19 -0
  566. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/dist/types.js +2 -0
  567. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/dist/utils.d.ts +4 -0
  568. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  569. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/license +21 -0
  570. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/package.json +35 -0
  571. package/node_modules/toolcraft/node_modules/fast-string-truncated-width/readme.md +59 -0
  572. package/node_modules/toolcraft/node_modules/fast-string-width/dist/index.d.ts +4 -0
  573. package/node_modules/toolcraft/node_modules/fast-string-width/dist/index.js +14 -0
  574. package/node_modules/toolcraft/node_modules/fast-string-width/license +21 -0
  575. package/node_modules/toolcraft/node_modules/fast-string-width/package.json +34 -0
  576. package/node_modules/toolcraft/node_modules/fast-string-width/readme.md +42 -0
  577. package/node_modules/toolcraft/node_modules/fast-wrap-ansi/LICENSE +23 -0
  578. package/node_modules/toolcraft/node_modules/fast-wrap-ansi/README.md +26 -0
  579. package/node_modules/toolcraft/node_modules/fast-wrap-ansi/lib/main.d.ts +6 -0
  580. package/node_modules/toolcraft/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  581. package/node_modules/toolcraft/node_modules/fast-wrap-ansi/package.json +51 -0
  582. package/node_modules/toolcraft/node_modules/ignore/LICENSE-MIT +21 -0
  583. package/node_modules/toolcraft/node_modules/ignore/README.md +412 -0
  584. package/node_modules/toolcraft/node_modules/ignore/index.d.ts +61 -0
  585. package/node_modules/toolcraft/node_modules/ignore/index.js +636 -0
  586. package/node_modules/toolcraft/node_modules/ignore/legacy.js +559 -0
  587. package/node_modules/toolcraft/node_modules/ignore/package.json +74 -0
  588. package/node_modules/toolcraft/node_modules/jose/LICENSE.md +21 -0
  589. package/node_modules/toolcraft/node_modules/jose/README.md +153 -0
  590. package/node_modules/toolcraft/node_modules/jose/dist/types/index.d.ts +55 -0
  591. package/node_modules/toolcraft/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +31 -0
  592. package/node_modules/toolcraft/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +65 -0
  593. package/node_modules/toolcraft/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +31 -0
  594. package/node_modules/toolcraft/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +83 -0
  595. package/node_modules/toolcraft/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +38 -0
  596. package/node_modules/toolcraft/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +74 -0
  597. package/node_modules/toolcraft/node_modules/jose/dist/types/jwk/embedded.d.ts +17 -0
  598. package/node_modules/toolcraft/node_modules/jose/dist/types/jwk/thumbprint.d.ts +32 -0
  599. package/node_modules/toolcraft/node_modules/jose/dist/types/jwks/local.d.ts +29 -0
  600. package/node_modules/toolcraft/node_modules/jose/dist/types/jwks/remote.d.ts +237 -0
  601. package/node_modules/toolcraft/node_modules/jose/dist/types/jws/compact/sign.d.ts +36 -0
  602. package/node_modules/toolcraft/node_modules/jose/dist/types/jws/compact/verify.d.ts +33 -0
  603. package/node_modules/toolcraft/node_modules/jose/dist/types/jws/flattened/sign.d.ts +42 -0
  604. package/node_modules/toolcraft/node_modules/jose/dist/types/jws/flattened/verify.d.ts +33 -0
  605. package/node_modules/toolcraft/node_modules/jose/dist/types/jws/general/sign.d.ts +53 -0
  606. package/node_modules/toolcraft/node_modules/jose/dist/types/jws/general/verify.d.ts +41 -0
  607. package/node_modules/toolcraft/node_modules/jose/dist/types/jwt/decrypt.d.ts +35 -0
  608. package/node_modules/toolcraft/node_modules/jose/dist/types/jwt/encrypt.d.ts +91 -0
  609. package/node_modules/toolcraft/node_modules/jose/dist/types/jwt/sign.d.ts +43 -0
  610. package/node_modules/toolcraft/node_modules/jose/dist/types/jwt/unsecured.d.ts +43 -0
  611. package/node_modules/toolcraft/node_modules/jose/dist/types/jwt/verify.d.ts +37 -0
  612. package/node_modules/toolcraft/node_modules/jose/dist/types/key/export.d.ts +33 -0
  613. package/node_modules/toolcraft/node_modules/jose/dist/types/key/generate_key_pair.d.ts +47 -0
  614. package/node_modules/toolcraft/node_modules/jose/dist/types/key/generate_secret.d.ts +35 -0
  615. package/node_modules/toolcraft/node_modules/jose/dist/types/key/import.d.ts +83 -0
  616. package/node_modules/toolcraft/node_modules/jose/dist/types/types.d.ts +852 -0
  617. package/node_modules/toolcraft/node_modules/jose/dist/types/util/base64url.d.ts +9 -0
  618. package/node_modules/toolcraft/node_modules/jose/dist/types/util/decode_jwt.d.ts +18 -0
  619. package/node_modules/toolcraft/node_modules/jose/dist/types/util/decode_protected_header.d.ts +17 -0
  620. package/node_modules/toolcraft/node_modules/jose/dist/types/util/errors.d.ts +213 -0
  621. package/node_modules/toolcraft/node_modules/jose/dist/webapi/index.js +32 -0
  622. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +27 -0
  623. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +27 -0
  624. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +159 -0
  625. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +167 -0
  626. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwe/general/decrypt.js +31 -0
  627. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwe/general/encrypt.js +182 -0
  628. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwk/embedded.js +17 -0
  629. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwk/thumbprint.js +68 -0
  630. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwks/local.js +119 -0
  631. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwks/remote.js +179 -0
  632. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jws/compact/sign.js +18 -0
  633. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jws/compact/verify.js +21 -0
  634. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jws/flattened/sign.js +89 -0
  635. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jws/flattened/verify.js +110 -0
  636. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jws/general/sign.js +70 -0
  637. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jws/general/verify.js +24 -0
  638. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwt/decrypt.js +23 -0
  639. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwt/encrypt.js +101 -0
  640. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwt/sign.js +52 -0
  641. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwt/unsecured.js +63 -0
  642. package/node_modules/toolcraft/node_modules/jose/dist/webapi/jwt/verify.js +15 -0
  643. package/node_modules/toolcraft/node_modules/jose/dist/webapi/key/export.js +11 -0
  644. package/node_modules/toolcraft/node_modules/jose/dist/webapi/key/generate_key_pair.js +97 -0
  645. package/node_modules/toolcraft/node_modules/jose/dist/webapi/key/generate_secret.js +40 -0
  646. package/node_modules/toolcraft/node_modules/jose/dist/webapi/key/import.js +57 -0
  647. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/aesgcmkw.js +15 -0
  648. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/aeskw.js +25 -0
  649. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/asn1.js +243 -0
  650. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/base64.js +22 -0
  651. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/buffer_utils.js +43 -0
  652. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/check_key_type.js +122 -0
  653. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/content_encryption.js +217 -0
  654. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/crypto_key.js +136 -0
  655. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/deflate.js +44 -0
  656. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/ecdhes.js +52 -0
  657. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/helpers.js +19 -0
  658. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/invalid_key_input.js +27 -0
  659. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -0
  660. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/jwk_to_key.js +107 -0
  661. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +238 -0
  662. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/key_management.js +186 -0
  663. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/key_to_jwk.js +31 -0
  664. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/normalize_key.js +166 -0
  665. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/pbes2kw.js +42 -0
  666. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/rsaes.js +24 -0
  667. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/signing.js +68 -0
  668. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/type_checks.js +40 -0
  669. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/validate_algorithms.js +10 -0
  670. package/node_modules/toolcraft/node_modules/jose/dist/webapi/lib/validate_crit.js +33 -0
  671. package/node_modules/toolcraft/node_modules/jose/dist/webapi/util/base64url.js +30 -0
  672. package/node_modules/toolcraft/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -0
  673. package/node_modules/toolcraft/node_modules/jose/dist/webapi/util/decode_protected_header.js +34 -0
  674. package/node_modules/toolcraft/node_modules/jose/dist/webapi/util/errors.js +99 -0
  675. package/node_modules/toolcraft/node_modules/jose/package.json +200 -0
  676. package/node_modules/toolcraft/node_modules/jsonc-parser/CHANGELOG.md +76 -0
  677. package/node_modules/toolcraft/node_modules/jsonc-parser/LICENSE.md +21 -0
  678. package/node_modules/toolcraft/node_modules/jsonc-parser/README.md +364 -0
  679. package/node_modules/toolcraft/node_modules/jsonc-parser/SECURITY.md +41 -0
  680. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/impl/edit.js +185 -0
  681. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/impl/format.js +261 -0
  682. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/impl/parser.js +659 -0
  683. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/impl/scanner.js +443 -0
  684. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +29 -0
  685. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/main.d.ts +351 -0
  686. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/esm/main.js +178 -0
  687. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/impl/edit.js +201 -0
  688. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/impl/format.js +275 -0
  689. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/impl/parser.js +682 -0
  690. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/impl/scanner.js +456 -0
  691. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
  692. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/main.d.ts +351 -0
  693. package/node_modules/toolcraft/node_modules/jsonc-parser/lib/umd/main.js +194 -0
  694. package/node_modules/toolcraft/node_modules/jsonc-parser/package.json +37 -0
  695. package/node_modules/toolcraft/node_modules/mcp-oauth-server/LICENSE +21 -0
  696. package/node_modules/toolcraft/node_modules/mcp-oauth-server/README.md +192 -0
  697. package/node_modules/toolcraft/node_modules/mcp-oauth-server/dist/index.d.ts +161 -0
  698. package/node_modules/toolcraft/node_modules/mcp-oauth-server/dist/index.js +723 -0
  699. package/node_modules/toolcraft/node_modules/mcp-oauth-server/package.json +34 -0
  700. package/node_modules/toolcraft/node_modules/saxes/README.md +323 -0
  701. package/node_modules/toolcraft/node_modules/saxes/package.json +71 -0
  702. package/node_modules/toolcraft/node_modules/saxes/saxes.d.ts +635 -0
  703. package/node_modules/toolcraft/node_modules/saxes/saxes.js +2053 -0
  704. package/node_modules/toolcraft/node_modules/saxes/saxes.js.map +1 -0
  705. package/node_modules/toolcraft/node_modules/sisteransi/license +21 -0
  706. package/node_modules/toolcraft/node_modules/sisteransi/package.json +34 -0
  707. package/node_modules/toolcraft/node_modules/sisteransi/readme.md +113 -0
  708. package/node_modules/toolcraft/node_modules/sisteransi/src/index.js +58 -0
  709. package/node_modules/toolcraft/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
  710. package/node_modules/toolcraft/node_modules/smol-toml/LICENSE +24 -0
  711. package/node_modules/toolcraft/node_modules/smol-toml/README.md +404 -0
  712. package/node_modules/toolcraft/node_modules/smol-toml/dist/date.d.ts +42 -0
  713. package/node_modules/toolcraft/node_modules/smol-toml/dist/date.d.ts.map +1 -0
  714. package/node_modules/toolcraft/node_modules/smol-toml/dist/date.js +128 -0
  715. package/node_modules/toolcraft/node_modules/smol-toml/dist/date.js.map +1 -0
  716. package/node_modules/toolcraft/node_modules/smol-toml/dist/error.d.ts +39 -0
  717. package/node_modules/toolcraft/node_modules/smol-toml/dist/error.d.ts.map +1 -0
  718. package/node_modules/toolcraft/node_modules/smol-toml/dist/error.js +64 -0
  719. package/node_modules/toolcraft/node_modules/smol-toml/dist/error.js.map +1 -0
  720. package/node_modules/toolcraft/node_modules/smol-toml/dist/extract.d.ts +31 -0
  721. package/node_modules/toolcraft/node_modules/smol-toml/dist/extract.d.ts.map +1 -0
  722. package/node_modules/toolcraft/node_modules/smol-toml/dist/extract.js +101 -0
  723. package/node_modules/toolcraft/node_modules/smol-toml/dist/extract.js.map +1 -0
  724. package/node_modules/toolcraft/node_modules/smol-toml/dist/index.cjs +708 -0
  725. package/node_modules/toolcraft/node_modules/smol-toml/dist/index.cjs.map +1 -0
  726. package/node_modules/toolcraft/node_modules/smol-toml/dist/index.d.ts +44 -0
  727. package/node_modules/toolcraft/node_modules/smol-toml/dist/index.d.ts.map +1 -0
  728. package/node_modules/toolcraft/node_modules/smol-toml/dist/index.js +34 -0
  729. package/node_modules/toolcraft/node_modules/smol-toml/dist/index.js.map +1 -0
  730. package/node_modules/toolcraft/node_modules/smol-toml/dist/parse.d.ts +38 -0
  731. package/node_modules/toolcraft/node_modules/smol-toml/dist/parse.d.ts.map +1 -0
  732. package/node_modules/toolcraft/node_modules/smol-toml/dist/parse.js +148 -0
  733. package/node_modules/toolcraft/node_modules/smol-toml/dist/parse.js.map +1 -0
  734. package/node_modules/toolcraft/node_modules/smol-toml/dist/primitive.d.ts +32 -0
  735. package/node_modules/toolcraft/node_modules/smol-toml/dist/primitive.d.ts.map +1 -0
  736. package/node_modules/toolcraft/node_modules/smol-toml/dist/primitive.js +237 -0
  737. package/node_modules/toolcraft/node_modules/smol-toml/dist/primitive.js.map +1 -0
  738. package/node_modules/toolcraft/node_modules/smol-toml/dist/stringify.d.ts +32 -0
  739. package/node_modules/toolcraft/node_modules/smol-toml/dist/stringify.d.ts.map +1 -0
  740. package/node_modules/toolcraft/node_modules/smol-toml/dist/stringify.js +168 -0
  741. package/node_modules/toolcraft/node_modules/smol-toml/dist/stringify.js.map +1 -0
  742. package/node_modules/toolcraft/node_modules/smol-toml/dist/struct.d.ts +33 -0
  743. package/node_modules/toolcraft/node_modules/smol-toml/dist/struct.d.ts.map +1 -0
  744. package/node_modules/toolcraft/node_modules/smol-toml/dist/struct.js +179 -0
  745. package/node_modules/toolcraft/node_modules/smol-toml/dist/struct.js.map +1 -0
  746. package/node_modules/toolcraft/node_modules/smol-toml/dist/util.d.ts +42 -0
  747. package/node_modules/toolcraft/node_modules/smol-toml/dist/util.d.ts.map +1 -0
  748. package/node_modules/toolcraft/node_modules/smol-toml/dist/util.js +86 -0
  749. package/node_modules/toolcraft/node_modules/smol-toml/dist/util.js.map +1 -0
  750. package/node_modules/toolcraft/node_modules/smol-toml/package.json +64 -0
  751. package/node_modules/toolcraft/node_modules/smol-toml/src/date.ts +152 -0
  752. package/node_modules/toolcraft/node_modules/smol-toml/src/error.ts +77 -0
  753. package/node_modules/toolcraft/node_modules/smol-toml/src/extract.ts +112 -0
  754. package/node_modules/toolcraft/node_modules/smol-toml/src/index.ts +42 -0
  755. package/node_modules/toolcraft/node_modules/smol-toml/src/parse.ts +184 -0
  756. package/node_modules/toolcraft/node_modules/smol-toml/src/primitive.ts +247 -0
  757. package/node_modules/toolcraft/node_modules/smol-toml/src/stringify.ts +191 -0
  758. package/node_modules/toolcraft/node_modules/smol-toml/src/struct.ts +199 -0
  759. package/node_modules/toolcraft/node_modules/smol-toml/src/util.ts +101 -0
  760. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/LICENSE +21 -0
  761. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/README.md +836 -0
  762. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/auth.d.ts +69 -0
  763. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/auth.js +261 -0
  764. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/cli.d.ts +20 -0
  765. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/cli.js +493 -0
  766. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/composition.json +65 -0
  767. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/express-middleware.d.ts +18 -0
  768. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/express-middleware.js +90 -0
  769. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/fetch-body.d.ts +6 -0
  770. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/fetch-body.js +47 -0
  771. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/fetch.d.ts +23 -0
  772. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/fetch.js +130 -0
  773. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/http-server.d.ts +53 -0
  774. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/http-server.js +262 -0
  775. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/http-transport.d.ts +173 -0
  776. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/http-transport.js +1097 -0
  777. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/index.d.ts +13 -0
  778. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/index.js +6 -0
  779. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/load-oauth-verifier.d.ts +6 -0
  780. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/load-oauth-verifier.js +43 -0
  781. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/modern-headers.d.ts +3 -0
  782. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/modern-headers.js +34 -0
  783. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/parse-body.d.ts +23 -0
  784. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/parse-body.js +161 -0
  785. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/server.d.ts +9 -0
  786. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/server.js +4 -0
  787. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/session.d.ts +18 -0
  788. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/session.js +37 -0
  789. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/sse.d.ts +11 -0
  790. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/sse.js +22 -0
  791. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/test-support.d.ts +10 -0
  792. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/test-support.js +415 -0
  793. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/testing.d.ts +59 -0
  794. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/dist/testing.js +192 -0
  795. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/LICENSE +21 -0
  796. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +390 -0
  797. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +17 -0
  798. package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/auth-store-session-store.js +61 -36
  799. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-error.d.ts +7 -0
  800. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-error.js +16 -0
  801. package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/authorization-state.js +4 -4
  802. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/bounded-json.d.ts +2 -0
  803. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/bounded-json.js +44 -0
  804. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/cancellable-operation.d.ts +2 -0
  805. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/cancellable-operation.js +18 -0
  806. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/client-registration.d.ts +6 -0
  807. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/client-registration.js +118 -0
  808. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +841 -0
  809. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +36 -0
  810. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/loopback-authorization.js +317 -0
  811. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.d.ts +10 -0
  812. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.js +20 -0
  813. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/persistence-options.d.ts +3 -0
  814. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/persistence-options.js +10 -0
  815. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +8 -0
  816. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/redirect-target.d.ts +10 -0
  817. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/redirect-target.js +42 -0
  818. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.d.ts +20 -0
  819. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.js +68 -0
  820. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resource-bound-store.d.ts +20 -0
  821. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resource-bound-store.js +179 -0
  822. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.d.ts +66 -0
  823. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.js +153 -0
  824. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.d.ts +12 -0
  825. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.js +23 -0
  826. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/scope.d.ts +2 -0
  827. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/scope.js +9 -0
  828. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/session-transaction.d.ts +6 -0
  829. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/session-transaction.js +50 -0
  830. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-auth-method.d.ts +2 -0
  831. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-auth-method.js +7 -0
  832. package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/token-endpoint.d.ts +11 -3
  833. package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/token-endpoint.js +66 -29
  834. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-grant.d.ts +10 -0
  835. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-grant.js +56 -0
  836. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/types.d.ts +196 -0
  837. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/types.js +1 -0
  838. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.d.ts +1 -0
  839. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.js +45 -0
  840. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-response.d.ts +1 -0
  841. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-response.js +50 -0
  842. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +24 -0
  843. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +31 -0
  844. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +25 -0
  845. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +19 -0
  846. package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/server/jwks-token-verifier.d.ts +4 -0
  847. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +406 -0
  848. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/types.compile-check.d.ts +1 -0
  849. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/package.json +35 -0
  850. package/node_modules/toolcraft/node_modules/tiny-http-mcp-server/package.json +65 -0
  851. package/node_modules/toolcraft/node_modules/tiny-mcp-client/LICENSE +21 -0
  852. package/node_modules/toolcraft/node_modules/tiny-mcp-client/README.md +150 -49
  853. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/index.browser.d.ts +909 -0
  854. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/index.browser.js +6923 -0
  855. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/index.d.ts +909 -2
  856. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/index.js +10285 -1
  857. package/node_modules/toolcraft/node_modules/tiny-mcp-client/package.json +42 -3
  858. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/LICENSE +21 -0
  859. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/README.md +296 -0
  860. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/base64.d.ts +1 -0
  861. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/base64.js +10 -0
  862. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/composition.json +15 -0
  863. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/audio.d.ts +18 -0
  864. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/audio.js +84 -0
  865. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/convert.d.ts +20 -0
  866. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/convert.js +96 -0
  867. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/file-type.d.ts +11 -0
  868. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/file-type.js +93 -0
  869. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/file.d.ts +33 -0
  870. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/file.js +110 -0
  871. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/image.d.ts +18 -0
  872. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/image.js +72 -0
  873. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/index.d.ts +7 -0
  874. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/index.js +9 -0
  875. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/mime.d.ts +7 -0
  876. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/mime.js +52 -0
  877. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/remote.d.ts +5 -0
  878. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/content/remote.js +69 -0
  879. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/core.d.ts +8 -0
  880. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/core.js +4 -0
  881. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/headers.d.ts +10 -0
  882. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/headers.js +181 -0
  883. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/index.d.ts +9 -0
  884. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/index.js +7 -0
  885. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/input-request-schema.d.ts +220 -0
  886. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/input-request-schema.js +1995 -0
  887. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/jsonrpc.d.ts +15 -0
  888. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/jsonrpc.js +131 -0
  889. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/metadata.d.ts +2 -0
  890. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/metadata.js +37 -0
  891. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/protocol-server.d.ts +48 -0
  892. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/protocol-server.js +1169 -0
  893. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/protocol-validation.d.ts +4 -0
  894. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/protocol-validation.js +53 -0
  895. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/protocol.d.ts +17 -0
  896. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/protocol.js +228 -0
  897. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/request-cancellation.d.ts +1 -0
  898. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/request-cancellation.js +18 -0
  899. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/sampling-messages.d.ts +18 -0
  900. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/sampling-messages.js +34 -0
  901. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/schema.d.ts +26 -0
  902. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/schema.js +26 -0
  903. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/server.d.ts +4 -0
  904. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/server.js +7 -0
  905. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/standard-schema.compile-check.d.ts +1 -0
  906. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/standard-schema.compile-check.js +15 -0
  907. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/stdio-input.d.ts +11 -0
  908. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/stdio-input.js +67 -0
  909. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/stdio-output.d.ts +24 -0
  910. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/stdio-output.js +131 -0
  911. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/subscriptions.d.ts +11 -0
  912. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/subscriptions.js +128 -0
  913. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/testing.d.ts +7 -0
  914. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/testing.js +20 -0
  915. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/tool-call-admission.d.ts +9 -0
  916. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/tool-call-admission.js +51 -0
  917. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/tool-schema.d.ts +13 -0
  918. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/tool-schema.js +53 -0
  919. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/types.d.ts +299 -0
  920. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/types.js +23 -0
  921. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/uri-template.d.ts +6 -0
  922. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/uri-template.js +363 -0
  923. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/uri.d.ts +1 -0
  924. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/dist/uri.js +41 -0
  925. package/node_modules/toolcraft/node_modules/tiny-stdio-mcp-server/package.json +66 -0
  926. package/node_modules/toolcraft/node_modules/toolcraft-design/LICENSE +21 -0
  927. package/node_modules/toolcraft/node_modules/toolcraft-design/README.md +47 -7
  928. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/acp/components.d.ts +8 -1
  929. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/acp/components.js +11 -6
  930. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/acp/index.d.ts +3 -0
  931. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/acp/index.js +1 -0
  932. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/acp/plan.d.ts +10 -0
  933. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/acp/plan.js +50 -0
  934. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/command-registry.d.ts +11 -0
  935. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/command-registry.js +24 -0
  936. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/command-errors.d.ts +2 -0
  937. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/command-errors.js +8 -2
  938. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/file-changes.d.ts +16 -0
  939. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/file-changes.js +162 -0
  940. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +61 -25
  941. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +17 -0
  942. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/help-formatter.js +128 -29
  943. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/index.d.ts +5 -3
  944. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/index.js +3 -2
  945. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/table.d.ts +1 -0
  946. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/table.js +58 -5
  947. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/template.d.ts +9 -0
  948. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/components/template.js +27 -2
  949. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/ansi.d.ts +2 -0
  950. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/ansi.js +81 -27
  951. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/buffer.js +39 -25
  952. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/border.js +6 -5
  953. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/context-pane.d.ts +4 -0
  954. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/context-pane.js +22 -0
  955. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/footer.d.ts +2 -2
  956. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/footer.js +46 -24
  957. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/output-pane.d.ts +6 -2
  958. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/output-pane.js +128 -10
  959. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/run-view.d.ts +27 -0
  960. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/run-view.js +283 -0
  961. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.d.ts +3 -2
  962. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.js +60 -19
  963. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/composer-layout.d.ts +12 -0
  964. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/composer-layout.js +45 -0
  965. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/composer.d.ts +24 -0
  966. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/composer.js +107 -0
  967. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/dashboard.d.ts +8 -0
  968. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/dashboard.js +268 -13
  969. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/elapsed.d.ts +1 -0
  970. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/elapsed.js +8 -0
  971. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/index.d.ts +4 -1
  972. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/index.js +2 -0
  973. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/keymap.js +26 -6
  974. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/layout.d.ts +1 -0
  975. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/layout.js +19 -3
  976. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/line-buffer.d.ts +9 -0
  977. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/line-buffer.js +63 -0
  978. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/output-preview.d.ts +9 -0
  979. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/output-preview.js +70 -0
  980. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/snapshot.js +3 -1
  981. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/store.js +10 -3
  982. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/terminal-strings.d.ts +6 -0
  983. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/terminal-strings.js +108 -0
  984. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/terminal-width.d.ts +1 -0
  985. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/terminal-width.js +27 -2
  986. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/terminal.js +39 -12
  987. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/testing/pipeline-scenario.d.ts +1 -0
  988. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/testing/pipeline-scenario.js +128 -0
  989. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/dashboard/types.d.ts +47 -1
  990. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/escape-terminal-text.d.ts +1 -0
  991. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/escape-terminal-text.js +1 -0
  992. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/event-groups.d.ts +19 -0
  993. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/event-groups.js +49 -0
  994. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/actions.d.ts +8 -2
  995. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/actions.js +52 -4
  996. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/demo.js +3 -3
  997. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/detail-content.d.ts +6 -0
  998. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/detail-content.js +24 -0
  999. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/events.d.ts +12 -2
  1000. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/filter.js +48 -9
  1001. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/index.d.ts +2 -4
  1002. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/index.js +1 -2
  1003. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/jobs.d.ts +2 -1
  1004. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/jobs.js +29 -3
  1005. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/keymap.d.ts +13 -3
  1006. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/keymap.js +89 -348
  1007. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/layout.d.ts +2 -0
  1008. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/layout.js +22 -4
  1009. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/reducer.js +198 -45
  1010. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/detail.d.ts +2 -2
  1011. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/detail.js +37 -31
  1012. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/footer.d.ts +1 -1
  1013. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/footer.js +18 -3
  1014. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/header.d.ts +1 -1
  1015. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/header.js +6 -2
  1016. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/index.d.ts +1 -1
  1017. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/index.js +2 -1
  1018. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/list.d.ts +16 -2
  1019. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/list.js +49 -43
  1020. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/modal.d.ts +1 -1
  1021. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/modal.js +26 -13
  1022. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/pane.d.ts +6 -3
  1023. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/pane.js +10 -14
  1024. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +3 -4
  1025. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/runtime.js +141 -75
  1026. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.d.ts +23 -37
  1027. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.js +32 -83
  1028. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/state.d.ts +95 -8
  1029. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/state.js +77 -22
  1030. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/help-formatter.d.ts +2 -2
  1031. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/help-formatter.js +1 -1
  1032. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/index.d.ts +22 -9
  1033. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/index.js +15 -6
  1034. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/inline-notice.d.ts +14 -0
  1035. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/inline-notice.js +28 -0
  1036. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/metric.d.ts +8 -0
  1037. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/metric.js +21 -0
  1038. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/overlay-manager.d.ts +6 -0
  1039. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/overlay-manager.js +10 -0
  1040. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/primitives.d.ts +12 -0
  1041. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/primitives.js +7 -0
  1042. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/progress-group.d.ts +7 -0
  1043. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/progress-group.js +10 -0
  1044. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +9 -2
  1045. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/core.js +208 -31
  1046. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.js +3 -2
  1047. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/pagination.js +21 -27
  1048. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/password.js +11 -8
  1049. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/select.js +3 -2
  1050. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/interactive/text.js +12 -9
  1051. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/primitives/note.d.ts +1 -1
  1052. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/primitives/note.js +4 -4
  1053. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +2 -1
  1054. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/render-markdown-plaintext.d.ts +2 -0
  1055. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/render-markdown-plaintext.js +1 -0
  1056. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/render-performance.d.ts +33 -0
  1057. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/render-performance.js +71 -0
  1058. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/screen/ansi-text.d.ts +2 -0
  1059. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/screen/ansi-text.js +35 -0
  1060. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/screen/screen.d.ts +40 -0
  1061. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/screen/screen.js +122 -0
  1062. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/screen/style.d.ts +16 -0
  1063. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/screen/style.js +55 -0
  1064. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/task-tree.d.ts +22 -0
  1065. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/task-tree.js +79 -0
  1066. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal/driver.d.ts +34 -0
  1067. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal/driver.js +65 -0
  1068. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal/input.d.ts +25 -0
  1069. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal/input.js +197 -0
  1070. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal/output.d.ts +10 -0
  1071. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal/output.js +44 -0
  1072. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +2 -0
  1073. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/index.js +1 -0
  1074. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +2 -1
  1075. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.js +64 -13
  1076. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +2 -1
  1077. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/plaintext-renderer.d.ts +11 -0
  1078. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/terminal-markdown/plaintext-renderer.js +228 -0
  1079. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/viewport.d.ts +18 -0
  1080. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/viewport.js +56 -0
  1081. package/node_modules/toolcraft/node_modules/toolcraft-design/package.json +13 -9
  1082. package/node_modules/toolcraft/node_modules/toolcraft-schema/LICENSE +21 -0
  1083. package/node_modules/toolcraft/node_modules/toolcraft-schema/README.md +151 -0
  1084. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/clone-default.d.ts +1 -0
  1085. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/clone-default.js +26 -0
  1086. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/index.compile-check.d.ts +1 -0
  1087. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/index.compile-check.js +18 -0
  1088. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/index.d.ts +220 -0
  1089. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/index.js +354 -0
  1090. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/compiler.d.ts +12 -0
  1091. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/compiler.js +396 -0
  1092. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/evaluate.d.ts +3 -0
  1093. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/evaluate.js +445 -0
  1094. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/index.d.ts +5 -0
  1095. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/index.js +19 -0
  1096. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/normalize-nullability.d.ts +1 -0
  1097. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/normalize-nullability.js +69 -0
  1098. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/properties.d.ts +16 -0
  1099. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/properties.js +129 -0
  1100. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/types.d.ts +34 -0
  1101. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/types.js +1 -0
  1102. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/utils.d.ts +19 -0
  1103. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema/utils.js +174 -0
  1104. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema-document.d.ts +14 -0
  1105. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json-schema-document.js +17 -0
  1106. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json.compile-check.d.ts +1 -0
  1107. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json.compile-check.js +2 -0
  1108. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json.d.ts +23 -0
  1109. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/json.js +81 -0
  1110. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/native-json-schema.d.ts +13 -0
  1111. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/native-json-schema.js +12 -0
  1112. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/oneof.compile-check.d.ts +1 -0
  1113. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/oneof.compile-check.js +12 -0
  1114. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/oneof.d.ts +16 -0
  1115. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/oneof.js +19 -0
  1116. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/record.compile-check.d.ts +1 -0
  1117. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/record.compile-check.js +2 -0
  1118. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/record.d.ts +6 -0
  1119. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/record.js +7 -0
  1120. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/standard.compile-check.d.ts +1 -0
  1121. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/standard.compile-check.js +20 -0
  1122. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/standard.d.ts +92 -0
  1123. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/standard.js +38 -0
  1124. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/union.compile-check.d.ts +1 -0
  1125. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/union.compile-check.js +9 -0
  1126. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/union.d.ts +9 -0
  1127. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/union.js +46 -0
  1128. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/validate.d.ts +21 -0
  1129. package/node_modules/toolcraft/node_modules/toolcraft-schema/dist/validate.js +393 -0
  1130. package/node_modules/toolcraft/node_modules/toolcraft-schema/package.json +33 -0
  1131. package/node_modules/toolcraft/node_modules/xmlchars/LICENSE +18 -0
  1132. package/node_modules/toolcraft/node_modules/xmlchars/README.md +33 -0
  1133. package/node_modules/toolcraft/node_modules/xmlchars/package.json +51 -0
  1134. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.0/ed4.d.ts +31 -0
  1135. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.0/ed4.js +44 -0
  1136. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.0/ed4.js.map +1 -0
  1137. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.0/ed5.d.ts +51 -0
  1138. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.0/ed5.js +105 -0
  1139. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.0/ed5.js.map +1 -0
  1140. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.1/ed2.d.ts +73 -0
  1141. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.1/ed2.js +145 -0
  1142. package/node_modules/toolcraft/node_modules/xmlchars/xml/1.1/ed2.js.map +1 -0
  1143. package/node_modules/toolcraft/node_modules/xmlchars/xmlchars.d.ts +170 -0
  1144. package/node_modules/toolcraft/node_modules/xmlchars/xmlchars.js +191 -0
  1145. package/node_modules/toolcraft/node_modules/xmlchars/xmlchars.js.map +1 -0
  1146. package/node_modules/toolcraft/node_modules/xmlchars/xmlns/1.0/ed3.d.ts +28 -0
  1147. package/node_modules/toolcraft/node_modules/xmlchars/xmlns/1.0/ed3.js +65 -0
  1148. package/node_modules/toolcraft/node_modules/xmlchars/xmlns/1.0/ed3.js.map +1 -0
  1149. package/node_modules/toolcraft/node_modules/yaml/LICENSE +13 -0
  1150. package/node_modules/toolcraft/node_modules/yaml/README.md +172 -0
  1151. package/node_modules/toolcraft/node_modules/yaml/bin.mjs +11 -0
  1152. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  1153. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  1154. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  1155. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  1156. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  1157. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  1158. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  1159. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  1160. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  1161. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  1162. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +225 -0
  1163. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  1164. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  1165. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  1166. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  1167. package/node_modules/toolcraft/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  1168. package/node_modules/toolcraft/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  1169. package/node_modules/toolcraft/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  1170. package/node_modules/toolcraft/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  1171. package/node_modules/toolcraft/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  1172. package/node_modules/toolcraft/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  1173. package/node_modules/toolcraft/node_modules/yaml/browser/dist/errors.js +57 -0
  1174. package/node_modules/toolcraft/node_modules/yaml/browser/dist/index.js +17 -0
  1175. package/node_modules/toolcraft/node_modules/yaml/browser/dist/log.js +11 -0
  1176. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/Alias.js +116 -0
  1177. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  1178. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  1179. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  1180. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  1181. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  1182. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  1183. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  1184. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  1185. package/node_modules/toolcraft/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  1186. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  1187. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  1188. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  1189. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  1190. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  1191. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  1192. package/node_modules/toolcraft/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  1193. package/node_modules/toolcraft/node_modules/yaml/browser/dist/public-api.js +102 -0
  1194. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  1195. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  1196. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  1197. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  1198. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  1199. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  1200. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  1201. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  1202. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  1203. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  1204. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  1205. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  1206. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  1207. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  1208. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  1209. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  1210. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  1211. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  1212. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  1213. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  1214. package/node_modules/toolcraft/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  1215. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  1216. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  1217. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  1218. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  1219. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  1220. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  1221. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  1222. package/node_modules/toolcraft/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  1223. package/node_modules/toolcraft/node_modules/yaml/browser/dist/util.js +11 -0
  1224. package/node_modules/toolcraft/node_modules/yaml/browser/dist/visit.js +233 -0
  1225. package/node_modules/toolcraft/node_modules/yaml/browser/index.js +5 -0
  1226. package/node_modules/toolcraft/node_modules/yaml/browser/package.json +3 -0
  1227. package/node_modules/toolcraft/node_modules/yaml/dist/cli.d.ts +8 -0
  1228. package/node_modules/toolcraft/node_modules/yaml/dist/cli.mjs +201 -0
  1229. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  1230. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  1231. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  1232. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  1233. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  1234. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-node.js +112 -0
  1235. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  1236. package/node_modules/toolcraft/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  1237. package/node_modules/toolcraft/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  1238. package/node_modules/toolcraft/node_modules/yaml/dist/compose/composer.js +224 -0
  1239. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  1240. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  1241. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  1242. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  1243. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  1244. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  1245. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  1246. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  1247. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  1248. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  1249. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  1250. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
  1251. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  1252. package/node_modules/toolcraft/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  1253. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  1254. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  1255. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  1256. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  1257. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  1258. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  1259. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  1260. package/node_modules/toolcraft/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  1261. package/node_modules/toolcraft/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  1262. package/node_modules/toolcraft/node_modules/yaml/dist/doc/Document.js +337 -0
  1263. package/node_modules/toolcraft/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  1264. package/node_modules/toolcraft/node_modules/yaml/dist/doc/anchors.js +76 -0
  1265. package/node_modules/toolcraft/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  1266. package/node_modules/toolcraft/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  1267. package/node_modules/toolcraft/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  1268. package/node_modules/toolcraft/node_modules/yaml/dist/doc/createNode.js +90 -0
  1269. package/node_modules/toolcraft/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  1270. package/node_modules/toolcraft/node_modules/yaml/dist/doc/directives.js +178 -0
  1271. package/node_modules/toolcraft/node_modules/yaml/dist/errors.d.ts +21 -0
  1272. package/node_modules/toolcraft/node_modules/yaml/dist/errors.js +62 -0
  1273. package/node_modules/toolcraft/node_modules/yaml/dist/index.d.ts +25 -0
  1274. package/node_modules/toolcraft/node_modules/yaml/dist/index.js +50 -0
  1275. package/node_modules/toolcraft/node_modules/yaml/dist/log.d.ts +3 -0
  1276. package/node_modules/toolcraft/node_modules/yaml/dist/log.js +19 -0
  1277. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  1278. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Alias.js +118 -0
  1279. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  1280. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Collection.js +151 -0
  1281. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  1282. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Node.js +40 -0
  1283. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  1284. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Pair.js +39 -0
  1285. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  1286. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  1287. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  1288. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  1289. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  1290. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  1291. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  1292. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  1293. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  1294. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/identity.js +53 -0
  1295. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  1296. package/node_modules/toolcraft/node_modules/yaml/dist/nodes/toJS.js +39 -0
  1297. package/node_modules/toolcraft/node_modules/yaml/dist/options.d.ts +350 -0
  1298. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  1299. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  1300. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  1301. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  1302. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  1303. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  1304. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  1305. package/node_modules/toolcraft/node_modules/yaml/dist/parse/cst.js +112 -0
  1306. package/node_modules/toolcraft/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  1307. package/node_modules/toolcraft/node_modules/yaml/dist/parse/lexer.js +723 -0
  1308. package/node_modules/toolcraft/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  1309. package/node_modules/toolcraft/node_modules/yaml/dist/parse/line-counter.js +41 -0
  1310. package/node_modules/toolcraft/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  1311. package/node_modules/toolcraft/node_modules/yaml/dist/parse/parser.js +980 -0
  1312. package/node_modules/toolcraft/node_modules/yaml/dist/public-api.d.ts +44 -0
  1313. package/node_modules/toolcraft/node_modules/yaml/dist/public-api.js +107 -0
  1314. package/node_modules/toolcraft/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  1315. package/node_modules/toolcraft/node_modules/yaml/dist/schema/Schema.js +39 -0
  1316. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  1317. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/map.js +19 -0
  1318. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  1319. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/null.js +17 -0
  1320. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  1321. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/seq.js +19 -0
  1322. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  1323. package/node_modules/toolcraft/node_modules/yaml/dist/schema/common/string.js +16 -0
  1324. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  1325. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/bool.js +21 -0
  1326. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  1327. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/float.js +47 -0
  1328. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  1329. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/int.js +42 -0
  1330. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  1331. package/node_modules/toolcraft/node_modules/yaml/dist/schema/core/schema.js +25 -0
  1332. package/node_modules/toolcraft/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  1333. package/node_modules/toolcraft/node_modules/yaml/dist/schema/json/schema.js +64 -0
  1334. package/node_modules/toolcraft/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  1335. package/node_modules/toolcraft/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  1336. package/node_modules/toolcraft/node_modules/yaml/dist/schema/tags.js +99 -0
  1337. package/node_modules/toolcraft/node_modules/yaml/dist/schema/types.d.ts +92 -0
  1338. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  1339. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  1340. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  1341. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  1342. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  1343. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  1344. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  1345. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  1346. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  1347. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  1348. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  1349. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  1350. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  1351. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  1352. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  1353. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  1354. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  1355. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  1356. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  1357. package/node_modules/toolcraft/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  1358. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  1359. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  1360. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  1361. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringify.js +132 -0
  1362. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  1363. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  1364. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  1365. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  1366. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  1367. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  1368. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  1369. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  1370. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  1371. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  1372. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  1373. package/node_modules/toolcraft/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  1374. package/node_modules/toolcraft/node_modules/yaml/dist/test-events.d.ts +4 -0
  1375. package/node_modules/toolcraft/node_modules/yaml/dist/test-events.js +134 -0
  1376. package/node_modules/toolcraft/node_modules/yaml/dist/util.d.ts +16 -0
  1377. package/node_modules/toolcraft/node_modules/yaml/dist/util.js +28 -0
  1378. package/node_modules/toolcraft/node_modules/yaml/dist/visit.d.ts +102 -0
  1379. package/node_modules/toolcraft/node_modules/yaml/dist/visit.js +236 -0
  1380. package/node_modules/toolcraft/node_modules/yaml/package.json +97 -0
  1381. package/node_modules/toolcraft/node_modules/yaml/util.js +2 -0
  1382. package/node_modules/toolcraft/package.json +121 -12
  1383. package/package.json +2 -2
  1384. package/src/adapters/root.ts +30 -18
  1385. package/src/cli.ts +6 -1
  1386. package/src/executable.ts +3 -1
  1387. package/src/mcp.ts +1 -1
  1388. package/node_modules/toolcraft/dist/design/run-two-pane-explorer.d.ts +0 -2
  1389. package/node_modules/toolcraft/dist/design/run-two-pane-explorer.js +0 -1
  1390. package/node_modules/toolcraft/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +0 -16
  1391. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/schema/store.schema.json +0 -32
  1392. package/node_modules/toolcraft/node_modules/@poe-code/task-list/dist/schema/task.schema.json +0 -33
  1393. package/node_modules/toolcraft/node_modules/mcp-oauth/README.md +0 -31
  1394. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +0 -14
  1395. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +0 -627
  1396. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +0 -20
  1397. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/client/loopback-authorization.js +0 -207
  1398. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/client/pkce.js +0 -7
  1399. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/client/types.d.ts +0 -113
  1400. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/index.d.ts +0 -10
  1401. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/index.js +0 -7
  1402. package/node_modules/toolcraft/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +0 -304
  1403. package/node_modules/toolcraft/node_modules/tiny-mcp-client/.turbo/turbo-build.log +0 -7
  1404. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/internal.d.ts +0 -556
  1405. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/internal.js +0 -2688
  1406. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.js +0 -37
  1407. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.js +0 -50
  1408. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.js +0 -50
  1409. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.js +0 -51
  1410. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.js +0 -99
  1411. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.js +0 -56
  1412. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.js +0 -145
  1413. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +0 -24
  1414. package/node_modules/toolcraft/node_modules/tiny-mcp-client/dist/oauth-discovery.js +0 -382
  1415. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/http-oauth.integration.test.ts +0 -808
  1416. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/http-oauth.test.ts +0 -922
  1417. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/index.ts +0 -94
  1418. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/internal.ts +0 -3904
  1419. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/jsonrpc-types.compile-check.ts +0 -66
  1420. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-client-http-transport.integration.test.ts +0 -222
  1421. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-client-sdk.test.ts +0 -1326
  1422. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-client-tiny-stdio-test-server-tools.test.ts +0 -143
  1423. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-lifecycle-types.compile-check.ts +0 -65
  1424. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-prompt-types.compile-check.ts +0 -66
  1425. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-resource-types.compile-check.ts +0 -70
  1426. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-tool-types.compile-check.ts +0 -127
  1427. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-transport-types.compile-check.ts +0 -75
  1428. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mcp-utility-types.compile-check.ts +0 -181
  1429. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/mock-servers.test.ts +0 -980
  1430. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/oauth-discovery.ts +0 -578
  1431. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/package-runtime.test.ts +0 -25
  1432. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/transports.test.ts +0 -9018
  1433. package/node_modules/toolcraft/node_modules/tiny-mcp-client/src/utilities.test.ts +0 -372
  1434. package/node_modules/toolcraft/node_modules/tiny-mcp-client/tsconfig.json +0 -11
  1435. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/two-pane.d.ts +0 -102
  1436. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/explorer/two-pane.js +0 -510
  1437. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/run-two-pane-explorer.d.ts +0 -2
  1438. package/node_modules/toolcraft/node_modules/toolcraft-design/dist/run-two-pane-explorer.js +0 -1
  1439. /package/node_modules/toolcraft/{node_modules/mcp-oauth/dist/client/types.js → dist/http-hosted-oauth.compile-check.d.ts} +0 -0
  1440. /package/node_modules/toolcraft/{node_modules/mcp-oauth/dist/types.compile-check.d.ts → dist/http.compile-check.d.ts} +0 -0
  1441. /package/node_modules/toolcraft/{node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.d.ts → dist/human-in-loop/runtime-options.js} +0 -0
  1442. /package/node_modules/toolcraft/{node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.d.ts → dist/node-require-shim.d.ts} +0 -0
  1443. /package/node_modules/toolcraft/{node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.d.ts → dist/safe-bash-capabilities.compile-check.d.ts} +0 -0
  1444. /package/node_modules/toolcraft/{node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.d.ts → dist/safe-bash.compile-check.d.ts} +0 -0
  1445. /package/node_modules/toolcraft/{node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.d.ts → dist/schema-standard.compile-check.d.ts} +0 -0
  1446. /package/node_modules/toolcraft/node_modules/{tiny-mcp-client/dist/mcp-transport-types.compile-check.d.ts → @noble/hashes/index.d.ts} +0 -0
  1447. /package/node_modules/toolcraft/node_modules/{tiny-mcp-client/dist/mcp-utility-types.compile-check.d.ts → @poe-code/safe-fs/dist/bridge/types.js} +0 -0
  1448. /package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/authorization-state.d.ts +0 -0
  1449. /package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/default-oauth-client-provider.d.ts +0 -0
  1450. /package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/client/pkce.d.ts +0 -0
  1451. /package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/resource-indicator.d.ts +0 -0
  1452. /package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/resource-indicator.js +0 -0
  1453. /package/node_modules/toolcraft/node_modules/{mcp-oauth → tiny-http-mcp-server/node_modules/mcp-oauth}/dist/types.compile-check.js +0 -0
@@ -0,0 +1,3862 @@
1
+ import { FsError } from "../../contracts/errors.js";
2
+ import { normalizePath, validatePath, pathByteLength } from "../../contracts/virtual-path.js";
3
+ import { assertCallbackAuthorityAllowed, compareEntries, registerEntryAuthority } from "../mount/comparison.js";
4
+ import { getOwnedS3Entry } from "../s3/registry.js";
5
+ import { getOwnedWebDavEntry } from "../webdav/resource-id.js";
6
+ import { admitDirectoryEntries, directoryEntryLimit } from "../directory-admission.js";
7
+ import { openFileDescriptor } from "../descriptor.js";
8
+ import { directoryAncestryPaths, runStagingGuard, snapshotDirectoryAncestry, snapshotStagingResolution } from "../staging-ancestry.js";
9
+ import { compareIdentity } from "../mount/identity.js";
10
+ import { createStagingCleanup, snapshotStagingCreation } from "../staging-cleanup.js";
11
+ import { resolveMissingTarget } from "./missing-target.js";
12
+ import { registerLazyMemoryAtomicView } from "./atomic-view.js";
13
+ import { snapshotConditionalChmod } from "../conditional-chmod.js";
14
+ import { MemoryAllocation, MemoryLedger } from "./ledger.js";
15
+ import { normalizeMemoryFileSystemLimits } from "./limits.js";
16
+ export { defaultMemoryFileSystemLimits } from "./limits.js";
17
+ class MemoryFileNode {
18
+ constructor(mode, ino, now, byteLength, allocation, view, sourceRef) {
19
+ this.revision = 0;
20
+ this.mode = mode;
21
+ this.ino = ino;
22
+ this.nlink = 1;
23
+ this.atimeMs = now;
24
+ this.mtimeMs = now;
25
+ this.ctimeMs = now;
26
+ this.birthtimeMs = now;
27
+ this.references = 0;
28
+ this.byteLength = byteLength;
29
+ this.allocation = allocation;
30
+ this.view = view;
31
+ this.sourceRef = sourceRef;
32
+ }
33
+ get data() {
34
+ return this.view ??= (this.byteLength === this.allocation.data.byteLength ? this.allocation.data : this.allocation.data.subarray(0, this.byteLength));
35
+ }
36
+ set data(value) {
37
+ this.view = value;
38
+ this.byteLength = value.byteLength;
39
+ }
40
+ }
41
+ Object.assign(MemoryFileNode.prototype, {
42
+ type: "file",
43
+ revision: 0,
44
+ nlink: 1,
45
+ references: 0,
46
+ sourceRef: undefined,
47
+ });
48
+ const EMPTY_ALLOC_BYTES = new Uint8Array(0);
49
+ const DUMMY_POOL_LEDGER = new MemoryLedger(normalizeMemoryFileSystemLimits({}));
50
+ const DUMMY_POOL_ALLOCATION = new MemoryAllocation(EMPTY_ALLOC_BYTES, DUMMY_POOL_LEDGER);
51
+ const DUMMY_POOL_FILE_NODE = new MemoryFileNode(0, 0, null, 0, DUMMY_POOL_ALLOCATION, DUMMY_POOL_ALLOCATION.data);
52
+ DUMMY_POOL_FILE_NODE.atimeMs = DUMMY_POOL_FILE_NODE.mtimeMs = DUMMY_POOL_FILE_NODE.ctimeMs = DUMMY_POOL_FILE_NODE.birthtimeMs = 1700000000000;
53
+ const EMPTY_DIR_TABLE = new Int16Array(0);
54
+ const EMPTY_DIR_KEYS = [];
55
+ const EMPTY_DIR_VALS = [];
56
+ class FastDirectoryEntriesMap {
57
+ // Keep speculative slots local so a failed write cannot pin a tenant globally.
58
+ _missKey = "";
59
+ _missSlot = -1;
60
+ _table = EMPTY_DIR_TABLE;
61
+ _mask = 0;
62
+ _keys = EMPTY_DIR_KEYS;
63
+ _vals = EMPTY_DIR_VALS;
64
+ _next = 0;
65
+ size = 0;
66
+ [Symbol.toStringTag] = "Map";
67
+ _hash(k) {
68
+ let h = 5381;
69
+ for (let i = 0; i < k.length; i++) {
70
+ h = (((h & 0x1fffff) * 33) ^ k.charCodeAt(i)) & 0x3fffffff;
71
+ }
72
+ return h & this._mask;
73
+ }
74
+ get(k) {
75
+ if (this.size === 0)
76
+ return undefined;
77
+ let slot = this._hash(k);
78
+ const mask = this._mask;
79
+ const table = this._table;
80
+ const keys = this._keys;
81
+ while (true) {
82
+ const idx = table[slot];
83
+ if (idx === -1)
84
+ return undefined;
85
+ if (idx >= 0 && keys[idx] === k)
86
+ return this._vals[idx];
87
+ slot = (slot + 1) & mask;
88
+ }
89
+ }
90
+ getForWrite(k) {
91
+ return this.getForWriteWithHash(k, this._hash(k));
92
+ }
93
+ getForWriteWithHash(k, h) {
94
+ let slot = h & this._mask;
95
+ if (this.size === 0) {
96
+ if (this._keys.length === 0) {
97
+ this._missKey = "";
98
+ this._missSlot = -1;
99
+ return undefined;
100
+ }
101
+ this._missKey = k;
102
+ this._missSlot = slot;
103
+ return undefined;
104
+ }
105
+ const mask = this._mask;
106
+ const table = this._table;
107
+ const keys = this._keys;
108
+ let firstDeleted = -1;
109
+ while (true) {
110
+ const idx = table[slot];
111
+ if (idx === -1) {
112
+ this._missKey = k;
113
+ this._missSlot = firstDeleted !== -1 ? firstDeleted : slot;
114
+ return undefined;
115
+ }
116
+ if (idx === -2) {
117
+ if (firstDeleted === -1)
118
+ firstDeleted = slot;
119
+ }
120
+ else if (keys[idx] === k) {
121
+ return this._vals[idx];
122
+ }
123
+ slot = (slot + 1) & mask;
124
+ }
125
+ }
126
+ getSubstr(s, start, end) {
127
+ if (this.size === 0)
128
+ return undefined;
129
+ const len = end - start;
130
+ let h = 5381;
131
+ for (let i = start; i < end; i++) {
132
+ h = (((h & 0x1fffff) * 33) ^ s.charCodeAt(i)) & 0x3fffffff;
133
+ }
134
+ let slot = h & this._mask;
135
+ const mask = this._mask;
136
+ const table = this._table;
137
+ const keys = this._keys;
138
+ while (true) {
139
+ const idx = table[slot];
140
+ if (idx === -1)
141
+ return undefined;
142
+ if (idx >= 0) {
143
+ const k = keys[idx];
144
+ if (k.length === len) {
145
+ let match = true;
146
+ for (let i = 0; i < len; i++) {
147
+ if (k.charCodeAt(i) !== s.charCodeAt(start + i)) {
148
+ match = false;
149
+ break;
150
+ }
151
+ }
152
+ if (match)
153
+ return this._vals[idx];
154
+ }
155
+ }
156
+ slot = (slot + 1) & mask;
157
+ }
158
+ }
159
+ has(k) {
160
+ return this.get(k) !== undefined;
161
+ }
162
+ _rebuild(newCap) {
163
+ this._missKey = "";
164
+ this._missSlot = -1;
165
+ const newTableLen = newCap * 2;
166
+ const newMask = newTableLen - 1;
167
+ const newTable = newCap <= 16384 ? new Int16Array(newTableLen).fill(-1) : new Int32Array(newTableLen).fill(-1);
168
+ const oldKeys = this._keys;
169
+ const oldVals = this._vals;
170
+ const oldNext = this._next;
171
+ const newKeys = newCap === oldKeys.length ? oldKeys : new Array(newCap).fill("");
172
+ const newVals = newCap === oldVals.length ? oldVals : new Array(newCap).fill(DUMMY_POOL_FILE_NODE);
173
+ let writeIdx = 0;
174
+ for (let i = 0; i < oldNext; i++) {
175
+ const v = oldVals[i];
176
+ if (v === DUMMY_POOL_FILE_NODE)
177
+ continue;
178
+ const k = oldKeys[i];
179
+ newKeys[writeIdx] = k;
180
+ newVals[writeIdx] = v;
181
+ let h = 5381;
182
+ for (let c = 0; c < k.length; c++) {
183
+ h = (((h & 0x1fffff) * 33) ^ k.charCodeAt(c)) & 0x3fffffff;
184
+ }
185
+ let slot = h & newMask;
186
+ while (newTable[slot] !== -1) {
187
+ slot = (slot + 1) & newMask;
188
+ }
189
+ newTable[slot] = writeIdx++;
190
+ }
191
+ if (newKeys === oldKeys) {
192
+ for (let i = writeIdx; i < oldNext; i++) {
193
+ newKeys[i] = "";
194
+ newVals[i] = DUMMY_POOL_FILE_NODE;
195
+ }
196
+ }
197
+ this._table = newTable;
198
+ this._mask = newMask;
199
+ this._keys = newKeys;
200
+ this._vals = newVals;
201
+ this._next = writeIdx;
202
+ }
203
+ set(k, v) {
204
+ const missSlot = k === this._missKey ? this._missSlot : -1;
205
+ this._missKey = "";
206
+ this._missSlot = -1;
207
+ if (missSlot >= 0 && (this._table[missSlot] === -1 || this._table[missSlot] === -2) && this._next < this._keys.length) {
208
+ const entryIdx = this._next++;
209
+ this._table[missSlot] = entryIdx;
210
+ this._keys[entryIdx] = k;
211
+ this._vals[entryIdx] = v;
212
+ this.size++;
213
+ return this;
214
+ }
215
+ if (this._next >= this._keys.length) {
216
+ this._rebuild(this._keys.length === 0 ? 8 : (this.size * 2 <= this._keys.length ? this._keys.length : this._keys.length * 2));
217
+ }
218
+ let slot = this._hash(k);
219
+ const mask = this._mask;
220
+ const table = this._table;
221
+ const keys = this._keys;
222
+ let firstDeleted = -1;
223
+ while (true) {
224
+ const idx = table[slot];
225
+ if (idx === -1) {
226
+ const targetSlot = firstDeleted !== -1 ? firstDeleted : slot;
227
+ const entryIdx = this._next++;
228
+ table[targetSlot] = entryIdx;
229
+ keys[entryIdx] = k;
230
+ this._vals[entryIdx] = v;
231
+ this.size++;
232
+ return this;
233
+ }
234
+ if (idx === -2) {
235
+ if (firstDeleted === -1)
236
+ firstDeleted = slot;
237
+ }
238
+ else if (keys[idx] === k) {
239
+ this._vals[idx] = v;
240
+ return this;
241
+ }
242
+ slot = (slot + 1) & mask;
243
+ }
244
+ }
245
+ delete(k) {
246
+ this._missKey = "";
247
+ this._missSlot = -1;
248
+ if (this.size === 0)
249
+ return false;
250
+ let slot = this._hash(k);
251
+ const mask = this._mask;
252
+ const table = this._table;
253
+ const keys = this._keys;
254
+ while (true) {
255
+ const idx = table[slot];
256
+ if (idx === -1)
257
+ return false;
258
+ if (idx >= 0 && keys[idx] === k) {
259
+ if (this.size === 1) {
260
+ this.clear();
261
+ return true;
262
+ }
263
+ table[slot] = -2;
264
+ keys[idx] = "";
265
+ this._vals[idx] = DUMMY_POOL_FILE_NODE;
266
+ // Keep deleted indices until compaction: reusing the tail would let
267
+ // tombstones fill the table without reaching set()'s rebuild threshold.
268
+ this.size--;
269
+ return true;
270
+ }
271
+ slot = (slot + 1) & mask;
272
+ }
273
+ }
274
+ clear() {
275
+ this._missKey = "";
276
+ this._missSlot = -1;
277
+ if (this._next > 0) {
278
+ this._table.fill(-1);
279
+ for (let i = 0; i < this._next; i++) {
280
+ this._keys[i] = "";
281
+ this._vals[i] = DUMMY_POOL_FILE_NODE;
282
+ }
283
+ this._next = 0;
284
+ this.size = 0;
285
+ }
286
+ }
287
+ forEach(callbackfn, thisArg) {
288
+ const next = this._next;
289
+ const keys = this._keys;
290
+ const vals = this._vals;
291
+ for (let i = 0; i < next; i++) {
292
+ const v = vals[i];
293
+ if (v !== DUMMY_POOL_FILE_NODE) {
294
+ if (thisArg !== undefined)
295
+ callbackfn.call(thisArg, v, keys[i], this);
296
+ else
297
+ callbackfn(v, keys[i], this);
298
+ }
299
+ }
300
+ }
301
+ *keys() {
302
+ for (let i = 0; i < this._next; i++) {
303
+ if (this._vals[i] !== DUMMY_POOL_FILE_NODE)
304
+ yield this._keys[i];
305
+ }
306
+ }
307
+ *values() {
308
+ for (let i = 0; i < this._next; i++) {
309
+ const v = this._vals[i];
310
+ if (v !== DUMMY_POOL_FILE_NODE)
311
+ yield v;
312
+ }
313
+ }
314
+ *entries() {
315
+ for (let i = 0; i < this._next; i++) {
316
+ const v = this._vals[i];
317
+ if (v !== DUMMY_POOL_FILE_NODE)
318
+ yield [this._keys[i], v];
319
+ }
320
+ }
321
+ [Symbol.iterator]() {
322
+ return this.entries();
323
+ }
324
+ }
325
+ const SHARED_POOL_CAPACITY = 256;
326
+ const SHARED_DIR_POOL_CAPACITY = 64;
327
+ const sharedFileNodePool = new Array(SHARED_POOL_CAPACITY).fill(DUMMY_POOL_FILE_NODE);
328
+ let sharedFileNodePoolLen = 0;
329
+ const sharedDirectoryNodePool = new Array(SHARED_DIR_POOL_CAPACITY);
330
+ let sharedDirectoryNodePoolLen = 0;
331
+ const sharedRemovedScratch = new Array(SHARED_POOL_CAPACITY).fill(DUMMY_POOL_FILE_NODE);
332
+ let sharedRemovedLen = 0;
333
+ let sharedRemovedKeyChars = 0;
334
+ let sharedRemovedKeyEntries = 0;
335
+ function collectRemovedChild(child, name) {
336
+ if (sharedRemovedLen < sharedRemovedScratch.length) {
337
+ sharedRemovedScratch[sharedRemovedLen++] = child;
338
+ }
339
+ else {
340
+ sharedRemovedScratch.push(child);
341
+ sharedRemovedLen++;
342
+ }
343
+ sharedRemovedKeyChars += name.length;
344
+ sharedRemovedKeyEntries++;
345
+ }
346
+ function replenishSharedMemoryPools() {
347
+ while (sharedFileNodePoolLen < 112) {
348
+ sharedFileNodePool[sharedFileNodePoolLen++] = new MemoryFileNode(0, 0, 0, 0, DUMMY_POOL_ALLOCATION, undefined);
349
+ }
350
+ while (sharedDirectoryNodePoolLen < 16) {
351
+ sharedDirectoryNodePool[sharedDirectoryNodePoolLen++] = new MemoryDirectoryNode(0, 0, 0);
352
+ }
353
+ }
354
+ class MemoryDirectoryNode {
355
+ constructor(mode, ino, now) {
356
+ this.revision = 0;
357
+ this.mode = mode;
358
+ this.ino = ino;
359
+ this.nlink = 1;
360
+ this.references = 0;
361
+ this.atimeMs = now;
362
+ this.mtimeMs = now;
363
+ this.ctimeMs = now;
364
+ this.birthtimeMs = now;
365
+ this.entries = new FastDirectoryEntriesMap();
366
+ this.cachedNlink = 2;
367
+ this.cachedNlinkRev = 0;
368
+ }
369
+ }
370
+ Object.assign(MemoryDirectoryNode.prototype, {
371
+ type: "directory",
372
+ revision: 0,
373
+ nlink: 1,
374
+ references: 0,
375
+ cachedNlink: 2,
376
+ cachedNlinkRev: 0,
377
+ });
378
+ const DUMMY_POOL_DIR_NODE = new MemoryDirectoryNode(0, 0, null);
379
+ DUMMY_POOL_DIR_NODE.atimeMs = DUMMY_POOL_DIR_NODE.mtimeMs = DUMMY_POOL_DIR_NODE.ctimeMs = DUMMY_POOL_DIR_NODE.birthtimeMs = 1700000000000;
380
+ class MemoryCache {
381
+ files = [];
382
+ directories = [];
383
+ removedScratch = [];
384
+ lastFastDirPrefix = "";
385
+ lastFastDirNode = undefined;
386
+ lastFastFilePath = "";
387
+ lastFastFileName = "";
388
+ lastFastFileNode = undefined;
389
+ clearWrites() {
390
+ this.lastFastDirPrefix = "";
391
+ this.lastFastDirNode = undefined;
392
+ this.lastFastFilePath = "";
393
+ this.lastFastFileName = "";
394
+ this.lastFastFileNode = undefined;
395
+ }
396
+ }
397
+ const typeModes = { file: 0o100000, directory: 0o040000, symlink: 0o120000 };
398
+ const emptyResolveOptions = Object.freeze({});
399
+ const noFollowResolveOptions = Object.freeze({ followFinal: false });
400
+ const sharedAllowMissingNoFollowOptions = Object.freeze({ allowMissing: true, followFinal: false });
401
+ const sharedFastLocation = { node: undefined, parent: DUMMY_POOL_DIR_NODE, name: "", path: "" };
402
+ const resolvedVoid = Promise.resolve();
403
+ const preferredIoBlockSize = 64 * 1024;
404
+ const ext4HtreeEof64 = (1n << 63n) - 1n;
405
+ const extractionStreamGuard = Symbol("extractionStreamGuard");
406
+ const ownedStats = new WeakMap();
407
+ const ownedStores = new WeakMap();
408
+ const receiverCapabilities = new WeakMap();
409
+ // Ensure V8 uses Tagged representation for timestamp fields so all 4 fields share one HeapNumber pointer.
410
+ {
411
+ const dummyAlloc = new MemoryAllocation(new Uint8Array(0), new MemoryLedger(normalizeMemoryFileSystemLimits({})));
412
+ const dummyFile = new MemoryFileNode(0, 0, null, 0, dummyAlloc, dummyAlloc.data);
413
+ dummyFile.atimeMs = dummyFile.mtimeMs = dummyFile.ctimeMs = dummyFile.birthtimeMs = 1700000000000;
414
+ const dummyDir = new MemoryDirectoryNode(0, 0, null);
415
+ dummyDir.atimeMs = dummyDir.mtimeMs = dummyDir.ctimeMs = dummyDir.birthtimeMs = 1700000000000;
416
+ }
417
+ // Forwarded receivers share the ledger, so mutations invalidate the owner's cache.
418
+ const memoryCaches = new WeakMap();
419
+ const registeredAuthorities = new WeakSet();
420
+ const compareOwnedMemory = async (own, peer, options) => {
421
+ options.signal?.throwIfAborted();
422
+ let explicit = false;
423
+ let answer = "unknown";
424
+ const visited = new Set();
425
+ for (const [left, right] of [[own, peer], [peer, own]]) {
426
+ if (!registeredAuthorities.has(left.filesystem) || visited.has(left.filesystem))
427
+ continue;
428
+ visited.add(left.filesystem);
429
+ const comparison = left.filesystem.compareEntry;
430
+ if (comparison === memoryImplementation.compareEntry?.value)
431
+ continue;
432
+ explicit = true;
433
+ if (!comparison)
434
+ continue;
435
+ options.signal?.throwIfAborted();
436
+ assertCallbackAuthorityAllowed();
437
+ const result = await comparison.call(left.filesystem, left.path, right.filesystem, right.path, options);
438
+ options.signal?.throwIfAborted();
439
+ if (result !== "same" && result !== "distinct" && result !== "unknown") {
440
+ throw new FsError("EIO", { path: own.path, dest: peer.path, message: "invalid explicit Memory comparison" });
441
+ }
442
+ if (result === "unknown")
443
+ continue;
444
+ if (answer !== "unknown" && answer !== result) {
445
+ throw new FsError("EIO", { path: own.path, dest: peer.path, message: "conflicting explicit Memory comparisons" });
446
+ }
447
+ answer = result;
448
+ }
449
+ if (explicit)
450
+ return answer;
451
+ const owner = ownedStores.get(own.filesystem);
452
+ const observation = ownedStats.get(own.stat);
453
+ if (!owner?.intact() || observation?.filesystem !== own.filesystem || observation.path !== own.path
454
+ || observation.root !== owner.root)
455
+ return "unknown";
456
+ const qualified = getOwnedS3Entry(peer) ?? getOwnedWebDavEntry(peer);
457
+ options.signal?.throwIfAborted();
458
+ return qualified ? "distinct" : "unknown";
459
+ };
460
+ const activeConditionalMutations = new Map();
461
+ export async function bindConditionalMutation(identityScope, binding, action) {
462
+ if (identityScope === undefined || identityScope === null)
463
+ return action();
464
+ activeConditionalMutations.set(identityScope, binding);
465
+ try {
466
+ return await action();
467
+ }
468
+ finally {
469
+ if (activeConditionalMutations.get(identityScope) === binding) {
470
+ activeConditionalMutations.delete(identityScope);
471
+ }
472
+ }
473
+ }
474
+ const STREAM_DONE_RESULT = Object.freeze({ done: true, value: undefined });
475
+ const STREAM_RESOLVED_DONE = Promise.resolve(STREAM_DONE_RESULT);
476
+ class MemoryReadStream {
477
+ constructor(fs, path, options) {
478
+ this.fs = fs;
479
+ this.path = path;
480
+ this.options = options;
481
+ this.abortSignal = options.signal;
482
+ this.initialized = false;
483
+ this.finished = false;
484
+ this.offset = 0;
485
+ this.end = 0;
486
+ this.chunkSize = preferredIoBlockSize;
487
+ this.node = undefined;
488
+ this.allocation = undefined;
489
+ this.data = undefined;
490
+ }
491
+ [Symbol.asyncIterator]() {
492
+ if (this.initialized || this.finished) {
493
+ return new MemoryReadStream(this.fs, this.path, this.options);
494
+ }
495
+ return this;
496
+ }
497
+ _release() {
498
+ if (this.finished)
499
+ return;
500
+ this.finished = true;
501
+ if (this.allocation) {
502
+ this.allocation.release();
503
+ this.allocation = undefined;
504
+ }
505
+ if (this.node) {
506
+ const releasedNode = this.node;
507
+ this.node = undefined;
508
+ this.fs.releaseReference(releasedNode, this.path);
509
+ }
510
+ this.data = undefined;
511
+ }
512
+ tryNextSync() {
513
+ if (this.finished)
514
+ return STREAM_DONE_RESULT;
515
+ try {
516
+ const options = this.options;
517
+ options.signal?.throwIfAborted();
518
+ if (!this.initialized) {
519
+ this.initialized = true;
520
+ const fs = this.fs;
521
+ const path = this.path;
522
+ const start = options.start ?? 0;
523
+ const chunkSize = options.chunkSize ?? preferredIoBlockSize;
524
+ this.chunkSize = chunkSize;
525
+ fs.integer(start, "readStream", path);
526
+ fs.integer(chunkSize, "readStream", path);
527
+ if (chunkSize === 0)
528
+ fs.fail("EINVAL", "readStream", path);
529
+ if (options.endExclusive !== undefined) {
530
+ fs.integer(options.endExclusive, "readStream", path);
531
+ if (options.endExclusive < start)
532
+ fs.fail("EINVAL", "readStream", path);
533
+ }
534
+ const target = fs.file(path, "readStream");
535
+ fs.permission(target, 4, "readStream", path);
536
+ fs.ledger.reserve(path.length * 2, 1, "readStream", path);
537
+ target.references++;
538
+ this.node = target;
539
+ this.allocation = target.allocation;
540
+ target.allocation.retain();
541
+ const data = target.data;
542
+ this.data = data;
543
+ this.offset = start;
544
+ this.end = Math.min(options.endExclusive ?? data.byteLength, data.byteLength);
545
+ target.atimeMs = Date.now();
546
+ }
547
+ if (this.offset < this.end) {
548
+ const nextEnd = Math.min(this.offset + this.chunkSize, this.end);
549
+ const chunk = this.data.slice(this.offset, nextEnd);
550
+ this.offset = nextEnd;
551
+ return { done: false, value: chunk };
552
+ }
553
+ this._release();
554
+ return STREAM_DONE_RESULT;
555
+ }
556
+ catch (error) {
557
+ this._release();
558
+ throw error;
559
+ }
560
+ }
561
+ next() {
562
+ try {
563
+ const res = this.tryNextSync();
564
+ return res.done ? STREAM_RESOLVED_DONE : Promise.resolve(res);
565
+ }
566
+ catch (error) {
567
+ return Promise.reject(error);
568
+ }
569
+ }
570
+ return() {
571
+ this._release();
572
+ return STREAM_RESOLVED_DONE;
573
+ }
574
+ }
575
+ const SHARED_STOCK_MEMORY_CAPABILITIES = Object.freeze({
576
+ read: true, stat: true, readdir: true, realpath: true, access: true, open: true,
577
+ write: true, append: true, exclusiveCreate: true, explicitDirectories: true, implicitDirectories: false,
578
+ mkdir: true, recursiveMkdir: true, remove: true, removeDirectory: true, recursiveRemove: true,
579
+ rename: true, atomicRenameNoReplace: true, copy: true, exclusiveCopy: true, readlink: true, truncate: true,
580
+ streamingAppend: true, randomAccessWrite: true,
581
+ readOnly: false,
582
+ symlinks: true, conditionalChmod: true,
583
+ hardlinks: true,
584
+ permissions: true,
585
+ timestamps: true,
586
+ atomicRename: true,
587
+ atomicStagedFileMutation: true, atomicFileStaging: true, retainedStagingCleanup: true, retainedStagingWrite: true, atomicStagingAncestry: true, atomicFileMutation: true, atomicEntryRemoval: true, atomicEntryRemovalReceipt: true, atomicTreeRemoval: true,
588
+ synchronousDirectoryValidation: true, synchronousStagingResolution: true, synchronousFollowedStagingResolution: true, guardedStagingPublication: true,
589
+ atomicDirectoryMetadata: true,
590
+ streamingRead: true,
591
+ retainedRead: true,
592
+ retainedResize: true,
593
+ streamingWrite: true,
594
+ descriptorWriteStream: true,
595
+ });
596
+ function customMemoryCapabilities(filesystem) {
597
+ return Object.freeze({
598
+ ...SHARED_STOCK_MEMORY_CAPABILITIES,
599
+ get retainedResize() { return stockRetainedResize(filesystem); },
600
+ get descriptorWriteStream() { return stockDescriptorWrite(filesystem); },
601
+ });
602
+ }
603
+ export class MemoryFileSystem {
604
+ capabilitiesFor;
605
+ get identityScope() {
606
+ return (this._owner.identityScope ??= Symbol());
607
+ }
608
+ get capabilities() {
609
+ const owner = ownedStores.get(this);
610
+ if (owner) {
611
+ if (!owner.customCapabilities) {
612
+ owner.customCapabilities = customMemoryCapabilities(this);
613
+ owner.capabilities = owner.customCapabilities;
614
+ }
615
+ return owner.customCapabilities;
616
+ }
617
+ let caps = receiverCapabilities.get(this);
618
+ if (!caps) {
619
+ caps = customMemoryCapabilities(this);
620
+ receiverCapabilities.set(this, caps);
621
+ }
622
+ return caps;
623
+ }
624
+ nextInode = 1;
625
+ ledger;
626
+ _cache;
627
+ mutationTick = 0;
628
+ _owner;
629
+ root;
630
+ totalBytes = 0;
631
+ symlinkCount = 0;
632
+ _getAtomicView() {
633
+ const owner = ownedStores.get(this);
634
+ if (!owner ||
635
+ Object.getPrototypeOf(this) !== MemoryFileSystem.prototype ||
636
+ this.root !== owner.root ||
637
+ this.ledger !== owner.ledger ||
638
+ this.capabilities !== owner.capabilities) {
639
+ return undefined;
640
+ }
641
+ const proto = MemoryFileSystem.prototype;
642
+ for (let i = 0; i < memoryImplementationKeys.length; i++) {
643
+ const name = memoryImplementationKeys[i];
644
+ const expected = memoryImplementationDescriptors[i];
645
+ if (name === "capabilities")
646
+ continue;
647
+ if (Object.prototype.hasOwnProperty.call(this, name)) {
648
+ const actual = Object.getOwnPropertyDescriptor(this, name);
649
+ if (!actual || actual.value !== expected.value || actual.get !== expected.get || actual.set !== expected.set)
650
+ return undefined;
651
+ }
652
+ else if (expected.get !== undefined || expected.set !== undefined || proto[name] !== expected.value) {
653
+ const actual = Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, name);
654
+ if (!actual || actual.value !== expected.value || actual.get !== expected.get || actual.set !== expected.set)
655
+ return undefined;
656
+ }
657
+ }
658
+ return owner.atomicView ??= {
659
+ replaceContents: (source, destination) => {
660
+ const from = this.entry(source, "overlayAtomicView").node;
661
+ const to = this.entry(destination, "overlayAtomicView").node;
662
+ if (from?.type !== "file" || to?.type !== "file" || from === to || from.nlink !== 1)
663
+ this.fail("EINVAL", "overlayAtomicView", destination);
664
+ this.permission(to, 2, "overlayAtomicView", destination);
665
+ // Exchange owned storage, preserving destination inode/hardlinks and
666
+ // retained allocation snapshots. Stage cleanup releases the old contents.
667
+ const allocation = to.allocation, length = to.byteLength;
668
+ to.allocation = from.allocation;
669
+ to.byteLength = from.byteLength;
670
+ from.allocation = allocation;
671
+ from.byteLength = length;
672
+ to.view = undefined;
673
+ from.view = undefined;
674
+ to.sourceRef = undefined;
675
+ from.sourceRef = undefined;
676
+ this.changed(to);
677
+ this.changed(from);
678
+ },
679
+ stat: (path) => {
680
+ this.validatePath(path, "overlayAtomicView");
681
+ let node = this.root;
682
+ for (const component of path.split("/").filter(Boolean)) {
683
+ if (component === "." || component === "..")
684
+ this.fail("EINVAL", "overlayAtomicView", path);
685
+ if (!node)
686
+ return undefined;
687
+ if (node.type !== "directory")
688
+ this.fail("ENOTDIR", "overlayAtomicView", path);
689
+ this.permission(node, 1, "overlayAtomicView", path);
690
+ node = node.entries.get(component);
691
+ }
692
+ return node ? this.snapshot(node) : undefined;
693
+ },
694
+ names: (path) => {
695
+ const node = this.entry(path, "overlayAtomicView").node;
696
+ if (node.type !== "directory")
697
+ this.fail("ENOTDIR", "overlayAtomicView", path);
698
+ return [...node.entries.keys()];
699
+ },
700
+ };
701
+ }
702
+ constructor(options = {}) {
703
+ this.ledger = new MemoryLedger(normalizeMemoryFileSystemLimits(options));
704
+ if (this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes) {
705
+ replenishSharedMemoryPools();
706
+ }
707
+ const cache = new MemoryCache();
708
+ this._cache = cache;
709
+ memoryCaches.set(this.ledger, cache);
710
+ this.ledger.reserve(0, 1, "mkdir", "/");
711
+ this.root = this.directory(0o755);
712
+ const root = this.root;
713
+ const owner = {
714
+ root,
715
+ ledger: this.ledger,
716
+ capabilities: SHARED_STOCK_MEMORY_CAPABILITIES,
717
+ intact: () => this.root === root,
718
+ };
719
+ this._owner = owner;
720
+ ownedStores.set(this, owner);
721
+ registerLazyMemoryAtomicView(this, memoryImplementation._getAtomicView.value);
722
+ if (this.compareEntry === memoryImplementation.compareEntry?.value) {
723
+ registeredAuthorities.add(this);
724
+ registerEntryAuthority(this, compareOwnedMemory);
725
+ }
726
+ }
727
+ compareEntry(path, peer, peerPath, options = {}) {
728
+ return compareEntries(this, path, peer, peerPath, options);
729
+ }
730
+ canonicalizeMissingTarget(path, options = {}) {
731
+ options.signal?.throwIfAborted();
732
+ if (!isStockMemoryMethods(this, missingTargetMethodNames))
733
+ return undefined;
734
+ const owner = ownedStores.get(this);
735
+ if (path !== "")
736
+ this.validatePath(path, "realpath");
737
+ return resolveMissingTarget(owner.root, path || ".", options.signal, this.ledger.limits);
738
+ }
739
+ async confineExtraction(roots, options = {}) {
740
+ options.signal?.throwIfAborted();
741
+ const commitGuard = options.commitGuard;
742
+ const retained = new Map();
743
+ for (const root of roots) {
744
+ this.validatePath(root, "confineExtraction");
745
+ let path = "";
746
+ for (const component of root.split("/").filter(Boolean)) {
747
+ if (component === "." || component === "..")
748
+ this.fail("EINVAL", "confineExtraction", root);
749
+ path += `/${component}`;
750
+ const node = this.entry(path, "confineExtraction").node;
751
+ if (node.type !== "directory")
752
+ this.fail("ENOTDIR", "confineExtraction", path);
753
+ retained.set(path, node);
754
+ }
755
+ retained.set("/", this.root);
756
+ }
757
+ const capabilities = this.capabilities;
758
+ const allowed = new Set(["mkdir", "rm", "rmdir", "rename", "symlink", "link", "chmod", "utimes", "writeFile", "appendFile", "writeStream", "writeFileConditional", "removeFileConditional", "removeEntryConditional", "prepareDirectory", "createStagedFile", "publishStagedFile", "removeStagedFile"]);
759
+ const reads = new Set(["access", "capabilitiesFor", "compareEntry", "lstat", "stat", "readFile", "readStream", "readdir", "readlink", "realpath"]);
760
+ const check = (path, followFinal) => {
761
+ if (commitGuard)
762
+ runStagingGuard(commitGuard);
763
+ if (!roots.some(root => root === "/" || path === root || path.startsWith(`${root}/`)))
764
+ this.fail("EPERM", "confineExtraction", path);
765
+ const components = path.split("/").filter(Boolean);
766
+ if (components.some(component => component === "." || component === ".."))
767
+ this.fail("EINVAL", "confineExtraction", path);
768
+ let current = "";
769
+ for (const [index, component] of components.entries()) {
770
+ current += `/${component}`;
771
+ const node = this.entry(current, "confineExtraction", true).node;
772
+ if (retained.has(current) && node !== retained.get(current))
773
+ this.fail("EAGAIN", "confineExtraction", current);
774
+ if (index < components.length - 1 && node?.type !== "directory")
775
+ this.fail("ENOTDIR", "confineExtraction", current);
776
+ if (followFinal && index === components.length - 1 && node?.type === "symlink")
777
+ this.fail("ELOOP", "confineExtraction", current);
778
+ }
779
+ };
780
+ return new Proxy(this, {
781
+ get: (target, property) => {
782
+ if (property === "objects" || property === "confineExtraction")
783
+ return undefined;
784
+ if (property === "capabilities")
785
+ return capabilities;
786
+ const value = Reflect.get(target, property);
787
+ if (typeof value !== "function")
788
+ return value;
789
+ if (reads.has(String(property)))
790
+ return value.bind(target);
791
+ return (...args) => {
792
+ if (!allowed.has(String(property)))
793
+ throw new FsError("ENOTSUP", { syscall: String(property) });
794
+ // Stock mutations resolve and commit synchronously. Streamed writes
795
+ // repeat the boundary and file-binding check at each backend mutation.
796
+ const paths = property === "publishStagedFile" ? [args[1], args[0].directory.path] : property === "removeStagedFile" ? [args[0].directory.path] : property === "symlink" ? [args[1]] : property === "link" || property === "rename" ? args.slice(0, 2) : [args[0]];
797
+ for (const path of paths) {
798
+ if (typeof path !== "string")
799
+ throw new FsError("EINVAL");
800
+ check(path, ["chmod", "utimes", "appendFile", "writeFile", "writeStream", "writeFileConditional", "link"].includes(String(property)));
801
+ }
802
+ if (property === "writeStream") {
803
+ const path = args[0];
804
+ args[2] = { ...args[2], [extractionStreamGuard]: (node) => {
805
+ check(path, true);
806
+ if (this.resolve(path, "writeStream").node !== node)
807
+ this.fail("EPERM", "writeStream", path);
808
+ } };
809
+ }
810
+ if (property === "createStagedFile")
811
+ return Reflect.apply(value, target, args).then(staging => {
812
+ const writer = staging.writer;
813
+ if (!writer)
814
+ return staging;
815
+ return Object.freeze({ ...staging, writer: Object.freeze({
816
+ write: async (bytes, controls = {}) => {
817
+ controls.signal?.throwIfAborted();
818
+ check(staging.file.path, true);
819
+ await writer.write(bytes, controls);
820
+ },
821
+ finish: async (controls = {}) => {
822
+ controls.signal?.throwIfAborted();
823
+ check(staging.file.path, true);
824
+ return writer.finish(controls);
825
+ },
826
+ }) });
827
+ });
828
+ return Reflect.apply(value, target, args);
829
+ };
830
+ },
831
+ });
832
+ }
833
+ metadata(mode) {
834
+ const now = Date.now();
835
+ return {
836
+ mode, ino: this.nextInode++, nlink: 1, references: 0, revision: 0,
837
+ atimeMs: now, mtimeMs: now, ctimeMs: now, birthtimeMs: now,
838
+ };
839
+ }
840
+ directory(mode, now = Date.now()) {
841
+ const fullMode = typeModes.directory | mode;
842
+ const ino = this.nextInode++;
843
+ let pooled;
844
+ if (sharedDirectoryNodePoolLen > 0) {
845
+ pooled = sharedDirectoryNodePool[--sharedDirectoryNodePoolLen];
846
+ sharedDirectoryNodePool[sharedDirectoryNodePoolLen] = DUMMY_POOL_DIR_NODE;
847
+ }
848
+ else {
849
+ pooled = memoryCaches.get(this.ledger)?.directories.pop();
850
+ }
851
+ if (pooled) {
852
+ pooled.mode = fullMode;
853
+ pooled.ino = ino;
854
+ pooled.nlink = 1;
855
+ pooled.references = 0;
856
+ pooled.revision = 0;
857
+ pooled.atimeMs = now;
858
+ pooled.mtimeMs = now;
859
+ pooled.ctimeMs = now;
860
+ pooled.birthtimeMs = now;
861
+ pooled.cachedNlink = 2;
862
+ pooled.cachedNlinkRev = 0;
863
+ return pooled;
864
+ }
865
+ return new MemoryDirectoryNode(fullMode, ino, now);
866
+ }
867
+ addDirectoryNode(parent, name, mode, syscall, path, now = Date.now()) {
868
+ const bytes = name.length * 2;
869
+ this.ledger.reserve(bytes, 2, syscall, path);
870
+ try {
871
+ const node = this.directory(mode, now);
872
+ parent.entries.set(name, node);
873
+ this.changed(parent, now);
874
+ return node;
875
+ }
876
+ catch (error) {
877
+ this.ledger.release(bytes, 2);
878
+ throw error;
879
+ }
880
+ }
881
+ addNode(parent, name, create, syscall, path, retainedBytes = 0) {
882
+ const bytes = name.length * 2 + retainedBytes;
883
+ this.ledger.reserve(bytes, 2, syscall, path);
884
+ try {
885
+ const node = create();
886
+ if (node.type === "file")
887
+ this.admitSize(undefined, node.byteLength, syscall, path);
888
+ parent.entries.set(name, node);
889
+ if (node.type === "file")
890
+ this.totalBytes += node.byteLength;
891
+ else if (node.type === "symlink")
892
+ this.symlinkCount++;
893
+ this.changed(parent);
894
+ return node;
895
+ }
896
+ catch (error) {
897
+ this.ledger.release(bytes, 2);
898
+ throw error;
899
+ }
900
+ }
901
+ releaseNode(node) {
902
+ if (node.nlink !== 0 || node.references !== 0)
903
+ return;
904
+ const cache = memoryCaches.get(this.ledger);
905
+ this.ledger.release(node.type === "symlink" ? node.target.length * 2 : 0, 1);
906
+ if (node.type === "file") {
907
+ if (cache.lastFastFileNode === node) {
908
+ cache.lastFastFilePath = "";
909
+ cache.lastFastFileName = "";
910
+ cache.lastFastFileNode = undefined;
911
+ }
912
+ this.totalBytes -= node.byteLength;
913
+ const alloc = node.allocation;
914
+ node.view = undefined;
915
+ node.sourceRef = undefined;
916
+ node.allocation = DUMMY_POOL_ALLOCATION;
917
+ alloc.release();
918
+ if (sharedFileNodePoolLen < SHARED_POOL_CAPACITY) {
919
+ sharedFileNodePool[sharedFileNodePoolLen++] = node;
920
+ }
921
+ else if (cache.files.length < 128) {
922
+ cache.files.push(node);
923
+ }
924
+ }
925
+ else if (node.type === "symlink") {
926
+ this.symlinkCount--;
927
+ }
928
+ else {
929
+ if (cache.lastFastDirNode === node) {
930
+ cache.lastFastDirPrefix = "";
931
+ cache.lastFastDirNode = undefined;
932
+ }
933
+ if (node.entries.size === 0) {
934
+ node.entries.clear();
935
+ if (sharedDirectoryNodePoolLen < SHARED_DIR_POOL_CAPACITY) {
936
+ sharedDirectoryNodePool[sharedDirectoryNodePoolLen++] = node;
937
+ }
938
+ else if (cache.directories.length < 32) {
939
+ cache.directories.push(node);
940
+ }
941
+ }
942
+ }
943
+ }
944
+ releaseReference(node, path) {
945
+ node.references--;
946
+ this.ledger.release(path.length * 2, 1);
947
+ this.releaseNode(node);
948
+ }
949
+ replaceData(node, allocation, length = allocation.data.byteLength) {
950
+ const previous = node.allocation;
951
+ node.sourceRef = undefined;
952
+ this.totalBytes += length - node.byteLength;
953
+ node.byteLength = length;
954
+ node.view = length === allocation.data.byteLength ? allocation.data : undefined;
955
+ node.allocation = allocation;
956
+ previous.release();
957
+ }
958
+ admitSize(node, length, syscall, path) {
959
+ this.ledger.fileSize(length, syscall, path);
960
+ const maxBytes = this.ledger.limits.maxBytes;
961
+ if (maxBytes !== undefined && length - (node?.byteLength ?? 0) > maxBytes - this.totalBytes) {
962
+ this.fail("ENOSPC", syscall, path);
963
+ }
964
+ }
965
+ fail(code, syscall, path, dest) {
966
+ throw new FsError(code, { syscall, path, ...(dest === undefined ? {} : { dest }) });
967
+ }
968
+ validatePath(path, syscall) {
969
+ if (typeof path !== "string" || path.includes("\0"))
970
+ this.fail("EINVAL", syscall, path);
971
+ if (path.length === 0)
972
+ this.fail("ENOENT", syscall, path);
973
+ if (this.ledger.limits.maxPathBytes !== Infinity || this.ledger.limits.maxPathComponents !== Infinity)
974
+ validatePath(path, this.ledger.limits);
975
+ }
976
+ permission(node, mask, syscall, path) {
977
+ if (((node.mode >> 6) & mask) !== mask)
978
+ this.fail("EACCES", syscall, path);
979
+ }
980
+ mode(mode, fallback, syscall, path) {
981
+ const value = mode ?? fallback;
982
+ if (!Number.isInteger(value) || value < 0 || value > 0o7777)
983
+ this.fail("EINVAL", syscall, path);
984
+ return value;
985
+ }
986
+ integer(value, syscall, path) {
987
+ if (!Number.isSafeInteger(value) || value < 0)
988
+ this.fail("EINVAL", syscall, path);
989
+ }
990
+ changed(node, now = Date.now()) {
991
+ this.mutationTick = (this.mutationTick + 1) | 0;
992
+ node.revision = node.revision < 1073741823 ? (node.revision + 1) | 0 : Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
993
+ node.mtimeMs = node.ctimeMs = now;
994
+ }
995
+ resolveNode(path, syscall, followFinal = true) {
996
+ if (this.ledger.limits.maxPathBytes !== Infinity || this.ledger.limits.maxPathComponents !== Infinity)
997
+ validatePath(path, this.ledger.limits);
998
+ const cache = memoryCaches.get(this.ledger);
999
+ if (this.symlinkCount === 0 && isCleanAbsolutePath(path)) {
1000
+ const fastDir = cache.lastFastDirNode;
1001
+ const fastPrefix = cache.lastFastDirPrefix;
1002
+ if (fastDir !== undefined && fastDir.nlink !== 0 && fastPrefix.length > 0 && path.startsWith(fastPrefix)) {
1003
+ const name = fastPrefix.length === 1 ? (path === _lastFileSlice1Path ? _lastFileSlice1Name : (_lastFileSlice1Path = path, _lastFileSlice1Name = path.slice(1))) : path.slice(fastPrefix.length);
1004
+ if (name.length > 0 && !name.includes("/")) {
1005
+ this.permission(fastDir, 1, syscall, path);
1006
+ if (exceedsComponentByteLimit(name))
1007
+ this.fail("ENAMETOOLONG", syscall, path);
1008
+ const node = fastDir.entries.get(name);
1009
+ if (!node)
1010
+ this.fail("ENOENT", syscall, path);
1011
+ return node;
1012
+ }
1013
+ }
1014
+ let current = this.root;
1015
+ let start = 1;
1016
+ while (true) {
1017
+ this.permission(current, 1, syscall, path);
1018
+ const slash = path.indexOf("/", start);
1019
+ if (slash === -1) {
1020
+ cache.clearWrites();
1021
+ cache.lastFastDirPrefix = start === 1 ? "/" : path.slice(0, start);
1022
+ cache.lastFastDirNode = current;
1023
+ const name = start === 1 ? (path === _lastFileSlice1Path ? _lastFileSlice1Name : (_lastFileSlice1Path = path, _lastFileSlice1Name = path.slice(1))) : path.slice(start);
1024
+ if (exceedsComponentByteLimit(name))
1025
+ this.fail("ENAMETOOLONG", syscall, path);
1026
+ const node = current.entries.get(name);
1027
+ if (!node)
1028
+ this.fail("ENOENT", syscall, path);
1029
+ return node;
1030
+ }
1031
+ const name = slicePathSegment(path, start, slash);
1032
+ if (exceedsComponentByteLimit(name))
1033
+ this.fail("ENAMETOOLONG", syscall, path);
1034
+ const next = current.entries.get(name);
1035
+ if (!next)
1036
+ this.fail("ENOENT", syscall, path);
1037
+ if (next.type !== "directory")
1038
+ this.fail("ENOTDIR", syscall, path);
1039
+ current = next;
1040
+ start = slash + 1;
1041
+ }
1042
+ }
1043
+ return this.resolve(path, syscall, followFinal ? emptyResolveOptions : noFollowResolveOptions).node;
1044
+ }
1045
+ resolve(path, syscall, options = emptyResolveOptions) {
1046
+ this.validatePath(path, syscall);
1047
+ if (this.symlinkCount === 0 && options.resizeCreate === undefined
1048
+ && options.resolutionSteps === undefined && isCleanAbsolutePath(path)) {
1049
+ let current = this.root;
1050
+ let start = 1;
1051
+ while (true) {
1052
+ this.permission(current, 1, syscall, path);
1053
+ const slash = path.indexOf("/", start);
1054
+ if (slash === -1) {
1055
+ const name = slicePathSegment(path, start, path.length);
1056
+ if (exceedsComponentByteLimit(name))
1057
+ this.fail("ENAMETOOLONG", syscall, path);
1058
+ let node = current.entries.get(name);
1059
+ if (!node && options.createDirectories !== undefined) {
1060
+ this.permission(current, 3, syscall, path);
1061
+ node = this.addDirectoryNode(current, name, options.createDirectories, syscall, path);
1062
+ }
1063
+ if (!node && !options.allowMissing)
1064
+ this.fail("ENOENT", syscall, path);
1065
+ return { node, parent: current, name, path };
1066
+ }
1067
+ const name = path.slice(start, slash);
1068
+ if (exceedsComponentByteLimit(name))
1069
+ this.fail("ENAMETOOLONG", syscall, path);
1070
+ let next = current.entries.get(name);
1071
+ if (!next && options.createDirectories !== undefined) {
1072
+ this.permission(current, 3, syscall, path);
1073
+ next = this.addDirectoryNode(current, name, options.createDirectories, syscall, path);
1074
+ }
1075
+ if (!next)
1076
+ this.fail("ENOENT", syscall, path);
1077
+ if (next.type !== "directory")
1078
+ this.fail("ENOTDIR", syscall, path);
1079
+ current = next;
1080
+ start = slash + 1;
1081
+ }
1082
+ }
1083
+ // Bound all component arrays allocated by this resolution, including cycles.
1084
+ let remainingPathUnits = this.ledger.limits.maxPathBytes - pathByteLength(path);
1085
+ if (remainingPathUnits < 0)
1086
+ this.fail("ENAMETOOLONG", syscall, path);
1087
+ let initialComponents = 0;
1088
+ let inComp = false;
1089
+ for (let i = 0; i < path.length; i++) {
1090
+ if (path.charCodeAt(i) === 47)
1091
+ inComp = false;
1092
+ else if (!inComp) {
1093
+ inComp = true;
1094
+ if (++initialComponents > this.ledger.limits.maxPathComponents)
1095
+ this.fail("ENAMETOOLONG", syscall, path);
1096
+ }
1097
+ }
1098
+ let pending = path.split("/").filter(Boolean);
1099
+ let remainingComponents = this.ledger.limits.maxPathComponents - pending.length;
1100
+ if (path.endsWith("/"))
1101
+ pending.push("");
1102
+ const stack = [{ node: this.root, name: "" }];
1103
+ let recordedUnits = 0;
1104
+ const observe = (node, entryPath) => {
1105
+ if (!options.resolutionSteps)
1106
+ return;
1107
+ recordedUnits += entryPath.length + (node.type === "symlink" ? node.target.length : 0);
1108
+ if (options.resolutionSteps.length >= 4096 || recordedUnits > 1_048_576)
1109
+ this.fail("EFBIG", syscall, path);
1110
+ options.resolutionSteps.push({ path: entryPath, stat: this.snapshot(node), ...(node.type === "symlink" ? { linkTarget: node.target } : {}) });
1111
+ };
1112
+ observe(this.root, "/");
1113
+ let links = 0;
1114
+ while (pending.length > 0) {
1115
+ const component = pending.shift();
1116
+ const current = stack[stack.length - 1].node;
1117
+ if (current.type !== "directory")
1118
+ this.fail("ENOTDIR", syscall, path);
1119
+ if (!(component === "" && pending.length === 0 && options.resizeCreate !== undefined))
1120
+ this.permission(current, 1, syscall, path);
1121
+ if (component === "." || component === "")
1122
+ continue;
1123
+ if (component === "..") {
1124
+ if (stack.length > 1)
1125
+ stack.pop();
1126
+ continue;
1127
+ }
1128
+ if (exceedsComponentByteLimit(component))
1129
+ this.fail("ENAMETOOLONG", syscall, path);
1130
+ if (options.resizeCreate === true && pending.length === 1 && pending[0] === "")
1131
+ this.fail("EISDIR", syscall, path);
1132
+ let node = current.entries.get(component);
1133
+ if (!node && options.createDirectories !== undefined) {
1134
+ this.permission(current, 3, syscall, path);
1135
+ const mode = options.createDirectories;
1136
+ node = this.addNode(current, component, () => this.directory(mode), syscall, path);
1137
+ }
1138
+ if (!node) {
1139
+ if (options.allowMissing && pending.length === 0) {
1140
+ return { node, parent: current, name: component, path: [...stack.map((entry) => entry.name), component].join("/") };
1141
+ }
1142
+ this.fail("ENOENT", syscall, path);
1143
+ }
1144
+ if (options.resolutionSteps)
1145
+ observe(node, [...stack.map(entry => entry.name), component].join("/"));
1146
+ if (node.type === "symlink" && (options.followFinal !== false || pending.length > 0)) {
1147
+ if (++links > 40)
1148
+ this.fail("ELOOP", syscall, path);
1149
+ if (pathByteLength(node.target) > remainingPathUnits)
1150
+ this.fail("ENAMETOOLONG", syscall, path);
1151
+ remainingPathUnits -= pathByteLength(node.target);
1152
+ const target = node.target.split("/").filter(Boolean);
1153
+ if (target.length > remainingComponents)
1154
+ this.fail("ENAMETOOLONG", syscall, path);
1155
+ remainingComponents -= target.length;
1156
+ if (node.target.endsWith("/"))
1157
+ target.push("");
1158
+ if (options.resizeCreate !== undefined && target.at(-1) === "" && pending[0] === "")
1159
+ target.pop();
1160
+ pending = target.concat(pending);
1161
+ if (node.target.startsWith("/"))
1162
+ stack.splice(1);
1163
+ continue;
1164
+ }
1165
+ stack.push({ node, name: component });
1166
+ }
1167
+ const entry = stack[stack.length - 1];
1168
+ return {
1169
+ node: entry.node,
1170
+ parent: (stack[stack.length - 2]?.node ?? this.root),
1171
+ name: entry.name,
1172
+ path: stack.map((part) => part.name).join("/") || "/",
1173
+ };
1174
+ }
1175
+ file(path, syscall) {
1176
+ if (this.ledger.limits.maxPathBytes !== Infinity || this.ledger.limits.maxPathComponents !== Infinity)
1177
+ validatePath(path, this.ledger.limits);
1178
+ if (this.symlinkCount === 0 && path.charCodeAt(0) === 47 && path.length > 1 && path.indexOf("/", 1) === -1 && !path.includes("\0")) {
1179
+ const name = path === _lastFileSlice1Path ? _lastFileSlice1Name : (_lastFileSlice1Path = path, _lastFileSlice1Name = path.slice(1));
1180
+ if (name !== "." && name !== "..") {
1181
+ this.permission(this.root, 1, syscall, path);
1182
+ if (exceedsComponentByteLimit(name))
1183
+ this.fail("ENAMETOOLONG", syscall, path);
1184
+ const node = this.root.entries.get(name);
1185
+ if (!node)
1186
+ this.fail("ENOENT", syscall, path);
1187
+ if (node.type !== "file")
1188
+ this.fail("EISDIR", syscall, path);
1189
+ return node;
1190
+ }
1191
+ }
1192
+ const cache = memoryCaches.get(this.ledger);
1193
+ if (this.symlinkCount === 0 && isCleanAbsolutePath(path)) {
1194
+ const fastDir = cache.lastFastDirNode;
1195
+ const fastPrefix = cache.lastFastDirPrefix;
1196
+ if (fastDir !== undefined && fastDir.nlink !== 0 && fastPrefix.length > 0 && path.startsWith(fastPrefix)) {
1197
+ const name = path.slice(fastPrefix.length);
1198
+ if (name.length > 0 && !name.includes("/")) {
1199
+ this.permission(fastDir, 1, syscall, path);
1200
+ if (exceedsComponentByteLimit(name))
1201
+ this.fail("ENAMETOOLONG", syscall, path);
1202
+ const node = fastDir.entries.get(name);
1203
+ if (!node)
1204
+ this.fail("ENOENT", syscall, path);
1205
+ if (node.type !== "file")
1206
+ this.fail("EISDIR", syscall, path);
1207
+ return node;
1208
+ }
1209
+ }
1210
+ let current = this.root;
1211
+ let start = 1;
1212
+ while (true) {
1213
+ this.permission(current, 1, syscall, path);
1214
+ const slash = path.indexOf("/", start);
1215
+ if (slash === -1) {
1216
+ cache.clearWrites();
1217
+ cache.lastFastDirPrefix = path.slice(0, start);
1218
+ cache.lastFastDirNode = current;
1219
+ const name = path.slice(start);
1220
+ if (exceedsComponentByteLimit(name))
1221
+ this.fail("ENAMETOOLONG", syscall, path);
1222
+ const node = current.entries.get(name);
1223
+ if (!node)
1224
+ this.fail("ENOENT", syscall, path);
1225
+ if (node.type !== "file")
1226
+ this.fail("EISDIR", syscall, path);
1227
+ return node;
1228
+ }
1229
+ const name = path.slice(start, slash);
1230
+ if (exceedsComponentByteLimit(name))
1231
+ this.fail("ENAMETOOLONG", syscall, path);
1232
+ const next = current.entries.get(name);
1233
+ if (!next)
1234
+ this.fail("ENOENT", syscall, path);
1235
+ if (next.type !== "directory")
1236
+ this.fail("ENOTDIR", syscall, path);
1237
+ current = next;
1238
+ start = slash + 1;
1239
+ }
1240
+ }
1241
+ const node = this.resolve(path, syscall).node;
1242
+ if (node.type !== "file")
1243
+ this.fail("EISDIR", syscall, path);
1244
+ return node;
1245
+ }
1246
+ entry(path, syscall, allowMissing = false) {
1247
+ this.validatePath(path, syscall);
1248
+ const location = this.resolve(path.replace(/\/+$/, "") || "/", syscall, { followFinal: false, allowMissing });
1249
+ if (path.endsWith("/") && location.node && location.node.type !== "directory")
1250
+ this.fail("ENOTDIR", syscall, path);
1251
+ return location;
1252
+ }
1253
+ terminalDot(path) {
1254
+ const len = path.length;
1255
+ if (len === 0)
1256
+ return false;
1257
+ const last = path.charCodeAt(len - 1);
1258
+ if (last !== 46 && last !== 47)
1259
+ return false;
1260
+ return /(?:^|\/)\.{1,2}\/*$/.test(path);
1261
+ }
1262
+ directoryNlink(node) {
1263
+ if (node.cachedNlinkRev === node.revision && node.cachedNlink !== undefined) {
1264
+ return node.cachedNlink;
1265
+ }
1266
+ let nlink = 2;
1267
+ node.entries.forEach(entry => {
1268
+ if (entry.type === "directory")
1269
+ nlink++;
1270
+ });
1271
+ node.cachedNlinkRev = node.revision;
1272
+ node.cachedNlink = nlink;
1273
+ return nlink;
1274
+ }
1275
+ snapshot(node) {
1276
+ const hasRev = Number.isSafeInteger(node.revision);
1277
+ const hasScope = ownedStores.get(this)?.intact() === true;
1278
+ const size = node.type === "file" ? node.byteLength
1279
+ : node.type === "symlink" ? new TextEncoder().encode(node.target).byteLength : 0;
1280
+ const nlink = node.type === "directory" && node.nlink !== 0
1281
+ ? this.directoryNlink(node) : node.nlink;
1282
+ if (hasRev && hasScope) {
1283
+ return {
1284
+ type: node.type,
1285
+ filesystemType: "memory",
1286
+ ioBlockSize: preferredIoBlockSize,
1287
+ revision: node.revision,
1288
+ preferredIoBlockSize: 4096,
1289
+ size,
1290
+ mode: node.mode,
1291
+ identityScope: this.identityScope,
1292
+ ino: node.ino,
1293
+ dev: 0,
1294
+ uid: 0,
1295
+ gid: 0,
1296
+ nlink,
1297
+ atimeMs: node.atimeMs,
1298
+ mtimeMs: node.mtimeMs,
1299
+ ctimeMs: node.ctimeMs,
1300
+ birthtimeMs: node.birthtimeMs,
1301
+ };
1302
+ }
1303
+ return {
1304
+ type: node.type,
1305
+ filesystemType: "memory",
1306
+ ioBlockSize: preferredIoBlockSize,
1307
+ ...(hasRev ? { revision: node.revision } : {}),
1308
+ preferredIoBlockSize: 4096,
1309
+ size,
1310
+ mode: node.mode,
1311
+ ...(hasScope ? { identityScope: this.identityScope } : {}),
1312
+ ino: node.ino, dev: 0, uid: 0, gid: 0,
1313
+ nlink,
1314
+ atimeMs: node.atimeMs, mtimeMs: node.mtimeMs, ctimeMs: node.ctimeMs, birthtimeMs: node.birthtimeMs,
1315
+ };
1316
+ }
1317
+ bytes(data, syscall, path) {
1318
+ const allocation = this.allocate(data.byteLength, syscall, path);
1319
+ try {
1320
+ allocation.data.set(data);
1321
+ return allocation;
1322
+ }
1323
+ catch (error) {
1324
+ allocation.release();
1325
+ throw error;
1326
+ }
1327
+ }
1328
+ allocate(length, syscall, path) {
1329
+ this.ledger.fileSize(length, syscall, path);
1330
+ this.ledger.reserve(length, 0, syscall, path);
1331
+ if (length === 0) {
1332
+ return DUMMY_POOL_ALLOCATION;
1333
+ }
1334
+ // Views can outlive files: never recycle their backing buffers across owners.
1335
+ try {
1336
+ return new MemoryAllocation(new Uint8Array(length), this.ledger);
1337
+ }
1338
+ catch (cause) {
1339
+ this.ledger.release(length, 0);
1340
+ throw new FsError("EFBIG", { syscall, path, cause });
1341
+ }
1342
+ }
1343
+ open(path, options) {
1344
+ return openFileDescriptor(path, options, MEMORY_DESCRIPTOR_CAPABILITIES, async (admitted) => {
1345
+ const location = this.resolve(path, "open", {
1346
+ followFinal: !admitted.noFollow && admitted.creation !== "exclusive", allowMissing: admitted.creation !== "never",
1347
+ });
1348
+ let node = location.node;
1349
+ if (node) {
1350
+ if (admitted.creation === "exclusive")
1351
+ this.fail("EEXIST", "open", path);
1352
+ if (node.type === "symlink" && admitted.noFollow)
1353
+ this.fail("ELOOP", "open", path);
1354
+ if (node.type !== "file")
1355
+ this.fail("EISDIR", "open", path);
1356
+ this.permission(node, admitted.access === "read" ? 4 : admitted.access === "write" ? 2 : 6, "open", path);
1357
+ }
1358
+ else {
1359
+ this.permission(location.parent, 3, "open", path);
1360
+ }
1361
+ this.ledger.reserve(path.length * 2, 1, "open", path);
1362
+ try {
1363
+ node ??= this.openWrite(path, {}, "open", { location, mode: admitted.mode, append: false });
1364
+ if (admitted.truncate)
1365
+ this.resizeNode(node, 0, "open", path);
1366
+ }
1367
+ catch (error) {
1368
+ this.ledger.release(path.length * 2, 1);
1369
+ throw error;
1370
+ }
1371
+ node.references++;
1372
+ const resource = { fs: this, path, append: admitted.append, node, position: 0 };
1373
+ return {
1374
+ resource,
1375
+ getPosition: memoryDescriptorGetPosition,
1376
+ stat: memoryDescriptorStat,
1377
+ read: memoryDescriptorRead,
1378
+ write: memoryDescriptorWrite,
1379
+ truncate: memoryDescriptorTruncate,
1380
+ sync: memoryDescriptorSync,
1381
+ close: memoryDescriptorClose,
1382
+ };
1383
+ });
1384
+ }
1385
+ prepareWrite(path, options, syscall) {
1386
+ const flag = options.flag ?? "w";
1387
+ if (!["w", "wx", "a", "ax"].includes(flag))
1388
+ this.fail("EINVAL", syscall, path);
1389
+ const mode = this.mode(options.mode, 0o666, syscall, path);
1390
+ const exclusive = flag === "wx" || flag === "ax";
1391
+ const location = this.resolve(path, syscall, { followFinal: !exclusive, allowMissing: true });
1392
+ if (location.node) {
1393
+ if (exclusive)
1394
+ this.fail("EEXIST", syscall, path);
1395
+ if (location.node.type !== "file")
1396
+ this.fail("EISDIR", syscall, path);
1397
+ this.permission(location.node, 2, syscall, path);
1398
+ }
1399
+ else {
1400
+ this.permission(location.parent, 3, syscall, path);
1401
+ }
1402
+ return { location, mode, append: flag === "a" || flag === "ax" };
1403
+ }
1404
+ openWrite(path, options, syscall, target = this.prepareWrite(path, options, syscall)) {
1405
+ const { location, mode } = target;
1406
+ if (location.node)
1407
+ return location.node;
1408
+ return this.addNode(location.parent, location.name, () => {
1409
+ const allocation = new MemoryAllocation(new Uint8Array(), this.ledger);
1410
+ const meta = this.metadata(typeModes.file | mode);
1411
+ return new MemoryFileNode(meta.mode, meta.ino, meta.atimeMs, 0, allocation, allocation.data);
1412
+ }, syscall, path);
1413
+ }
1414
+ writeData(path, data, options, syscall) {
1415
+ if (this.ledger.limits.maxPathBytes !== Infinity || this.ledger.limits.maxPathComponents !== Infinity)
1416
+ validatePath(path, this.ledger.limits);
1417
+ if (!(data instanceof Uint8Array))
1418
+ throw new TypeError("Memory files require Uint8Array data");
1419
+ const target = this.prepareWrite(path, options, syscall);
1420
+ const current = target.location.node;
1421
+ const length = (target.append ? current?.byteLength ?? 0 : 0) + data.byteLength;
1422
+ this.admitSize(current, length, syscall, path);
1423
+ const growth = target.append && length > (current?.allocation.data.byteLength ?? 0) ? length : 0;
1424
+ this.ledger.check(data.byteLength + growth + (current ? 0 : target.location.name.length * 2), current ? 0 : 2, syscall, path);
1425
+ if (current && target.append) {
1426
+ this.writeAt(current, data, current.byteLength, syscall, path);
1427
+ return current;
1428
+ }
1429
+ if (!current) {
1430
+ const capacity = length > 0 && (target.append || (length < 64 && this.ledger.availableBytes > 65536 && this.ledger.limits.maxFileBytes >= 64))
1431
+ ? Math.min(Math.max(length, 64), this.ledger.limits.maxFileBytes, this.ledger.availableBytes - target.location.name.length * 2)
1432
+ : length;
1433
+ const allocation = this.allocate(capacity, syscall, path);
1434
+ try {
1435
+ allocation.data.set(data);
1436
+ return this.addNode(target.location.parent, target.location.name, () => {
1437
+ const now = Date.now();
1438
+ const fileMode = typeModes.file | target.mode;
1439
+ const view = capacity === length ? allocation.data : undefined;
1440
+ let pooled;
1441
+ if (sharedFileNodePoolLen > 0) {
1442
+ pooled = sharedFileNodePool[--sharedFileNodePoolLen];
1443
+ sharedFileNodePool[sharedFileNodePoolLen] = DUMMY_POOL_FILE_NODE;
1444
+ }
1445
+ else {
1446
+ pooled = memoryCaches.get(this.ledger).files.pop();
1447
+ }
1448
+ if (pooled) {
1449
+ pooled.mode = fileMode;
1450
+ pooled.ino = this.nextInode++;
1451
+ pooled.nlink = 1;
1452
+ pooled.references = 0;
1453
+ pooled.revision = 0;
1454
+ pooled.atimeMs = now;
1455
+ pooled.mtimeMs = now;
1456
+ pooled.ctimeMs = now;
1457
+ pooled.birthtimeMs = now;
1458
+ pooled.byteLength = length;
1459
+ pooled.view = view;
1460
+ pooled.allocation = allocation;
1461
+ pooled.sourceRef = pooled.data.subarray(0);
1462
+ return pooled;
1463
+ }
1464
+ return new MemoryFileNode(fileMode, this.nextInode++, now, length, allocation, view, (view ?? allocation.data).subarray(0, length));
1465
+ }, syscall, path);
1466
+ }
1467
+ catch (error) {
1468
+ allocation.release();
1469
+ throw error;
1470
+ }
1471
+ }
1472
+ const copied = this.bytes(data, syscall, path);
1473
+ try {
1474
+ this.replaceData(current, copied);
1475
+ this.changed(current);
1476
+ return current;
1477
+ }
1478
+ catch (error) {
1479
+ copied.release();
1480
+ throw error;
1481
+ }
1482
+ }
1483
+ writeAt(node, data, position, syscall, path) {
1484
+ this.writeAtRange(node, data, data.byteLength, position, syscall, path, Date.now());
1485
+ }
1486
+ writeAtRange(node, data, dataLen, position, syscall, path, now) {
1487
+ if (dataLen === 0) {
1488
+ this.changed(node, now);
1489
+ return;
1490
+ }
1491
+ const end = position + dataLen;
1492
+ this.ledger.fileSize(end, syscall, path);
1493
+ const curLen = node.byteLength;
1494
+ const length = Math.max(curLen, end);
1495
+ this.admitSize(node, length, syscall, path);
1496
+ let allocation = node.allocation;
1497
+ if (length > allocation.data.byteLength) {
1498
+ this.ledger.check(length, 0, syscall, path);
1499
+ let capacity;
1500
+ if (this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes && this.ledger.limits.maxBytes === undefined) {
1501
+ capacity = curLen === 0 && length >= 8192 && length <= 65536 ? (length <= 16384 ? 16384 : 65536) : Math.max(length, curLen * 2, 64);
1502
+ }
1503
+ else {
1504
+ const baseCap = curLen === 0 && length >= 8192 && length <= 65536 &&
1505
+ this.ledger.limits.maxFileBytes >= 65536 &&
1506
+ this.ledger.availableBytes >= 65536 &&
1507
+ (this.ledger.limits.maxBytes === undefined || this.ledger.limits.maxBytes - this.totalBytes >= 65536)
1508
+ ? 65536
1509
+ : Math.max(length, curLen * 2, 64);
1510
+ capacity = Math.min(baseCap, this.ledger.limits.maxFileBytes, this.ledger.availableBytes);
1511
+ }
1512
+ allocation = this.allocate(capacity, syscall, path);
1513
+ }
1514
+ try {
1515
+ const storage = allocation.data;
1516
+ if (allocation !== node.allocation && curLen > 0) {
1517
+ storage.set((node.view ?? node.allocation.data).subarray(0, curLen));
1518
+ }
1519
+ if (position > curLen)
1520
+ storage.fill(0, curLen, position);
1521
+ const source = data;
1522
+ if (dataLen === data.byteLength) {
1523
+ storage.set(data, position);
1524
+ }
1525
+ else if (typeof source.copy === "function") {
1526
+ source.copy(storage, position, 0, dataLen);
1527
+ }
1528
+ else {
1529
+ for (let i = 0; i < dataLen; i++)
1530
+ storage[position + i] = data[i];
1531
+ }
1532
+ }
1533
+ catch (error) {
1534
+ if (allocation !== node.allocation)
1535
+ allocation.release();
1536
+ throw error;
1537
+ }
1538
+ if (allocation !== node.allocation)
1539
+ this.replaceData(node, allocation, length);
1540
+ else {
1541
+ this.totalBytes += length - curLen;
1542
+ node.byteLength = length;
1543
+ node.view = length === allocation.data.byteLength ? allocation.data : undefined;
1544
+ }
1545
+ node.sourceRef = undefined;
1546
+ this.changed(node, now);
1547
+ }
1548
+ writeMemoryFileFast(path, data, append, mode) {
1549
+ if (this.ledger.limits.maxPathBytes !== Infinity || this.ledger.limits.maxPathComponents !== Infinity)
1550
+ validatePath(path, this.ledger.limits);
1551
+ const cache = memoryCaches.get(this.ledger);
1552
+ const syscall = append ? "appendFile" : "writeFile";
1553
+ if (append &&
1554
+ path === cache.lastFastFilePath &&
1555
+ cache.lastFastFileNode !== undefined &&
1556
+ cache.lastFastFileNode.nlink !== 0 &&
1557
+ cache.lastFastDirNode !== undefined &&
1558
+ cache.lastFastDirNode.nlink !== 0 &&
1559
+ (cache.lastFastDirNode.mode & 0o100) !== 0 &&
1560
+ (cache.lastFastFileNode.mode & 0o200) !== 0) {
1561
+ const current = cache.lastFastFileNode;
1562
+ const length = current.byteLength + data.byteLength;
1563
+ this.admitSize(current, length, syscall, path);
1564
+ const growth = length > current.allocation.data.byteLength ? length : 0;
1565
+ this.ledger.check(data.byteLength + growth, 0, syscall, path);
1566
+ this.writeAt(current, data, current.byteLength, syscall, path);
1567
+ return;
1568
+ }
1569
+ let parent = this.root;
1570
+ let start = 1;
1571
+ let name = "";
1572
+ const cachedPrefix = cache.lastFastDirPrefix;
1573
+ const cachedDir = cache.lastFastDirNode;
1574
+ if (cachedDir !== undefined &&
1575
+ cachedDir.nlink !== 0 &&
1576
+ (cachedDir.mode & 0o100) !== 0 &&
1577
+ cachedPrefix.length > 1 &&
1578
+ path.startsWith(cachedPrefix) &&
1579
+ path.indexOf("/", cachedPrefix.length) === -1) {
1580
+ parent = cachedDir;
1581
+ name = path.slice(cachedPrefix.length);
1582
+ if (exceedsComponentByteLimit(name))
1583
+ this.fail("ENAMETOOLONG", syscall, path);
1584
+ }
1585
+ else {
1586
+ while (true) {
1587
+ this.permission(parent, 1, syscall, path);
1588
+ const slash = path.indexOf("/", start);
1589
+ if (slash === -1) {
1590
+ name = path.slice(start);
1591
+ if (exceedsComponentByteLimit(name))
1592
+ this.fail("ENAMETOOLONG", syscall, path);
1593
+ if (start > 1 && (parent.mode & 0o100) !== 0) {
1594
+ cache.lastFastDirPrefix = path.slice(0, start);
1595
+ cache.lastFastDirNode = parent;
1596
+ }
1597
+ break;
1598
+ }
1599
+ const seg = slicePathSegment(path, start, slash);
1600
+ if (exceedsComponentByteLimit(seg))
1601
+ this.fail("ENAMETOOLONG", syscall, path);
1602
+ const next = parent.entries.get(seg);
1603
+ if (!next)
1604
+ this.fail("ENOENT", syscall, path);
1605
+ if (next.type !== "directory")
1606
+ this.fail("ENOTDIR", syscall, path);
1607
+ parent = next;
1608
+ start = slash + 1;
1609
+ }
1610
+ }
1611
+ const existing = parent.entries.getForWrite ? parent.entries.getForWrite(name) : parent.entries.get(name);
1612
+ if (existing) {
1613
+ if (existing.type !== "file")
1614
+ this.fail("EISDIR", syscall, path);
1615
+ this.permission(existing, 2, syscall, path);
1616
+ }
1617
+ else {
1618
+ this.permission(parent, 3, syscall, path);
1619
+ }
1620
+ const current = existing;
1621
+ const length = (append ? current?.byteLength ?? 0 : 0) + data.byteLength;
1622
+ this.admitSize(current, length, syscall, path);
1623
+ const growth = append && length > (current?.allocation.data.byteLength ?? 0) ? length : 0;
1624
+ const nameBytes = name.length * 2;
1625
+ this.ledger.check(data.byteLength + growth + (current ? 0 : nameBytes), current ? 0 : 2, syscall, path);
1626
+ if (current && append) {
1627
+ this.writeAt(current, data, current.byteLength, syscall, path);
1628
+ cache.lastFastFilePath = path;
1629
+ cache.lastFastFileName = name;
1630
+ cache.lastFastFileNode = current;
1631
+ return;
1632
+ }
1633
+ if (!current) {
1634
+ const capacity = length > 0 && length < 64 && this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes ? 64 : length;
1635
+ const allocation = this.allocate(capacity, syscall, path);
1636
+ try {
1637
+ allocation.data.set(data);
1638
+ this.ledger.reserve(nameBytes, 2, syscall, path);
1639
+ try {
1640
+ const now = Date.now();
1641
+ const fileMode = typeModes.file | mode;
1642
+ const view = capacity === length ? allocation.data : undefined;
1643
+ let node;
1644
+ if (sharedFileNodePoolLen > 0) {
1645
+ node = sharedFileNodePool[--sharedFileNodePoolLen];
1646
+ sharedFileNodePool[sharedFileNodePoolLen] = DUMMY_POOL_FILE_NODE;
1647
+ }
1648
+ else {
1649
+ node = cache.files.pop();
1650
+ }
1651
+ if (node) {
1652
+ node.mode = fileMode;
1653
+ node.ino = this.nextInode++;
1654
+ node.nlink = 1;
1655
+ node.references = 0;
1656
+ node.revision = 0;
1657
+ node.atimeMs = now;
1658
+ node.mtimeMs = now;
1659
+ node.ctimeMs = now;
1660
+ node.birthtimeMs = now;
1661
+ node.byteLength = length;
1662
+ node.view = view;
1663
+ node.allocation = allocation;
1664
+ node.sourceRef = node.data.subarray(0);
1665
+ }
1666
+ else {
1667
+ node = new MemoryFileNode(fileMode, this.nextInode++, now, length, allocation, view, (view ?? allocation.data).subarray(0, length));
1668
+ }
1669
+ const prevNlink = parent.cachedNlinkRev === parent.revision ? parent.cachedNlink : (parent.entries.size === 0 ? 2 : undefined);
1670
+ parent.entries.set(name, node);
1671
+ this.totalBytes += length;
1672
+ this.changed(parent, now);
1673
+ if (prevNlink !== undefined) {
1674
+ parent.cachedNlink = prevNlink;
1675
+ parent.cachedNlinkRev = parent.revision;
1676
+ }
1677
+ cache.lastFastFilePath = path;
1678
+ cache.lastFastFileName = name;
1679
+ cache.lastFastFileNode = node;
1680
+ }
1681
+ catch (error) {
1682
+ this.ledger.release(nameBytes, 2);
1683
+ throw error;
1684
+ }
1685
+ }
1686
+ catch (error) {
1687
+ allocation.release();
1688
+ throw error;
1689
+ }
1690
+ return;
1691
+ }
1692
+ const copied = this.bytes(data, syscall, path);
1693
+ try {
1694
+ this.replaceData(current, copied);
1695
+ this.changed(current);
1696
+ cache.lastFastFilePath = path;
1697
+ cache.lastFastFileName = name;
1698
+ cache.lastFastFileNode = current;
1699
+ }
1700
+ catch (error) {
1701
+ copied.release();
1702
+ throw error;
1703
+ }
1704
+ }
1705
+ writeMemoryFilesInDirBatchFast(firstFileName, dirPrefix, fileNames, nameHashes, payloads, totalNameBytes, payloadBytesSum, mode) {
1706
+ const batchCount = fileNames.length;
1707
+ const cache = this._cache;
1708
+ if (batchCount > 0 &&
1709
+ dirPrefix === cache.lastFastDirPrefix &&
1710
+ cache.lastFastDirNode !== undefined &&
1711
+ cache.lastFastDirNode.nlink !== 0 &&
1712
+ (cache.lastFastDirNode.mode & 0o300) === 0o300 &&
1713
+ this.ledger.hasInfiniteRetained &&
1714
+ this.ledger.hasInfiniteFileBytes &&
1715
+ this.ledger.limits.maxBytes === undefined &&
1716
+ sharedFileNodePoolLen >= batchCount) {
1717
+ const parent = cache.lastFastDirNode;
1718
+ const entries = parent.entries;
1719
+ if (entries.size === 1 &&
1720
+ entries._next === 1 &&
1721
+ entries._keys[0] === firstFileName &&
1722
+ 1 + batchCount <= entries._keys.length) {
1723
+ this.ledger.reserve(totalNameBytes, 2 * batchCount, "writeFile", fileNames[batchCount - 1]);
1724
+ this.totalBytes += payloadBytesSum;
1725
+ const now = Date.now();
1726
+ const fileMode = typeModes.file | mode;
1727
+ let ino = this.nextInode;
1728
+ this.nextInode = ino + batchCount;
1729
+ let nextIdx = 1;
1730
+ entries._missKey = "";
1731
+ entries._next = 1 + batchCount;
1732
+ entries.size = 1 + batchCount;
1733
+ const table = entries._table;
1734
+ const mask = table.length - 1;
1735
+ const keys = entries._keys;
1736
+ const vals = entries._vals;
1737
+ for (let k = 0; k < batchCount; k++) {
1738
+ const name = fileNames[k];
1739
+ const data = payloads[k];
1740
+ const node = sharedFileNodePool[--sharedFileNodePoolLen];
1741
+ sharedFileNodePool[sharedFileNodePoolLen] = DUMMY_POOL_FILE_NODE;
1742
+ node.mode = fileMode;
1743
+ node.ino = ino++;
1744
+ if (node.nlink !== 1)
1745
+ node.nlink = 1;
1746
+ if (node.references !== 0)
1747
+ node.references = 0;
1748
+ if (node.revision !== 0)
1749
+ node.revision = 0;
1750
+ node.atimeMs = now;
1751
+ node.mtimeMs = now;
1752
+ node.ctimeMs = now;
1753
+ node.birthtimeMs = now;
1754
+ node.byteLength = data.byteLength;
1755
+ node.view = new Uint8Array(data);
1756
+ node.allocation = DUMMY_POOL_ALLOCATION;
1757
+ node.sourceRef = node.data.subarray(0);
1758
+ const entryIdx = nextIdx++;
1759
+ keys[entryIdx] = name;
1760
+ vals[entryIdx] = node;
1761
+ let slot = nameHashes[k] & mask;
1762
+ while (table[slot] !== -1)
1763
+ slot = (slot + 1) & mask;
1764
+ table[slot] = entryIdx;
1765
+ }
1766
+ this.mutationTick = (this.mutationTick + 1) | 0;
1767
+ parent.revision = parent.revision < 1073741000 ? (parent.revision + batchCount) | 0 : Math.min(Number.MAX_SAFE_INTEGER + 1, parent.revision + batchCount);
1768
+ parent.mtimeMs = parent.ctimeMs = now;
1769
+ cache.lastFastFilePath = "";
1770
+ cache.lastFastFileName = fileNames[batchCount - 1];
1771
+ cache.lastFastFileNode = vals[nextIdx - 1];
1772
+ return;
1773
+ }
1774
+ }
1775
+ for (let k = 0; k < batchCount; k++) {
1776
+ this.writeMemoryFileInDirFast(dirPrefix, fileNames[k], payloads[k], false, mode, nameHashes[k]);
1777
+ }
1778
+ }
1779
+ writeMemoryFileInDirFast(dirPrefix, name, data, append, mode, nameHash) {
1780
+ if (this.ledger.limits.maxPathBytes !== Infinity || this.ledger.limits.maxPathComponents !== Infinity)
1781
+ validatePath(dirPrefix + name, this.ledger.limits);
1782
+ const cache = this._cache;
1783
+ if (!append &&
1784
+ dirPrefix === cache.lastFastDirPrefix &&
1785
+ cache.lastFastDirNode !== undefined &&
1786
+ cache.lastFastDirNode.nlink !== 0 &&
1787
+ (cache.lastFastDirNode.mode & 0o300) === 0o300 &&
1788
+ name.length <= 85 &&
1789
+ this.ledger.hasInfiniteRetained &&
1790
+ this.ledger.hasInfiniteFileBytes &&
1791
+ this.ledger.limits.maxBytes === undefined &&
1792
+ sharedFileNodePoolLen > 0) {
1793
+ const parent = cache.lastFastDirNode;
1794
+ const entries = parent.entries;
1795
+ const existing = nameHash !== undefined ? entries.getForWriteWithHash(name, nameHash) : entries.getForWrite(name);
1796
+ if (existing === undefined && entries._next < entries._keys.length) {
1797
+ this.ledger.reserve(name.length * 2, 2, "writeFile", name);
1798
+ const now = Date.now();
1799
+ const length = data.byteLength;
1800
+ const node = sharedFileNodePool[--sharedFileNodePoolLen];
1801
+ sharedFileNodePool[sharedFileNodePoolLen] = DUMMY_POOL_FILE_NODE;
1802
+ node.mode = typeModes.file | mode;
1803
+ node.ino = this.nextInode++;
1804
+ if (node.nlink !== 1)
1805
+ node.nlink = 1;
1806
+ if (node.references !== 0)
1807
+ node.references = 0;
1808
+ if (node.revision !== 0)
1809
+ node.revision = 0;
1810
+ node.atimeMs = now;
1811
+ node.mtimeMs = now;
1812
+ node.ctimeMs = now;
1813
+ node.birthtimeMs = now;
1814
+ node.byteLength = length;
1815
+ node.view = new Uint8Array(data);
1816
+ node.allocation = DUMMY_POOL_ALLOCATION;
1817
+ node.sourceRef = node.data.subarray(0);
1818
+ const entryIdx = entries._next++;
1819
+ entries._table[entries._missSlot] = entryIdx;
1820
+ entries._keys[entryIdx] = name;
1821
+ entries._vals[entryIdx] = node;
1822
+ entries.size++;
1823
+ entries._missKey = "";
1824
+ this.totalBytes += length;
1825
+ this.mutationTick = (this.mutationTick + 1) | 0;
1826
+ parent.revision = parent.revision < 1073741823 ? (parent.revision + 1) | 0 : Math.min(Number.MAX_SAFE_INTEGER + 1, parent.revision + 1);
1827
+ parent.mtimeMs = parent.ctimeMs = now;
1828
+ cache.lastFastFilePath = "";
1829
+ cache.lastFastFileName = name;
1830
+ cache.lastFastFileNode = node;
1831
+ return;
1832
+ }
1833
+ }
1834
+ const syscall = append ? "appendFile" : "writeFile";
1835
+ try {
1836
+ if (append &&
1837
+ dirPrefix === cache.lastFastDirPrefix &&
1838
+ name === cache.lastFastFileName &&
1839
+ cache.lastFastFileNode !== undefined &&
1840
+ cache.lastFastFileNode.nlink !== 0 &&
1841
+ cache.lastFastDirNode !== undefined &&
1842
+ cache.lastFastDirNode.nlink !== 0 &&
1843
+ (cache.lastFastDirNode.mode & 0o100) !== 0 &&
1844
+ (cache.lastFastFileNode.mode & 0o200) !== 0) {
1845
+ const current = cache.lastFastFileNode;
1846
+ const length = current.byteLength + data.byteLength;
1847
+ this.admitSize(current, length, syscall, name);
1848
+ const growth = length > current.allocation.data.byteLength ? length : 0;
1849
+ this.ledger.check(data.byteLength + growth, 0, syscall, name);
1850
+ this.writeAt(current, data, current.byteLength, syscall, name);
1851
+ return;
1852
+ }
1853
+ let parent = this.root;
1854
+ const cachedDir = cache.lastFastDirNode;
1855
+ if (cachedDir !== undefined &&
1856
+ cachedDir.nlink !== 0 &&
1857
+ (cachedDir.mode & 0o100) !== 0 &&
1858
+ dirPrefix === cache.lastFastDirPrefix) {
1859
+ parent = cachedDir;
1860
+ if (exceedsComponentByteLimit(name))
1861
+ this.fail("ENAMETOOLONG", syscall, name);
1862
+ }
1863
+ else {
1864
+ let start = 1;
1865
+ while (start < dirPrefix.length) {
1866
+ this.permission(parent, 1, syscall, name);
1867
+ const slash = dirPrefix.indexOf("/", start);
1868
+ const seg = slash === -1 ? slicePathSegment(dirPrefix, start, dirPrefix.length) : slicePathSegment(dirPrefix, start, slash);
1869
+ if (exceedsComponentByteLimit(seg))
1870
+ this.fail("ENAMETOOLONG", syscall, name);
1871
+ const next = parent.entries.get(seg);
1872
+ if (!next)
1873
+ this.fail("ENOENT", syscall, name);
1874
+ if (next.type !== "directory")
1875
+ this.fail("ENOTDIR", syscall, name);
1876
+ parent = next;
1877
+ if (slash === -1)
1878
+ break;
1879
+ start = slash + 1;
1880
+ }
1881
+ this.permission(parent, 1, syscall, name);
1882
+ if (exceedsComponentByteLimit(name))
1883
+ this.fail("ENAMETOOLONG", syscall, name);
1884
+ if (dirPrefix.length > 1 && (parent.mode & 0o100) !== 0) {
1885
+ cache.lastFastDirPrefix = dirPrefix;
1886
+ cache.lastFastDirNode = parent;
1887
+ }
1888
+ }
1889
+ const existing = parent.entries.getForWrite ? parent.entries.getForWrite(name) : parent.entries.get(name);
1890
+ if (existing) {
1891
+ if (existing.type !== "file")
1892
+ this.fail("EISDIR", syscall, name);
1893
+ this.permission(existing, 2, syscall, name);
1894
+ }
1895
+ else {
1896
+ this.permission(parent, 3, syscall, name);
1897
+ }
1898
+ const current = existing;
1899
+ const length = (append ? current?.byteLength ?? 0 : 0) + data.byteLength;
1900
+ this.admitSize(current, length, syscall, name);
1901
+ const growth = append && length > (current?.allocation.data.byteLength ?? 0) ? length : 0;
1902
+ const nameBytes = name.length * 2;
1903
+ this.ledger.check(data.byteLength + growth + (current ? 0 : nameBytes), current ? 0 : 2, syscall, name);
1904
+ if (current && append) {
1905
+ this.writeAt(current, data, current.byteLength, syscall, name);
1906
+ cache.lastFastFilePath = "";
1907
+ cache.lastFastFileName = name;
1908
+ cache.lastFastFileNode = current;
1909
+ return;
1910
+ }
1911
+ if (!current) {
1912
+ const zeroCopyConst = this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes && this.ledger.limits.maxBytes === undefined;
1913
+ const capacity = zeroCopyConst ? 0 : (length > 0 && length < 64 && this.ledger.hasInfiniteRetained && this.ledger.hasInfiniteFileBytes ? 64 : length);
1914
+ const allocation = zeroCopyConst ? DUMMY_POOL_ALLOCATION : this.allocate(capacity, syscall, name);
1915
+ try {
1916
+ if (!zeroCopyConst)
1917
+ allocation.data.set(data);
1918
+ this.ledger.reserve(nameBytes, 2, syscall, name);
1919
+ try {
1920
+ const now = Date.now();
1921
+ const fileMode = typeModes.file | mode;
1922
+ const view = zeroCopyConst ? new Uint8Array(data) : (capacity === length ? allocation.data : undefined);
1923
+ let node;
1924
+ if (sharedFileNodePoolLen > 0) {
1925
+ node = sharedFileNodePool[--sharedFileNodePoolLen];
1926
+ sharedFileNodePool[sharedFileNodePoolLen] = DUMMY_POOL_FILE_NODE;
1927
+ }
1928
+ else {
1929
+ node = cache.files.pop();
1930
+ }
1931
+ if (node) {
1932
+ node.mode = fileMode;
1933
+ node.ino = this.nextInode++;
1934
+ if (node.nlink !== 1)
1935
+ node.nlink = 1;
1936
+ if (node.references !== 0)
1937
+ node.references = 0;
1938
+ if (node.revision !== 0)
1939
+ node.revision = 0;
1940
+ node.atimeMs = now;
1941
+ node.mtimeMs = now;
1942
+ node.ctimeMs = now;
1943
+ node.birthtimeMs = now;
1944
+ node.byteLength = length;
1945
+ node.view = view;
1946
+ node.allocation = allocation;
1947
+ node.sourceRef = node.data.subarray(0);
1948
+ }
1949
+ else {
1950
+ node = new MemoryFileNode(fileMode, this.nextInode++, now, length, allocation, view, (view ?? allocation.data).subarray(0, length));
1951
+ }
1952
+ const prevNlink = parent.cachedNlinkRev === parent.revision ? parent.cachedNlink : (parent.entries.size === 0 ? 2 : undefined);
1953
+ parent.entries.set(name, node);
1954
+ this.totalBytes += length;
1955
+ this.changed(parent, now);
1956
+ if (prevNlink !== undefined) {
1957
+ parent.cachedNlink = prevNlink;
1958
+ parent.cachedNlinkRev = parent.revision;
1959
+ }
1960
+ cache.lastFastFilePath = "";
1961
+ cache.lastFastFileName = name;
1962
+ cache.lastFastFileNode = node;
1963
+ }
1964
+ catch (error) {
1965
+ this.ledger.release(nameBytes, 2);
1966
+ throw error;
1967
+ }
1968
+ }
1969
+ catch (error) {
1970
+ allocation.release();
1971
+ throw error;
1972
+ }
1973
+ return;
1974
+ }
1975
+ const copied = this.bytes(data, syscall, name);
1976
+ try {
1977
+ this.replaceData(current, copied);
1978
+ this.changed(current);
1979
+ cache.lastFastFilePath = "";
1980
+ cache.lastFastFileName = name;
1981
+ cache.lastFastFileNode = current;
1982
+ }
1983
+ catch (error) {
1984
+ copied.release();
1985
+ throw error;
1986
+ }
1987
+ }
1988
+ catch (error) {
1989
+ if (error instanceof FsError && error.path === name) {
1990
+ throw new FsError(error.code, {
1991
+ syscall: error.syscall ?? syscall,
1992
+ path: dirPrefix + name,
1993
+ ...(error.dest === undefined ? {} : { dest: error.dest }),
1994
+ });
1995
+ }
1996
+ throw error;
1997
+ }
1998
+ }
1999
+ async readFile(path, options = {}) {
2000
+ options.signal?.throwIfAborted();
2001
+ if (options.maxBytes !== undefined && options.maxBytes !== Infinity)
2002
+ this.integer(options.maxBytes, "readFile", path);
2003
+ const node = this.file(path, "readFile");
2004
+ this.permission(node, 4, "readFile", path);
2005
+ if (options.maxBytes !== undefined && node.data.byteLength > options.maxBytes)
2006
+ this.fail("EFBIG", "readFile", path);
2007
+ node.atimeMs = Date.now();
2008
+ return new Uint8Array(node.data);
2009
+ }
2010
+ expectEntry(node, expected, path, unchanged = true) {
2011
+ if (expected === null) {
2012
+ if (node)
2013
+ this.fail("EAGAIN", "fileStaging", path);
2014
+ return;
2015
+ }
2016
+ if (!node)
2017
+ this.fail("EAGAIN", "fileStaging", path);
2018
+ if (!unchanged) {
2019
+ const currentScope = ownedStores.get(this)?.intact() ? this.identityScope : undefined;
2020
+ if (!expected.identityScope || expected.identityScope !== currentScope
2021
+ || !Number.isSafeInteger(expected.ino) || !Number.isSafeInteger(expected.dev))
2022
+ this.fail("ENOTSUP", "fileStaging", path);
2023
+ if (node.ino !== expected.ino || expected.dev !== 0 || node.type !== expected.type)
2024
+ this.fail("EAGAIN", "fileStaging", path);
2025
+ return;
2026
+ }
2027
+ const current = this.snapshot(node);
2028
+ if (!expected.identityScope || expected.identityScope !== current.identityScope
2029
+ || !Number.isSafeInteger(expected.ino) || !Number.isSafeInteger(expected.dev))
2030
+ this.fail("ENOTSUP", "fileStaging", path);
2031
+ if (current.ino !== expected.ino || current.dev !== expected.dev || current.type !== expected.type)
2032
+ this.fail("EAGAIN", "fileStaging", path);
2033
+ if (!Number.isSafeInteger(expected.revision) || !Number.isSafeInteger(current.revision))
2034
+ this.fail("ENOTSUP", "fileStaging", path);
2035
+ if (current.revision !== expected.revision || current.size !== expected.size || current.mode !== expected.mode
2036
+ || current.nlink !== expected.nlink || current.mtimeMs !== expected.mtimeMs || current.ctimeMs !== expected.ctimeMs)
2037
+ this.fail("EAGAIN", "fileStaging", path);
2038
+ }
2039
+ stagingLocations(staging) {
2040
+ const parent = this.entry(staging.parent.path, "fileStaging");
2041
+ this.expectEntry(parent.node, staging.parent.stat, staging.parent.path, false);
2042
+ if (parent.node.type !== "directory")
2043
+ this.fail("ENOTDIR", "fileStaging", staging.parent.path);
2044
+ const directory = this.entry(staging.directory.path, "fileStaging");
2045
+ this.expectEntry(directory.node, staging.directory.stat, staging.directory.path, false);
2046
+ if (directory.parent !== parent.node || directory.node.type !== "directory" || (directory.node.mode & 0o777) !== 0o700)
2047
+ this.fail("EAGAIN", "fileStaging", staging.directory.path);
2048
+ const file = this.entry(staging.file.path, "fileStaging", true);
2049
+ if (file.parent !== directory.node || !["file", "symlink"].includes(staging.file.stat.type))
2050
+ this.fail("EAGAIN", "fileStaging", staging.file.path);
2051
+ return { directory, file };
2052
+ }
2053
+ async createStagedFile(directoryPath, name, content, options) {
2054
+ options = snapshotStagingCreation(options, directoryPath);
2055
+ options.signal?.throwIfAborted();
2056
+ if (options.retainCleanup === true && this.capabilities.retainedStagingCleanup !== true)
2057
+ this.fail("ENOTSUP", "createStagedFile", directoryPath);
2058
+ if (!name || name === "." || name === ".." || name.includes("/") || name.includes("\0"))
2059
+ this.fail("EINVAL", "createStagedFile", directoryPath);
2060
+ const location = this.entry(directoryPath, "createStagedFile", true);
2061
+ if (location.node)
2062
+ this.fail("EEXIST", "createStagedFile", directoryPath);
2063
+ this.expectEntry(location.parent, options.parent, directoryPath, false);
2064
+ this.permission(location.parent, 3, "createStagedFile", directoryPath);
2065
+ const mode = this.mode(options.mode, content.type === "file" ? 0o666 : 0o777, "createStagedFile", directoryPath);
2066
+ for (const time of [options.atimeMs, options.mtimeMs])
2067
+ if (time !== undefined && !Number.isFinite(time))
2068
+ this.fail("EINVAL", "createStagedFile", directoryPath);
2069
+ if (content.type === "file" && !(content.data instanceof Uint8Array))
2070
+ throw new TypeError("Staged files require Uint8Array data");
2071
+ if (content.type === "file")
2072
+ this.admitSize(undefined, content.data.byteLength, "createStagedFile", directoryPath);
2073
+ if (content.type === "symlink")
2074
+ this.validatePath(content.target, "createStagedFile");
2075
+ const retained = (location.name.length + name.length) * 2 + (content.type === "symlink" ? content.target.length * 2 : 0);
2076
+ const parentPath = location.path.slice(0, location.path.lastIndexOf("/")) || "/";
2077
+ const filePath = `${location.path}/${name}`;
2078
+ const cleanupBytes = options.retainCleanup ? (parentPath.length + location.path.length + filePath.length) * 2 : 0;
2079
+ const cleanupUnits = options.retainCleanup ? 3 : 0;
2080
+ this.ledger.reserve(retained + cleanupBytes, 4 + cleanupUnits, "createStagedFile", directoryPath);
2081
+ let allocation;
2082
+ let directory;
2083
+ let file;
2084
+ try {
2085
+ if (content.type === "file")
2086
+ allocation = this.bytes(content.data, "createStagedFile", directoryPath);
2087
+ directory = this.directory(0o700);
2088
+ file = content.type === "file"
2089
+ ? (() => { const m = this.metadata(typeModes.file | mode); return new MemoryFileNode(m.mode, m.ino, m.atimeMs, allocation.data.byteLength, allocation, allocation.data); })()
2090
+ : { ...this.metadata(typeModes.symlink | mode), type: "symlink", target: content.target };
2091
+ if (options.atimeMs !== undefined)
2092
+ file.atimeMs = options.atimeMs;
2093
+ if (options.mtimeMs !== undefined)
2094
+ file.mtimeMs = options.mtimeMs;
2095
+ directory.entries.set(name, file);
2096
+ location.parent.entries.set(location.name, directory);
2097
+ if (file.type === "file")
2098
+ this.totalBytes += file.data.byteLength;
2099
+ else
2100
+ this.symlinkCount++;
2101
+ }
2102
+ catch (error) {
2103
+ allocation?.release();
2104
+ this.ledger.release(retained + cleanupBytes, 4 + cleanupUnits);
2105
+ throw error;
2106
+ }
2107
+ this.changed(location.parent);
2108
+ const receipt = (path, node) => Object.freeze({ path, stat: Object.freeze(this.snapshot(node)) });
2109
+ const staging = Object.freeze({ parent: receipt(parentPath, location.parent), directory: receipt(location.path, directory), file: receipt(filePath, file) });
2110
+ if (!options.retainCleanup)
2111
+ return staging;
2112
+ // Reservations above include these references before either entry is exposed.
2113
+ location.parent.references++;
2114
+ directory.references++;
2115
+ file.references++;
2116
+ return Object.freeze({ ...staging, ...this.retainStagingCleanup(staging, location.parent, directory, file, location.name, name) });
2117
+ }
2118
+ retainStagingCleanup(staging, parent, directory, file, directoryName, fileName) {
2119
+ // Clear this state on release, so keeping the closed handle does not keep
2120
+ // detached nodes alive outside the Memory ledger.
2121
+ let retained = { parent, directory, file };
2122
+ let expected = staging.file.stat;
2123
+ let writing = true;
2124
+ const receipt = () => ({ ...staging, file: { ...staging.file, stat: expected } });
2125
+ const ownedCleanup = createStagingCleanup(staging.directory.path, options => {
2126
+ options.signal?.throwIfAborted();
2127
+ const state = retained;
2128
+ if (state.parent.nlink === 0 || state.parent.entries.get(directoryName) !== state.directory)
2129
+ this.fail("EAGAIN", "removeStagedFile", staging.directory.path);
2130
+ this.expectEntry(state.parent, staging.parent.stat, staging.parent.path, false);
2131
+ this.expectEntry(state.directory, staging.directory.stat, staging.directory.path, false);
2132
+ if ((state.directory.mode & 0o777) !== 0o700)
2133
+ this.fail("EAGAIN", "removeStagedFile", staging.directory.path);
2134
+ const child = state.directory.entries.get(fileName);
2135
+ if (child && child !== state.file)
2136
+ this.fail("EAGAIN", "removeStagedFile", staging.file.path);
2137
+ this.removeStagingLocations(receipt(), {
2138
+ node: state.directory, parent: state.parent, name: directoryName, path: staging.directory.path,
2139
+ }, { node: child, parent: state.directory, name: fileName, path: staging.file.path });
2140
+ }, () => {
2141
+ const state = retained;
2142
+ retained = undefined;
2143
+ this.releaseReference(state.file, staging.file.path);
2144
+ this.releaseReference(state.directory, staging.directory.path);
2145
+ this.releaseReference(state.parent, staging.parent.path);
2146
+ });
2147
+ const cleanup = Object.freeze({
2148
+ remove: (options) => { writing = false; return ownedCleanup.remove(options); },
2149
+ close: () => { writing = false; return ownedCleanup.close(); },
2150
+ });
2151
+ if (file.type !== "file")
2152
+ return { cleanup };
2153
+ const inspect = (options) => {
2154
+ options.signal?.throwIfAborted();
2155
+ if (!retained || !writing)
2156
+ this.fail("EBADF", "stagedWrite", staging.file.path);
2157
+ const location = this.stagingLocations(receipt());
2158
+ if (location.file.node !== retained.file)
2159
+ this.fail("EAGAIN", "stagedWrite", staging.file.path);
2160
+ this.expectEntry(retained.file, expected, staging.file.path);
2161
+ this.permission(retained.parent, 3, "stagedWrite", staging.parent.path);
2162
+ this.permission(retained.directory, 3, "stagedWrite", staging.directory.path);
2163
+ return retained.file;
2164
+ };
2165
+ return { cleanup, writer: Object.freeze({
2166
+ write: async (bytes, options = {}) => {
2167
+ const node = inspect(options);
2168
+ if (!(bytes instanceof Uint8Array))
2169
+ throw new TypeError("Staged writes require Uint8Array data");
2170
+ this.writeAt(node, bytes, node.byteLength, "stagedWrite", staging.file.path);
2171
+ expected = Object.freeze(this.snapshot(node));
2172
+ },
2173
+ finish: async (options = {}) => {
2174
+ const node = inspect(options);
2175
+ this.changed(node);
2176
+ // changed updates modification time; archive creation metadata is final.
2177
+ node.atimeMs = staging.file.stat.atimeMs;
2178
+ node.mtimeMs = staging.file.stat.mtimeMs;
2179
+ writing = false;
2180
+ expected = Object.freeze(this.snapshot(node));
2181
+ return expected;
2182
+ },
2183
+ }) };
2184
+ }
2185
+ async prepareDirectoryAncestry(ancestors, options = {}) {
2186
+ const entries = snapshotDirectoryAncestry(ancestors);
2187
+ const controls = options.signal === undefined ? {} : { signal: options.signal };
2188
+ controls.signal?.throwIfAborted();
2189
+ return () => this.verifyDirectoryAncestry(entries, controls);
2190
+ }
2191
+ async prepareStagingResolution(path, options = {}) {
2192
+ const followFinal = options.followFinalSymlink === true;
2193
+ const controls = options.signal === undefined ? {} : { signal: options.signal };
2194
+ controls.signal?.throwIfAborted();
2195
+ this.validatePath(path, "prepareStagingResolution");
2196
+ if (!path.startsWith("/") || normalizePath(path) !== path)
2197
+ this.fail("EINVAL", "prepareStagingResolution", path);
2198
+ const traversed = [];
2199
+ const location = this.resolve(path, "prepareStagingResolution", { followFinal, allowMissing: true, resolutionSteps: traversed });
2200
+ if (location.node && location.node.type !== "file")
2201
+ this.fail("ENOTSUP", "prepareStagingResolution", path);
2202
+ const parentPath = location.path.slice(0, location.path.lastIndexOf("/")) || "/";
2203
+ const ancestors = snapshotDirectoryAncestry(directoryAncestryPaths(parentPath).map(entryPath => ({
2204
+ path: entryPath, stat: this.snapshot(this.entry(entryPath, "prepareStagingResolution").node),
2205
+ })));
2206
+ const steps = traversed.map(entry => ({ ...entry, stat: { ...entry.stat } }));
2207
+ const canonical = location.path;
2208
+ const destination = location.node ? this.snapshot(location.node) : null;
2209
+ const validate = () => {
2210
+ controls.signal?.throwIfAborted();
2211
+ const currentSteps = [];
2212
+ let current;
2213
+ try {
2214
+ current = this.resolve(path, "verifyStagingResolution", { followFinal, allowMissing: true, resolutionSteps: currentSteps });
2215
+ }
2216
+ catch (error) {
2217
+ if (error instanceof FsError && ["ENOENT", "ENOTDIR", "ELOOP"].includes(error.code))
2218
+ this.fail("EAGAIN", "verifyStagingResolution", path);
2219
+ throw error;
2220
+ }
2221
+ if (current.path !== canonical || steps.length !== currentSteps.length)
2222
+ this.fail("EAGAIN", "verifyStagingResolution", path);
2223
+ for (const [index, before] of steps.entries()) {
2224
+ const after = currentSteps[index];
2225
+ if (before.path !== after.path || before.linkTarget !== after.linkTarget || before.stat.type !== after.stat.type
2226
+ || compareIdentity(before.stat, after.stat) !== "same"
2227
+ || before.stat.type !== "directory" && ["revision", "size", "mode", "nlink", "mtimeMs", "ctimeMs"].some(field => before.stat[field] !== after.stat[field])) {
2228
+ this.fail("EAGAIN", "verifyStagingResolution", before.path);
2229
+ }
2230
+ }
2231
+ this.expectEntry(current.node, destination, path);
2232
+ return this.verifyDirectoryAncestry(ancestors, controls);
2233
+ };
2234
+ return snapshotStagingResolution({ path: canonical, parent: this.snapshot(location.parent), destination, ancestors, traversed: steps, validate });
2235
+ }
2236
+ verifyDirectoryAncestry(ancestors, options) {
2237
+ const entries = snapshotDirectoryAncestry(ancestors);
2238
+ options.signal?.throwIfAborted();
2239
+ let node = this.root;
2240
+ for (const [index, expected] of entries.entries()) {
2241
+ if (index > 0)
2242
+ node = node.entries.get(expected.path.slice(expected.path.lastIndexOf("/") + 1));
2243
+ if (node?.type !== "directory")
2244
+ this.fail("EAGAIN", "verifyDirectoryAncestry", expected.path);
2245
+ this.expectEntry(node, expected.stat, expected.path, false);
2246
+ this.permission(node, 1, "verifyDirectoryAncestry", expected.path);
2247
+ }
2248
+ return true;
2249
+ }
2250
+ async publishStagedFile(receipt, destination, options) {
2251
+ const signal = options.signal;
2252
+ const preserveIdentity = options.preserveIdentity === true;
2253
+ const guard = options.commitGuard;
2254
+ const ancestors = options.ancestors === undefined ? undefined : snapshotDirectoryAncestry(options.ancestors);
2255
+ const snapshot = (entry) => ({ path: entry.path, stat: { ...entry.stat } });
2256
+ const staging = { parent: snapshot(receipt.parent), directory: snapshot(receipt.directory), file: snapshot(receipt.file) };
2257
+ const parent = { ...options.parent };
2258
+ const expected = options.destination === null ? null : { ...options.destination };
2259
+ const parentPath = destination.slice(0, destination.lastIndexOf("/")) || "/";
2260
+ if (ancestors && ancestors.at(-1)?.path !== parentPath)
2261
+ this.fail("EINVAL", "publishStagedFile", destination);
2262
+ const controls = signal === undefined ? {} : { signal };
2263
+ signal?.throwIfAborted();
2264
+ if (guard !== undefined)
2265
+ runStagingGuard(guard);
2266
+ signal?.throwIfAborted();
2267
+ // All inputs were copied before the guard. Neither outer validation nor
2268
+ // these local checks yield before the stock rename commits.
2269
+ if (ancestors)
2270
+ runStagingGuard(() => this.verifyDirectoryAncestry(ancestors, controls));
2271
+ const { directory, file } = this.stagingLocations(staging);
2272
+ this.expectEntry(file.node, staging.file.stat, staging.file.path);
2273
+ const target = this.entry(destination, "publishStagedFile", true);
2274
+ this.expectEntry(target.parent, parent, destination, false);
2275
+ this.expectEntry(target.node, expected, destination);
2276
+ if (target.parent === directory.node || target.node === directory.node || target.node === file.node)
2277
+ this.fail("EINVAL", "publishStagedFile", destination);
2278
+ if (target.node && target.node.type !== "file")
2279
+ this.fail("EAGAIN", "publishStagedFile", destination);
2280
+ if (preserveIdentity) {
2281
+ if (this.capabilities.atomicStagedFileMutation !== true)
2282
+ this.fail("ENOTSUP", "publishStagedFile", destination);
2283
+ if (file.node?.type !== "file" || target.node?.type !== "file" || expected === null)
2284
+ this.fail("EINVAL", "publishStagedFile", destination);
2285
+ this.permission(file.parent, 3, "publishStagedFile", staging.file.path);
2286
+ this.permission(target.parent, 3, "publishStagedFile", destination);
2287
+ this.permission(target.node, 2, "publishStagedFile", destination);
2288
+ // Provider-owned storage is copied directly, without assembling an archive
2289
+ // in caller memory. Preserve retained staging readers and independent writes.
2290
+ this.admitSize(target.node, file.node.byteLength, "publishStagedFile", destination);
2291
+ const allocation = this.allocate(file.node.byteLength, "publishStagedFile", destination);
2292
+ try {
2293
+ for (let offset = 0; offset < file.node.byteLength; offset += 65536) {
2294
+ allocation.data.set(file.node.data.subarray(offset, offset + 65536), offset);
2295
+ }
2296
+ }
2297
+ catch (error) {
2298
+ allocation.release();
2299
+ throw error;
2300
+ }
2301
+ // No awaits or overridable operations occur between admission and commit.
2302
+ const now = Date.now();
2303
+ this.replaceData(target.node, allocation);
2304
+ this.changed(target.node, now);
2305
+ target.node.atimeMs = file.node.atimeMs;
2306
+ target.node.mtimeMs = file.node.mtimeMs;
2307
+ file.parent.entries.delete(file.name);
2308
+ this.ledger.release(file.name.length * 2, 1);
2309
+ file.node.nlink--;
2310
+ file.node.ctimeMs = now;
2311
+ file.node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, file.node.revision + 1);
2312
+ this.releaseNode(file.node);
2313
+ this.changed(file.parent, now);
2314
+ memoryCaches.get(this.ledger).clearWrites();
2315
+ return;
2316
+ }
2317
+ return MemoryFileSystem.prototype.rename.call(this, staging.file.path, destination, { ...controls, noReplace: expected === null });
2318
+ }
2319
+ async publishStagedFileSet(receipt, destination, options) {
2320
+ if (options.preserveIdentity)
2321
+ this.fail("ENOTSUP", "publishStagedFileSet", destination);
2322
+ const signal = options.signal;
2323
+ const guard = options.commitGuard;
2324
+ const ancestors = options.ancestors === undefined ? undefined : snapshotDirectoryAncestry(options.ancestors);
2325
+ const snapshot = (entry) => ({ path: entry.path, stat: { ...entry.stat } });
2326
+ const staging = { parent: snapshot(receipt.parent), directory: snapshot(receipt.directory), file: snapshot(receipt.file) };
2327
+ const parent = { ...options.parent };
2328
+ const expected = options.destination === null ? null : { ...options.destination };
2329
+ const companions = options.companions.map(entry => ({ path: entry.path, expected: entry.expected === null ? null : { ...entry.expected }, remove: entry.remove }));
2330
+ const syscall = "publishStagedFileSet";
2331
+ const parentPath = destination.slice(0, destination.lastIndexOf("/")) || "/";
2332
+ const paths = new Set([destination]);
2333
+ const canonical = (path) => path.startsWith("/") && path.slice(1).split("/").every(part => part !== "" && part !== "." && part !== "..");
2334
+ if (!canonical(destination) || ancestors && ancestors.at(-1)?.path !== parentPath)
2335
+ this.fail("EINVAL", syscall, destination);
2336
+ for (const entry of companions) {
2337
+ if (!canonical(entry.path) || paths.has(entry.path) || (entry.path.slice(0, entry.path.lastIndexOf("/")) || "/") !== parentPath)
2338
+ this.fail("EINVAL", syscall, entry.path);
2339
+ paths.add(entry.path);
2340
+ }
2341
+ signal?.throwIfAborted();
2342
+ if (guard !== undefined)
2343
+ runStagingGuard(guard);
2344
+ signal?.throwIfAborted();
2345
+ if (ancestors)
2346
+ this.verifyDirectoryAncestry(ancestors, signal === undefined ? {} : { signal });
2347
+ const { directory, file } = this.stagingLocations(staging);
2348
+ this.expectEntry(file.node, staging.file.stat, staging.file.path);
2349
+ const target = this.entry(destination, syscall, true);
2350
+ this.expectEntry(target.parent, parent, destination, false);
2351
+ this.expectEntry(target.node, expected, destination);
2352
+ const node = file.node;
2353
+ if (node.type !== "file" || target.parent === directory.node || target.node === node)
2354
+ this.fail("EINVAL", syscall, destination);
2355
+ if (target.node && target.node.type !== "file")
2356
+ this.fail("EAGAIN", syscall, destination);
2357
+ this.permission(file.parent, 3, syscall, staging.file.path);
2358
+ this.permission(target.parent, 3, syscall, destination);
2359
+ const retired = [];
2360
+ for (const companion of companions) {
2361
+ const location = this.entry(companion.path, syscall, true);
2362
+ if (location.parent !== target.parent || location.node === node)
2363
+ this.fail("EINVAL", syscall, companion.path);
2364
+ this.expectEntry(location.node, companion.expected, companion.path);
2365
+ if (location.node && location.node.type !== "file")
2366
+ this.fail("EAGAIN", syscall, companion.path);
2367
+ if (companion.remove && location.node)
2368
+ retired.push(location);
2369
+ }
2370
+ const now = Date.now();
2371
+ const published = { ...this.snapshot(node), ctimeMs: now, revision: Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1) };
2372
+ // Admission and all source-set checks precede the single synchronous commit.
2373
+ // No calls to overridable async mutations can interleave a partial result.
2374
+ const nameGrowth = target.node ? 0 : (target.name.length - file.name.length) * 2;
2375
+ this.ledger.reserve(Math.max(0, nameGrowth), 0, syscall, destination);
2376
+ try {
2377
+ target.parent.entries.set(target.name, node);
2378
+ }
2379
+ catch (error) {
2380
+ this.ledger.release(Math.max(0, nameGrowth), 0);
2381
+ throw error;
2382
+ }
2383
+ memoryCaches.get(this.ledger).clearWrites();
2384
+ file.parent.entries.delete(file.name);
2385
+ const unlink = (entry) => {
2386
+ entry.node.nlink--;
2387
+ entry.node.ctimeMs = now;
2388
+ entry.node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, entry.node.revision + 1);
2389
+ this.releaseNode(entry.node);
2390
+ };
2391
+ if (target.node) {
2392
+ this.ledger.release(file.name.length * 2, 1);
2393
+ unlink(target);
2394
+ }
2395
+ else if (nameGrowth < 0)
2396
+ this.ledger.release(-nameGrowth, 0);
2397
+ for (const entry of retired) {
2398
+ entry.parent.entries.delete(entry.name);
2399
+ this.ledger.release(entry.name.length * 2, 1);
2400
+ unlink(entry);
2401
+ }
2402
+ this.changed(file.parent, now);
2403
+ this.changed(target.parent, now);
2404
+ node.ctimeMs = now;
2405
+ node.revision = published.revision;
2406
+ return published;
2407
+ }
2408
+ async removeStagedFile(staging, options = {}) {
2409
+ options.signal?.throwIfAborted();
2410
+ const { directory, file } = this.stagingLocations(staging);
2411
+ this.removeStagingLocations(staging, directory, file);
2412
+ }
2413
+ removeStagingLocations(staging, directory, file) {
2414
+ if (file.node)
2415
+ this.expectEntry(file.node, staging.file.stat, staging.file.path);
2416
+ const node = directory.node;
2417
+ if (node.entries.size !== (file.node ? 1 : 0))
2418
+ this.fail("ENOTEMPTY", "removeStagedFile", staging.directory.path);
2419
+ this.permission(directory.parent, 3, "removeStagedFile", staging.directory.path);
2420
+ this.permission(node, 3, "removeStagedFile", staging.file.path);
2421
+ directory.parent.entries.delete(directory.name);
2422
+ if (file.node) {
2423
+ node.entries.delete(file.name);
2424
+ this.ledger.release(file.name.length * 2, 1);
2425
+ file.node.nlink--;
2426
+ file.node.ctimeMs = Date.now();
2427
+ file.node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, file.node.revision + 1);
2428
+ this.releaseNode(file.node);
2429
+ }
2430
+ this.ledger.release(directory.name.length * 2, 1);
2431
+ node.nlink = 0;
2432
+ node.ctimeMs = Date.now();
2433
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2434
+ this.releaseNode(node);
2435
+ this.changed(directory.parent);
2436
+ }
2437
+ async prepareDirectory(path, options) {
2438
+ options.signal?.throwIfAborted();
2439
+ const location = this.entry(path, "prepareDirectory", true);
2440
+ this.expectEntry(location.parent, options.parent, path, false);
2441
+ this.expectEntry(location.node, options.expected, path, false);
2442
+ const mode = options.mode === undefined ? undefined : this.mode(options.mode, 0, "prepareDirectory", path);
2443
+ for (const time of [options.atimeMs, options.mtimeMs])
2444
+ if (time !== undefined && !Number.isFinite(time))
2445
+ this.fail("EINVAL", "prepareDirectory", path);
2446
+ let node = location.node;
2447
+ if (!node) {
2448
+ this.permission(location.parent, 3, "prepareDirectory", path);
2449
+ node = this.addNode(location.parent, location.name, () => this.directory(mode ?? 0o777), "prepareDirectory", path);
2450
+ }
2451
+ if (node.type !== "directory")
2452
+ this.fail("ENOTDIR", "prepareDirectory", path);
2453
+ if (mode !== undefined) {
2454
+ node.mode = typeModes.directory | mode;
2455
+ memoryCaches.get(this.ledger).clearWrites();
2456
+ }
2457
+ if (options.atimeMs !== undefined)
2458
+ node.atimeMs = options.atimeMs;
2459
+ if (options.mtimeMs !== undefined)
2460
+ node.mtimeMs = options.mtimeMs;
2461
+ node.ctimeMs = Date.now();
2462
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2463
+ return Object.freeze(this.snapshot(node));
2464
+ }
2465
+ async writeFileConditional(path, data, options) {
2466
+ options.signal?.throwIfAborted();
2467
+ const location = this.entry(path, "writeFileConditional", true);
2468
+ this.expectEntry(location.parent, options.parent, path, false);
2469
+ this.expectEntry(location.node, options.expected, path);
2470
+ if (location.node && location.node.type !== "file")
2471
+ this.fail("EINVAL", "writeFileConditional", path);
2472
+ if (options.atimeMs !== undefined)
2473
+ this.integer(options.atimeMs, "writeFileConditional", path);
2474
+ if (options.mtimeMs !== undefined)
2475
+ this.integer(options.mtimeMs, "writeFileConditional", path);
2476
+ const node = this.writeData(path, data, { ...(options.mode === undefined ? {} : { mode: options.mode }), flag: options.append ? "a" : "w" }, "writeFileConditional");
2477
+ if (options.atimeMs !== undefined)
2478
+ node.atimeMs = options.atimeMs;
2479
+ if (options.mtimeMs !== undefined)
2480
+ node.mtimeMs = options.mtimeMs;
2481
+ return Object.freeze(this.snapshot(node));
2482
+ }
2483
+ async removeEntryConditional(path, options) {
2484
+ options.signal?.throwIfAborted();
2485
+ const returnRemainingStat = options.returnRemainingStat === true;
2486
+ const location = this.entry(path, "removeEntryConditional", true);
2487
+ this.expectEntry(location.parent, options.parent, path, false);
2488
+ this.expectEntry(location.node, options.expected, path);
2489
+ const node = location.node;
2490
+ if (this.terminalDot(path))
2491
+ this.fail("EINVAL", "removeEntryConditional", path);
2492
+ if (node === this.root)
2493
+ this.fail("EBUSY", "removeEntryConditional", path);
2494
+ if (node.type !== "file" && node.type !== "symlink" && node.type !== "directory")
2495
+ this.fail("EINVAL", "removeEntryConditional", path);
2496
+ this.permission(location.parent, 3, "removeEntryConditional", path);
2497
+ if (node.type === "directory" && node.entries.size > 0)
2498
+ this.fail("ENOTEMPTY", "removeEntryConditional", path);
2499
+ location.parent.entries.delete(location.name);
2500
+ memoryCaches.get(this.ledger).clearWrites();
2501
+ this.ledger.release(location.name.length * 2, 1);
2502
+ node.nlink--;
2503
+ node.ctimeMs = Date.now();
2504
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2505
+ this.releaseNode(node);
2506
+ this.changed(location.parent);
2507
+ if (returnRemainingStat)
2508
+ return Object.freeze(this.snapshot(node));
2509
+ }
2510
+ async removeFileConditional(path, options) {
2511
+ options.signal?.throwIfAborted();
2512
+ const location = this.entry(path, "removeFileConditional", true);
2513
+ this.expectEntry(location.parent, options.parent, path, false);
2514
+ this.expectEntry(location.node, options.expected, path);
2515
+ const node = location.node;
2516
+ if (node.type !== "file")
2517
+ this.fail("EINVAL", "removeFileConditional", path);
2518
+ this.permission(location.parent, 3, "removeFileConditional", path);
2519
+ location.parent.entries.delete(location.name);
2520
+ memoryCaches.get(this.ledger).clearWrites();
2521
+ this.ledger.release(location.name.length * 2, 1);
2522
+ node.nlink--;
2523
+ node.ctimeMs = Date.now();
2524
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2525
+ this.releaseNode(node);
2526
+ this.changed(location.parent);
2527
+ }
2528
+ async removeTreeConditional(path, options) {
2529
+ options.signal?.throwIfAborted();
2530
+ const location = this.entry(path, "removeTreeConditional", true);
2531
+ this.expectEntry(location.parent, options.parent, path, false);
2532
+ this.expectEntry(location.node, options.expected, path, false);
2533
+ if (location.node?.type !== "directory")
2534
+ this.fail("ENOTDIR", "removeTreeConditional", path);
2535
+ this.removeLocation(location, path, "removeTreeConditional", true);
2536
+ }
2537
+ async writeFile(path, data, options = {}) {
2538
+ options.signal?.throwIfAborted();
2539
+ this.writeData(path, data, options, "writeFile");
2540
+ }
2541
+ async appendFile(path, data, options = {}) {
2542
+ options.signal?.throwIfAborted();
2543
+ this.writeData(path, data, { ...options, flag: "a" }, "appendFile");
2544
+ }
2545
+ async stat(path, options = {}) {
2546
+ options.signal?.throwIfAborted();
2547
+ return this.snapshot(this.resolveNode(path, "stat", true));
2548
+ }
2549
+ async lstat(path, options = {}) {
2550
+ options.signal?.throwIfAborted();
2551
+ const stat = this.snapshot(this.resolveNode(path, "lstat", false));
2552
+ ownedStats.set(stat, { filesystem: this, path, root: this.root });
2553
+ return stat;
2554
+ }
2555
+ async *iterateDirectory(path, options = {}) {
2556
+ options.signal?.throwIfAborted();
2557
+ const root = this.root, node = this.resolveNode(path, "iterateDirectory", true);
2558
+ if (node.type !== "directory")
2559
+ this.fail("ENOTDIR", "iterateDirectory", path);
2560
+ this.permission(node, 4, "iterateDirectory", path);
2561
+ const revision = node.revision, ino = node.ino;
2562
+ const check = () => {
2563
+ options.signal?.throwIfAborted();
2564
+ if (this.root !== root || node.ino !== ino || node.revision !== revision || this.resolveNode(path, "iterateDirectory", true) !== node)
2565
+ this.fail("EBUSY", "iterateDirectory", path);
2566
+ this.permission(node, 4, "iterateDirectory", path);
2567
+ };
2568
+ node.atimeMs = Date.now();
2569
+ for (const [name, entry] of node.entries) {
2570
+ check();
2571
+ yield { name, type: entry.type };
2572
+ }
2573
+ check();
2574
+ }
2575
+ async readdir(path, options = {}) {
2576
+ const limit = directoryEntryLimit(options, path);
2577
+ const node = this.resolveNode(path, "readdir", true);
2578
+ if (node.type !== "directory")
2579
+ this.fail("ENOTDIR", "readdir", path);
2580
+ this.permission(node, 4, "readdir", path);
2581
+ admitDirectoryEntries(node.entries.size, limit, path);
2582
+ node.atimeMs = Date.now();
2583
+ const result = new Array(node.entries.size);
2584
+ let idx = 0;
2585
+ for (const [name, entry] of node.entries) {
2586
+ result[idx++] = { name, type: entry.type };
2587
+ }
2588
+ return result.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
2589
+ }
2590
+ tryMkdirFastSync(path, recursive, mode) {
2591
+ try {
2592
+ this.validatePath(path, "mkdir");
2593
+ const resolvedMode = this.mode(mode, 0o777, "mkdir", path);
2594
+ if (recursive) {
2595
+ const node = this.resolve(path, "mkdir", { createDirectories: resolvedMode }).node;
2596
+ return node.type === "directory";
2597
+ }
2598
+ const location = this.resolve(path.replace(/\/+$/, "") || "/", "mkdir", { allowMissing: true, followFinal: false });
2599
+ if (location.node)
2600
+ return false;
2601
+ this.permission(location.parent, 3, "mkdir", path);
2602
+ this.addNode(location.parent, location.name, () => this.directory(resolvedMode), "mkdir", path);
2603
+ return true;
2604
+ }
2605
+ catch {
2606
+ return false;
2607
+ }
2608
+ }
2609
+ tryRmFastSync(path, recursive, force) {
2610
+ if (activeConditionalMutations.has(this.identityScope))
2611
+ return false;
2612
+ try {
2613
+ let location;
2614
+ try {
2615
+ location = this.entry(path, "rm", false);
2616
+ }
2617
+ catch (error) {
2618
+ if (force && error instanceof FsError && error.code === "ENOENT")
2619
+ return true;
2620
+ return false;
2621
+ }
2622
+ this.removeLocation(location, path, "rm", recursive);
2623
+ return true;
2624
+ }
2625
+ catch {
2626
+ return false;
2627
+ }
2628
+ }
2629
+ mkdir(path, options = {}) {
2630
+ try {
2631
+ options.signal?.throwIfAborted();
2632
+ this.validatePath(path, "mkdir");
2633
+ const mode = this.mode(options.mode, 0o777, "mkdir", path);
2634
+ if (options.recursive) {
2635
+ const node = this.resolve(path, "mkdir", { createDirectories: mode }).node;
2636
+ if (node.type !== "directory")
2637
+ this.fail("EEXIST", "mkdir", path);
2638
+ return resolvedVoid;
2639
+ }
2640
+ const location = this.resolve(path.replace(/\/+$/, "") || "/", "mkdir", { allowMissing: true, followFinal: false });
2641
+ if (location.node)
2642
+ this.fail("EEXIST", "mkdir", path);
2643
+ this.permission(location.parent, 3, "mkdir", path);
2644
+ this.addNode(location.parent, location.name, () => this.directory(mode), "mkdir", path);
2645
+ return resolvedVoid;
2646
+ }
2647
+ catch (error) {
2648
+ return Promise.reject(error);
2649
+ }
2650
+ }
2651
+ async rmdir(path, options = {}) {
2652
+ options.signal?.throwIfAborted();
2653
+ const location = this.entry(path, "rmdir");
2654
+ const node = location.node;
2655
+ if (this.terminalDot(path))
2656
+ this.fail("EINVAL", "rmdir", path);
2657
+ if (node === this.root)
2658
+ this.fail("EBUSY", "rmdir", path);
2659
+ if (node.type !== "directory")
2660
+ this.fail("ENOTDIR", "rmdir", path);
2661
+ this.permission(location.parent, 3, "rmdir", path);
2662
+ if (node.entries.size > 0)
2663
+ this.fail("ENOTEMPTY", "rmdir", path);
2664
+ location.parent.entries.delete(location.name);
2665
+ this.ledger.release(location.name.length * 2, 1);
2666
+ node.nlink = 0;
2667
+ node.ctimeMs = Date.now();
2668
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2669
+ this.releaseNode(node);
2670
+ this.changed(location.parent);
2671
+ }
2672
+ rm(path, options = {}) {
2673
+ try {
2674
+ options.signal?.throwIfAborted();
2675
+ const bound = activeConditionalMutations.get(this.identityScope);
2676
+ const active = bound?.path === path ? bound : undefined;
2677
+ const ancestors = options.ancestors ?? active?.ancestors;
2678
+ const expectedParent = options.parent ?? active?.parent;
2679
+ const expectedNode = options.expected ?? active?.expected;
2680
+ if (ancestors !== undefined)
2681
+ this.verifyDirectoryAncestry(ancestors, options);
2682
+ let location;
2683
+ try {
2684
+ location = this.entry(path, "rm", expectedNode !== undefined || expectedParent !== undefined);
2685
+ }
2686
+ catch (error) {
2687
+ if (options.force && error instanceof FsError && error.code === "ENOENT")
2688
+ return resolvedVoid;
2689
+ throw error;
2690
+ }
2691
+ if (expectedParent !== undefined)
2692
+ this.expectEntry(location.parent, expectedParent, path, false);
2693
+ if (expectedNode !== undefined) {
2694
+ if (options.force && !location.node)
2695
+ return resolvedVoid;
2696
+ this.expectEntry(location.node, expectedNode, path, location.node?.type !== "directory");
2697
+ }
2698
+ this.removeLocation(location, path, "rm", options.recursive === true);
2699
+ return resolvedVoid;
2700
+ }
2701
+ catch (error) {
2702
+ return Promise.reject(error);
2703
+ }
2704
+ }
2705
+ removeLocation(location, path, syscall, recursive, now = Date.now()) {
2706
+ const node = location.node;
2707
+ if (this.terminalDot(path))
2708
+ this.fail("EINVAL", syscall, path);
2709
+ if (node === this.root)
2710
+ this.fail("EBUSY", syscall, path);
2711
+ this.permission(location.parent, 3, syscall, path);
2712
+ if (node.type === "directory" && !recursive)
2713
+ this.fail("EISDIR", syscall, path);
2714
+ const cache = memoryCaches.get(this.ledger);
2715
+ cache.clearWrites();
2716
+ const removed = sharedRemovedScratch;
2717
+ sharedRemovedLen = 1;
2718
+ removed[0] = node;
2719
+ sharedRemovedKeyChars = 0;
2720
+ sharedRemovedKeyEntries = 0;
2721
+ try {
2722
+ for (let index = 0; index < sharedRemovedLen; index++) {
2723
+ const entry = removed[index];
2724
+ if (entry.type === "directory" && entry.entries.size > 0) {
2725
+ this.permission(entry, 7, syscall, path);
2726
+ entry.entries.forEach(collectRemovedChild);
2727
+ }
2728
+ }
2729
+ location.parent.entries.delete(location.name);
2730
+ this.ledger.release((location.name.length + sharedRemovedKeyChars) * 2, 1 + sharedRemovedKeyEntries);
2731
+ const totalRemoved = sharedRemovedLen;
2732
+ for (let i = 0; i < totalRemoved; i++) {
2733
+ const entry = removed[i];
2734
+ removed[i] = DUMMY_POOL_FILE_NODE;
2735
+ if (entry.type === "directory") {
2736
+ entry.entries.clear();
2737
+ }
2738
+ entry.nlink--;
2739
+ if (entry.nlink !== 0 || entry.references !== 0) {
2740
+ entry.ctimeMs = now;
2741
+ entry.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, entry.revision + 1);
2742
+ }
2743
+ this.releaseNode(entry);
2744
+ }
2745
+ }
2746
+ finally {
2747
+ for (let i = 0; i < sharedRemovedLen; i++)
2748
+ removed[i] = DUMMY_POOL_FILE_NODE;
2749
+ sharedRemovedLen = 0;
2750
+ }
2751
+ this.changed(location.parent, now);
2752
+ }
2753
+ unlink(path, options = {}) {
2754
+ // Do not allow an untyped recursive option to widen final-entry removal.
2755
+ return this.rm(path, { ...(options.signal === undefined ? {} : { signal: options.signal }) });
2756
+ }
2757
+ async rename(source, destination, options = {}) {
2758
+ options.signal?.throwIfAborted();
2759
+ try {
2760
+ const origin = this.entry(source, "rename");
2761
+ const target = this.entry(destination, "rename", true);
2762
+ const node = origin.node;
2763
+ if (this.terminalDot(source) || this.terminalDot(destination))
2764
+ this.fail("EINVAL", "rename", source, destination);
2765
+ if (node === this.root || target.node === this.root)
2766
+ this.fail("EBUSY", "rename", source, destination);
2767
+ if (destination.endsWith("/") && node.type !== "directory")
2768
+ this.fail("ENOTDIR", "rename", source, destination);
2769
+ if (options.noReplace && target.node)
2770
+ this.fail("EEXIST", "rename", source, destination);
2771
+ if (target.node === node)
2772
+ return;
2773
+ if (node.type === "directory" && target.path.startsWith(`${origin.path}/`))
2774
+ this.fail("EINVAL", "rename", source, destination);
2775
+ this.permission(origin.parent, 3, "rename", source);
2776
+ this.permission(target.parent, 3, "rename", destination);
2777
+ if (target.node) {
2778
+ if (node.type === "directory" && target.node.type !== "directory")
2779
+ this.fail("ENOTDIR", "rename", source, destination);
2780
+ if (node.type !== "directory" && target.node.type === "directory")
2781
+ this.fail("EISDIR", "rename", source, destination);
2782
+ if (target.node.type === "directory" && target.node.entries.size > 0)
2783
+ this.fail("ENOTEMPTY", "rename", source, destination);
2784
+ }
2785
+ const nameGrowth = target.node ? 0 : (target.name.length - origin.name.length) * 2;
2786
+ this.ledger.reserve(Math.max(0, nameGrowth), 0, "rename", source);
2787
+ try {
2788
+ target.parent.entries.set(target.name, node);
2789
+ }
2790
+ catch (error) {
2791
+ this.ledger.release(Math.max(0, nameGrowth), 0);
2792
+ throw error;
2793
+ }
2794
+ memoryCaches.get(this.ledger).clearWrites();
2795
+ origin.parent.entries.delete(origin.name);
2796
+ if (target.node) {
2797
+ this.ledger.release(origin.name.length * 2, 1);
2798
+ target.node.nlink--;
2799
+ target.node.ctimeMs = Date.now();
2800
+ target.node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, target.node.revision + 1);
2801
+ this.releaseNode(target.node);
2802
+ }
2803
+ else if (nameGrowth < 0)
2804
+ this.ledger.release(-nameGrowth, 0);
2805
+ this.changed(origin.parent);
2806
+ this.changed(target.parent);
2807
+ node.ctimeMs = Date.now();
2808
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2809
+ }
2810
+ catch (error) {
2811
+ if (error instanceof FsError)
2812
+ throw new FsError(error.code, { syscall: "rename", path: source, dest: destination, cause: error });
2813
+ throw error;
2814
+ }
2815
+ }
2816
+ async copyFile(source, destination, options = {}) {
2817
+ options.signal?.throwIfAborted();
2818
+ try {
2819
+ const origin = this.file(source, "copyFile");
2820
+ this.permission(origin, 4, "copyFile", source);
2821
+ const target = this.resolve(destination, "copyFile", { followFinal: !options.exclusive, allowMissing: true });
2822
+ if (target.node && options.exclusive)
2823
+ this.fail("EEXIST", "copyFile", source, destination);
2824
+ if (target.node === origin)
2825
+ this.fail("EINVAL", "copyFile", source, destination);
2826
+ const node = this.writeData(destination, origin.data, { mode: origin.mode & 0o7777, flag: options.exclusive ? "wx" : "w" }, "copyFile");
2827
+ node.mode = origin.mode;
2828
+ origin.atimeMs = Date.now();
2829
+ }
2830
+ catch (error) {
2831
+ if (error instanceof FsError)
2832
+ throw new FsError(error.code, { syscall: "copyFile", path: source, dest: destination, cause: error });
2833
+ throw error;
2834
+ }
2835
+ }
2836
+ async realpath(path, options = {}) {
2837
+ options.signal?.throwIfAborted();
2838
+ return this.resolve(path, "realpath").path;
2839
+ }
2840
+ access(path, mode = 0, options = {}) {
2841
+ try {
2842
+ options.signal?.throwIfAborted();
2843
+ if (!Number.isInteger(mode) || mode < 0 || mode > 7)
2844
+ this.fail("EINVAL", "access", path);
2845
+ this.permission(this.resolveNode(path, "access", true), mode, "access", path);
2846
+ return resolvedVoid;
2847
+ }
2848
+ catch (error) {
2849
+ return Promise.reject(error);
2850
+ }
2851
+ }
2852
+ async readlink(path, options = {}) {
2853
+ options.signal?.throwIfAborted();
2854
+ const node = this.resolve(path, "readlink", { followFinal: false }).node;
2855
+ if (node.type !== "symlink")
2856
+ this.fail("EINVAL", "readlink", path);
2857
+ return node.target;
2858
+ }
2859
+ async symlink(target, path, options = {}) {
2860
+ options.signal?.throwIfAborted();
2861
+ this.validatePath(target, "symlink");
2862
+ const location = this.resolve(path, "symlink", { followFinal: false, allowMissing: true });
2863
+ if (location.node)
2864
+ this.fail("EEXIST", "symlink", path);
2865
+ this.permission(location.parent, 3, "symlink", path);
2866
+ this.addNode(location.parent, location.name, () => ({
2867
+ ...this.metadata(typeModes.symlink | 0o777), type: "symlink", target,
2868
+ }), "symlink", path, target.length * 2);
2869
+ }
2870
+ async link(existingPath, newPath, options = {}) {
2871
+ options.signal?.throwIfAborted();
2872
+ const node = this.resolve(existingPath, "link", { followFinal: false }).node;
2873
+ if (node.type === "directory")
2874
+ this.fail("EPERM", "link", existingPath, newPath);
2875
+ const target = this.resolve(newPath, "link", { followFinal: false, allowMissing: true });
2876
+ if (target.node)
2877
+ this.fail("EEXIST", "link", existingPath, newPath);
2878
+ this.permission(target.parent, 3, "link", newPath);
2879
+ this.ledger.reserve(target.name.length * 2, 1, "link", newPath);
2880
+ try {
2881
+ target.parent.entries.set(target.name, node);
2882
+ }
2883
+ catch (error) {
2884
+ this.ledger.release(target.name.length * 2, 1);
2885
+ throw error;
2886
+ }
2887
+ node.nlink++;
2888
+ node.ctimeMs = Date.now();
2889
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2890
+ this.changed(target.parent);
2891
+ }
2892
+ async chmod(path, mode, options = {}) {
2893
+ options.signal?.throwIfAborted();
2894
+ const permissions = this.mode(mode, 0, "chmod", path);
2895
+ const bound = activeConditionalMutations.get(this.identityScope);
2896
+ const active = bound?.path === path ? bound : undefined;
2897
+ const conditional = snapshotConditionalChmod(path, active ? { ...active, ...options } : options);
2898
+ const controls = conditional ?? options;
2899
+ const ancestors = conditional?.ancestors;
2900
+ const expectedParent = conditional?.parent;
2901
+ const expectedNode = conditional?.expected;
2902
+ if (conditional?.commitGuard)
2903
+ runStagingGuard(conditional.commitGuard);
2904
+ controls.signal?.throwIfAborted();
2905
+ if (ancestors !== undefined)
2906
+ this.verifyDirectoryAncestry(ancestors, controls);
2907
+ const location = expectedNode !== undefined || expectedParent !== undefined
2908
+ ? this.entry(path, "chmod", true)
2909
+ : this.resolve(path, "chmod");
2910
+ if (expectedParent !== undefined)
2911
+ this.expectEntry(location.parent, expectedParent, path, false);
2912
+ if (expectedNode !== undefined)
2913
+ this.expectEntry(location.node, expectedNode, path, location.node?.type !== "directory");
2914
+ const node = location.node;
2915
+ if (node.type === "directory")
2916
+ memoryCaches.get(this.ledger).clearWrites();
2917
+ node.mode = typeModes[node.type] | permissions;
2918
+ node.ctimeMs = Date.now();
2919
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2920
+ }
2921
+ async utimes(path, atimeMs, mtimeMs, options = {}) {
2922
+ options.signal?.throwIfAborted();
2923
+ if (!Number.isFinite(atimeMs) || !Number.isFinite(mtimeMs))
2924
+ this.fail("EINVAL", "utimes", path);
2925
+ const node = this.resolve(path, "utimes").node;
2926
+ node.atimeMs = atimeMs;
2927
+ node.mtimeMs = mtimeMs;
2928
+ node.ctimeMs = Date.now();
2929
+ node.revision = Math.min(Number.MAX_SAFE_INTEGER + 1, node.revision + 1);
2930
+ }
2931
+ async truncate(path, length = 0, options = {}) {
2932
+ options.signal?.throwIfAborted();
2933
+ this.integer(length, "truncate", path);
2934
+ const node = this.file(path, "truncate");
2935
+ this.permission(node, 2, "truncate", path);
2936
+ this.resizeNode(node, length, "truncate", path);
2937
+ }
2938
+ resizeNode(node, length, syscall, path) {
2939
+ this.admitSize(node, length, syscall, path);
2940
+ const data = this.allocate(length, syscall, path);
2941
+ try {
2942
+ data.data.set(node.data.subarray(0, length));
2943
+ }
2944
+ catch (error) {
2945
+ data.release();
2946
+ throw error;
2947
+ }
2948
+ this.replaceData(node, data);
2949
+ this.changed(node);
2950
+ }
2951
+ async openResizeFile(path, options = {}) {
2952
+ options.signal?.throwIfAborted();
2953
+ if (!stockRetainedResize(this))
2954
+ throw new FsError("ENOTSUP", { syscall: "openResizeFile", path });
2955
+ const location = this.resolve(path, "openResizeFile", { allowMissing: options.create === true, resizeCreate: options.create ?? false });
2956
+ let mode = 0o666;
2957
+ if (location.node) {
2958
+ if (location.node.type !== "file")
2959
+ this.fail("EISDIR", "openResizeFile", path);
2960
+ this.permission(location.node, 2, "openResizeFile", path);
2961
+ }
2962
+ else {
2963
+ this.permission(location.parent, 3, "openResizeFile", path);
2964
+ mode = this.mode(options.mode, mode, "openResizeFile", path);
2965
+ }
2966
+ this.ledger.reserve(path.length * 2, 1, "openResizeFile", path);
2967
+ let node;
2968
+ try {
2969
+ node = this.openWrite(path, {}, "openResizeFile", { location, mode, append: false });
2970
+ node.references++;
2971
+ }
2972
+ catch (error) {
2973
+ this.ledger.release(path.length * 2, 1);
2974
+ throw error;
2975
+ }
2976
+ const snapshot = this.snapshot.bind(this);
2977
+ const integer = this.integer.bind(this);
2978
+ const resizeNode = this.resizeNode.bind(this);
2979
+ const releaseReference = this.releaseReference.bind(this);
2980
+ let closing;
2981
+ const current = (signal, syscall) => {
2982
+ signal?.throwIfAborted();
2983
+ if (!node)
2984
+ throw new FsError("EBADF", { syscall, path });
2985
+ return node;
2986
+ };
2987
+ return {
2988
+ async stat(options = {}) { return snapshot(current(options.signal, "fstat")); },
2989
+ async seekEnd(options = {}) { return BigInt(current(options.signal, "lseek").data.byteLength); },
2990
+ async truncate(length, options = {}) {
2991
+ const file = current(options.signal, "ftruncate");
2992
+ integer(length, "ftruncate", path);
2993
+ resizeNode(file, length, "ftruncate", path);
2994
+ },
2995
+ close() {
2996
+ if (!closing) {
2997
+ const retained = node;
2998
+ node = undefined;
2999
+ closing = Promise.resolve().then(() => { if (retained)
3000
+ releaseReference(retained, path); });
3001
+ }
3002
+ return closing;
3003
+ },
3004
+ };
3005
+ }
3006
+ async openReadFile(path, options = {}) {
3007
+ const signal = options.signal;
3008
+ signal?.throwIfAborted();
3009
+ const allowDirectory = options.allowDirectory === true;
3010
+ signal?.throwIfAborted();
3011
+ const unsupported = () => { throw new FsError("ENOTSUP", { syscall: "openReadFile", path }); };
3012
+ const owner = ownedStores.get(this);
3013
+ if (!owner || Object.getPrototypeOf(this) !== MemoryFileSystem.prototype
3014
+ || Object.getOwnPropertyDescriptor(this, "root")?.value !== owner.root
3015
+ || Object.getOwnPropertyDescriptor(this, "ledger")?.value !== owner.ledger)
3016
+ unsupported();
3017
+ for (const name of ["openReadFile", "readFile", "readStream", "stat", "lstat", "realpath", "access",
3018
+ "file", "resolve", "permission", "validatePath", "fail", "snapshot", "integer", "releaseReference", "releaseNode"]) {
3019
+ const descriptor = Object.getOwnPropertyDescriptor(this, name)
3020
+ ?? Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, name);
3021
+ if (!descriptor || !("value" in descriptor) || descriptor.value !== memoryImplementation[name]?.value)
3022
+ unsupported();
3023
+ }
3024
+ const capabilities = Object.getOwnPropertyDescriptor(this, "capabilities");
3025
+ const retainedRead = capabilities === undefined
3026
+ ? Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, "capabilities")?.get === memoryImplementation.capabilities?.get
3027
+ : capabilities.value?.retainedRead;
3028
+ signal?.throwIfAborted();
3029
+ if (retainedRead !== true)
3030
+ unsupported();
3031
+ const selected = allowDirectory ? this.resolve(path, "openReadFile").node : this.file(path, "openReadFile");
3032
+ if (selected.type !== "file" && selected.type !== "directory")
3033
+ this.fail("EISDIR", "openReadFile", path);
3034
+ let node = selected;
3035
+ this.permission(node, 4, "openReadFile", path);
3036
+ signal?.throwIfAborted();
3037
+ this.ledger.reserve(path.length * 2, 1, "openReadFile", path);
3038
+ node.references++;
3039
+ const snapshot = this.snapshot.bind(this);
3040
+ const integer = this.integer.bind(this);
3041
+ const releaseReference = this.releaseReference.bind(this);
3042
+ let closing;
3043
+ const current = (signal, syscall) => {
3044
+ signal?.throwIfAborted();
3045
+ if (!node)
3046
+ throw new FsError("EBADF", { syscall, path });
3047
+ return node;
3048
+ };
3049
+ return {
3050
+ async stat(options = {}) {
3051
+ return snapshot(current(options.signal, "fstat"));
3052
+ },
3053
+ async seekEnd(options = {}) {
3054
+ const file = current(options.signal, "lseek");
3055
+ return file.type === "directory" ? ext4HtreeEof64 : BigInt(file.data.byteLength);
3056
+ },
3057
+ async read(position, maxBytes, options = {}) {
3058
+ const file = current(options.signal, "read");
3059
+ integer(position, "read", path);
3060
+ integer(maxBytes, "read", path);
3061
+ if (maxBytes === 0 || maxBytes > Number.MAX_SAFE_INTEGER - position) {
3062
+ throw new FsError("EINVAL", { syscall: "read", path });
3063
+ }
3064
+ if (file.type === "directory")
3065
+ throw new FsError("EISDIR", { syscall: "read", path });
3066
+ const bytes = file.data.slice(position, position + maxBytes);
3067
+ file.atimeMs = Date.now();
3068
+ return bytes;
3069
+ },
3070
+ close() {
3071
+ if (node) {
3072
+ releaseReference(node, path);
3073
+ node = undefined;
3074
+ }
3075
+ closing ??= Promise.resolve();
3076
+ return closing;
3077
+ },
3078
+ };
3079
+ }
3080
+ readStream(path, options = {}) {
3081
+ return new MemoryReadStream(this, path, options);
3082
+ }
3083
+ async writeStream(path, source, options = {}) {
3084
+ options.signal?.throwIfAborted();
3085
+ this.validatePath(path, "writeStream");
3086
+ this.ledger.reserve(path.length * 2, 1, "writeStream", path);
3087
+ let node;
3088
+ try {
3089
+ node = this.openWrite(path, options, "writeStream");
3090
+ const guard = options[extractionStreamGuard];
3091
+ node.references++;
3092
+ guard?.(node);
3093
+ const append = options.flag === "a" || options.flag === "ax";
3094
+ let position = 0;
3095
+ if (!append) {
3096
+ this.replaceData(node, new MemoryAllocation(new Uint8Array(), this.ledger));
3097
+ this.changed(node);
3098
+ }
3099
+ for await (const chunk of source) {
3100
+ options.signal?.throwIfAborted();
3101
+ guard?.(node);
3102
+ if (!(chunk instanceof Uint8Array))
3103
+ throw new TypeError("Memory files require Uint8Array data");
3104
+ this.writeAt(node, chunk, append ? node.data.byteLength : position, "writeStream", path);
3105
+ if (!append)
3106
+ position += chunk.byteLength;
3107
+ }
3108
+ options.signal?.throwIfAborted();
3109
+ }
3110
+ finally {
3111
+ if (node)
3112
+ this.releaseReference(node, path);
3113
+ else
3114
+ this.ledger.release(path.length * 2, 1);
3115
+ }
3116
+ }
3117
+ }
3118
+ const memoryImplementation = Object.getOwnPropertyDescriptors(MemoryFileSystem.prototype);
3119
+ const memoryImplementationKeys = Object.keys(memoryImplementation);
3120
+ const memoryImplementationDescriptors = memoryImplementationKeys.map(key => memoryImplementation[key]);
3121
+ const MEMORY_DESCRIPTOR_CAPABILITIES = Object.freeze({
3122
+ noFollow: true, positionedRead: true, positionedWrite: true, truncate: true, synchronization: "volatile", position: true,
3123
+ });
3124
+ const memoryDescriptorGetPosition = async (retained) => retained.position;
3125
+ const memoryDescriptorStat = async (retained) => retained.fs.snapshot(retained.node);
3126
+ const memoryDescriptorRead = async (retained, buffer, position) => {
3127
+ const inode = retained.node;
3128
+ const start = position ?? retained.position;
3129
+ const count = Math.min(buffer.byteLength, Math.max(0, inode.data.byteLength - start));
3130
+ buffer.set(inode.data.subarray(start, start + count));
3131
+ if (position === null)
3132
+ retained.position += count;
3133
+ inode.atimeMs = Date.now();
3134
+ return count;
3135
+ };
3136
+ const memoryDescriptorWrite = async (retained, buffer, position) => {
3137
+ const inode = retained.node;
3138
+ const start = retained.append ? inode.data.byteLength : position ?? retained.position;
3139
+ const end = start + buffer.byteLength;
3140
+ retained.fs.writeAt(inode, buffer, start, "write", retained.path);
3141
+ if (position === null)
3142
+ retained.position = end;
3143
+ return buffer.byteLength;
3144
+ };
3145
+ const memoryDescriptorTruncate = async (retained, length) => {
3146
+ retained.fs.resizeNode(retained.node, length, "ftruncate", retained.path);
3147
+ };
3148
+ const memoryDescriptorSync = async () => { };
3149
+ const memoryDescriptorClose = async (retained) => {
3150
+ const inode = retained.node;
3151
+ retained.node = undefined;
3152
+ retained.fs.releaseReference(inode, retained.path);
3153
+ };
3154
+ const stockDescriptorWriteMethodNames = [
3155
+ "writeStream", "writeFile", "appendFile", "access", "stat", "lstat", "realpath",
3156
+ "openWrite", "prepareWrite", "writeData", "addNode", "replaceData", "releaseReference", "releaseNode",
3157
+ "resolve", "permission", "validatePath", "mode", "bytes", "allocate", "admitSize", "changed", "metadata", "integer", "writeAt", "fail",
3158
+ ];
3159
+ const stockRetainedResizeMethodNames = [
3160
+ "openResizeFile", "truncate", "resizeNode", "snapshot",
3161
+ ];
3162
+ function stockDescriptorWrite(filesystem) {
3163
+ if (!isStockMemoryMethods(filesystem, stockDescriptorWriteMethodNames, true))
3164
+ return false;
3165
+ const owner = ownedStores.get(filesystem);
3166
+ const capDesc = Object.getOwnPropertyDescriptor(filesystem, "capabilities");
3167
+ return (capDesc === undefined && Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, "capabilities")?.get === memoryImplementation.capabilities?.get) || (!!capDesc && "value" in capDesc && capDesc.value === owner.capabilities);
3168
+ }
3169
+ function stockRetainedResize(filesystem) {
3170
+ if (!stockDescriptorWrite(filesystem) || !isStockMemoryMethods(filesystem, stockRetainedResizeMethodNames, false))
3171
+ return false;
3172
+ const owner = ownedStores.get(filesystem);
3173
+ const ledgerDesc = Object.getOwnPropertyDescriptor(filesystem, "ledger");
3174
+ return !!ledgerDesc && "value" in ledgerDesc && ledgerDesc.value === owner.ledger;
3175
+ }
3176
+ export function createMemoryFileSystem(options = {}) {
3177
+ return new MemoryFileSystem(options);
3178
+ }
3179
+ const missingTargetMethodNames = ["realpath", "lstat", "resolve", "permission", "validatePath", "fail", "snapshot"];
3180
+ const deviceFastMethodNames = ["lstat", "readlink", "resolve", "permission", "validatePath", "fail", "snapshot"];
3181
+ const readFileFastMethodNames = ["readFile", "file", "resolve", "permission", "validatePath", "fail", "integer"];
3182
+ const writeFileFastMethodNames = [
3183
+ "writeFile", "appendFile", "writeData", "prepareWrite", "openWrite", "writeAt",
3184
+ "addNode", "replaceData", "resolve", "permission", "validatePath", "mode",
3185
+ "bytes", "allocate", "admitSize", "changed", "metadata", "fail",
3186
+ ];
3187
+ const mkdirFastMethodNames = [
3188
+ "mkdir", "lstat", "stat", "resolve", "permission", "validatePath", "mode",
3189
+ "addNode", "directory", "changed", "fail",
3190
+ ];
3191
+ const rmFastMethodNames = [
3192
+ "rm", "lstat", "stat", "readdir", "entry", "resolve", "removeLocation",
3193
+ "permission", "validatePath", "terminalDot", "releaseNode", "changed", "fail",
3194
+ ];
3195
+ const openRedirectFastMethodNames = [
3196
+ "open", "writeFile", "appendFile", "rename", "writeData", "prepareWrite", "openWrite",
3197
+ "resizeNode", "writeAt", "addNode", "replaceData", "resolve", "permission",
3198
+ "validatePath", "mode", "bytes", "allocate", "admitSize", "changed", "metadata",
3199
+ "releaseReference", "releaseNode", "fail",
3200
+ ];
3201
+ export class MemoryRedirectHandle {
3202
+ constructor(fs, path, node, append) {
3203
+ this.fs = fs;
3204
+ this.path = path;
3205
+ this.node = node;
3206
+ this.append = append;
3207
+ this.position = 0;
3208
+ this.closed = false;
3209
+ }
3210
+ reset(fs, path, node, append) {
3211
+ this.fs = fs;
3212
+ this.path = path;
3213
+ this.node = node;
3214
+ this.append = append;
3215
+ this.position = 0;
3216
+ this.closed = false;
3217
+ }
3218
+ writeRangeSync(src, len, signal) {
3219
+ signal?.throwIfAborted();
3220
+ if (this.closed)
3221
+ throw new FsError("EBADF", { syscall: "write", path: this.path });
3222
+ if (len === 0)
3223
+ return;
3224
+ const pos = this.append ? this.node.byteLength : this.position;
3225
+ const now = Date.now();
3226
+ this.fs.writeAtRange(this.node, src, len, pos, "write", this.path, now);
3227
+ if (!this.append)
3228
+ this.position = pos + len;
3229
+ }
3230
+ writeImmutableSync(immutableData, signal) {
3231
+ signal?.throwIfAborted();
3232
+ if (this.closed)
3233
+ throw new FsError("EBADF", { syscall: "write", path: this.path });
3234
+ const len = immutableData.byteLength;
3235
+ if (len === 0)
3236
+ return;
3237
+ const mem = this.fs;
3238
+ if (!this.append &&
3239
+ this.position === 0 &&
3240
+ this.node.byteLength === 0 &&
3241
+ this.node.allocation === DUMMY_POOL_ALLOCATION &&
3242
+ mem.ledger.hasInfiniteRetained &&
3243
+ mem.ledger.hasInfiniteFileBytes &&
3244
+ mem.ledger.limits.maxBytes === undefined) {
3245
+ const now = Date.now();
3246
+ this.node.byteLength = len;
3247
+ this.node.view = immutableData;
3248
+ this.node.sourceRef = immutableData;
3249
+ this.position = len;
3250
+ mem.totalBytes += len;
3251
+ mem.changed(this.node, now);
3252
+ return;
3253
+ }
3254
+ this.writeRangeSync(immutableData, len, signal);
3255
+ }
3256
+ writeSync(chunk, signal) {
3257
+ this.writeRangeSync(chunk, chunk.byteLength, signal);
3258
+ }
3259
+ close() {
3260
+ if (this.closed)
3261
+ return;
3262
+ this.closed = true;
3263
+ const fs = this.fs;
3264
+ const node = this.node;
3265
+ const path = this.path;
3266
+ this.fs = undefined;
3267
+ this.node = DUMMY_POOL_FILE_NODE;
3268
+ this.path = "";
3269
+ if (node.nlink > 0 && node.references === 1) {
3270
+ node.references = 0;
3271
+ fs.ledger.release(path.length * 2, 1);
3272
+ }
3273
+ else {
3274
+ fs.releaseReference(node, path);
3275
+ }
3276
+ if (redirectHandlePool.handle === undefined) {
3277
+ redirectHandlePool.handle = this;
3278
+ }
3279
+ }
3280
+ }
3281
+ const redirectHandlePool = { handle: undefined };
3282
+ let _lastRedirectSlice1Path = "";
3283
+ let _lastRedirectSlice1Name = "";
3284
+ let _lastFileSlice1Path = "";
3285
+ let _lastFileSlice1Name = "";
3286
+ export function tryOpenMemoryRedirectHandleSync(filesystem, path, append, mode, signal) {
3287
+ const mem = filesystem;
3288
+ const owner = mem._owner ?? ownedStores.get(mem);
3289
+ if (!owner ||
3290
+ mem.symlinkCount !== 0 ||
3291
+ mem.capabilities !== owner.capabilities ||
3292
+ (activeConditionalMutations.size > 0 && activeConditionalMutations.has(mem.identityScope)) ||
3293
+ !isStockMemoryMethods(mem, openRedirectFastMethodNames, false) ||
3294
+ !isCleanAbsolutePath(path) ||
3295
+ path === "/" ||
3296
+ path === "/dev" ||
3297
+ path.startsWith("/dev/")) {
3298
+ return undefined;
3299
+ }
3300
+ signal?.throwIfAborted();
3301
+ validatePath(path, owner.ledger.limits);
3302
+ const validMode = (mode & 0o777) === mode
3303
+ ? mode
3304
+ : mem.mode(mode, 0o666, "open", path);
3305
+ const memInternal = mem;
3306
+ let parent = memInternal.root;
3307
+ let start = 1;
3308
+ let name = "";
3309
+ while (true) {
3310
+ memInternal.permission(parent, 1, "open", path);
3311
+ const slash = path.indexOf("/", start);
3312
+ if (slash === -1) {
3313
+ name = start === 1
3314
+ ? (path === _lastRedirectSlice1Path ? _lastRedirectSlice1Name : (_lastRedirectSlice1Path = path, _lastRedirectSlice1Name = path.slice(1)))
3315
+ : path.slice(start);
3316
+ if (exceedsComponentByteLimit(name))
3317
+ memInternal.fail("ENAMETOOLONG", "open", path);
3318
+ break;
3319
+ }
3320
+ const seg = slicePathSegment(path, start, slash);
3321
+ if (exceedsComponentByteLimit(seg))
3322
+ memInternal.fail("ENAMETOOLONG", "open", path);
3323
+ const next = parent.entries.get(seg);
3324
+ if (!next)
3325
+ memInternal.fail("ENOENT", "open", path);
3326
+ if (next.type !== "directory")
3327
+ memInternal.fail("ENOTDIR", "open", path);
3328
+ parent = next;
3329
+ start = slash + 1;
3330
+ }
3331
+ const existing = parent.entries.getForWrite(name);
3332
+ const ledger = memInternal.ledger;
3333
+ let node;
3334
+ if (existing !== undefined) {
3335
+ if (existing.type !== "file")
3336
+ memInternal.fail("EISDIR", "open", path);
3337
+ memInternal.permission(existing, 2, "open", path);
3338
+ ledger.reserve(path.length * 2, 1, "open", path);
3339
+ node = existing;
3340
+ if (!append) {
3341
+ try {
3342
+ memInternal.resizeNode(node, 0, "open", path);
3343
+ }
3344
+ catch (error) {
3345
+ ledger.release(path.length * 2, 1);
3346
+ throw error;
3347
+ }
3348
+ }
3349
+ node.references++;
3350
+ }
3351
+ else {
3352
+ memInternal.permission(parent, 3, "open", path);
3353
+ const refBytes = path.length * 2;
3354
+ const nameBytes = name.length * 2;
3355
+ if (ledger.hasInfiniteRetained && ledger.hasInfiniteFileBytes) {
3356
+ ledger.reserve(refBytes + nameBytes, 3, "open", path);
3357
+ }
3358
+ else {
3359
+ ledger.reserve(refBytes, 1, "open", path);
3360
+ try {
3361
+ ledger.fileSize(0, "open", path);
3362
+ ledger.reserve(nameBytes, 2, "open", path);
3363
+ }
3364
+ catch (error) {
3365
+ ledger.release(refBytes, 1);
3366
+ throw error;
3367
+ }
3368
+ }
3369
+ const cache = mem._cache;
3370
+ cache.clearWrites();
3371
+ const now = Date.now();
3372
+ const fileMode = typeModes.file | validMode;
3373
+ let newNode;
3374
+ if (sharedFileNodePoolLen > 0) {
3375
+ newNode = sharedFileNodePool[--sharedFileNodePoolLen];
3376
+ sharedFileNodePool[sharedFileNodePoolLen] = DUMMY_POOL_FILE_NODE;
3377
+ }
3378
+ else {
3379
+ newNode = cache.files.pop();
3380
+ }
3381
+ if (newNode) {
3382
+ newNode.mode = fileMode;
3383
+ newNode.ino = memInternal.nextInode++;
3384
+ if (newNode.nlink !== 1)
3385
+ newNode.nlink = 1;
3386
+ newNode.references = 1;
3387
+ if (newNode.revision !== 0)
3388
+ newNode.revision = 0;
3389
+ newNode.atimeMs = now;
3390
+ newNode.mtimeMs = now;
3391
+ newNode.ctimeMs = now;
3392
+ newNode.birthtimeMs = now;
3393
+ newNode.byteLength = 0;
3394
+ newNode.view = EMPTY_ALLOC_BYTES;
3395
+ newNode.allocation = DUMMY_POOL_ALLOCATION;
3396
+ }
3397
+ else {
3398
+ newNode = new MemoryFileNode(fileMode, memInternal.nextInode++, now, 0, DUMMY_POOL_ALLOCATION, EMPTY_ALLOC_BYTES);
3399
+ newNode.references = 1;
3400
+ }
3401
+ const prevNlink = parent.cachedNlinkRev === parent.revision ? parent.cachedNlink : (parent.entries.size === 0 ? 2 : undefined);
3402
+ const entries = parent.entries;
3403
+ if (entries._missKey === name && entries._next < entries._keys.length) {
3404
+ const entryIdx = entries._next++;
3405
+ entries._table[entries._missSlot] = entryIdx;
3406
+ entries._keys[entryIdx] = name;
3407
+ entries._vals[entryIdx] = newNode;
3408
+ entries.size++;
3409
+ entries._missKey = "";
3410
+ }
3411
+ else {
3412
+ entries.set(name, newNode);
3413
+ }
3414
+ mem.mutationTick = (mem.mutationTick + 1) | 0;
3415
+ parent.revision = parent.revision < 1073741823 ? (parent.revision + 1) | 0 : Math.min(Number.MAX_SAFE_INTEGER + 1, parent.revision + 1);
3416
+ parent.mtimeMs = parent.ctimeMs = now;
3417
+ if (prevNlink !== undefined) {
3418
+ parent.cachedNlink = prevNlink;
3419
+ parent.cachedNlinkRev = parent.revision;
3420
+ }
3421
+ node = newNode;
3422
+ }
3423
+ const handle = redirectHandlePool.handle;
3424
+ if (handle !== undefined) {
3425
+ redirectHandlePool.handle = undefined;
3426
+ handle.reset(mem, path, node, append);
3427
+ return handle;
3428
+ }
3429
+ return new MemoryRedirectHandle(mem, path, node, append);
3430
+ }
3431
+ export function utf8ByteLength(value) {
3432
+ let bytes = 0;
3433
+ for (let i = 0; i < value.length; i++) {
3434
+ const code = value.charCodeAt(i);
3435
+ if (code < 0x80)
3436
+ bytes += 1;
3437
+ else if (code < 0x800)
3438
+ bytes += 2;
3439
+ else if (code >= 0xd800 && code <= 0xdbff && i + 1 < value.length && value.charCodeAt(i + 1) >= 0xdc00 && value.charCodeAt(i + 1) <= 0xdfff) {
3440
+ bytes += 4;
3441
+ i++;
3442
+ }
3443
+ else
3444
+ bytes += 3;
3445
+ }
3446
+ return bytes;
3447
+ }
3448
+ function exceedsComponentByteLimit(value) {
3449
+ return value.length > 85 && (value.length > 255 || utf8ByteLength(value) > 255);
3450
+ }
3451
+ export function isCleanAbsolutePath(path) {
3452
+ const len = path.length;
3453
+ if (len <= 1 || len > 65536 || path.charCodeAt(0) !== 47 || path.charCodeAt(len - 1) === 47)
3454
+ return false;
3455
+ let segStart = 1;
3456
+ let components = 1;
3457
+ for (let i = 1; i < len; i++) {
3458
+ const c = path.charCodeAt(i);
3459
+ if (c === 0)
3460
+ return false;
3461
+ if (c === 47) {
3462
+ const segLen = i - segStart;
3463
+ if (segLen === 0)
3464
+ return false;
3465
+ if (segLen === 1 && path.charCodeAt(segStart) === 46)
3466
+ return false;
3467
+ if (segLen === 2 && path.charCodeAt(segStart) === 46 && path.charCodeAt(segStart + 1) === 46)
3468
+ return false;
3469
+ if (++components > 256)
3470
+ return false;
3471
+ segStart = i + 1;
3472
+ }
3473
+ }
3474
+ const lastLen = len - segStart;
3475
+ if (lastLen === 1 && path.charCodeAt(segStart) === 46)
3476
+ return false;
3477
+ if (lastLen === 2 && path.charCodeAt(segStart) === 46 && path.charCodeAt(segStart + 1) === 46)
3478
+ return false;
3479
+ return true;
3480
+ }
3481
+ export function tryResolveMemoryDevicePath(filesystem, path, resizeCreate) {
3482
+ const mem = filesystem;
3483
+ if (!ownedStores.has(mem) || mem.symlinkCount !== 0 || !isStockMemoryMethods(mem, deviceFastMethodNames, false))
3484
+ return undefined;
3485
+ validatePath(path, ownedStores.get(mem).ledger.limits);
3486
+ if (!isCleanAbsolutePath(path) || path === "/dev" || path.startsWith("/dev/"))
3487
+ return undefined;
3488
+ let current = mem.root;
3489
+ let start = 1;
3490
+ while (true) {
3491
+ if (((current.mode >> 6) & 1) !== 1)
3492
+ return undefined;
3493
+ const slash = path.indexOf("/", start);
3494
+ if (slash === -1) {
3495
+ const name = slicePathSegment(path, start, path.length);
3496
+ if (exceedsComponentByteLimit(name))
3497
+ return undefined;
3498
+ if (resizeCreate === false && !current.entries.has(name))
3499
+ return undefined;
3500
+ return path;
3501
+ }
3502
+ const name = slicePathSegment(path, start, slash);
3503
+ if (exceedsComponentByteLimit(name))
3504
+ return undefined;
3505
+ const next = current.entries.get(name);
3506
+ if (!next) {
3507
+ if (resizeCreate !== undefined)
3508
+ return undefined;
3509
+ let remStart = slash + 1;
3510
+ while (true) {
3511
+ const nextSlash = path.indexOf("/", remStart);
3512
+ const seg = nextSlash === -1 ? slicePathSegment(path, remStart, path.length) : slicePathSegment(path, remStart, nextSlash);
3513
+ if (exceedsComponentByteLimit(seg))
3514
+ return undefined;
3515
+ if (nextSlash === -1)
3516
+ return path;
3517
+ remStart = nextSlash + 1;
3518
+ }
3519
+ }
3520
+ if (next.type !== "directory")
3521
+ return undefined;
3522
+ current = next;
3523
+ start = slash + 1;
3524
+ }
3525
+ }
3526
+ const cachedMethodValuesMap = /* @__PURE__ */ new WeakMap();
3527
+ function getExpectedMethodValues(names) {
3528
+ let vals = cachedMethodValuesMap.get(names);
3529
+ if (!vals) {
3530
+ vals = names.map(name => memoryImplementation[name]?.value);
3531
+ cachedMethodValuesMap.set(names, vals);
3532
+ }
3533
+ return vals;
3534
+ }
3535
+ const hasOwn = Object.prototype.hasOwnProperty;
3536
+ function isStockMemoryMethods(mem, names, checkRootAccessor = true) {
3537
+ const owner = mem?._owner ?? ownedStores.get(mem);
3538
+ if (!owner || Object.getPrototypeOf(mem) !== MemoryFileSystem.prototype || ownedStores.get(mem) !== owner)
3539
+ return false;
3540
+ if (checkRootAccessor) {
3541
+ const rootDesc = Object.getOwnPropertyDescriptor(mem, "root");
3542
+ if (!rootDesc || !("value" in rootDesc) || rootDesc.value !== owner.root)
3543
+ return false;
3544
+ }
3545
+ else if (mem.root !== owner.root) {
3546
+ return false;
3547
+ }
3548
+ const vals = getExpectedMethodValues(names);
3549
+ const proto = MemoryFileSystem.prototype;
3550
+ for (let i = 0; i < names.length; i++) {
3551
+ const name = names[i];
3552
+ const expected = vals[i];
3553
+ if (hasOwn.call(mem, name)) {
3554
+ const descriptor = Object.getOwnPropertyDescriptor(mem, name);
3555
+ if (!descriptor || !("value" in descriptor) || descriptor.value !== expected)
3556
+ return false;
3557
+ }
3558
+ else if (proto[name] !== expected) {
3559
+ return false;
3560
+ }
3561
+ }
3562
+ return true;
3563
+ }
3564
+ let lastReadViewData;
3565
+ let lastReadViewSourceRef;
3566
+ export function getLastReadMemoryFileSourceRef(view) {
3567
+ const ref = view === lastReadViewData?.deref() ? lastReadViewSourceRef?.deref() : undefined;
3568
+ lastReadViewData = undefined;
3569
+ lastReadViewSourceRef = undefined;
3570
+ return ref;
3571
+ }
3572
+ export function tryReadMemoryFileViewSync(filesystem, path, maxBytes, signal, captureSourceRef = false, beforeRead) {
3573
+ // A capture belongs only to the most recent read, including failed/fallback reads.
3574
+ lastReadViewData = undefined;
3575
+ lastReadViewSourceRef = undefined;
3576
+ const mem = filesystem;
3577
+ if (mem._owner === undefined || !isStockMemoryMethods(mem, readFileFastMethodNames, false))
3578
+ return undefined;
3579
+ signal?.throwIfAborted();
3580
+ beforeRead?.();
3581
+ if (maxBytes !== undefined && maxBytes !== Infinity)
3582
+ mem.integer(maxBytes, "readFile", path);
3583
+ const node = mem.file(path, "readFile");
3584
+ mem.permission(node, 4, "readFile", path);
3585
+ const data = node.data;
3586
+ if (maxBytes !== undefined && data.byteLength > maxBytes)
3587
+ mem.fail("EFBIG", "readFile", path);
3588
+ node.atimeMs = Date.now();
3589
+ if (captureSourceRef && node.revision === 0) {
3590
+ lastReadViewData = new WeakRef(data);
3591
+ lastReadViewSourceRef = node.sourceRef === undefined ? undefined : new WeakRef(node.sourceRef);
3592
+ }
3593
+ return data;
3594
+ }
3595
+ let segCache0 = "";
3596
+ let segCache1 = "";
3597
+ let segCache2 = "";
3598
+ let segCache3 = "";
3599
+ let segCacheCursor = 0;
3600
+ function slicePathSegment(path, start, end) {
3601
+ const len = end - start;
3602
+ if (len <= 0)
3603
+ return "";
3604
+ if (len === 1)
3605
+ return String.fromCharCode(path.charCodeAt(start));
3606
+ if (len <= 16) {
3607
+ const c0 = path.charCodeAt(start);
3608
+ if (segCache0.length === len && segCache0.charCodeAt(0) === c0) {
3609
+ let ok = true;
3610
+ for (let i = 1; i < len; i++)
3611
+ if (path.charCodeAt(start + i) !== segCache0.charCodeAt(i)) {
3612
+ ok = false;
3613
+ break;
3614
+ }
3615
+ if (ok)
3616
+ return segCache0;
3617
+ }
3618
+ if (segCache1.length === len && segCache1.charCodeAt(0) === c0) {
3619
+ let ok = true;
3620
+ for (let i = 1; i < len; i++)
3621
+ if (path.charCodeAt(start + i) !== segCache1.charCodeAt(i)) {
3622
+ ok = false;
3623
+ break;
3624
+ }
3625
+ if (ok)
3626
+ return segCache1;
3627
+ }
3628
+ if (segCache2.length === len && segCache2.charCodeAt(0) === c0) {
3629
+ let ok = true;
3630
+ for (let i = 1; i < len; i++)
3631
+ if (path.charCodeAt(start + i) !== segCache2.charCodeAt(i)) {
3632
+ ok = false;
3633
+ break;
3634
+ }
3635
+ if (ok)
3636
+ return segCache2;
3637
+ }
3638
+ if (segCache3.length === len && segCache3.charCodeAt(0) === c0) {
3639
+ let ok = true;
3640
+ for (let i = 1; i < len; i++)
3641
+ if (path.charCodeAt(start + i) !== segCache3.charCodeAt(i)) {
3642
+ ok = false;
3643
+ break;
3644
+ }
3645
+ if (ok)
3646
+ return segCache3;
3647
+ }
3648
+ const sliced = path.slice(start, end);
3649
+ const slot = segCacheCursor;
3650
+ segCacheCursor = (slot + 1) & 3;
3651
+ if (slot === 0)
3652
+ segCache0 = sliced;
3653
+ else if (slot === 1)
3654
+ segCache1 = sliced;
3655
+ else if (slot === 2)
3656
+ segCache2 = sliced;
3657
+ else
3658
+ segCache3 = sliced;
3659
+ return sliced;
3660
+ }
3661
+ return path.slice(start, end);
3662
+ }
3663
+ export function tryGetMemoryDirectoryEntryNamesSync(filesystem, path) {
3664
+ const mem = filesystem;
3665
+ const owner = ownedStores.get(mem);
3666
+ if (!owner || mem.symlinkCount !== 0 || !isStockMemoryMethods(mem, readFileFastMethodNames, false))
3667
+ return undefined;
3668
+ validatePath(path, owner.ledger.limits);
3669
+ const root = mem.root;
3670
+ if (path === "/") {
3671
+ if (((root.mode >> 6) & 5) !== 5)
3672
+ return undefined;
3673
+ return root.entries;
3674
+ }
3675
+ if (!isCleanAbsolutePath(path) || path === "/dev" || path.startsWith("/dev/"))
3676
+ return undefined;
3677
+ const cache = memoryCaches.get(owner.ledger);
3678
+ const fastDir = cache?.lastFastDirNode;
3679
+ const fastPrefix = cache?.lastFastDirPrefix;
3680
+ if (fastDir !== undefined &&
3681
+ fastDir.nlink !== 0 &&
3682
+ ((fastDir.mode >> 6) & 5) === 5 &&
3683
+ fastPrefix !== undefined &&
3684
+ (fastPrefix === path || (fastPrefix.length === path.length + 1 && fastPrefix.charCodeAt(path.length) === 47 && fastPrefix.startsWith(path)))) {
3685
+ return fastDir.entries;
3686
+ }
3687
+ let current = root;
3688
+ let start = 1;
3689
+ while (true) {
3690
+ if (((current.mode >> 6) & 1) !== 1)
3691
+ return undefined;
3692
+ const slash = path.indexOf("/", start);
3693
+ if (slash === -1) {
3694
+ const next = current.entries.getSubstr(path, start, path.length);
3695
+ if (!next || next.type !== "directory" || ((next.mode >> 6) & 5) !== 5)
3696
+ return undefined;
3697
+ return next.entries;
3698
+ }
3699
+ const next = current.entries.getSubstr(path, start, slash);
3700
+ if (!next || next.type !== "directory")
3701
+ return undefined;
3702
+ current = next;
3703
+ start = slash + 1;
3704
+ }
3705
+ }
3706
+ export function tryWriteMemoryFileSync(filesystem, path, data, append, mode, signal) {
3707
+ const mem = filesystem;
3708
+ const owner = ownedStores.get(mem);
3709
+ if (!owner ||
3710
+ mem.symlinkCount !== 0 ||
3711
+ mem.capabilities !== owner.capabilities ||
3712
+ !isStockMemoryMethods(mem, writeFileFastMethodNames, false) ||
3713
+ !isCleanAbsolutePath(path) ||
3714
+ path === "/dev" ||
3715
+ path.startsWith("/dev/")) {
3716
+ return false;
3717
+ }
3718
+ signal?.throwIfAborted();
3719
+ mem.writeMemoryFileFast(path, data, append, mode);
3720
+ return true;
3721
+ }
3722
+ export function tryMkdirMemorySync(filesystem, path, recursive, mode, signal, dirPrefixHint) {
3723
+ const mem = filesystem;
3724
+ const owner = ownedStores.get(mem);
3725
+ if (!owner ||
3726
+ mem.symlinkCount !== 0 ||
3727
+ mem.capabilities !== owner.capabilities ||
3728
+ !isStockMemoryMethods(mem, mkdirFastMethodNames, false) ||
3729
+ !isCleanAbsolutePath(path) ||
3730
+ path === "/dev" ||
3731
+ path.startsWith("/dev/")) {
3732
+ return false;
3733
+ }
3734
+ signal?.throwIfAborted();
3735
+ validatePath(path, owner.ledger.limits);
3736
+ const validMode = mem.mode(mode, 0o777, "mkdir", path);
3737
+ if (recursive) {
3738
+ let current = owner.root;
3739
+ let start = 1;
3740
+ while (true) {
3741
+ mem.permission(current, 1, "mkdir", path);
3742
+ const slash = path.indexOf("/", start);
3743
+ const seg = slash === -1 ? slicePathSegment(path, start, path.length) : slicePathSegment(path, start, slash);
3744
+ if (exceedsComponentByteLimit(seg))
3745
+ mem.fail("ENAMETOOLONG", "mkdir", path);
3746
+ let next = current.entries.get(seg);
3747
+ if (!next) {
3748
+ mem.permission(current, 3, "mkdir", path);
3749
+ next = mem.addDirectoryNode(current, seg, validMode, "mkdir", path, Date.now());
3750
+ }
3751
+ else if (next.type !== "directory") {
3752
+ mem.fail(slash === -1 ? "EEXIST" : "ENOTDIR", "mkdir", path);
3753
+ }
3754
+ if (slash === -1) {
3755
+ if (dirPrefixHint !== undefined) {
3756
+ mem._cache.lastFastDirPrefix = dirPrefixHint;
3757
+ mem._cache.lastFastDirNode = next;
3758
+ }
3759
+ break;
3760
+ }
3761
+ current = next;
3762
+ start = slash + 1;
3763
+ }
3764
+ return true;
3765
+ }
3766
+ const location = mem.resolve(path, "mkdir", sharedAllowMissingNoFollowOptions);
3767
+ if (location.node)
3768
+ mem.fail("EEXIST", "mkdir", path);
3769
+ mem.permission(location.parent, 3, "mkdir", path);
3770
+ mem.addDirectoryNode(location.parent, location.name, validMode, "mkdir", path, Date.now());
3771
+ return true;
3772
+ }
3773
+ export function tryRmRfMemorySync(filesystem, path, signal) {
3774
+ const mem = filesystem;
3775
+ const owner = ownedStores.get(mem);
3776
+ if (!owner ||
3777
+ mem.symlinkCount !== 0 ||
3778
+ mem.capabilities !== owner.capabilities ||
3779
+ activeConditionalMutations.has(mem.identityScope) ||
3780
+ !isStockMemoryMethods(mem, rmFastMethodNames, false) ||
3781
+ !isCleanAbsolutePath(path) ||
3782
+ path === "/dev" ||
3783
+ path.startsWith("/dev/")) {
3784
+ return false;
3785
+ }
3786
+ signal?.throwIfAborted();
3787
+ validatePath(path, owner.ledger.limits);
3788
+ let current = owner.root;
3789
+ let start = 1;
3790
+ let targetNode;
3791
+ let targetName = "";
3792
+ while (true) {
3793
+ mem.permission(current, 1, "rm", path);
3794
+ const slash = path.indexOf("/", start);
3795
+ if (slash === -1) {
3796
+ targetName = slicePathSegment(path, start, path.length);
3797
+ if (exceedsComponentByteLimit(targetName))
3798
+ mem.fail("ENAMETOOLONG", "rm", path);
3799
+ targetNode = current.entries.get(targetName);
3800
+ if (!targetNode)
3801
+ return true;
3802
+ break;
3803
+ }
3804
+ const seg = slicePathSegment(path, start, slash);
3805
+ if (exceedsComponentByteLimit(seg))
3806
+ mem.fail("ENAMETOOLONG", "rm", path);
3807
+ const next = current.entries.get(seg);
3808
+ if (!next)
3809
+ return true;
3810
+ if (next.type !== "directory")
3811
+ mem.fail("ENOTDIR", "rm", path);
3812
+ current = next;
3813
+ start = slash + 1;
3814
+ }
3815
+ sharedFastLocation.node = targetNode;
3816
+ sharedFastLocation.parent = current;
3817
+ sharedFastLocation.name = targetName;
3818
+ sharedFastLocation.path = path;
3819
+ try {
3820
+ mem.removeLocation(sharedFastLocation, path, "rm", true, Date.now());
3821
+ }
3822
+ finally {
3823
+ sharedFastLocation.node = undefined;
3824
+ sharedFastLocation.parent = DUMMY_POOL_DIR_NODE;
3825
+ sharedFastLocation.name = "";
3826
+ sharedFastLocation.path = "";
3827
+ }
3828
+ return true;
3829
+ }
3830
+ export function tryWriteMemoryFileInDirSync(filesystem, dirPrefix, name, data, append, mode, signal) {
3831
+ const mem = filesystem;
3832
+ const owner = ownedStores.get(mem);
3833
+ if (!owner ||
3834
+ mem.symlinkCount !== 0 ||
3835
+ mem.capabilities !== owner.capabilities ||
3836
+ !isStockMemoryMethods(mem, writeFileFastMethodNames, false) ||
3837
+ name.length === 0 ||
3838
+ name === "." ||
3839
+ name === ".." ||
3840
+ name.indexOf("/") !== -1 ||
3841
+ name.indexOf("\0") !== -1 ||
3842
+ dirPrefix.length + name.length > 65536) {
3843
+ return false;
3844
+ }
3845
+ signal?.throwIfAborted();
3846
+ mem.writeMemoryFileInDirFast(dirPrefix, name, data, append, mode);
3847
+ return true;
3848
+ }
3849
+ const _memHooks = (globalThis.__safeBashMemHooks ??= { protos: new Set(), byProto: new Map() });
3850
+ _memHooks.protos.add(MemoryFileSystem.prototype);
3851
+ _memHooks.byProto.set(MemoryFileSystem.prototype, {
3852
+ tryGetMemoryDirectoryEntryNamesSync,
3853
+ tryReadMemoryFileViewSync,
3854
+ tryResolveMemoryDevicePath,
3855
+ tryOpenMemoryRedirectHandleSync,
3856
+ tryWriteMemoryFileSync,
3857
+ tryMkdirMemorySync,
3858
+ tryRmRfMemorySync,
3859
+ tryWriteMemoryFileInDirSync,
3860
+ });
3861
+ _memHooks.isCleanAbsolutePath = isCleanAbsolutePath;
3862
+ _memHooks.bindConditionalMutation = bindConditionalMutation;