toolcraft 0.0.749 → 0.0.750

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 (374) hide show
  1. package/composition.json +23 -3
  2. package/dist/composition.json +23 -3
  3. package/dist/human-in-loop/approvals-commands.d.ts +1 -1
  4. package/dist/index.d.ts +1 -262
  5. package/dist/index.js +1 -573
  6. package/dist/runtime-platform.d.ts +2 -0
  7. package/dist/runtime-platform.js +2 -0
  8. package/dist/runtime-platform.workerd.d.ts +3 -0
  9. package/dist/runtime-platform.workerd.js +10 -0
  10. package/dist/runtime.d.ts +262 -0
  11. package/dist/runtime.js +576 -0
  12. package/node_modules/@noble/hashes/LICENSE +21 -0
  13. package/node_modules/@noble/hashes/README.md +478 -0
  14. package/node_modules/@noble/hashes/_blake.d.ts +20 -0
  15. package/node_modules/@noble/hashes/_blake.js +59 -0
  16. package/node_modules/@noble/hashes/_md.d.ts +95 -0
  17. package/node_modules/@noble/hashes/_md.js +209 -0
  18. package/node_modules/@noble/hashes/_u64.d.ts +36 -0
  19. package/node_modules/@noble/hashes/_u64.js +77 -0
  20. package/node_modules/@noble/hashes/argon2.d.ts +148 -0
  21. package/node_modules/@noble/hashes/argon2.js +577 -0
  22. package/node_modules/@noble/hashes/blake1.d.ts +162 -0
  23. package/node_modules/@noble/hashes/blake1.js +630 -0
  24. package/node_modules/@noble/hashes/blake2.d.ts +203 -0
  25. package/node_modules/@noble/hashes/blake2.js +573 -0
  26. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  27. package/node_modules/@noble/hashes/blake3.js +310 -0
  28. package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
  29. package/node_modules/@noble/hashes/eskdf.js +225 -0
  30. package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
  31. package/node_modules/@noble/hashes/hkdf.js +152 -0
  32. package/node_modules/@noble/hashes/hmac.d.ts +50 -0
  33. package/node_modules/@noble/hashes/hmac.js +93 -0
  34. package/node_modules/@noble/hashes/index.d.ts +1 -0
  35. package/node_modules/@noble/hashes/index.js +34 -0
  36. package/node_modules/@noble/hashes/legacy.d.ts +107 -0
  37. package/node_modules/@noble/hashes/legacy.js +348 -0
  38. package/node_modules/@noble/hashes/package.json +91 -0
  39. package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
  40. package/node_modules/@noble/hashes/pbkdf2.js +176 -0
  41. package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
  42. package/node_modules/@noble/hashes/scrypt.js +304 -0
  43. package/node_modules/@noble/hashes/sha2.d.ts +176 -0
  44. package/node_modules/@noble/hashes/sha2.js +446 -0
  45. package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
  46. package/node_modules/@noble/hashes/sha3-addons.js +973 -0
  47. package/node_modules/@noble/hashes/sha3.d.ts +208 -0
  48. package/node_modules/@noble/hashes/sha3.js +475 -0
  49. package/node_modules/@noble/hashes/src/_blake.ts +67 -0
  50. package/node_modules/@noble/hashes/src/_md.ts +227 -0
  51. package/node_modules/@noble/hashes/src/_u64.ts +111 -0
  52. package/node_modules/@noble/hashes/src/argon2.ts +693 -0
  53. package/node_modules/@noble/hashes/src/blake1.ts +677 -0
  54. package/node_modules/@noble/hashes/src/blake2.ts +648 -0
  55. package/node_modules/@noble/hashes/src/blake3.ts +344 -0
  56. package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
  57. package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
  58. package/node_modules/@noble/hashes/src/hmac.ts +130 -0
  59. package/node_modules/@noble/hashes/src/index.ts +33 -0
  60. package/node_modules/@noble/hashes/src/legacy.ts +361 -0
  61. package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
  62. package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
  63. package/node_modules/@noble/hashes/src/sha2.ts +486 -0
  64. package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
  65. package/node_modules/@noble/hashes/src/sha3.ts +525 -0
  66. package/node_modules/@noble/hashes/src/utils.ts +978 -0
  67. package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
  68. package/node_modules/@noble/hashes/utils.d.ts +560 -0
  69. package/node_modules/@noble/hashes/utils.js +687 -0
  70. package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
  71. package/node_modules/@noble/hashes/webcrypto.js +228 -0
  72. package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +23 -9
  73. package/node_modules/@poe-code/config-mutations/README.md +2 -0
  74. package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +4 -5
  75. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -4
  76. package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +3 -3
  77. package/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
  78. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +2 -2
  79. package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +3 -6
  80. package/node_modules/@poe-code/config-mutations/dist/types.d.ts +4 -2
  81. package/node_modules/@poe-code/process-runner/README.md +2 -1
  82. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.d.ts +1 -0
  83. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.js +1 -0
  84. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.d.ts +2 -0
  85. package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.js +1 -0
  86. package/node_modules/@poe-code/process-runner/dist/types.d.ts +1 -1
  87. package/node_modules/@poe-code/process-runner/dist/workspace-transfer.d.ts +6 -5
  88. package/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +67 -29
  89. package/node_modules/@poe-code/process-runner/package.json +13 -0
  90. package/node_modules/@poe-code/safe-fs/LICENSE +21 -0
  91. package/node_modules/@poe-code/safe-fs/PROVENANCE.json +428 -0
  92. package/node_modules/@poe-code/safe-fs/README.md +411 -0
  93. package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.d.ts +3 -0
  94. package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.js +171 -0
  95. package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.d.ts +93 -0
  96. package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.js +453 -0
  97. package/node_modules/@poe-code/safe-fs/dist/bridge/index.d.ts +7 -0
  98. package/node_modules/@poe-code/safe-fs/dist/bridge/index.js +19 -0
  99. package/node_modules/@poe-code/safe-fs/dist/bridge/stats.d.ts +4 -0
  100. package/node_modules/@poe-code/safe-fs/dist/bridge/stats.js +37 -0
  101. package/node_modules/@poe-code/safe-fs/dist/bridge/types.d.ts +81 -0
  102. package/node_modules/@poe-code/safe-fs/dist/bridge/types.js +1 -0
  103. package/node_modules/@poe-code/safe-fs/dist/bridge/values.d.ts +6 -0
  104. package/node_modules/@poe-code/safe-fs/dist/bridge/values.js +65 -0
  105. package/node_modules/@poe-code/safe-fs/dist/config/memory.d.ts +3 -0
  106. package/node_modules/@poe-code/safe-fs/dist/config/memory.js +7 -0
  107. package/node_modules/@poe-code/safe-fs/dist/config/real.d.ts +5 -0
  108. package/node_modules/@poe-code/safe-fs/dist/config/real.js +16 -0
  109. package/node_modules/@poe-code/safe-fs/dist/config/registry.d.ts +2 -0
  110. package/node_modules/@poe-code/safe-fs/dist/config/registry.js +15 -0
  111. package/node_modules/@poe-code/safe-fs/dist/config.d.ts +15 -0
  112. package/node_modules/@poe-code/safe-fs/dist/config.js +46 -0
  113. package/node_modules/@poe-code/safe-fs/dist/config.node.d.ts +2 -0
  114. package/node_modules/@poe-code/safe-fs/dist/config.node.js +11 -0
  115. package/node_modules/@poe-code/safe-fs/dist/config.portable.d.ts +3 -0
  116. package/node_modules/@poe-code/safe-fs/dist/config.portable.js +9 -0
  117. package/node_modules/@poe-code/safe-fs/dist/contracts/abort.d.ts +5 -0
  118. package/node_modules/@poe-code/safe-fs/dist/contracts/abort.js +34 -0
  119. package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.d.ts +1 -0
  120. package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.js +9 -0
  121. package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.d.ts +38 -0
  122. package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.js +1 -0
  123. package/node_modules/@poe-code/safe-fs/dist/contracts/errors.d.ts +53 -0
  124. package/node_modules/@poe-code/safe-fs/dist/contracts/errors.js +99 -0
  125. package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.d.ts +379 -0
  126. package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.js +1 -0
  127. package/node_modules/@poe-code/safe-fs/dist/contracts/index.d.ts +6 -0
  128. package/node_modules/@poe-code/safe-fs/dist/contracts/index.js +6 -0
  129. package/node_modules/@poe-code/safe-fs/dist/contracts/io.d.ts +12 -0
  130. package/node_modules/@poe-code/safe-fs/dist/contracts/io.js +321 -0
  131. package/node_modules/@poe-code/safe-fs/dist/contracts/object.d.ts +134 -0
  132. package/node_modules/@poe-code/safe-fs/dist/contracts/object.js +97 -0
  133. package/node_modules/@poe-code/safe-fs/dist/contracts/path.d.ts +3 -0
  134. package/node_modules/@poe-code/safe-fs/dist/contracts/path.js +2 -0
  135. package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.d.ts +21 -0
  136. package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.js +78 -0
  137. package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.d.ts +15 -0
  138. package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.js +162 -0
  139. package/node_modules/@poe-code/safe-fs/dist/core.d.ts +19 -0
  140. package/node_modules/@poe-code/safe-fs/dist/core.js +17 -0
  141. package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.d.ts +10 -0
  142. package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.js +216 -0
  143. package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.d.ts +7 -0
  144. package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.js +19 -0
  145. package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.d.ts +21 -0
  146. package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.js +279 -0
  147. package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.d.ts +59 -0
  148. package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.js +875 -0
  149. package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.d.ts +7 -0
  150. package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.js +250 -0
  151. package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.d.ts +6 -0
  152. package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.js +136 -0
  153. package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.d.ts +3 -0
  154. package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.js +14 -0
  155. package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.d.ts +11 -0
  156. package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.js +13 -0
  157. package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.d.ts +186 -0
  158. package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.js +3771 -0
  159. package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.d.ts +26 -0
  160. package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.js +96 -0
  161. package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.d.ts +13 -0
  162. package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.js +26 -0
  163. package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.d.ts +15 -0
  164. package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.js +144 -0
  165. package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.d.ts +19 -0
  166. package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.js +118 -0
  167. package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.d.ts +6 -0
  168. package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.js +29 -0
  169. package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.d.ts +74 -0
  170. package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.js +1291 -0
  171. package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.d.ts +27 -0
  172. package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.js +287 -0
  173. package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +45 -0
  174. package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +531 -0
  175. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.d.ts +87 -0
  176. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.js +1185 -0
  177. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.d.ts +42 -0
  178. package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.js +558 -0
  179. package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.d.ts +4 -0
  180. package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.js +63 -0
  181. package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.d.ts +12 -0
  182. package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.js +520 -0
  183. package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.d.ts +37 -0
  184. package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.js +208 -0
  185. package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.d.ts +1 -0
  186. package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.js +8 -0
  187. package/node_modules/@poe-code/safe-fs/dist/fs/real/index.d.ts +105 -0
  188. package/node_modules/@poe-code/safe-fs/dist/fs/real/index.js +1259 -0
  189. package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.d.ts +7 -0
  190. package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.js +38 -0
  191. package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.d.ts +130 -0
  192. package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.js +1137 -0
  193. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.d.ts +1 -0
  194. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.js +9 -0
  195. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
  196. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.js +1 -0
  197. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.d.ts +15 -0
  198. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.js +74 -0
  199. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.d.ts +4 -0
  200. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.js +111 -0
  201. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.d.ts +17 -0
  202. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.js +89 -0
  203. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
  204. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.js +76 -0
  205. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
  206. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.js +478 -0
  207. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
  208. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.js +1 -0
  209. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.d.ts +14 -0
  210. package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.js +192 -0
  211. package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.d.ts +8 -0
  212. package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.js +4 -0
  213. package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.d.ts +2 -0
  214. package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.js +11 -0
  215. package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.d.ts +8 -0
  216. package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.js +167 -0
  217. package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.d.ts +48 -0
  218. package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.js +249 -0
  219. package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.d.ts +13 -0
  220. package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.js +400 -0
  221. package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.d.ts +10 -0
  222. package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.js +73 -0
  223. package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.d.ts +103 -0
  224. package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.js +28 -0
  225. package/node_modules/@poe-code/safe-fs/dist/fs/scoped.d.ts +19 -0
  226. package/node_modules/@poe-code/safe-fs/dist/fs/scoped.js +663 -0
  227. package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.d.ts +8 -0
  228. package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.js +115 -0
  229. package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.d.ts +5 -0
  230. package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.js +63 -0
  231. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.d.ts +2 -0
  232. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.js +1 -0
  233. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
  234. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.js +109 -0
  235. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.d.ts +141 -0
  236. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.js +1377 -0
  237. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
  238. package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.js +59 -0
  239. package/node_modules/@poe-code/safe-fs/dist/index.d.ts +25 -0
  240. package/node_modules/@poe-code/safe-fs/dist/index.js +21 -0
  241. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/linux-x64-glibc.node +0 -0
  242. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.d.ts +5 -0
  243. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.mjs +120 -0
  244. package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/manifest.json +46 -0
  245. package/node_modules/@poe-code/safe-fs/dist/node/filesystem.d.ts +19 -0
  246. package/node_modules/@poe-code/safe-fs/dist/node/filesystem.js +30 -0
  247. package/node_modules/@poe-code/safe-fs/dist/node/host.d.ts +3 -0
  248. package/node_modules/@poe-code/safe-fs/dist/node/host.js +78 -0
  249. package/node_modules/@poe-code/safe-fs/dist/node/index.d.ts +3 -0
  250. package/node_modules/@poe-code/safe-fs/dist/node/index.js +2 -0
  251. package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.d.ts +1 -0
  252. package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.js +5 -0
  253. package/node_modules/@poe-code/safe-fs/dist/node/native-seek.d.ts +3 -0
  254. package/node_modules/@poe-code/safe-fs/dist/node/native-seek.js +54 -0
  255. package/node_modules/@poe-code/safe-fs/dist/node/stats.d.ts +1 -0
  256. package/node_modules/@poe-code/safe-fs/dist/node/stats.js +1 -0
  257. package/node_modules/@poe-code/safe-fs/dist/node/values.d.ts +1 -0
  258. package/node_modules/@poe-code/safe-fs/dist/node/values.js +1 -0
  259. package/node_modules/@poe-code/safe-fs/dist/node-host.d.ts +1 -0
  260. package/node_modules/@poe-code/safe-fs/dist/node-host.js +1 -0
  261. package/node_modules/@poe-code/safe-fs/dist/node-unavailable.d.ts +1 -0
  262. package/node_modules/@poe-code/safe-fs/dist/node-unavailable.js +1 -0
  263. package/node_modules/@poe-code/safe-fs/dist/package.json +29 -0
  264. package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.d.ts +1 -0
  265. package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.js +1 -0
  266. package/node_modules/@poe-code/safe-fs/dist/platform/browser.d.ts +26 -0
  267. package/node_modules/@poe-code/safe-fs/dist/platform/browser.js +58 -0
  268. package/node_modules/@poe-code/safe-fs/dist/platform/node-path.d.ts +1 -0
  269. package/node_modules/@poe-code/safe-fs/dist/platform/node-path.js +1 -0
  270. package/node_modules/@poe-code/safe-fs/dist/platform/node.d.ts +26 -0
  271. package/node_modules/@poe-code/safe-fs/dist/platform/node.js +64 -0
  272. package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.d.ts +9 -0
  273. package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.js +17 -0
  274. package/node_modules/@poe-code/safe-fs/dist/python/emscripten.d.ts +15 -0
  275. package/node_modules/@poe-code/safe-fs/dist/python/emscripten.js +357 -0
  276. package/node_modules/@poe-code/safe-fs/dist/python/filesystem.d.ts +51 -0
  277. package/node_modules/@poe-code/safe-fs/dist/python/filesystem.js +243 -0
  278. package/node_modules/@poe-code/safe-fs/dist/python/flags.d.ts +3 -0
  279. package/node_modules/@poe-code/safe-fs/dist/python/flags.js +14 -0
  280. package/node_modules/@poe-code/safe-fs/dist/python/index.d.ts +9 -0
  281. package/node_modules/@poe-code/safe-fs/dist/python/index.js +5 -0
  282. package/node_modules/@poe-code/safe-fs/dist/python/native.d.ts +18 -0
  283. package/node_modules/@poe-code/safe-fs/dist/python/native.js +446 -0
  284. package/node_modules/@poe-code/safe-fs/dist/python/request.d.ts +2 -0
  285. package/node_modules/@poe-code/safe-fs/dist/python/request.js +61 -0
  286. package/node_modules/@poe-code/safe-fs/dist/python/stat.d.ts +8 -0
  287. package/node_modules/@poe-code/safe-fs/dist/python/stat.js +34 -0
  288. package/node_modules/@poe-code/safe-fs/dist/runtime-core.d.ts +27 -0
  289. package/node_modules/@poe-code/safe-fs/dist/runtime-core.js +57 -0
  290. package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.d.ts +16 -0
  291. package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.js +496 -0
  292. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.d.ts +23 -0
  293. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.js +39 -0
  294. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.d.ts +31 -0
  295. package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.js +143 -0
  296. package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.d.ts +19 -0
  297. package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.js +209 -0
  298. package/node_modules/@poe-code/safe-fs/dist/xml.d.ts +1 -0
  299. package/node_modules/@poe-code/safe-fs/dist/xml.js +1 -0
  300. package/node_modules/@poe-code/safe-fs/package.json +189 -0
  301. package/node_modules/@poe-code/task-list/README.md +2 -0
  302. package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +1 -1
  303. package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +11 -4
  304. package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +2 -2
  305. package/node_modules/@poe-code/task-list/dist/backends/utils.js +5 -7
  306. package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +1 -1
  307. package/node_modules/@poe-code/task-list/dist/default-host.d.ts +2 -0
  308. package/node_modules/@poe-code/task-list/dist/default-host.js +2 -0
  309. package/node_modules/@poe-code/task-list/dist/default-host.workerd.d.ts +4 -0
  310. package/node_modules/@poe-code/task-list/dist/default-host.workerd.js +6 -0
  311. package/node_modules/@poe-code/task-list/dist/filesystem.d.ts +3 -0
  312. package/node_modules/@poe-code/task-list/dist/filesystem.js +32 -0
  313. package/node_modules/@poe-code/task-list/dist/move.js +3 -3
  314. package/node_modules/@poe-code/task-list/dist/open.js +2 -5
  315. package/node_modules/@poe-code/task-list/dist/paths.d.ts +12 -0
  316. package/node_modules/@poe-code/task-list/dist/paths.js +7 -0
  317. package/node_modules/@poe-code/task-list/dist/types.d.ts +6 -5
  318. package/node_modules/@poe-code/task-list/package.json +9 -0
  319. package/node_modules/@poe-code/terminal-text/LICENSE +21 -0
  320. package/node_modules/@poe-code/terminal-text/README.md +12 -0
  321. package/node_modules/@poe-code/terminal-text/dist/index.d.ts +2 -0
  322. package/node_modules/@poe-code/terminal-text/dist/index.js +20 -0
  323. package/node_modules/@poe-code/terminal-text/package.json +22 -0
  324. package/node_modules/@poe-code/xml-ast/LICENSE +21 -0
  325. package/node_modules/@poe-code/xml-ast/README.md +28 -0
  326. package/node_modules/@poe-code/xml-ast/dist/index.d.ts +47 -0
  327. package/node_modules/@poe-code/xml-ast/dist/index.js +635 -0
  328. package/node_modules/@poe-code/xml-ast/package.json +25 -0
  329. package/node_modules/auth-store/README.md +35 -0
  330. package/node_modules/auth-store/dist/index.browser.d.ts +4 -0
  331. package/node_modules/auth-store/dist/index.browser.js +2 -0
  332. package/node_modules/auth-store/dist/provider-store.d.ts +1 -1
  333. package/node_modules/auth-store/dist/safe-fs-secret-store.d.ts +21 -0
  334. package/node_modules/auth-store/dist/safe-fs-secret-store.js +119 -0
  335. package/node_modules/auth-store/dist/secret-store.d.ts +12 -0
  336. package/node_modules/auth-store/dist/secret-store.js +1 -0
  337. package/node_modules/auth-store/dist/transaction-lock.d.ts +2 -4
  338. package/node_modules/auth-store/dist/types.d.ts +2 -9
  339. package/node_modules/auth-store/package.json +16 -2
  340. package/node_modules/tiny-http-mcp-server/dist/composition.json +16 -1
  341. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +25 -0
  342. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.js +4 -4
  343. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +6 -40
  344. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.d.ts +10 -0
  345. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.js +20 -0
  346. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +4 -3
  347. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.d.ts +14 -0
  348. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.js +53 -0
  349. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.d.ts +16 -2
  350. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.js +29 -9
  351. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.d.ts +12 -0
  352. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.js +23 -0
  353. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.js +6 -19
  354. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.js +1 -1
  355. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +6 -2
  356. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +5 -1
  357. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +5 -2
  358. package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +4 -1
  359. package/node_modules/tiny-http-mcp-server/package.json +4 -4
  360. package/node_modules/tiny-mcp-client/README.md +2 -0
  361. package/node_modules/tiny-mcp-client/dist/index.browser.d.ts +25 -23
  362. package/node_modules/tiny-mcp-client/dist/index.browser.js +116 -1
  363. package/node_modules/tiny-mcp-client/dist/index.d.ts +25 -23
  364. package/node_modules/tiny-mcp-client/dist/index.js +1034 -561
  365. package/node_modules/tiny-mcp-client/package.json +15 -0
  366. package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
  367. package/node_modules/toolcraft-design/dist/components/table.js +6 -0
  368. package/node_modules/toolcraft-design/dist/escape-terminal-text.d.ts +1 -2
  369. package/node_modules/toolcraft-design/dist/escape-terminal-text.js +1 -20
  370. package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +2 -1
  371. package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +2 -1
  372. package/node_modules/toolcraft-schema/dist/json-schema/utils.js +3 -0
  373. package/node_modules/toolcraft-schema/package.json +1 -1
  374. package/package.json +32 -7
@@ -0,0 +1,12 @@
1
+ import type { FileSystem } from "../../contracts/filesystem.js";
2
+ export interface FileSystemQuotaOptions {
3
+ readonly maxBytes: number;
4
+ readonly maxScanEntries?: number;
5
+ readonly maxScanDepth?: number;
6
+ }
7
+ export declare class FileSystemQuotaError extends Error {
8
+ readonly maxBytes: number;
9
+ readonly code = "ENOSPC";
10
+ constructor(maxBytes: number);
11
+ }
12
+ export declare function withFileSystemQuota(fs: FileSystem, options: FileSystemQuotaOptions): FileSystem;
@@ -0,0 +1,520 @@
1
+ import { FsError } from "../../contracts/errors.js";
2
+ import { finishCleanup } from "../../contracts/cleanup.js";
3
+ import { openRetainedReadFile, openRetainedResizeFile, quotaCapabilities, retainedReadCapabilities, retainedResizeCapabilities } from "../capabilities.js";
4
+ import { admitDirectoryEntries } from "../directory-admission.js";
5
+ import { forwardFileDescriptor, openFileDescriptor } from "../descriptor.js";
6
+ export class FileSystemQuotaError extends Error {
7
+ maxBytes;
8
+ code = "ENOSPC";
9
+ constructor(maxBytes) {
10
+ super(`Filesystem quota exceeded (${maxBytes} bytes)`);
11
+ this.maxBytes = maxBytes;
12
+ this.name = "FileSystemQuotaError";
13
+ }
14
+ }
15
+ function completeIdentity(stat) {
16
+ return (typeof stat.identityScope === "symbol" || typeof stat.identityScope === "object" && stat.identityScope !== null)
17
+ && [stat.dev, stat.ino].every(value => typeof value === "number" && Number.isSafeInteger(value) && value >= 0);
18
+ }
19
+ function namespaceMetadata(metadata, signal) {
20
+ if (!signal)
21
+ return metadata;
22
+ return new Promise((resolve, reject) => {
23
+ const abort = () => { signal.removeEventListener("abort", abort); reject(signal.reason); };
24
+ signal.addEventListener("abort", abort, { once: true });
25
+ metadata.then(value => { signal.removeEventListener("abort", abort); resolve(value); }, error => { signal.removeEventListener("abort", abort); reject(error); });
26
+ if (signal.aborted)
27
+ abort();
28
+ });
29
+ }
30
+ async function scanUsedBytes(fs, limits, options, changeInput, retained = typeof changeInput !== "function" && changeInput?.retained === true) {
31
+ let change = typeof changeInput === "function" ? undefined : changeInput;
32
+ let prepare = typeof changeInput === "function" ? changeInput : undefined;
33
+ let total = 0;
34
+ let retainedTotal = 0n;
35
+ let shrinkCredited = false;
36
+ let possibleAliases = 0;
37
+ let remaining = limits.maxScanEntries;
38
+ const pending = [{ path: "/", depth: 0 }];
39
+ while (pending.length) {
40
+ options?.signal?.throwIfAborted();
41
+ const directory = pending.pop();
42
+ if (!directory)
43
+ break;
44
+ const signal = options?.signal;
45
+ const listing = fs.readdir(directory.path, { ...options, ...(signal ? { signal } : {}), ...(remaining === Infinity ? {} : { maxEntries: remaining }) });
46
+ const entries = await (retained ? namespaceMetadata(listing, signal) : listing);
47
+ options?.signal?.throwIfAborted();
48
+ const count = entries.length;
49
+ admitDirectoryEntries(count, remaining, directory.path);
50
+ remaining -= count;
51
+ if (prepare) {
52
+ change = await prepare();
53
+ prepare = undefined;
54
+ }
55
+ if (change?.stat.type === "directory") {
56
+ const stat = await fs.stat(directory.path, options);
57
+ const comparable = completeIdentity(stat) && completeIdentity(change.stat);
58
+ const comparison = comparable
59
+ ? stat.identityScope === change.stat.identityScope && stat.dev === change.stat.dev && stat.ino === change.stat.ino ? "same" : "distinct"
60
+ : fs.compareEntry ? await fs.compareEntry(change.path, fs, directory.path, options) : "unknown";
61
+ options?.signal?.throwIfAborted();
62
+ if (comparison !== "same" && comparison !== "distinct" && comparison !== "unknown")
63
+ throw new FsError("EIO", { syscall: "compareEntry", path: change.path });
64
+ if (comparison !== "distinct") {
65
+ total += Math.max(0, change.delta);
66
+ possibleAliases++;
67
+ }
68
+ }
69
+ let processed = 0;
70
+ for (const entry of entries) {
71
+ options?.signal?.throwIfAborted();
72
+ if (processed >= count) {
73
+ admitDirectoryEntries(1, remaining, directory.path);
74
+ remaining--;
75
+ }
76
+ processed++;
77
+ const path = `${directory.path === "/" ? "" : directory.path}/${entry.name}`;
78
+ if (entry.type === "directory") {
79
+ const depth = directory.depth + 1;
80
+ if (depth > limits.maxScanDepth)
81
+ throw new FsError("EFBIG", { syscall: "readdir", path, message: "quota scan depth limit exceeded" });
82
+ pending.push({ path, depth });
83
+ }
84
+ else {
85
+ const metadata = fs.lstat(path, options);
86
+ const stat = await (retained ? namespaceMetadata(metadata, signal) : metadata);
87
+ if (retained) {
88
+ options?.signal?.throwIfAborted();
89
+ if (!Number.isSafeInteger(stat.size) || stat.size < 0)
90
+ throw new FsError("EIO", { syscall: "lstat", path, message: "invalid quota entry size" });
91
+ retainedTotal += BigInt(stat.size);
92
+ if (!change || change.stat.type !== "file" || stat.type !== "file")
93
+ continue;
94
+ const known = completeIdentity(stat);
95
+ const same = known && change.stat.identityScope === stat.identityScope && change.stat.dev === stat.dev && change.stat.ino === stat.ino;
96
+ const nextBytes = change.stat.size + change.delta;
97
+ if (same) {
98
+ possibleAliases++;
99
+ retainedTotal += BigInt(Math.max(0, nextBytes - stat.size));
100
+ if (!shrinkCredited && change.delta < 0) {
101
+ retainedTotal -= BigInt(Math.max(0, Math.min(stat.size, change.stat.size) - nextBytes));
102
+ shrinkCredited = true;
103
+ }
104
+ }
105
+ else if (!known) {
106
+ possibleAliases++;
107
+ retainedTotal += BigInt(Math.max(0, change.delta, nextBytes - stat.size));
108
+ }
109
+ continue;
110
+ }
111
+ total += stat.size;
112
+ if (!change || change.stat.type !== "file" || stat.type !== "file")
113
+ continue;
114
+ const scope = change.stat.identityScope;
115
+ const comparable = [scope, stat.identityScope].every(value => typeof value === "symbol" || typeof value === "object" && value !== null)
116
+ && [change.stat.dev, change.stat.ino, stat.dev, stat.ino].every(value => typeof value === "number" && Number.isSafeInteger(value) && value >= 0);
117
+ const compare = comparable ? undefined : fs.compareEntry;
118
+ const comparison = comparable
119
+ ? scope === stat.identityScope && change.stat.dev === stat.dev && change.stat.ino === stat.ino ? "same" : "distinct"
120
+ : compare === undefined ? "unknown" : await compare.call(fs, change.path, fs, path, options);
121
+ options?.signal?.throwIfAborted();
122
+ if (comparison !== "same" && comparison !== "distinct" && comparison !== "unknown")
123
+ throw new FsError("EIO", { syscall: "compareEntry", path: change.path, dest: path, message: "invalid entry comparison" });
124
+ if (comparison === "same") {
125
+ total += change.delta;
126
+ possibleAliases++;
127
+ }
128
+ else if (comparison !== "distinct") {
129
+ total += Math.max(0, change.delta);
130
+ possibleAliases++;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ if (retained) {
136
+ if (change && possibleAliases === 0)
137
+ retainedTotal += BigInt(Math.max(0, change.delta));
138
+ return Number(retainedTotal);
139
+ }
140
+ if (change && possibleAliases === 0)
141
+ total += Math.max(0, change.delta);
142
+ return total;
143
+ }
144
+ async function existingBytes(fs, path, options) {
145
+ try {
146
+ const stat = await fs.stat(path, options);
147
+ return stat.type === "directory" ? 0 : stat.size;
148
+ }
149
+ catch (error) {
150
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
151
+ return 0;
152
+ throw error;
153
+ }
154
+ }
155
+ export function withFileSystemQuota(fs, options) {
156
+ if (options.maxBytes !== Infinity && (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 0))
157
+ throw new RangeError("maxBytes must be a nonnegative safe integer or Infinity");
158
+ const scanLimits = {
159
+ maxScanEntries: options.maxScanEntries ?? Infinity,
160
+ maxScanDepth: options.maxScanDepth ?? Infinity,
161
+ };
162
+ for (const [name, value] of Object.entries({ maxScanEntries: options.maxScanEntries, maxScanDepth: options.maxScanDepth })) {
163
+ if (value !== undefined && value !== Infinity && (!Number.isSafeInteger(value) || value < 0))
164
+ throw new RangeError(`${name} must be a nonnegative safe integer or Infinity`);
165
+ }
166
+ let queue = Promise.resolve();
167
+ let reservedBytes = 0;
168
+ const usedBytes = async (...args) => await scanUsedBytes(...args) + reservedBytes;
169
+ const mutate = (operation) => {
170
+ const result = queue.then(operation);
171
+ queue = result.catch(() => undefined);
172
+ return result;
173
+ };
174
+ const resizeBackend = new Proxy(Object.create(fs), {
175
+ get(_target, property) {
176
+ const original = Reflect.get(fs, property);
177
+ if (property === "openResizeFile" && typeof original === "function")
178
+ return async (path, resizeOptions) => {
179
+ resizeOptions.signal?.throwIfAborted();
180
+ if (resizeOptions.create) {
181
+ const total = await usedBytes(fs, scanLimits, resizeOptions, undefined, true);
182
+ resizeOptions.signal?.throwIfAborted();
183
+ if (total > options.maxBytes)
184
+ throw new FileSystemQuotaError(options.maxBytes);
185
+ }
186
+ resizeOptions.signal?.throwIfAborted();
187
+ return Reflect.apply(original, fs, [path, resizeOptions]);
188
+ };
189
+ return typeof original === "function" ? original.bind(fs) : original;
190
+ },
191
+ });
192
+ const creationChange = async (path, delta, fsOptions) => {
193
+ // Resolve existing ancestors before comparing directory identities. A dangling
194
+ // final symlink cannot safely identify its publication directory here.
195
+ let target;
196
+ try {
197
+ target = fs.canonicalizeMissingTarget?.(path, fsOptions) ?? path;
198
+ }
199
+ catch (error) {
200
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
201
+ throw new FileSystemQuotaError(options.maxBytes);
202
+ throw error;
203
+ }
204
+ try {
205
+ const entry = fs.canonicalizeMissingTarget ? undefined : await fs.lstat(target, fsOptions);
206
+ if (entry?.type === "symlink")
207
+ throw new FsError("ENOTSUP", { syscall: "write", path, message: "quota cannot locate missing symlink referent" });
208
+ }
209
+ catch (error) {
210
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
211
+ throw error;
212
+ }
213
+ const boundary = target.lastIndexOf("/");
214
+ const parent = await fs.realpath(boundary <= 0 ? "/" : target.slice(0, boundary), fsOptions);
215
+ const stat = await fs.stat(parent, fsOptions);
216
+ fsOptions?.signal?.throwIfAborted();
217
+ if (stat.type !== "directory")
218
+ throw new FsError("ENOTDIR", { syscall: "write", path });
219
+ return { path: parent, stat, delta };
220
+ };
221
+ const assertDelta = async (path, nextBytes, fsOptions) => {
222
+ fsOptions?.signal?.throwIfAborted();
223
+ let current;
224
+ try {
225
+ current = await fs.stat(path, fsOptions);
226
+ }
227
+ catch (error) {
228
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
229
+ throw error;
230
+ }
231
+ const projected = current?.type === "file" && nextBytes > current.size
232
+ ? await usedBytes(fs, scanLimits, fsOptions, { path, stat: current, delta: nextBytes - current.size })
233
+ : !current && nextBytes > 0
234
+ ? await usedBytes(fs, scanLimits, fsOptions, () => creationChange(path, nextBytes, fsOptions))
235
+ : await usedBytes(fs, scanLimits, fsOptions) - (current?.type === "directory" ? 0 : current?.size ?? 0) + nextBytes;
236
+ fsOptions?.signal?.throwIfAborted();
237
+ if (projected > options.maxBytes)
238
+ throw new FileSystemQuotaError(options.maxBytes);
239
+ };
240
+ const mutations = {
241
+ open(path, openOptions) {
242
+ return openFileDescriptor(path, openOptions, {
243
+ noFollow: true, positionedRead: true, positionedWrite: true, truncate: true, synchronization: "storage",
244
+ }, admitted => mutate(async () => {
245
+ admitted.signal?.throwIfAborted();
246
+ const open = fs.open;
247
+ const capabilities = admitted.noFollow || admitted.creation === "exclusive" ? fs.capabilities : await fs.capabilitiesFor?.(path, admitted) ?? fs.capabilities;
248
+ admitted.signal?.throwIfAborted();
249
+ if (!open || capabilities.open === false)
250
+ throw new FsError("ENOTSUP", { syscall: "open", path });
251
+ admitted.signal?.throwIfAborted();
252
+ const descriptor = await open.call(fs, path, admitted);
253
+ try {
254
+ admitted.signal?.throwIfAborted();
255
+ const pinned = admitted.access === "read" ? undefined : { ...await descriptor.stat(admitted) };
256
+ const conditional = descriptor.capabilities.publication === "conditional" && pinned !== undefined;
257
+ let publishedSize = pinned?.size ?? 0;
258
+ let reserved = 0;
259
+ let publicationAliases = 1;
260
+ if (conditional) {
261
+ const baseline = await usedBytes(fs, scanLimits, admitted);
262
+ publicationAliases = await usedBytes(fs, scanLimits, admitted, () => creationChange(path, 1, admitted)) - baseline;
263
+ if (!Number.isSafeInteger(publicationAliases) || publicationAliases < 1)
264
+ throw new FsError("ENOTSUP", { syscall: "open", path, message: "quota cannot determine publication aliases" });
265
+ }
266
+ const reserve = (size) => {
267
+ const next = Math.max(0, size - publishedSize) * publicationAliases;
268
+ reservedBytes += next - reserved;
269
+ reserved = next;
270
+ };
271
+ admitted.signal?.throwIfAborted();
272
+ if (pinned && (pinned.type !== "file" || !completeIdentity(pinned))) {
273
+ throw new FsError("ENOTSUP", { syscall: "open", path, message: "quota requires complete retained file identity" });
274
+ }
275
+ if (pinned && (!Number.isSafeInteger(pinned.size) || pinned.size < 0)) {
276
+ throw new FsError("EIO", { syscall: "fstat", path, message: "invalid retained file size" });
277
+ }
278
+ const current = async (operationOptions) => {
279
+ const stat = { ...await descriptor.stat(operationOptions) };
280
+ operationOptions.signal?.throwIfAborted();
281
+ if (!pinned || stat.type !== "file" || !completeIdentity(stat)
282
+ || !conditional && (stat.identityScope !== pinned.identityScope || stat.dev !== pinned.dev || stat.ino !== pinned.ino)
283
+ || !Number.isSafeInteger(stat.size) || stat.size < 0) {
284
+ throw new FsError("EIO", { syscall: "fstat", path, message: "invalid retained quota identity or size" });
285
+ }
286
+ return stat;
287
+ };
288
+ const admitSize = async (stat, nextBytes, operationOptions) => {
289
+ if (!Number.isSafeInteger(nextBytes) || nextBytes < 0)
290
+ throw new FsError("EFBIG", { syscall: "write", path });
291
+ const projected = conditional
292
+ ? await usedBytes(fs, scanLimits, operationOptions) - reserved + Math.max(0, nextBytes - publishedSize) * publicationAliases
293
+ : await usedBytes(fs, scanLimits, operationOptions, { path, stat, delta: nextBytes - stat.size, retained: true });
294
+ operationOptions.signal?.throwIfAborted();
295
+ if (projected > options.maxBytes)
296
+ throw new FileSystemQuotaError(options.maxBytes);
297
+ if (conditional)
298
+ reserve(Math.max(nextBytes, publishedSize + reserved / publicationAliases));
299
+ };
300
+ const forwarded = forwardFileDescriptor(descriptor, (syscall, operationOptions, action) => syscall === "close" && !conditional ? action() : mutate(async () => {
301
+ try {
302
+ operationOptions.signal?.throwIfAborted();
303
+ const result = await action();
304
+ if (conditional && (syscall === "fsync" || syscall === "fdatasync")) {
305
+ publishedSize = (await current(operationOptions)).size;
306
+ reserve(publishedSize);
307
+ }
308
+ return result;
309
+ }
310
+ finally {
311
+ if (syscall === "close") {
312
+ reservedBytes -= reserved;
313
+ reserved = 0;
314
+ }
315
+ }
316
+ }));
317
+ return {
318
+ ...forwarded,
319
+ write: (retained, buffer, position, operationOptions) => mutate(async () => {
320
+ operationOptions.signal?.throwIfAborted();
321
+ if (buffer.byteLength === 0)
322
+ return retained.write(buffer, position, operationOptions);
323
+ const stat = await current(operationOptions);
324
+ let offset = position;
325
+ if (offset === null) {
326
+ if (admitted.append)
327
+ offset = stat.size;
328
+ else {
329
+ if (forwarded.capabilities?.position !== true || !forwarded.getPosition) {
330
+ throw new FsError("ENOTSUP", { syscall: "getPosition", path });
331
+ }
332
+ offset = await retained.getPosition(operationOptions);
333
+ operationOptions.signal?.throwIfAborted();
334
+ }
335
+ }
336
+ if (!Number.isSafeInteger(offset) || offset < 0)
337
+ throw new FsError("EIO", { syscall: "getPosition", path });
338
+ await admitSize(stat, Math.max(stat.size, offset + buffer.byteLength), operationOptions);
339
+ const count = await retained.write(buffer, position, operationOptions);
340
+ if (conditional) {
341
+ const size = (await current(operationOptions)).size;
342
+ if (admitted.synchronization !== undefined)
343
+ publishedSize = size;
344
+ reserve(size);
345
+ }
346
+ return count;
347
+ }),
348
+ truncate: (retained, length, operationOptions) => mutate(async () => {
349
+ operationOptions.signal?.throwIfAborted();
350
+ await admitSize(await current(operationOptions), length, operationOptions);
351
+ await retained.truncate(length, operationOptions);
352
+ if (conditional) {
353
+ if (admitted.synchronization !== undefined)
354
+ publishedSize = length;
355
+ reserve(length);
356
+ }
357
+ }),
358
+ };
359
+ }
360
+ catch (error) {
361
+ await finishCleanup(() => descriptor.close(), true);
362
+ admitted.signal?.throwIfAborted();
363
+ throw error;
364
+ }
365
+ }));
366
+ },
367
+ openResizeFile(path, resizeOptions = {}) {
368
+ return mutate(async () => {
369
+ let retained;
370
+ try {
371
+ retained = await openRetainedResizeFile(resizeBackend, path, resizeOptions);
372
+ const pinned = { ...await retained.stat(resizeOptions) };
373
+ resizeOptions.signal?.throwIfAborted();
374
+ if (pinned.type !== "file" || !completeIdentity(pinned))
375
+ throw new FsError("ENOTSUP", { syscall: "openResizeFile", path, message: "quota requires complete retained file identity" });
376
+ if (!Number.isSafeInteger(pinned.size) || pinned.size < 0)
377
+ throw new FsError("EIO", { syscall: "stat", path, message: "invalid retained file size" });
378
+ const handle = retained;
379
+ const seekEnd = handle.seekEnd;
380
+ resizeOptions.signal?.throwIfAborted();
381
+ let pending = Promise.resolve();
382
+ let closing;
383
+ const admit = (operation, operationOptions) => {
384
+ if (closing)
385
+ return Promise.reject(new FsError("EBADF", { path }));
386
+ const result = mutate(async () => {
387
+ operationOptions?.signal?.throwIfAborted();
388
+ const value = await operation();
389
+ operationOptions?.signal?.throwIfAborted();
390
+ return value;
391
+ });
392
+ pending = result.catch(() => undefined);
393
+ return result;
394
+ };
395
+ const current = async (operationOptions) => {
396
+ const stat = { ...await handle.stat(operationOptions) };
397
+ operationOptions?.signal?.throwIfAborted();
398
+ if (stat.type !== "file" || !completeIdentity(stat) || stat.identityScope !== pinned.identityScope || stat.dev !== pinned.dev || stat.ino !== pinned.ino
399
+ || !Number.isSafeInteger(stat.size) || stat.size < 0)
400
+ throw new FsError("EIO", { syscall: "stat", path, message: "invalid retained quota identity or size" });
401
+ return stat;
402
+ };
403
+ return {
404
+ stat(operationOptions) { return admit(() => current(operationOptions), operationOptions); },
405
+ ...(typeof seekEnd === "function" ? {
406
+ seekEnd(operationOptions) {
407
+ return admit(() => Reflect.apply(seekEnd, handle, [operationOptions]), operationOptions);
408
+ },
409
+ } : {}),
410
+ truncate(length, operationOptions) {
411
+ return admit(async () => {
412
+ if (!Number.isSafeInteger(length) || length < 0)
413
+ throw new FsError("EINVAL", { syscall: "truncate", path });
414
+ const stat = await current(operationOptions);
415
+ const projected = await usedBytes(fs, scanLimits, operationOptions, { path, stat, delta: length - stat.size, retained: true });
416
+ operationOptions?.signal?.throwIfAborted();
417
+ if (projected > options.maxBytes)
418
+ throw new FileSystemQuotaError(options.maxBytes);
419
+ await handle.truncate(length, operationOptions);
420
+ }, operationOptions);
421
+ },
422
+ close() {
423
+ closing ??= pending.then(() => handle.close());
424
+ return closing;
425
+ },
426
+ };
427
+ }
428
+ catch (error) {
429
+ if (retained)
430
+ await finishCleanup(() => retained.close(), true);
431
+ resizeOptions.signal?.throwIfAborted();
432
+ throw error;
433
+ }
434
+ });
435
+ },
436
+ writeFile(path, data, writeOptions) {
437
+ return mutate(async () => {
438
+ const append = writeOptions?.flag === "a" || writeOptions?.flag === "ax";
439
+ const current = append ? await existingBytes(fs, path, writeOptions) : 0;
440
+ await assertDelta(path, current + data.length, writeOptions);
441
+ await fs.writeFile(path, data, writeOptions);
442
+ });
443
+ },
444
+ appendFile(path, data, appendOptions) {
445
+ return mutate(async () => {
446
+ await assertDelta(path, await existingBytes(fs, path, appendOptions) + data.length, appendOptions);
447
+ await fs.appendFile(path, data, appendOptions);
448
+ });
449
+ },
450
+ rename(source, destination, renameOptions) {
451
+ return mutate(async () => {
452
+ if (renameOptions?.noReplace) {
453
+ renameOptions.signal?.throwIfAborted();
454
+ const capabilities = await fs.capabilitiesFor?.(destination, renameOptions) ?? fs.capabilities;
455
+ renameOptions.signal?.throwIfAborted();
456
+ if (capabilities.atomicRenameNoReplace !== true)
457
+ throw new FsError("ENOTSUP", { syscall: "rename", path: source, dest: destination });
458
+ }
459
+ await fs.rename(source, destination, renameOptions);
460
+ });
461
+ },
462
+ copyFile(source, destination, copyOptions) {
463
+ return mutate(async () => {
464
+ await assertDelta(destination, (await fs.stat(source, copyOptions)).size, copyOptions);
465
+ await fs.copyFile(source, destination, copyOptions);
466
+ });
467
+ },
468
+ truncate(path, length = 0, truncateOptions) {
469
+ return mutate(async () => {
470
+ await assertDelta(path, length, truncateOptions);
471
+ await fs.truncate(path, length, truncateOptions);
472
+ });
473
+ },
474
+ link(source, destination, linkOptions) {
475
+ return mutate(async () => {
476
+ await assertDelta(destination, (await fs.lstat(source, linkOptions)).size, linkOptions);
477
+ await fs.link(source, destination, linkOptions);
478
+ });
479
+ },
480
+ symlink(target, path, linkOptions) {
481
+ return mutate(async () => {
482
+ await assertDelta(path, new TextEncoder().encode(target).length, linkOptions);
483
+ await fs.symlink(target, path, linkOptions);
484
+ });
485
+ },
486
+ writeStream(path, source, writeOptions) {
487
+ return mutate(async () => {
488
+ const append = writeOptions?.flag === "a" || writeOptions?.flag === "ax";
489
+ if (!append)
490
+ await fs.writeFile(path, new Uint8Array(), writeOptions);
491
+ for await (const chunk of source) {
492
+ await assertDelta(path, await existingBytes(fs, path, writeOptions) + chunk.length, writeOptions);
493
+ await fs.appendFile(path, chunk, writeOptions);
494
+ }
495
+ });
496
+ },
497
+ };
498
+ // Backend descriptors may be frozen. An independent view lets us adapt
499
+ // capabilities and methods without violating invariants on own properties.
500
+ return new Proxy(Object.create(fs), {
501
+ get(_target, property) {
502
+ if (property === "publishStagedFileSet" || property === "prepareStagingResolution" || property === "prepareDirectoryAncestry" || property === "publishFileConditional" || property === "removeEntryConditional" || property === "writeFileConditional" || property === "removeFileConditional" || property === "resizeFile" || property === "canonicalizeMissingTarget" || property === "createStagedFile" || property === "publishStagedFile" || property === "removeStagedFile" || property === "prepareDirectory")
503
+ return undefined;
504
+ if (property === "capabilities")
505
+ return quotaCapabilities({ ...retainedResizeCapabilities(fs, retainedReadCapabilities(fs)), ...(typeof fs.open === "function" ? {} : { open: false }) });
506
+ if (property === "capabilitiesFor")
507
+ return async (path, fsOptions) => {
508
+ const capabilities = await fs.capabilitiesFor?.(path, fsOptions) ?? fs.capabilities;
509
+ return quotaCapabilities({ ...retainedResizeCapabilities(fs, retainedReadCapabilities(fs, capabilities)), ...(typeof fs.open === "function" ? {} : { open: false }) });
510
+ };
511
+ if (property === "openReadFile")
512
+ return (path, fsOptions = {}) => openRetainedReadFile(fs, path, fsOptions);
513
+ const replacement = Reflect.get(mutations, property);
514
+ if (typeof replacement === "function")
515
+ return replacement;
516
+ const original = Reflect.get(fs, property);
517
+ return typeof original === "function" ? original.bind(fs) : original;
518
+ },
519
+ });
520
+ }
@@ -0,0 +1,37 @@
1
+ import type { ByteSource } from "../../contracts/io.js";
2
+ import type { AppendFileOptions, CapabilityQueryOptions, CopyFileOptions, DirectoryEntry, FileResizeHandle, FileStat, OpenReadFileOptions, OpenResizeFileOptions, FileSystem, FileSystemCapabilities, FsOptions, RenameOptions, MkdirOptions, ReadDirectoryOptions, ReadFileOptions, ReadStreamOptions, RemoveOptions, WriteFileOptions } from "../../contracts/filesystem.js";
3
+ import type { FileDescriptor, OpenFileOptions } from "../../contracts/descriptor.js";
4
+ export declare class ReadOnlyFileSystem implements FileSystem {
5
+ #private;
6
+ readonly removeEntryConditional?: NonNullable<FileSystem["removeEntryConditional"]>;
7
+ constructor(filesystem: FileSystem);
8
+ get capabilities(): FileSystemCapabilities;
9
+ capabilitiesFor(path: string, options?: CapabilityQueryOptions): Promise<FileSystemCapabilities>;
10
+ open(path: string, options: OpenFileOptions): Promise<FileDescriptor>;
11
+ openReadFile(path: string, options?: OpenReadFileOptions): Promise<import("../../contracts/filesystem.js").FileReadHandle>;
12
+ readFile(path: string, options?: ReadFileOptions): Promise<Uint8Array>;
13
+ stat(path: string, options?: FsOptions): Promise<FileStat>;
14
+ lstat(path: string, options?: FsOptions): Promise<FileStat>;
15
+ compareEntry(path: string, peer: FileSystem, peerPath: string, options?: FsOptions): Promise<import("../../contracts/filesystem.js").EntryComparison>;
16
+ readdir(path: string, options?: ReadDirectoryOptions): Promise<DirectoryEntry[]>;
17
+ realpath(path: string, options?: FsOptions): Promise<string>;
18
+ access(path: string, mode?: number, options?: FsOptions): Promise<void>;
19
+ readlink(path: string, options?: FsOptions): Promise<string>;
20
+ readStream(path: string, options?: ReadStreamOptions): ByteSource;
21
+ writeFile(path: string, _data: Uint8Array, _options?: WriteFileOptions): Promise<void>;
22
+ appendFile(path: string, _data: Uint8Array, _options?: AppendFileOptions): Promise<void>;
23
+ writeStream(path: string, _source: ByteSource, _options?: WriteFileOptions): Promise<void>;
24
+ mkdir(path: string, _options?: MkdirOptions): Promise<void>;
25
+ rm(path: string, _options?: RemoveOptions): Promise<void>;
26
+ unlink(path: string, _options?: FsOptions): Promise<void>;
27
+ rmdir(path: string, _options?: FsOptions): Promise<void>;
28
+ rename(source: string, destination: string, _options?: RenameOptions): Promise<void>;
29
+ copyFile(source: string, destination: string, _options?: CopyFileOptions): Promise<void>;
30
+ symlink(target: string, path: string, _options?: FsOptions): Promise<void>;
31
+ link(existingPath: string, newPath: string, _options?: FsOptions): Promise<void>;
32
+ chmod(path: string, _mode: number, _options?: FsOptions): Promise<void>;
33
+ utimes(path: string, _atimeMs: number, _mtimeMs: number, _options?: FsOptions): Promise<void>;
34
+ truncate(path: string, _length?: number, _options?: FsOptions): Promise<void>;
35
+ openResizeFile(path: string, options?: OpenResizeFileOptions): Promise<FileResizeHandle>;
36
+ }
37
+ export declare function createReadOnlyFileSystem(filesystem: FileSystem): ReadOnlyFileSystem;