@nimbus-sh/core 0.1.0

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 (1056) hide show
  1. package/dist/_shared/ai-egress.d.ts +73 -0
  2. package/dist/_shared/ai-egress.d.ts.map +1 -0
  3. package/dist/_shared/ai-egress.js +88 -0
  4. package/dist/_shared/byte-stream.d.ts +59 -0
  5. package/dist/_shared/byte-stream.d.ts.map +1 -0
  6. package/dist/_shared/byte-stream.js +77 -0
  7. package/dist/_shared/bytes.d.ts +18 -0
  8. package/dist/_shared/bytes.d.ts.map +1 -0
  9. package/dist/_shared/bytes.js +17 -0
  10. package/dist/_shared/cache-stats.d.ts +145 -0
  11. package/dist/_shared/cache-stats.d.ts.map +1 -0
  12. package/dist/_shared/cache-stats.js +161 -0
  13. package/dist/_shared/crypto.d.ts +17 -0
  14. package/dist/_shared/crypto.d.ts.map +1 -0
  15. package/dist/_shared/crypto.js +131 -0
  16. package/dist/_shared/esbuild-facet-shim.d.ts +21 -0
  17. package/dist/_shared/esbuild-facet-shim.d.ts.map +1 -0
  18. package/dist/_shared/esbuild-facet-shim.js +22 -0
  19. package/dist/_shared/exports-resolver.d.ts +74 -0
  20. package/dist/_shared/exports-resolver.d.ts.map +1 -0
  21. package/dist/_shared/exports-resolver.js +284 -0
  22. package/dist/_shared/facet-vfs-cursor.d.ts +48 -0
  23. package/dist/_shared/facet-vfs-cursor.d.ts.map +1 -0
  24. package/dist/_shared/facet-vfs-cursor.js +51 -0
  25. package/dist/_shared/install-phase.d.ts +47 -0
  26. package/dist/_shared/install-phase.d.ts.map +1 -0
  27. package/dist/_shared/install-phase.js +1 -0
  28. package/dist/_shared/lru-map.d.ts +25 -0
  29. package/dist/_shared/lru-map.d.ts.map +1 -0
  30. package/dist/_shared/lru-map.js +57 -0
  31. package/dist/_shared/real-node-imports.d.ts +43 -0
  32. package/dist/_shared/real-node-imports.d.ts.map +1 -0
  33. package/dist/_shared/real-node-imports.js +52 -0
  34. package/dist/_shared/retry.d.ts +92 -0
  35. package/dist/_shared/retry.d.ts.map +1 -0
  36. package/dist/_shared/retry.js +155 -0
  37. package/dist/_shared/rpc-dispose.d.ts +4 -0
  38. package/dist/_shared/rpc-dispose.d.ts.map +1 -0
  39. package/dist/_shared/rpc-dispose.js +30 -0
  40. package/dist/_shared/terminal.d.ts +2 -0
  41. package/dist/_shared/terminal.d.ts.map +1 -0
  42. package/dist/_shared/terminal.js +3 -0
  43. package/dist/_shared/typescript-specifiers.d.ts +58 -0
  44. package/dist/_shared/typescript-specifiers.d.ts.map +1 -0
  45. package/dist/_shared/typescript-specifiers.js +84 -0
  46. package/dist/_shared/untrusted-request.d.ts +34 -0
  47. package/dist/_shared/untrusted-request.d.ts.map +1 -0
  48. package/dist/_shared/untrusted-request.js +74 -0
  49. package/dist/_shared/vfs-write-ledger.d.ts +3 -0
  50. package/dist/_shared/vfs-write-ledger.d.ts.map +1 -0
  51. package/dist/_shared/vfs-write-ledger.js +439 -0
  52. package/dist/_shared/w7-frame.d.ts +79 -0
  53. package/dist/_shared/w7-frame.d.ts.map +1 -0
  54. package/dist/_shared/w7-frame.js +839 -0
  55. package/dist/_shared/weighted-credit-pool.d.ts +61 -0
  56. package/dist/_shared/weighted-credit-pool.d.ts.map +1 -0
  57. package/dist/_shared/weighted-credit-pool.js +196 -0
  58. package/dist/constants.d.ts +64 -0
  59. package/dist/constants.d.ts.map +1 -0
  60. package/dist/constants.js +264 -0
  61. package/dist/index.d.ts +16 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +13 -0
  64. package/dist/observability/diag-counters.d.ts +236 -0
  65. package/dist/observability/diag-counters.d.ts.map +1 -0
  66. package/dist/observability/diag-counters.js +195 -0
  67. package/dist/observability/heap-estimate.d.ts +225 -0
  68. package/dist/observability/heap-estimate.d.ts.map +1 -0
  69. package/dist/observability/heap-estimate.js +185 -0
  70. package/dist/observability/heavy-alloc-coord.d.ts +93 -0
  71. package/dist/observability/heavy-alloc-coord.d.ts.map +1 -0
  72. package/dist/observability/heavy-alloc-coord.js +181 -0
  73. package/dist/observability/oom-classify.d.ts +138 -0
  74. package/dist/observability/oom-classify.d.ts.map +1 -0
  75. package/dist/observability/oom-classify.js +261 -0
  76. package/dist/observability/oom-discriminator.d.ts +176 -0
  77. package/dist/observability/oom-discriminator.d.ts.map +1 -0
  78. package/dist/observability/oom-discriminator.js +272 -0
  79. package/dist/runtime/assets-loader.d.ts +71 -0
  80. package/dist/runtime/assets-loader.d.ts.map +1 -0
  81. package/dist/runtime/assets-loader.js +139 -0
  82. package/dist/runtime/barrel-detect.d.ts +46 -0
  83. package/dist/runtime/barrel-detect.d.ts.map +1 -0
  84. package/dist/runtime/barrel-detect.js +73 -0
  85. package/dist/runtime/bash/preamble.d.ts +2 -0
  86. package/dist/runtime/bash/preamble.d.ts.map +1 -0
  87. package/dist/runtime/bash/preamble.js +1849 -0
  88. package/dist/runtime/bash/types.d.ts +433 -0
  89. package/dist/runtime/bash/types.d.ts.map +1 -0
  90. package/dist/runtime/bash/types.js +1 -0
  91. package/dist/runtime/bundle-profile.d.ts +14 -0
  92. package/dist/runtime/bundle-profile.d.ts.map +1 -0
  93. package/dist/runtime/bundle-profile.js +20 -0
  94. package/dist/runtime/cirrus-vite-config-rewriter.d.ts +2 -0
  95. package/dist/runtime/cirrus-vite-config-rewriter.d.ts.map +1 -0
  96. package/dist/runtime/cirrus-vite-config-rewriter.js +28 -0
  97. package/dist/runtime/cli-flags.d.ts +2 -0
  98. package/dist/runtime/cli-flags.d.ts.map +1 -0
  99. package/dist/runtime/cli-flags.js +11 -0
  100. package/dist/runtime/comment-strip.d.ts +37 -0
  101. package/dist/runtime/comment-strip.d.ts.map +1 -0
  102. package/dist/runtime/comment-strip.js +74 -0
  103. package/dist/runtime/cpython-preamble.d.ts +32 -0
  104. package/dist/runtime/cpython-preamble.d.ts.map +1 -0
  105. package/dist/runtime/cpython-preamble.js +296 -0
  106. package/dist/runtime/esbuild-service.d.ts +242 -0
  107. package/dist/runtime/esbuild-service.d.ts.map +1 -0
  108. package/dist/runtime/esbuild-service.js +1452 -0
  109. package/dist/runtime/framework-detect.d.ts +70 -0
  110. package/dist/runtime/framework-detect.d.ts.map +1 -0
  111. package/dist/runtime/framework-detect.js +177 -0
  112. package/dist/runtime/import-meta-transform.d.ts +3 -0
  113. package/dist/runtime/import-meta-transform.d.ts.map +1 -0
  114. package/dist/runtime/import-meta-transform.js +15 -0
  115. package/dist/runtime/javascript-ast.d.ts +13 -0
  116. package/dist/runtime/javascript-ast.d.ts.map +1 -0
  117. package/dist/runtime/javascript-ast.js +57 -0
  118. package/dist/runtime/long-running-handle.d.ts +119 -0
  119. package/dist/runtime/long-running-handle.d.ts.map +1 -0
  120. package/dist/runtime/long-running-handle.js +169 -0
  121. package/dist/runtime/module-source-rewriter.d.ts +11 -0
  122. package/dist/runtime/module-source-rewriter.d.ts.map +1 -0
  123. package/dist/runtime/module-source-rewriter.js +61 -0
  124. package/dist/runtime/opentui-wasm-backend.d.ts +160 -0
  125. package/dist/runtime/opentui-wasm-backend.d.ts.map +1 -0
  126. package/dist/runtime/opentui-wasm-backend.js +416 -0
  127. package/dist/runtime/os-contracts.d.ts +436 -0
  128. package/dist/runtime/os-contracts.d.ts.map +1 -0
  129. package/dist/runtime/os-contracts.js +101 -0
  130. package/dist/runtime/port-registry.d.ts +100 -0
  131. package/dist/runtime/port-registry.d.ts.map +1 -0
  132. package/dist/runtime/port-registry.js +265 -0
  133. package/dist/runtime/process-input-routing.d.ts +33 -0
  134. package/dist/runtime/process-input-routing.d.ts.map +1 -0
  135. package/dist/runtime/process-input-routing.js +59 -0
  136. package/dist/runtime/process-input.d.ts +39 -0
  137. package/dist/runtime/process-input.d.ts.map +1 -0
  138. package/dist/runtime/process-input.js +117 -0
  139. package/dist/runtime/process-io-protocol.d.ts +90 -0
  140. package/dist/runtime/process-io-protocol.d.ts.map +1 -0
  141. package/dist/runtime/process-io-protocol.js +81 -0
  142. package/dist/runtime/process-logs.d.ts +352 -0
  143. package/dist/runtime/process-logs.d.ts.map +1 -0
  144. package/dist/runtime/process-logs.js +750 -0
  145. package/dist/runtime/process-table.d.ts +101 -0
  146. package/dist/runtime/process-table.d.ts.map +1 -0
  147. package/dist/runtime/process-table.js +175 -0
  148. package/dist/runtime/project-detect.d.ts +21 -0
  149. package/dist/runtime/project-detect.d.ts.map +1 -0
  150. package/dist/runtime/project-detect.js +46 -0
  151. package/dist/runtime/python-server-adapter.d.ts +33 -0
  152. package/dist/runtime/python-server-adapter.d.ts.map +1 -0
  153. package/dist/runtime/python-server-adapter.js +132 -0
  154. package/dist/runtime/require-resolver.d.ts +44 -0
  155. package/dist/runtime/require-resolver.d.ts.map +1 -0
  156. package/dist/runtime/require-resolver.js +698 -0
  157. package/dist/runtime/router-basename.d.ts +36 -0
  158. package/dist/runtime/router-basename.d.ts.map +1 -0
  159. package/dist/runtime/router-basename.js +310 -0
  160. package/dist/runtime/ruby-green-threads.d.ts +136 -0
  161. package/dist/runtime/ruby-green-threads.d.ts.map +1 -0
  162. package/dist/runtime/ruby-green-threads.js +904 -0
  163. package/dist/runtime/ruby-socket-shim.d.ts +2 -0
  164. package/dist/runtime/ruby-socket-shim.d.ts.map +1 -0
  165. package/dist/runtime/ruby-socket-shim.js +548 -0
  166. package/dist/runtime/session-process-supervisor.d.ts +156 -0
  167. package/dist/runtime/session-process-supervisor.d.ts.map +1 -0
  168. package/dist/runtime/session-process-supervisor.js +238 -0
  169. package/dist/runtime/sqlite-runtime-fs-bridge.d.ts +70 -0
  170. package/dist/runtime/sqlite-runtime-fs-bridge.d.ts.map +1 -0
  171. package/dist/runtime/sqlite-runtime-fs-bridge.js +425 -0
  172. package/dist/runtime/streams.d.ts +13 -0
  173. package/dist/runtime/streams.d.ts.map +1 -0
  174. package/dist/runtime/streams.js +546 -0
  175. package/dist/runtime/undici-shim.d.ts +62 -0
  176. package/dist/runtime/undici-shim.d.ts.map +1 -0
  177. package/dist/runtime/undici-shim.js +516 -0
  178. package/dist/runtime/vfs-manifest.d.ts +63 -0
  179. package/dist/runtime/vfs-manifest.d.ts.map +1 -0
  180. package/dist/runtime/vfs-manifest.js +141 -0
  181. package/dist/runtime/vfs-snapshot.d.ts +75 -0
  182. package/dist/runtime/vfs-snapshot.d.ts.map +1 -0
  183. package/dist/runtime/vfs-snapshot.js +220 -0
  184. package/dist/runtime/virtual-socket-kernel.d.ts +252 -0
  185. package/dist/runtime/virtual-socket-kernel.d.ts.map +1 -0
  186. package/dist/runtime/virtual-socket-kernel.js +1143 -0
  187. package/dist/runtime/vite-config-parser.d.ts +13 -0
  188. package/dist/runtime/vite-config-parser.d.ts.map +1 -0
  189. package/dist/runtime/vite-config-parser.js +258 -0
  190. package/dist/runtime/wasi/types.d.ts +347 -0
  191. package/dist/runtime/wasi/types.d.ts.map +1 -0
  192. package/dist/runtime/wasi/types.js +1 -0
  193. package/dist/runtime/wasi-instance.d.ts +215 -0
  194. package/dist/runtime/wasi-instance.d.ts.map +1 -0
  195. package/dist/runtime/wasi-instance.generated.d.ts +14 -0
  196. package/dist/runtime/wasi-instance.generated.d.ts.map +1 -0
  197. package/dist/runtime/wasi-instance.generated.js +13 -0
  198. package/dist/runtime/wasi-instance.js +179 -0
  199. package/dist/runtime/wasi-threads.d.ts +169 -0
  200. package/dist/runtime/wasi-threads.d.ts.map +1 -0
  201. package/dist/runtime/wasi-threads.js +669 -0
  202. package/dist/runtime/wasm-memory.d.ts +84 -0
  203. package/dist/runtime/wasm-memory.d.ts.map +1 -0
  204. package/dist/runtime/wasm-memory.js +235 -0
  205. package/dist/shell/elevation-commands.d.ts +5 -0
  206. package/dist/shell/elevation-commands.d.ts.map +1 -0
  207. package/dist/shell/elevation-commands.js +109 -0
  208. package/dist/shell/exec-dispatch.d.ts +57 -0
  209. package/dist/shell/exec-dispatch.d.ts.map +1 -0
  210. package/dist/shell/exec-dispatch.js +181 -0
  211. package/dist/shell/features.d.ts +154 -0
  212. package/dist/shell/features.d.ts.map +1 -0
  213. package/dist/shell/features.js +792 -0
  214. package/dist/shell/shell-entrypoints.d.ts +55 -0
  215. package/dist/shell/shell-entrypoints.d.ts.map +1 -0
  216. package/dist/shell/shell-entrypoints.js +230 -0
  217. package/dist/shell/shell-invocation.d.ts +36 -0
  218. package/dist/shell/shell-invocation.d.ts.map +1 -0
  219. package/dist/shell/shell-invocation.js +148 -0
  220. package/dist/shell/unix-accounts.d.ts +27 -0
  221. package/dist/shell/unix-accounts.d.ts.map +1 -0
  222. package/dist/shell/unix-accounts.js +105 -0
  223. package/dist/shell/unix-commands.d.ts +15 -0
  224. package/dist/shell/unix-commands.d.ts.map +1 -0
  225. package/dist/shell/unix-commands.js +4702 -0
  226. package/dist/substrate/lifo/commands/archive/gunzip.d.ts +4 -0
  227. package/dist/substrate/lifo/commands/archive/gunzip.d.ts.map +1 -0
  228. package/dist/substrate/lifo/commands/archive/gunzip.js +58 -0
  229. package/dist/substrate/lifo/commands/archive/gzip.d.ts +4 -0
  230. package/dist/substrate/lifo/commands/archive/gzip.d.ts.map +1 -0
  231. package/dist/substrate/lifo/commands/archive/gzip.js +73 -0
  232. package/dist/substrate/lifo/commands/archive/tar.d.ts +4 -0
  233. package/dist/substrate/lifo/commands/archive/tar.d.ts.map +1 -0
  234. package/dist/substrate/lifo/commands/archive/tar.js +158 -0
  235. package/dist/substrate/lifo/commands/archive/unzip.d.ts +4 -0
  236. package/dist/substrate/lifo/commands/archive/unzip.d.ts.map +1 -0
  237. package/dist/substrate/lifo/commands/archive/unzip.js +114 -0
  238. package/dist/substrate/lifo/commands/archive/zip.d.ts +4 -0
  239. package/dist/substrate/lifo/commands/archive/zip.d.ts.map +1 -0
  240. package/dist/substrate/lifo/commands/archive/zip.js +58 -0
  241. package/dist/substrate/lifo/commands/fs/basename.d.ts +4 -0
  242. package/dist/substrate/lifo/commands/fs/basename.d.ts.map +1 -0
  243. package/dist/substrate/lifo/commands/fs/basename.js +12 -0
  244. package/dist/substrate/lifo/commands/fs/cat.d.ts +4 -0
  245. package/dist/substrate/lifo/commands/fs/cat.d.ts.map +1 -0
  246. package/dist/substrate/lifo/commands/fs/cat.js +52 -0
  247. package/dist/substrate/lifo/commands/fs/chmod.d.ts +25 -0
  248. package/dist/substrate/lifo/commands/fs/chmod.d.ts.map +1 -0
  249. package/dist/substrate/lifo/commands/fs/chmod.js +97 -0
  250. package/dist/substrate/lifo/commands/fs/chown.d.ts +4 -0
  251. package/dist/substrate/lifo/commands/fs/chown.d.ts.map +1 -0
  252. package/dist/substrate/lifo/commands/fs/chown.js +41 -0
  253. package/dist/substrate/lifo/commands/fs/cp.d.ts +4 -0
  254. package/dist/substrate/lifo/commands/fs/cp.d.ts.map +1 -0
  255. package/dist/substrate/lifo/commands/fs/cp.js +29 -0
  256. package/dist/substrate/lifo/commands/fs/df.d.ts +4 -0
  257. package/dist/substrate/lifo/commands/fs/df.d.ts.map +1 -0
  258. package/dist/substrate/lifo/commands/fs/df.js +52 -0
  259. package/dist/substrate/lifo/commands/fs/dirname.d.ts +4 -0
  260. package/dist/substrate/lifo/commands/fs/dirname.d.ts.map +1 -0
  261. package/dist/substrate/lifo/commands/fs/dirname.js +12 -0
  262. package/dist/substrate/lifo/commands/fs/du.d.ts +4 -0
  263. package/dist/substrate/lifo/commands/fs/du.d.ts.map +1 -0
  264. package/dist/substrate/lifo/commands/fs/du.js +104 -0
  265. package/dist/substrate/lifo/commands/fs/file.d.ts +4 -0
  266. package/dist/substrate/lifo/commands/fs/file.d.ts.map +1 -0
  267. package/dist/substrate/lifo/commands/fs/file.js +84 -0
  268. package/dist/substrate/lifo/commands/fs/find.d.ts +4 -0
  269. package/dist/substrate/lifo/commands/fs/find.d.ts.map +1 -0
  270. package/dist/substrate/lifo/commands/fs/find.js +72 -0
  271. package/dist/substrate/lifo/commands/fs/ln.d.ts +4 -0
  272. package/dist/substrate/lifo/commands/fs/ln.d.ts.map +1 -0
  273. package/dist/substrate/lifo/commands/fs/ln.js +15 -0
  274. package/dist/substrate/lifo/commands/fs/ls.d.ts +4 -0
  275. package/dist/substrate/lifo/commands/fs/ls.d.ts.map +1 -0
  276. package/dist/substrate/lifo/commands/fs/ls.js +146 -0
  277. package/dist/substrate/lifo/commands/fs/mkdir.d.ts +4 -0
  278. package/dist/substrate/lifo/commands/fs/mkdir.d.ts.map +1 -0
  279. package/dist/substrate/lifo/commands/fs/mkdir.js +31 -0
  280. package/dist/substrate/lifo/commands/fs/mktemp.d.ts +4 -0
  281. package/dist/substrate/lifo/commands/fs/mktemp.d.ts.map +1 -0
  282. package/dist/substrate/lifo/commands/fs/mktemp.js +48 -0
  283. package/dist/substrate/lifo/commands/fs/mv.d.ts +4 -0
  284. package/dist/substrate/lifo/commands/fs/mv.d.ts.map +1 -0
  285. package/dist/substrate/lifo/commands/fs/mv.js +113 -0
  286. package/dist/substrate/lifo/commands/fs/realpath.d.ts +4 -0
  287. package/dist/substrate/lifo/commands/fs/realpath.d.ts.map +1 -0
  288. package/dist/substrate/lifo/commands/fs/realpath.js +27 -0
  289. package/dist/substrate/lifo/commands/fs/rm.d.ts +4 -0
  290. package/dist/substrate/lifo/commands/fs/rm.d.ts.map +1 -0
  291. package/dist/substrate/lifo/commands/fs/rm.js +48 -0
  292. package/dist/substrate/lifo/commands/fs/rmdir.d.ts +4 -0
  293. package/dist/substrate/lifo/commands/fs/rmdir.d.ts.map +1 -0
  294. package/dist/substrate/lifo/commands/fs/rmdir.js +44 -0
  295. package/dist/substrate/lifo/commands/fs/stat.d.ts +4 -0
  296. package/dist/substrate/lifo/commands/fs/stat.d.ts.map +1 -0
  297. package/dist/substrate/lifo/commands/fs/stat.js +35 -0
  298. package/dist/substrate/lifo/commands/fs/touch.d.ts +4 -0
  299. package/dist/substrate/lifo/commands/fs/touch.d.ts.map +1 -0
  300. package/dist/substrate/lifo/commands/fs/touch.js +26 -0
  301. package/dist/substrate/lifo/commands/fs/tree.d.ts +4 -0
  302. package/dist/substrate/lifo/commands/fs/tree.d.ts.map +1 -0
  303. package/dist/substrate/lifo/commands/fs/tree.js +69 -0
  304. package/dist/substrate/lifo/commands/index.d.ts +3 -0
  305. package/dist/substrate/lifo/commands/index.d.ts.map +1 -0
  306. package/dist/substrate/lifo/commands/index.js +1 -0
  307. package/dist/substrate/lifo/commands/io/dd.d.ts +4 -0
  308. package/dist/substrate/lifo/commands/io/dd.d.ts.map +1 -0
  309. package/dist/substrate/lifo/commands/io/dd.js +256 -0
  310. package/dist/substrate/lifo/commands/io/printf.d.ts +4 -0
  311. package/dist/substrate/lifo/commands/io/printf.d.ts.map +1 -0
  312. package/dist/substrate/lifo/commands/io/printf.js +82 -0
  313. package/dist/substrate/lifo/commands/io/tee.d.ts +4 -0
  314. package/dist/substrate/lifo/commands/io/tee.d.ts.map +1 -0
  315. package/dist/substrate/lifo/commands/io/tee.js +31 -0
  316. package/dist/substrate/lifo/commands/io/xargs.d.ts +4 -0
  317. package/dist/substrate/lifo/commands/io/xargs.d.ts.map +1 -0
  318. package/dist/substrate/lifo/commands/io/xargs.js +44 -0
  319. package/dist/substrate/lifo/commands/io/yes.d.ts +4 -0
  320. package/dist/substrate/lifo/commands/io/yes.d.ts.map +1 -0
  321. package/dist/substrate/lifo/commands/io/yes.js +10 -0
  322. package/dist/substrate/lifo/commands/net/curl.d.ts +6 -0
  323. package/dist/substrate/lifo/commands/net/curl.d.ts.map +1 -0
  324. package/dist/substrate/lifo/commands/net/curl.js +617 -0
  325. package/dist/substrate/lifo/commands/net/dig.d.ts +4 -0
  326. package/dist/substrate/lifo/commands/net/dig.d.ts.map +1 -0
  327. package/dist/substrate/lifo/commands/net/dig.js +77 -0
  328. package/dist/substrate/lifo/commands/net/forward.d.ts +14 -0
  329. package/dist/substrate/lifo/commands/net/forward.d.ts.map +1 -0
  330. package/dist/substrate/lifo/commands/net/forward.js +80 -0
  331. package/dist/substrate/lifo/commands/net/host.d.ts +14 -0
  332. package/dist/substrate/lifo/commands/net/host.d.ts.map +1 -0
  333. package/dist/substrate/lifo/commands/net/host.js +160 -0
  334. package/dist/substrate/lifo/commands/net/ifconfig.d.ts +8 -0
  335. package/dist/substrate/lifo/commands/net/ifconfig.d.ts.map +1 -0
  336. package/dist/substrate/lifo/commands/net/ifconfig.js +120 -0
  337. package/dist/substrate/lifo/commands/net/ip.d.ts +14 -0
  338. package/dist/substrate/lifo/commands/net/ip.d.ts.map +1 -0
  339. package/dist/substrate/lifo/commands/net/ip.js +508 -0
  340. package/dist/substrate/lifo/commands/net/netstat.d.ts +8 -0
  341. package/dist/substrate/lifo/commands/net/netstat.d.ts.map +1 -0
  342. package/dist/substrate/lifo/commands/net/netstat.js +94 -0
  343. package/dist/substrate/lifo/commands/net/ping.d.ts +4 -0
  344. package/dist/substrate/lifo/commands/net/ping.d.ts.map +1 -0
  345. package/dist/substrate/lifo/commands/net/ping.js +64 -0
  346. package/dist/substrate/lifo/commands/net/ports.d.ts +8 -0
  347. package/dist/substrate/lifo/commands/net/ports.d.ts.map +1 -0
  348. package/dist/substrate/lifo/commands/net/ports.js +36 -0
  349. package/dist/substrate/lifo/commands/net/route.d.ts +8 -0
  350. package/dist/substrate/lifo/commands/net/route.d.ts.map +1 -0
  351. package/dist/substrate/lifo/commands/net/route.js +128 -0
  352. package/dist/substrate/lifo/commands/net/tunnel-v2.d.ts +4 -0
  353. package/dist/substrate/lifo/commands/net/tunnel-v2.d.ts.map +1 -0
  354. package/dist/substrate/lifo/commands/net/tunnel-v2.js +141 -0
  355. package/dist/substrate/lifo/commands/net/tunnel.d.ts +6 -0
  356. package/dist/substrate/lifo/commands/net/tunnel.d.ts.map +1 -0
  357. package/dist/substrate/lifo/commands/net/tunnel.js +232 -0
  358. package/dist/substrate/lifo/commands/net/wget.d.ts +4 -0
  359. package/dist/substrate/lifo/commands/net/wget.d.ts.map +1 -0
  360. package/dist/substrate/lifo/commands/net/wget.js +78 -0
  361. package/dist/substrate/lifo/commands/registry.d.ts +15 -0
  362. package/dist/substrate/lifo/commands/registry.d.ts.map +1 -0
  363. package/dist/substrate/lifo/commands/registry.js +120 -0
  364. package/dist/substrate/lifo/commands/signal.d.ts +12 -0
  365. package/dist/substrate/lifo/commands/signal.d.ts.map +1 -0
  366. package/dist/substrate/lifo/commands/signal.js +47 -0
  367. package/dist/substrate/lifo/commands/system/bc.d.ts +4 -0
  368. package/dist/substrate/lifo/commands/system/bc.d.ts.map +1 -0
  369. package/dist/substrate/lifo/commands/system/bc.js +243 -0
  370. package/dist/substrate/lifo/commands/system/cal.d.ts +4 -0
  371. package/dist/substrate/lifo/commands/system/cal.d.ts.map +1 -0
  372. package/dist/substrate/lifo/commands/system/cal.js +81 -0
  373. package/dist/substrate/lifo/commands/system/date.d.ts +4 -0
  374. package/dist/substrate/lifo/commands/system/date.d.ts.map +1 -0
  375. package/dist/substrate/lifo/commands/system/date.js +79 -0
  376. package/dist/substrate/lifo/commands/system/env.d.ts +4 -0
  377. package/dist/substrate/lifo/commands/system/env.d.ts.map +1 -0
  378. package/dist/substrate/lifo/commands/system/env.js +7 -0
  379. package/dist/substrate/lifo/commands/system/fastfetch.d.ts +4 -0
  380. package/dist/substrate/lifo/commands/system/fastfetch.d.ts.map +1 -0
  381. package/dist/substrate/lifo/commands/system/fastfetch.js +385 -0
  382. package/dist/substrate/lifo/commands/system/free.d.ts +4 -0
  383. package/dist/substrate/lifo/commands/system/free.d.ts.map +1 -0
  384. package/dist/substrate/lifo/commands/system/free.js +36 -0
  385. package/dist/substrate/lifo/commands/system/help.d.ts +4 -0
  386. package/dist/substrate/lifo/commands/system/help.d.ts.map +1 -0
  387. package/dist/substrate/lifo/commands/system/help.js +46 -0
  388. package/dist/substrate/lifo/commands/system/hostname.d.ts +4 -0
  389. package/dist/substrate/lifo/commands/system/hostname.d.ts.map +1 -0
  390. package/dist/substrate/lifo/commands/system/hostname.js +6 -0
  391. package/dist/substrate/lifo/commands/system/kill.d.ts +4 -0
  392. package/dist/substrate/lifo/commands/system/kill.d.ts.map +1 -0
  393. package/dist/substrate/lifo/commands/system/kill.js +76 -0
  394. package/dist/substrate/lifo/commands/system/lifo.d.ts +41 -0
  395. package/dist/substrate/lifo/commands/system/lifo.d.ts.map +1 -0
  396. package/dist/substrate/lifo/commands/system/lifo.js +446 -0
  397. package/dist/substrate/lifo/commands/system/logout.d.ts +5 -0
  398. package/dist/substrate/lifo/commands/system/logout.d.ts.map +1 -0
  399. package/dist/substrate/lifo/commands/system/logout.js +15 -0
  400. package/dist/substrate/lifo/commands/system/man.d.ts +4 -0
  401. package/dist/substrate/lifo/commands/system/man.d.ts.map +1 -0
  402. package/dist/substrate/lifo/commands/system/man.js +144 -0
  403. package/dist/substrate/lifo/commands/system/node.d.ts +6 -0
  404. package/dist/substrate/lifo/commands/system/node.d.ts.map +1 -0
  405. package/dist/substrate/lifo/commands/system/node.js +1241 -0
  406. package/dist/substrate/lifo/commands/system/npm.d.ts +26 -0
  407. package/dist/substrate/lifo/commands/system/npm.d.ts.map +1 -0
  408. package/dist/substrate/lifo/commands/system/npm.js +934 -0
  409. package/dist/substrate/lifo/commands/system/pkg.d.ts +4 -0
  410. package/dist/substrate/lifo/commands/system/pkg.d.ts.map +1 -0
  411. package/dist/substrate/lifo/commands/system/pkg.js +97 -0
  412. package/dist/substrate/lifo/commands/system/ps.d.ts +5 -0
  413. package/dist/substrate/lifo/commands/system/ps.d.ts.map +1 -0
  414. package/dist/substrate/lifo/commands/system/ps.js +35 -0
  415. package/dist/substrate/lifo/commands/system/registry-schemas.d.ts +44 -0
  416. package/dist/substrate/lifo/commands/system/registry-schemas.d.ts.map +1 -0
  417. package/dist/substrate/lifo/commands/system/registry-schemas.js +28 -0
  418. package/dist/substrate/lifo/commands/system/sha256sum.d.ts +4 -0
  419. package/dist/substrate/lifo/commands/system/sha256sum.d.ts.map +1 -0
  420. package/dist/substrate/lifo/commands/system/sha256sum.js +86 -0
  421. package/dist/substrate/lifo/commands/system/sl.d.ts +4 -0
  422. package/dist/substrate/lifo/commands/system/sl.d.ts.map +1 -0
  423. package/dist/substrate/lifo/commands/system/sl.js +204 -0
  424. package/dist/substrate/lifo/commands/system/sleep.d.ts +4 -0
  425. package/dist/substrate/lifo/commands/system/sleep.d.ts.map +1 -0
  426. package/dist/substrate/lifo/commands/system/sleep.js +27 -0
  427. package/dist/substrate/lifo/commands/system/stty.d.ts +4 -0
  428. package/dist/substrate/lifo/commands/system/stty.d.ts.map +1 -0
  429. package/dist/substrate/lifo/commands/system/stty.js +61 -0
  430. package/dist/substrate/lifo/commands/system/systemctl.d.ts +4 -0
  431. package/dist/substrate/lifo/commands/system/systemctl.d.ts.map +1 -0
  432. package/dist/substrate/lifo/commands/system/systemctl.js +164 -0
  433. package/dist/substrate/lifo/commands/system/top.d.ts +4 -0
  434. package/dist/substrate/lifo/commands/system/top.d.ts.map +1 -0
  435. package/dist/substrate/lifo/commands/system/top.js +38 -0
  436. package/dist/substrate/lifo/commands/system/uname.d.ts +4 -0
  437. package/dist/substrate/lifo/commands/system/uname.d.ts.map +1 -0
  438. package/dist/substrate/lifo/commands/system/uname.js +55 -0
  439. package/dist/substrate/lifo/commands/system/uptime.d.ts +4 -0
  440. package/dist/substrate/lifo/commands/system/uptime.d.ts.map +1 -0
  441. package/dist/substrate/lifo/commands/system/uptime.js +16 -0
  442. package/dist/substrate/lifo/commands/system/watch.d.ts +4 -0
  443. package/dist/substrate/lifo/commands/system/watch.d.ts.map +1 -0
  444. package/dist/substrate/lifo/commands/system/watch.js +53 -0
  445. package/dist/substrate/lifo/commands/system/which.d.ts +4 -0
  446. package/dist/substrate/lifo/commands/system/which.d.ts.map +1 -0
  447. package/dist/substrate/lifo/commands/system/which.js +45 -0
  448. package/dist/substrate/lifo/commands/system/whoami.d.ts +4 -0
  449. package/dist/substrate/lifo/commands/system/whoami.d.ts.map +1 -0
  450. package/dist/substrate/lifo/commands/system/whoami.js +6 -0
  451. package/dist/substrate/lifo/commands/text/awk.d.ts +4 -0
  452. package/dist/substrate/lifo/commands/text/awk.d.ts.map +1 -0
  453. package/dist/substrate/lifo/commands/text/awk.js +200 -0
  454. package/dist/substrate/lifo/commands/text/base64.d.ts +4 -0
  455. package/dist/substrate/lifo/commands/text/base64.d.ts.map +1 -0
  456. package/dist/substrate/lifo/commands/text/base64.js +102 -0
  457. package/dist/substrate/lifo/commands/text/cut.d.ts +4 -0
  458. package/dist/substrate/lifo/commands/text/cut.d.ts.map +1 -0
  459. package/dist/substrate/lifo/commands/text/cut.js +91 -0
  460. package/dist/substrate/lifo/commands/text/diff.d.ts +4 -0
  461. package/dist/substrate/lifo/commands/text/diff.d.ts.map +1 -0
  462. package/dist/substrate/lifo/commands/text/diff.js +292 -0
  463. package/dist/substrate/lifo/commands/text/grep.d.ts +4 -0
  464. package/dist/substrate/lifo/commands/text/grep.d.ts.map +1 -0
  465. package/dist/substrate/lifo/commands/text/grep.js +189 -0
  466. package/dist/substrate/lifo/commands/text/head.d.ts +4 -0
  467. package/dist/substrate/lifo/commands/text/head.d.ts.map +1 -0
  468. package/dist/substrate/lifo/commands/text/head.js +111 -0
  469. package/dist/substrate/lifo/commands/text/less.d.ts +4 -0
  470. package/dist/substrate/lifo/commands/text/less.d.ts.map +1 -0
  471. package/dist/substrate/lifo/commands/text/less.js +335 -0
  472. package/dist/substrate/lifo/commands/text/nano.d.ts +4 -0
  473. package/dist/substrate/lifo/commands/text/nano.d.ts.map +1 -0
  474. package/dist/substrate/lifo/commands/text/nano.js +510 -0
  475. package/dist/substrate/lifo/commands/text/nl.d.ts +4 -0
  476. package/dist/substrate/lifo/commands/text/nl.d.ts.map +1 -0
  477. package/dist/substrate/lifo/commands/text/nl.js +64 -0
  478. package/dist/substrate/lifo/commands/text/rev.d.ts +4 -0
  479. package/dist/substrate/lifo/commands/text/rev.d.ts.map +1 -0
  480. package/dist/substrate/lifo/commands/text/rev.js +41 -0
  481. package/dist/substrate/lifo/commands/text/sed.d.ts +21 -0
  482. package/dist/substrate/lifo/commands/text/sed.d.ts.map +1 -0
  483. package/dist/substrate/lifo/commands/text/sed.js +248 -0
  484. package/dist/substrate/lifo/commands/text/seq.d.ts +4 -0
  485. package/dist/substrate/lifo/commands/text/seq.d.ts.map +1 -0
  486. package/dist/substrate/lifo/commands/text/seq.js +69 -0
  487. package/dist/substrate/lifo/commands/text/sort.d.ts +4 -0
  488. package/dist/substrate/lifo/commands/text/sort.d.ts.map +1 -0
  489. package/dist/substrate/lifo/commands/text/sort.js +90 -0
  490. package/dist/substrate/lifo/commands/text/strings.d.ts +4 -0
  491. package/dist/substrate/lifo/commands/text/strings.d.ts.map +1 -0
  492. package/dist/substrate/lifo/commands/text/strings.js +69 -0
  493. package/dist/substrate/lifo/commands/text/tac.d.ts +4 -0
  494. package/dist/substrate/lifo/commands/text/tac.d.ts.map +1 -0
  495. package/dist/substrate/lifo/commands/text/tac.js +32 -0
  496. package/dist/substrate/lifo/commands/text/tail.d.ts +4 -0
  497. package/dist/substrate/lifo/commands/text/tail.d.ts.map +1 -0
  498. package/dist/substrate/lifo/commands/text/tail.js +64 -0
  499. package/dist/substrate/lifo/commands/text/tr.d.ts +4 -0
  500. package/dist/substrate/lifo/commands/text/tr.d.ts.map +1 -0
  501. package/dist/substrate/lifo/commands/text/tr.js +180 -0
  502. package/dist/substrate/lifo/commands/text/uniq.d.ts +4 -0
  503. package/dist/substrate/lifo/commands/text/uniq.d.ts.map +1 -0
  504. package/dist/substrate/lifo/commands/text/uniq.js +82 -0
  505. package/dist/substrate/lifo/commands/text/wc.d.ts +4 -0
  506. package/dist/substrate/lifo/commands/text/wc.d.ts.map +1 -0
  507. package/dist/substrate/lifo/commands/text/wc.js +107 -0
  508. package/dist/substrate/lifo/commands/types.d.ts +49 -0
  509. package/dist/substrate/lifo/commands/types.d.ts.map +1 -0
  510. package/dist/substrate/lifo/commands/types.js +1 -0
  511. package/dist/substrate/lifo/index.d.ts +67 -0
  512. package/dist/substrate/lifo/index.d.ts.map +1 -0
  513. package/dist/substrate/lifo/index.js +66 -0
  514. package/dist/substrate/lifo/kernel/ServiceManager.d.ts +51 -0
  515. package/dist/substrate/lifo/kernel/ServiceManager.d.ts.map +1 -0
  516. package/dist/substrate/lifo/kernel/ServiceManager.js +302 -0
  517. package/dist/substrate/lifo/kernel/index.d.ts +40 -0
  518. package/dist/substrate/lifo/kernel/index.d.ts.map +1 -0
  519. package/dist/substrate/lifo/kernel/index.js +170 -0
  520. package/dist/substrate/lifo/kernel/network/Bridge.d.ts +110 -0
  521. package/dist/substrate/lifo/kernel/network/Bridge.d.ts.map +1 -0
  522. package/dist/substrate/lifo/kernel/network/Bridge.js +278 -0
  523. package/dist/substrate/lifo/kernel/network/DNSResolver.d.ts +50 -0
  524. package/dist/substrate/lifo/kernel/network/DNSResolver.d.ts.map +1 -0
  525. package/dist/substrate/lifo/kernel/network/DNSResolver.js +135 -0
  526. package/dist/substrate/lifo/kernel/network/NetworkInterface.d.ts +83 -0
  527. package/dist/substrate/lifo/kernel/network/NetworkInterface.d.ts.map +1 -0
  528. package/dist/substrate/lifo/kernel/network/NetworkInterface.js +183 -0
  529. package/dist/substrate/lifo/kernel/network/NetworkNamespace.d.ts +98 -0
  530. package/dist/substrate/lifo/kernel/network/NetworkNamespace.d.ts.map +1 -0
  531. package/dist/substrate/lifo/kernel/network/NetworkNamespace.js +149 -0
  532. package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts +178 -0
  533. package/dist/substrate/lifo/kernel/network/NetworkStack.d.ts.map +1 -0
  534. package/dist/substrate/lifo/kernel/network/NetworkStack.js +460 -0
  535. package/dist/substrate/lifo/kernel/network/PortBridge.d.ts +44 -0
  536. package/dist/substrate/lifo/kernel/network/PortBridge.d.ts.map +1 -0
  537. package/dist/substrate/lifo/kernel/network/PortBridge.js +158 -0
  538. package/dist/substrate/lifo/kernel/network/RoutingTable.d.ts +55 -0
  539. package/dist/substrate/lifo/kernel/network/RoutingTable.d.ts.map +1 -0
  540. package/dist/substrate/lifo/kernel/network/RoutingTable.js +167 -0
  541. package/dist/substrate/lifo/kernel/network/Socket.d.ts +65 -0
  542. package/dist/substrate/lifo/kernel/network/Socket.d.ts.map +1 -0
  543. package/dist/substrate/lifo/kernel/network/Socket.js +201 -0
  544. package/dist/substrate/lifo/kernel/network/index.d.ts +11 -0
  545. package/dist/substrate/lifo/kernel/network/index.d.ts.map +1 -0
  546. package/dist/substrate/lifo/kernel/network/index.js +9 -0
  547. package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.d.ts +55 -0
  548. package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.d.ts.map +1 -0
  549. package/dist/substrate/lifo/kernel/network/tunnel/BaseTunnel.js +88 -0
  550. package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.d.ts +71 -0
  551. package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.d.ts.map +1 -0
  552. package/dist/substrate/lifo/kernel/network/tunnel/VETHPair.js +191 -0
  553. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts +89 -0
  554. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.d.ts.map +1 -0
  555. package/dist/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.js +324 -0
  556. package/dist/substrate/lifo/kernel/network/types.d.ts +159 -0
  557. package/dist/substrate/lifo/kernel/network/types.d.ts.map +1 -0
  558. package/dist/substrate/lifo/kernel/network/types.js +5 -0
  559. package/dist/substrate/lifo/kernel/persistence/PersistenceManager.d.ts +12 -0
  560. package/dist/substrate/lifo/kernel/persistence/PersistenceManager.d.ts.map +1 -0
  561. package/dist/substrate/lifo/kernel/persistence/PersistenceManager.js +47 -0
  562. package/dist/substrate/lifo/kernel/persistence/backends.d.ts +15 -0
  563. package/dist/substrate/lifo/kernel/persistence/backends.d.ts.map +1 -0
  564. package/dist/substrate/lifo/kernel/persistence/backends.js +18 -0
  565. package/dist/substrate/lifo/kernel/persistence/index.d.ts +6 -0
  566. package/dist/substrate/lifo/kernel/persistence/index.d.ts.map +1 -0
  567. package/dist/substrate/lifo/kernel/persistence/index.js +3 -0
  568. package/dist/substrate/lifo/kernel/persistence/serializer.d.ts +21 -0
  569. package/dist/substrate/lifo/kernel/persistence/serializer.d.ts.map +1 -0
  570. package/dist/substrate/lifo/kernel/persistence/serializer.js +99 -0
  571. package/dist/substrate/lifo/kernel/samples.d.ts +3 -0
  572. package/dist/substrate/lifo/kernel/samples.d.ts.map +1 -0
  573. package/dist/substrate/lifo/kernel/samples.js +930 -0
  574. package/dist/substrate/lifo/kernel/storage/BlobStore.d.ts +22 -0
  575. package/dist/substrate/lifo/kernel/storage/BlobStore.d.ts.map +1 -0
  576. package/dist/substrate/lifo/kernel/storage/BlobStore.js +84 -0
  577. package/dist/substrate/lifo/kernel/storage/ContentStore.d.ts +54 -0
  578. package/dist/substrate/lifo/kernel/storage/ContentStore.d.ts.map +1 -0
  579. package/dist/substrate/lifo/kernel/storage/ContentStore.js +120 -0
  580. package/dist/substrate/lifo/kernel/storage/index.d.ts +6 -0
  581. package/dist/substrate/lifo/kernel/storage/index.d.ts.map +1 -0
  582. package/dist/substrate/lifo/kernel/storage/index.js +3 -0
  583. package/dist/substrate/lifo/kernel/unit-parser.d.ts +22 -0
  584. package/dist/substrate/lifo/kernel/unit-parser.d.ts.map +1 -0
  585. package/dist/substrate/lifo/kernel/unit-parser.js +80 -0
  586. package/dist/substrate/lifo/kernel/vfs/VFS.d.ts +99 -0
  587. package/dist/substrate/lifo/kernel/vfs/VFS.d.ts.map +1 -0
  588. package/dist/substrate/lifo/kernel/vfs/VFS.js +679 -0
  589. package/dist/substrate/lifo/kernel/vfs/index.d.ts +8 -0
  590. package/dist/substrate/lifo/kernel/vfs/index.d.ts.map +1 -0
  591. package/dist/substrate/lifo/kernel/vfs/index.js +5 -0
  592. package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.d.ts +21 -0
  593. package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.d.ts.map +1 -0
  594. package/dist/substrate/lifo/kernel/vfs/providers/DevProvider.js +137 -0
  595. package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.d.ts +63 -0
  596. package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.d.ts.map +1 -0
  597. package/dist/substrate/lifo/kernel/vfs/providers/NativeFsProvider.js +175 -0
  598. package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.d.ts +14 -0
  599. package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.d.ts.map +1 -0
  600. package/dist/substrate/lifo/kernel/vfs/providers/ProcProvider.js +126 -0
  601. package/dist/substrate/lifo/kernel/vfs/types.d.ts +117 -0
  602. package/dist/substrate/lifo/kernel/vfs/types.d.ts.map +1 -0
  603. package/dist/substrate/lifo/kernel/vfs/types.js +42 -0
  604. package/dist/substrate/lifo/node-compat/buffer.d.ts +44 -0
  605. package/dist/substrate/lifo/node-compat/buffer.d.ts.map +1 -0
  606. package/dist/substrate/lifo/node-compat/buffer.js +331 -0
  607. package/dist/substrate/lifo/node-compat/child_process.d.ts +10 -0
  608. package/dist/substrate/lifo/node-compat/child_process.d.ts.map +1 -0
  609. package/dist/substrate/lifo/node-compat/child_process.js +42 -0
  610. package/dist/substrate/lifo/node-compat/console.d.ts +21 -0
  611. package/dist/substrate/lifo/node-compat/console.d.ts.map +1 -0
  612. package/dist/substrate/lifo/node-compat/console.js +68 -0
  613. package/dist/substrate/lifo/node-compat/crypto.d.ts +24 -0
  614. package/dist/substrate/lifo/node-compat/crypto.d.ts.map +1 -0
  615. package/dist/substrate/lifo/node-compat/crypto.js +216 -0
  616. package/dist/substrate/lifo/node-compat/dns.d.ts +117 -0
  617. package/dist/substrate/lifo/node-compat/dns.d.ts.map +1 -0
  618. package/dist/substrate/lifo/node-compat/dns.js +144 -0
  619. package/dist/substrate/lifo/node-compat/esbuild.d.ts +10 -0
  620. package/dist/substrate/lifo/node-compat/esbuild.d.ts.map +1 -0
  621. package/dist/substrate/lifo/node-compat/esbuild.js +70 -0
  622. package/dist/substrate/lifo/node-compat/events.d.ts +19 -0
  623. package/dist/substrate/lifo/node-compat/events.d.ts.map +1 -0
  624. package/dist/substrate/lifo/node-compat/events.js +83 -0
  625. package/dist/substrate/lifo/node-compat/fs.d.ts +195 -0
  626. package/dist/substrate/lifo/node-compat/fs.d.ts.map +1 -0
  627. package/dist/substrate/lifo/node-compat/fs.js +624 -0
  628. package/dist/substrate/lifo/node-compat/http.d.ts +133 -0
  629. package/dist/substrate/lifo/node-compat/http.d.ts.map +1 -0
  630. package/dist/substrate/lifo/node-compat/http.js +452 -0
  631. package/dist/substrate/lifo/node-compat/index.d.ts +20 -0
  632. package/dist/substrate/lifo/node-compat/index.d.ts.map +1 -0
  633. package/dist/substrate/lifo/node-compat/index.js +291 -0
  634. package/dist/substrate/lifo/node-compat/module.d.ts +55 -0
  635. package/dist/substrate/lifo/node-compat/module.d.ts.map +1 -0
  636. package/dist/substrate/lifo/node-compat/module.js +124 -0
  637. package/dist/substrate/lifo/node-compat/os.d.ts +39 -0
  638. package/dist/substrate/lifo/node-compat/os.d.ts.map +1 -0
  639. package/dist/substrate/lifo/node-compat/os.js +45 -0
  640. package/dist/substrate/lifo/node-compat/path.d.ts +86 -0
  641. package/dist/substrate/lifo/node-compat/path.d.ts.map +1 -0
  642. package/dist/substrate/lifo/node-compat/path.js +49 -0
  643. package/dist/substrate/lifo/node-compat/process.d.ts +127 -0
  644. package/dist/substrate/lifo/node-compat/process.d.ts.map +1 -0
  645. package/dist/substrate/lifo/node-compat/process.js +173 -0
  646. package/dist/substrate/lifo/node-compat/readline.d.ts +85 -0
  647. package/dist/substrate/lifo/node-compat/readline.d.ts.map +1 -0
  648. package/dist/substrate/lifo/node-compat/readline.js +205 -0
  649. package/dist/substrate/lifo/node-compat/rimraf.d.ts +30 -0
  650. package/dist/substrate/lifo/node-compat/rimraf.d.ts.map +1 -0
  651. package/dist/substrate/lifo/node-compat/rimraf.js +63 -0
  652. package/dist/substrate/lifo/node-compat/stream.d.ts +36 -0
  653. package/dist/substrate/lifo/node-compat/stream.d.ts.map +1 -0
  654. package/dist/substrate/lifo/node-compat/stream.js +90 -0
  655. package/dist/substrate/lifo/node-compat/string_decoder.d.ts +11 -0
  656. package/dist/substrate/lifo/node-compat/string_decoder.d.ts.map +1 -0
  657. package/dist/substrate/lifo/node-compat/string_decoder.js +23 -0
  658. package/dist/substrate/lifo/node-compat/timers.d.ts +16 -0
  659. package/dist/substrate/lifo/node-compat/timers.d.ts.map +1 -0
  660. package/dist/substrate/lifo/node-compat/timers.js +18 -0
  661. package/dist/substrate/lifo/node-compat/tty.d.ts +32 -0
  662. package/dist/substrate/lifo/node-compat/tty.d.ts.map +1 -0
  663. package/dist/substrate/lifo/node-compat/tty.js +76 -0
  664. package/dist/substrate/lifo/node-compat/url.d.ts +37 -0
  665. package/dist/substrate/lifo/node-compat/url.d.ts.map +1 -0
  666. package/dist/substrate/lifo/node-compat/url.js +65 -0
  667. package/dist/substrate/lifo/node-compat/util.d.ts +42 -0
  668. package/dist/substrate/lifo/node-compat/util.d.ts.map +1 -0
  669. package/dist/substrate/lifo/node-compat/util.js +132 -0
  670. package/dist/substrate/lifo/node-compat/zlib.d.ts +66 -0
  671. package/dist/substrate/lifo/node-compat/zlib.d.ts.map +1 -0
  672. package/dist/substrate/lifo/node-compat/zlib.js +80 -0
  673. package/dist/substrate/lifo/pkg/PackageManager.d.ts +19 -0
  674. package/dist/substrate/lifo/pkg/PackageManager.d.ts.map +1 -0
  675. package/dist/substrate/lifo/pkg/PackageManager.js +97 -0
  676. package/dist/substrate/lifo/pkg/lifo-dev.d.ts +38 -0
  677. package/dist/substrate/lifo/pkg/lifo-dev.d.ts.map +1 -0
  678. package/dist/substrate/lifo/pkg/lifo-dev.js +98 -0
  679. package/dist/substrate/lifo/pkg/lifo-runtime.d.ts +44 -0
  680. package/dist/substrate/lifo/pkg/lifo-runtime.d.ts.map +1 -0
  681. package/dist/substrate/lifo/pkg/lifo-runtime.js +372 -0
  682. package/dist/substrate/lifo/pkg/loader.d.ts +4 -0
  683. package/dist/substrate/lifo/pkg/loader.d.ts.map +1 -0
  684. package/dist/substrate/lifo/pkg/loader.js +24 -0
  685. package/dist/substrate/lifo/sandbox/HeadlessTerminal.d.ts +18 -0
  686. package/dist/substrate/lifo/sandbox/HeadlessTerminal.d.ts.map +1 -0
  687. package/dist/substrate/lifo/sandbox/HeadlessTerminal.js +28 -0
  688. package/dist/substrate/lifo/sandbox/Sandbox.d.ts +59 -0
  689. package/dist/substrate/lifo/sandbox/Sandbox.d.ts.map +1 -0
  690. package/dist/substrate/lifo/sandbox/Sandbox.js +234 -0
  691. package/dist/substrate/lifo/sandbox/SandboxCommands.d.ts +18 -0
  692. package/dist/substrate/lifo/sandbox/SandboxCommands.d.ts.map +1 -0
  693. package/dist/substrate/lifo/sandbox/SandboxCommands.js +64 -0
  694. package/dist/substrate/lifo/sandbox/SandboxFs.d.ts +43 -0
  695. package/dist/substrate/lifo/sandbox/SandboxFs.d.ts.map +1 -0
  696. package/dist/substrate/lifo/sandbox/SandboxFs.js +136 -0
  697. package/dist/substrate/lifo/sandbox/index.d.ts +3 -0
  698. package/dist/substrate/lifo/sandbox/index.d.ts.map +1 -0
  699. package/dist/substrate/lifo/sandbox/index.js +1 -0
  700. package/dist/substrate/lifo/sandbox/types.d.ts +116 -0
  701. package/dist/substrate/lifo/sandbox/types.d.ts.map +1 -0
  702. package/dist/substrate/lifo/sandbox/types.js +1 -0
  703. package/dist/substrate/lifo/shell/ProcessRegistry.d.ts +142 -0
  704. package/dist/substrate/lifo/shell/ProcessRegistry.d.ts.map +1 -0
  705. package/dist/substrate/lifo/shell/ProcessRegistry.js +256 -0
  706. package/dist/substrate/lifo/shell/Shell.d.ts +170 -0
  707. package/dist/substrate/lifo/shell/Shell.d.ts.map +1 -0
  708. package/dist/substrate/lifo/shell/Shell.js +1863 -0
  709. package/dist/substrate/lifo/shell/completer.d.ts +19 -0
  710. package/dist/substrate/lifo/shell/completer.d.ts.map +1 -0
  711. package/dist/substrate/lifo/shell/completer.js +164 -0
  712. package/dist/substrate/lifo/shell/default-shell.d.ts +9 -0
  713. package/dist/substrate/lifo/shell/default-shell.d.ts.map +1 -0
  714. package/dist/substrate/lifo/shell/default-shell.js +53 -0
  715. package/dist/substrate/lifo/shell/expander.d.ts +48 -0
  716. package/dist/substrate/lifo/shell/expander.d.ts.map +1 -0
  717. package/dist/substrate/lifo/shell/expander.js +1204 -0
  718. package/dist/substrate/lifo/shell/history.d.ts +22 -0
  719. package/dist/substrate/lifo/shell/history.d.ts.map +1 -0
  720. package/dist/substrate/lifo/shell/history.js +121 -0
  721. package/dist/substrate/lifo/shell/interpreter.d.ts +257 -0
  722. package/dist/substrate/lifo/shell/interpreter.d.ts.map +1 -0
  723. package/dist/substrate/lifo/shell/interpreter.js +1490 -0
  724. package/dist/substrate/lifo/shell/jobs.d.ts +21 -0
  725. package/dist/substrate/lifo/shell/jobs.d.ts.map +1 -0
  726. package/dist/substrate/lifo/shell/jobs.js +48 -0
  727. package/dist/substrate/lifo/shell/lexer.d.ts +13 -0
  728. package/dist/substrate/lifo/shell/lexer.d.ts.map +1 -0
  729. package/dist/substrate/lifo/shell/lexer.js +614 -0
  730. package/dist/substrate/lifo/shell/parser.d.ts +7 -0
  731. package/dist/substrate/lifo/shell/parser.d.ts.map +1 -0
  732. package/dist/substrate/lifo/shell/parser.js +573 -0
  733. package/dist/substrate/lifo/shell/pipe.d.ts +15 -0
  734. package/dist/substrate/lifo/shell/pipe.d.ts.map +1 -0
  735. package/dist/substrate/lifo/shell/pipe.js +86 -0
  736. package/dist/substrate/lifo/shell/signals.d.ts +11 -0
  737. package/dist/substrate/lifo/shell/signals.d.ts.map +1 -0
  738. package/dist/substrate/lifo/shell/signals.js +57 -0
  739. package/dist/substrate/lifo/shell/terminal-stdin.d.ts +28 -0
  740. package/dist/substrate/lifo/shell/terminal-stdin.d.ts.map +1 -0
  741. package/dist/substrate/lifo/shell/terminal-stdin.js +100 -0
  742. package/dist/substrate/lifo/shell/test-builtin.d.ts +16 -0
  743. package/dist/substrate/lifo/shell/test-builtin.d.ts.map +1 -0
  744. package/dist/substrate/lifo/shell/test-builtin.js +237 -0
  745. package/dist/substrate/lifo/shell/types.d.ts +140 -0
  746. package/dist/substrate/lifo/shell/types.d.ts.map +1 -0
  747. package/dist/substrate/lifo/shell/types.js +25 -0
  748. package/dist/substrate/lifo/terminal/ITerminal.d.ts +10 -0
  749. package/dist/substrate/lifo/terminal/ITerminal.d.ts.map +1 -0
  750. package/dist/substrate/lifo/terminal/ITerminal.js +1 -0
  751. package/dist/substrate/lifo/utils/archive.d.ts +28 -0
  752. package/dist/substrate/lifo/utils/archive.d.ts.map +1 -0
  753. package/dist/substrate/lifo/utils/archive.js +323 -0
  754. package/dist/substrate/lifo/utils/args.d.ts +18 -0
  755. package/dist/substrate/lifo/utils/args.d.ts.map +1 -0
  756. package/dist/substrate/lifo/utils/args.js +73 -0
  757. package/dist/substrate/lifo/utils/colors.d.ts +27 -0
  758. package/dist/substrate/lifo/utils/colors.d.ts.map +1 -0
  759. package/dist/substrate/lifo/utils/colors.js +26 -0
  760. package/dist/substrate/lifo/utils/encoding.d.ts +4 -0
  761. package/dist/substrate/lifo/utils/encoding.d.ts.map +1 -0
  762. package/dist/substrate/lifo/utils/encoding.js +18 -0
  763. package/dist/substrate/lifo/utils/glob.d.ts +12 -0
  764. package/dist/substrate/lifo/utils/glob.d.ts.map +1 -0
  765. package/dist/substrate/lifo/utils/glob.js +150 -0
  766. package/dist/substrate/lifo/utils/mime.d.ts +4 -0
  767. package/dist/substrate/lifo/utils/mime.d.ts.map +1 -0
  768. package/dist/substrate/lifo/utils/mime.js +107 -0
  769. package/dist/substrate/lifo/utils/path.d.ts +12 -0
  770. package/dist/substrate/lifo/utils/path.d.ts.map +1 -0
  771. package/dist/substrate/lifo/utils/path.js +82 -0
  772. package/dist/vfs/events.d.ts +51 -0
  773. package/dist/vfs/events.d.ts.map +1 -0
  774. package/dist/vfs/events.js +127 -0
  775. package/dist/vfs/path.d.ts +46 -0
  776. package/dist/vfs/path.d.ts.map +1 -0
  777. package/dist/vfs/path.js +69 -0
  778. package/dist/vfs/seed-project.d.ts +62 -0
  779. package/dist/vfs/seed-project.d.ts.map +1 -0
  780. package/dist/vfs/seed-project.js +1054 -0
  781. package/dist/vfs/sqlite-vfs.d.ts +821 -0
  782. package/dist/vfs/sqlite-vfs.d.ts.map +1 -0
  783. package/dist/vfs/sqlite-vfs.js +4135 -0
  784. package/dist/vfs/symlink-registry.d.ts +60 -0
  785. package/dist/vfs/symlink-registry.d.ts.map +1 -0
  786. package/dist/vfs/symlink-registry.js +162 -0
  787. package/dist/workspace/nimbus-workspace.d.ts +94 -0
  788. package/dist/workspace/nimbus-workspace.d.ts.map +1 -0
  789. package/dist/workspace/nimbus-workspace.js +167 -0
  790. package/package.json +69 -0
  791. package/src/_shared/ai-egress.ts +91 -0
  792. package/src/_shared/byte-stream.ts +97 -0
  793. package/src/_shared/bytes.ts +19 -0
  794. package/src/_shared/cache-stats.ts +231 -0
  795. package/src/_shared/crypto.ts +184 -0
  796. package/src/_shared/esbuild-facet-shim.ts +22 -0
  797. package/src/_shared/exports-resolver.ts +308 -0
  798. package/src/_shared/facet-vfs-cursor.ts +58 -0
  799. package/src/_shared/install-phase.ts +56 -0
  800. package/src/_shared/lru-map.ts +59 -0
  801. package/src/_shared/real-node-imports.ts +53 -0
  802. package/src/_shared/retry.ts +202 -0
  803. package/src/_shared/rpc-dispose.ts +31 -0
  804. package/src/_shared/terminal.ts +3 -0
  805. package/src/_shared/typescript-specifiers.ts +86 -0
  806. package/src/_shared/untrusted-request.ts +75 -0
  807. package/src/_shared/vfs-write-ledger.ts +440 -0
  808. package/src/_shared/w7-frame.ts +1012 -0
  809. package/src/_shared/weighted-credit-pool.ts +244 -0
  810. package/src/constants.ts +285 -0
  811. package/src/index.ts +22 -0
  812. package/src/observability/diag-counters.ts +343 -0
  813. package/src/observability/heap-estimate.ts +331 -0
  814. package/src/observability/heavy-alloc-coord.ts +241 -0
  815. package/src/observability/oom-classify.ts +253 -0
  816. package/src/observability/oom-discriminator.ts +405 -0
  817. package/src/runtime/assets-loader.ts +189 -0
  818. package/src/runtime/barrel-detect.ts +69 -0
  819. package/src/runtime/bash/preamble.ts +1519 -0
  820. package/src/runtime/bash/types.ts +497 -0
  821. package/src/runtime/bundle-profile.ts +32 -0
  822. package/src/runtime/cirrus-vite-config-rewriter.ts +28 -0
  823. package/src/runtime/cli-flags.ts +11 -0
  824. package/src/runtime/comment-strip.ts +73 -0
  825. package/src/runtime/cpython-preamble.ts +298 -0
  826. package/src/runtime/esbuild-service.ts +1470 -0
  827. package/src/runtime/framework-detect.ts +245 -0
  828. package/src/runtime/import-meta-transform.ts +16 -0
  829. package/src/runtime/javascript-ast.ts +66 -0
  830. package/src/runtime/long-running-handle.ts +185 -0
  831. package/src/runtime/module-source-rewriter.ts +95 -0
  832. package/src/runtime/opentui-wasm-backend.ts +608 -0
  833. package/src/runtime/os-contracts.ts +529 -0
  834. package/src/runtime/port-registry.ts +298 -0
  835. package/src/runtime/process-input-routing.ts +92 -0
  836. package/src/runtime/process-input.ts +148 -0
  837. package/src/runtime/process-io-protocol.ts +97 -0
  838. package/src/runtime/process-logs.ts +882 -0
  839. package/src/runtime/process-table.ts +225 -0
  840. package/src/runtime/project-detect.ts +42 -0
  841. package/src/runtime/python-server-adapter.ts +133 -0
  842. package/src/runtime/require-resolver.ts +760 -0
  843. package/src/runtime/router-basename.ts +279 -0
  844. package/src/runtime/ruby-green-threads.ts +904 -0
  845. package/src/runtime/ruby-socket-shim.ts +548 -0
  846. package/src/runtime/session-process-supervisor.ts +323 -0
  847. package/src/runtime/sqlite-runtime-fs-bridge.ts +468 -0
  848. package/src/runtime/streams.ts +547 -0
  849. package/src/runtime/undici-shim.ts +517 -0
  850. package/src/runtime/vfs-manifest.ts +170 -0
  851. package/src/runtime/vfs-snapshot.ts +273 -0
  852. package/src/runtime/virtual-socket-kernel.ts +1370 -0
  853. package/src/runtime/vite-config-parser.ts +273 -0
  854. package/src/runtime/wasi/types.ts +448 -0
  855. package/src/runtime/wasi-instance.generated.ts +14 -0
  856. package/src/runtime/wasi-instance.ts +259 -0
  857. package/src/runtime/wasi-threads.ts +682 -0
  858. package/src/runtime/wasm-memory.ts +261 -0
  859. package/src/shell/elevation-commands.ts +117 -0
  860. package/src/shell/exec-dispatch.ts +201 -0
  861. package/src/shell/features.ts +870 -0
  862. package/src/shell/shell-entrypoints.ts +323 -0
  863. package/src/shell/shell-invocation.ts +181 -0
  864. package/src/shell/unix-accounts.ts +128 -0
  865. package/src/shell/unix-commands.ts +4335 -0
  866. package/src/substrate/lifo/UPSTREAM.md +14 -0
  867. package/src/substrate/lifo/commands/archive/gunzip.ts +63 -0
  868. package/src/substrate/lifo/commands/archive/gzip.ts +76 -0
  869. package/src/substrate/lifo/commands/archive/tar.ts +157 -0
  870. package/src/substrate/lifo/commands/archive/unzip.ts +112 -0
  871. package/src/substrate/lifo/commands/archive/zip.ts +70 -0
  872. package/src/substrate/lifo/commands/fs/basename.ts +16 -0
  873. package/src/substrate/lifo/commands/fs/cat.ts +54 -0
  874. package/src/substrate/lifo/commands/fs/chmod.ts +110 -0
  875. package/src/substrate/lifo/commands/fs/chown.ts +45 -0
  876. package/src/substrate/lifo/commands/fs/cp.ts +33 -0
  877. package/src/substrate/lifo/commands/fs/df.ts +56 -0
  878. package/src/substrate/lifo/commands/fs/dirname.ts +16 -0
  879. package/src/substrate/lifo/commands/fs/du.ts +100 -0
  880. package/src/substrate/lifo/commands/fs/file.ts +90 -0
  881. package/src/substrate/lifo/commands/fs/find.ts +76 -0
  882. package/src/substrate/lifo/commands/fs/ln.ts +19 -0
  883. package/src/substrate/lifo/commands/fs/ls.ts +164 -0
  884. package/src/substrate/lifo/commands/fs/mkdir.ts +37 -0
  885. package/src/substrate/lifo/commands/fs/mktemp.ts +56 -0
  886. package/src/substrate/lifo/commands/fs/mv.ts +111 -0
  887. package/src/substrate/lifo/commands/fs/realpath.ts +31 -0
  888. package/src/substrate/lifo/commands/fs/rm.ts +53 -0
  889. package/src/substrate/lifo/commands/fs/rmdir.ts +50 -0
  890. package/src/substrate/lifo/commands/fs/stat.ts +39 -0
  891. package/src/substrate/lifo/commands/fs/touch.ts +30 -0
  892. package/src/substrate/lifo/commands/fs/tree.ts +76 -0
  893. package/src/substrate/lifo/commands/index.ts +2 -0
  894. package/src/substrate/lifo/commands/io/dd.ts +289 -0
  895. package/src/substrate/lifo/commands/io/printf.ts +78 -0
  896. package/src/substrate/lifo/commands/io/tee.ts +37 -0
  897. package/src/substrate/lifo/commands/io/xargs.ts +49 -0
  898. package/src/substrate/lifo/commands/io/yes.ts +15 -0
  899. package/src/substrate/lifo/commands/net/curl.ts +739 -0
  900. package/src/substrate/lifo/commands/net/dig.ts +99 -0
  901. package/src/substrate/lifo/commands/net/forward.ts +90 -0
  902. package/src/substrate/lifo/commands/net/host.ts +182 -0
  903. package/src/substrate/lifo/commands/net/ifconfig.ts +139 -0
  904. package/src/substrate/lifo/commands/net/ip.ts +633 -0
  905. package/src/substrate/lifo/commands/net/netstat.ts +106 -0
  906. package/src/substrate/lifo/commands/net/ping.ts +74 -0
  907. package/src/substrate/lifo/commands/net/ports.ts +45 -0
  908. package/src/substrate/lifo/commands/net/route.ts +153 -0
  909. package/src/substrate/lifo/commands/net/tunnel-v2.ts +183 -0
  910. package/src/substrate/lifo/commands/net/tunnel.ts +272 -0
  911. package/src/substrate/lifo/commands/net/wget.ts +88 -0
  912. package/src/substrate/lifo/commands/registry.ts +141 -0
  913. package/src/substrate/lifo/commands/signal.ts +65 -0
  914. package/src/substrate/lifo/commands/system/bc.ts +265 -0
  915. package/src/substrate/lifo/commands/system/cal.ts +90 -0
  916. package/src/substrate/lifo/commands/system/date.ts +59 -0
  917. package/src/substrate/lifo/commands/system/env.ts +10 -0
  918. package/src/substrate/lifo/commands/system/fastfetch.ts +428 -0
  919. package/src/substrate/lifo/commands/system/free.ts +38 -0
  920. package/src/substrate/lifo/commands/system/help.ts +53 -0
  921. package/src/substrate/lifo/commands/system/hostname.ts +9 -0
  922. package/src/substrate/lifo/commands/system/kill.ts +89 -0
  923. package/src/substrate/lifo/commands/system/lifo.ts +525 -0
  924. package/src/substrate/lifo/commands/system/logout.ts +17 -0
  925. package/src/substrate/lifo/commands/system/man.ts +167 -0
  926. package/src/substrate/lifo/commands/system/node.ts +1305 -0
  927. package/src/substrate/lifo/commands/system/npm.ts +1078 -0
  928. package/src/substrate/lifo/commands/system/pkg.ts +111 -0
  929. package/src/substrate/lifo/commands/system/ps.ts +46 -0
  930. package/src/substrate/lifo/commands/system/registry-schemas.ts +33 -0
  931. package/src/substrate/lifo/commands/system/sha256sum.ts +89 -0
  932. package/src/substrate/lifo/commands/system/sl.ts +249 -0
  933. package/src/substrate/lifo/commands/system/sleep.ts +36 -0
  934. package/src/substrate/lifo/commands/system/stty.ts +69 -0
  935. package/src/substrate/lifo/commands/system/systemctl.ts +184 -0
  936. package/src/substrate/lifo/commands/system/top.ts +53 -0
  937. package/src/substrate/lifo/commands/system/uname.ts +59 -0
  938. package/src/substrate/lifo/commands/system/uptime.ts +19 -0
  939. package/src/substrate/lifo/commands/system/watch.ts +67 -0
  940. package/src/substrate/lifo/commands/system/which.ts +51 -0
  941. package/src/substrate/lifo/commands/system/whoami.ts +9 -0
  942. package/src/substrate/lifo/commands/text/awk.ts +210 -0
  943. package/src/substrate/lifo/commands/text/base64.ts +102 -0
  944. package/src/substrate/lifo/commands/text/cut.ts +92 -0
  945. package/src/substrate/lifo/commands/text/diff.ts +314 -0
  946. package/src/substrate/lifo/commands/text/grep.ts +170 -0
  947. package/src/substrate/lifo/commands/text/head.ts +95 -0
  948. package/src/substrate/lifo/commands/text/less.ts +335 -0
  949. package/src/substrate/lifo/commands/text/nano.ts +513 -0
  950. package/src/substrate/lifo/commands/text/nl.ts +74 -0
  951. package/src/substrate/lifo/commands/text/rev.ts +46 -0
  952. package/src/substrate/lifo/commands/text/sed.ts +297 -0
  953. package/src/substrate/lifo/commands/text/seq.ts +76 -0
  954. package/src/substrate/lifo/commands/text/sort.ts +88 -0
  955. package/src/substrate/lifo/commands/text/strings.ts +73 -0
  956. package/src/substrate/lifo/commands/text/tac.ts +37 -0
  957. package/src/substrate/lifo/commands/text/tail.ts +63 -0
  958. package/src/substrate/lifo/commands/text/tr.ts +192 -0
  959. package/src/substrate/lifo/commands/text/uniq.ts +77 -0
  960. package/src/substrate/lifo/commands/text/wc.ts +104 -0
  961. package/src/substrate/lifo/commands/types.ts +58 -0
  962. package/src/substrate/lifo/index.ts +173 -0
  963. package/src/substrate/lifo/kernel/ServiceManager.ts +371 -0
  964. package/src/substrate/lifo/kernel/index.ts +209 -0
  965. package/src/substrate/lifo/kernel/network/Bridge.ts +336 -0
  966. package/src/substrate/lifo/kernel/network/DNSResolver.ts +158 -0
  967. package/src/substrate/lifo/kernel/network/NetworkInterface.ts +235 -0
  968. package/src/substrate/lifo/kernel/network/NetworkNamespace.ts +182 -0
  969. package/src/substrate/lifo/kernel/network/NetworkStack.ts +590 -0
  970. package/src/substrate/lifo/kernel/network/PortBridge.ts +182 -0
  971. package/src/substrate/lifo/kernel/network/RoutingTable.ts +209 -0
  972. package/src/substrate/lifo/kernel/network/Socket.ts +245 -0
  973. package/src/substrate/lifo/kernel/network/index.ts +29 -0
  974. package/src/substrate/lifo/kernel/network/tunnel/BaseTunnel.ts +124 -0
  975. package/src/substrate/lifo/kernel/network/tunnel/VETHPair.ts +227 -0
  976. package/src/substrate/lifo/kernel/network/tunnel/WebSocketTunnel.ts +387 -0
  977. package/src/substrate/lifo/kernel/network/types.ts +178 -0
  978. package/src/substrate/lifo/kernel/persistence/PersistenceManager.ts +50 -0
  979. package/src/substrate/lifo/kernel/persistence/backends.ts +36 -0
  980. package/src/substrate/lifo/kernel/persistence/index.ts +5 -0
  981. package/src/substrate/lifo/kernel/persistence/serializer.ts +127 -0
  982. package/src/substrate/lifo/kernel/samples.ts +966 -0
  983. package/src/substrate/lifo/kernel/storage/BlobStore.ts +114 -0
  984. package/src/substrate/lifo/kernel/storage/ContentStore.ts +150 -0
  985. package/src/substrate/lifo/kernel/storage/index.ts +5 -0
  986. package/src/substrate/lifo/kernel/unit-parser.ts +95 -0
  987. package/src/substrate/lifo/kernel/vfs/VFS.ts +768 -0
  988. package/src/substrate/lifo/kernel/vfs/index.ts +9 -0
  989. package/src/substrate/lifo/kernel/vfs/providers/DevProvider.ts +172 -0
  990. package/src/substrate/lifo/kernel/vfs/providers/NativeFsProvider.ts +198 -0
  991. package/src/substrate/lifo/kernel/vfs/providers/ProcProvider.ts +144 -0
  992. package/src/substrate/lifo/kernel/vfs/types.ts +145 -0
  993. package/src/substrate/lifo/node-compat/buffer.ts +357 -0
  994. package/src/substrate/lifo/node-compat/child_process.ts +52 -0
  995. package/src/substrate/lifo/node-compat/console.ts +70 -0
  996. package/src/substrate/lifo/node-compat/crypto.ts +186 -0
  997. package/src/substrate/lifo/node-compat/dns.ts +214 -0
  998. package/src/substrate/lifo/node-compat/esbuild.ts +85 -0
  999. package/src/substrate/lifo/node-compat/events.ts +94 -0
  1000. package/src/substrate/lifo/node-compat/fs.ts +762 -0
  1001. package/src/substrate/lifo/node-compat/http.ts +561 -0
  1002. package/src/substrate/lifo/node-compat/index.ts +300 -0
  1003. package/src/substrate/lifo/node-compat/module.ts +148 -0
  1004. package/src/substrate/lifo/node-compat/os.ts +44 -0
  1005. package/src/substrate/lifo/node-compat/path.ts +74 -0
  1006. package/src/substrate/lifo/node-compat/process.ts +178 -0
  1007. package/src/substrate/lifo/node-compat/readline.ts +244 -0
  1008. package/src/substrate/lifo/node-compat/rimraf.ts +80 -0
  1009. package/src/substrate/lifo/node-compat/stream.ts +98 -0
  1010. package/src/substrate/lifo/node-compat/string_decoder.ts +26 -0
  1011. package/src/substrate/lifo/node-compat/timers.ts +21 -0
  1012. package/src/substrate/lifo/node-compat/tty.ts +83 -0
  1013. package/src/substrate/lifo/node-compat/url.ts +76 -0
  1014. package/src/substrate/lifo/node-compat/util.ts +133 -0
  1015. package/src/substrate/lifo/node-compat/zlib.ts +94 -0
  1016. package/src/substrate/lifo/pkg/PackageManager.ts +105 -0
  1017. package/src/substrate/lifo/pkg/lifo-dev.ts +130 -0
  1018. package/src/substrate/lifo/pkg/lifo-runtime.ts +473 -0
  1019. package/src/substrate/lifo/pkg/loader.ts +33 -0
  1020. package/src/substrate/lifo/platform-globals.d.ts +41 -0
  1021. package/src/substrate/lifo/sandbox/HeadlessTerminal.ts +38 -0
  1022. package/src/substrate/lifo/sandbox/Sandbox.ts +279 -0
  1023. package/src/substrate/lifo/sandbox/SandboxCommands.ts +74 -0
  1024. package/src/substrate/lifo/sandbox/SandboxFs.ts +160 -0
  1025. package/src/substrate/lifo/sandbox/index.ts +8 -0
  1026. package/src/substrate/lifo/sandbox/types.ts +117 -0
  1027. package/src/substrate/lifo/shell/ProcessRegistry.ts +379 -0
  1028. package/src/substrate/lifo/shell/Shell.ts +2048 -0
  1029. package/src/substrate/lifo/shell/completer.ts +212 -0
  1030. package/src/substrate/lifo/shell/default-shell.ts +63 -0
  1031. package/src/substrate/lifo/shell/expander.ts +1349 -0
  1032. package/src/substrate/lifo/shell/history.ts +138 -0
  1033. package/src/substrate/lifo/shell/interpreter.ts +1754 -0
  1034. package/src/substrate/lifo/shell/jobs.ts +64 -0
  1035. package/src/substrate/lifo/shell/lexer.ts +698 -0
  1036. package/src/substrate/lifo/shell/parser.ts +711 -0
  1037. package/src/substrate/lifo/shell/pipe.ts +92 -0
  1038. package/src/substrate/lifo/shell/signals.ts +70 -0
  1039. package/src/substrate/lifo/shell/terminal-stdin.ts +109 -0
  1040. package/src/substrate/lifo/shell/test-builtin.ts +316 -0
  1041. package/src/substrate/lifo/shell/types.ts +166 -0
  1042. package/src/substrate/lifo/terminal/ITerminal.ts +9 -0
  1043. package/src/substrate/lifo/utils/archive.ts +389 -0
  1044. package/src/substrate/lifo/utils/args.ts +89 -0
  1045. package/src/substrate/lifo/utils/colors.ts +29 -0
  1046. package/src/substrate/lifo/utils/encoding.ts +21 -0
  1047. package/src/substrate/lifo/utils/glob.ts +172 -0
  1048. package/src/substrate/lifo/utils/mime.ts +114 -0
  1049. package/src/substrate/lifo/utils/path.ts +83 -0
  1050. package/src/types/assets.d.ts +4 -0
  1051. package/src/vfs/events.ts +134 -0
  1052. package/src/vfs/path.ts +71 -0
  1053. package/src/vfs/seed-project.ts +1094 -0
  1054. package/src/vfs/sqlite-vfs.ts +5035 -0
  1055. package/src/vfs/symlink-registry.ts +172 -0
  1056. package/src/workspace/nimbus-workspace.ts +213 -0
@@ -0,0 +1,1490 @@
1
+ import { lex } from './lexer.js';
2
+ import { parse } from './parser.js';
3
+ import { expandWords, expandWord, evaluateSubscript, ExpansionError, } from './expander.js';
4
+ import { evaluateDoubleBracketWords } from './test-builtin.js';
5
+ import { PipeChannel } from './pipe.js';
6
+ import { exitCodeForAbortSignal } from './signals.js';
7
+ import { resolve } from '../utils/path.js';
8
+ import { encode } from '../utils/encoding.js';
9
+ import { globMatch } from '../utils/glob.js';
10
+ /**
11
+ * Bytes a file-backed descriptor holds before committing. Matches the stream
12
+ * chunk size used elsewhere and keeps a line-at-a-time producer from paying a
13
+ * store write per line.
14
+ */
15
+ const FILE_WRITE_BLOCK_BYTES = 64 * 1024;
16
+ function concatBytes(parts, total) {
17
+ const out = new Uint8Array(total);
18
+ let at = 0;
19
+ for (const part of parts) {
20
+ out.set(part, at);
21
+ at += part.length;
22
+ }
23
+ return out;
24
+ }
25
+ // ─── Signal classes for control flow ───
26
+ export class BreakSignal {
27
+ levels;
28
+ constructor(levels) {
29
+ this.levels = levels;
30
+ }
31
+ }
32
+ export class ContinueSignal {
33
+ levels;
34
+ constructor(levels) {
35
+ this.levels = levels;
36
+ }
37
+ }
38
+ export class ReturnSignal {
39
+ exitCode;
40
+ constructor(exitCode) {
41
+ this.exitCode = exitCode;
42
+ }
43
+ }
44
+ export class ErrexitSignal {
45
+ exitCode;
46
+ constructor(exitCode) {
47
+ this.exitCode = exitCode;
48
+ }
49
+ }
50
+ export class ExitSignal {
51
+ exitCode;
52
+ constructor(exitCode) {
53
+ this.exitCode = exitCode;
54
+ }
55
+ }
56
+ class RedirectionOpenError extends Error {
57
+ target;
58
+ fsError;
59
+ constructor(target, fsError) {
60
+ super(fsError instanceof Error ? fsError.message : String(fsError));
61
+ this.target = target;
62
+ this.fsError = fsError;
63
+ }
64
+ }
65
+ function redirectionDiagnostic(error) {
66
+ const code = typeof error.fsError === 'object' && error.fsError !== null
67
+ && 'code' in error.fsError && typeof error.fsError.code === 'string'
68
+ ? error.fsError.code
69
+ : /^([A-Z][A-Z0-9]+):/.exec(error.message)?.[1];
70
+ const reason = code === 'EACCES' || code === 'EPERM'
71
+ ? 'Permission denied'
72
+ : code === 'ENOENT'
73
+ ? 'No such file or directory'
74
+ : code === 'ENOTDIR'
75
+ ? 'Not a directory'
76
+ : code === 'EISDIR'
77
+ ? 'Is a directory'
78
+ : error.message;
79
+ return `sh: ${error.target}: ${reason}\n`;
80
+ }
81
+ /**
82
+ * Assign a plain value to a name. A name that already holds an array keeps it:
83
+ * `a=(x y); a=plain` sets `a[0]` and leaves `a[1]` alone, which is bash's rule
84
+ * and the reason a variable's type only changes through `unset`.
85
+ */
86
+ export function assignScalar(env, arrays, name, value) {
87
+ const array = arrays.get(name);
88
+ if (array === undefined)
89
+ env[name] = value;
90
+ else
91
+ array[0] = value;
92
+ }
93
+ export class Interpreter {
94
+ config;
95
+ lastExitCode = 0;
96
+ functions = new Map();
97
+ persistentOutputFds = new Map();
98
+ persistentInputFds = new Map();
99
+ persistentTerminalOutputFds = new Set();
100
+ persistentTerminalInputFds = new Set();
101
+ errexitSuppressionDepth = 0;
102
+ exitTrapDepth = 0;
103
+ /** One frame per running function call, holding the bindings `local` shadowed. */
104
+ localFrames = [];
105
+ constructor(config) {
106
+ this.config = config;
107
+ }
108
+ getLastExitCode() {
109
+ return this.lastExitCode;
110
+ }
111
+ async executeScript(script, terminalStdin) {
112
+ return this.executeScriptWithIo(script, this.createTerminalIo(terminalStdin));
113
+ }
114
+ async executeScriptWithIo(script, io) {
115
+ let exitCode = 0;
116
+ try {
117
+ for (const list of script.lists) {
118
+ exitCode = await this.executeList(list, io);
119
+ }
120
+ }
121
+ catch (error) {
122
+ if (error instanceof ErrexitSignal) {
123
+ exitCode = error.exitCode;
124
+ }
125
+ else if (error instanceof ExitSignal) {
126
+ exitCode = error.exitCode;
127
+ }
128
+ else {
129
+ throw error;
130
+ }
131
+ }
132
+ this.lastExitCode = exitCode;
133
+ return exitCode;
134
+ }
135
+ async executeLine(input, terminalStdin, options) {
136
+ const io = this.createTerminalIo(terminalStdin, options?.terminalFds, options?.scriptMode === true, options?.stdin);
137
+ if (options?.stdout)
138
+ io.stdout = options.stdout;
139
+ if (options?.stderr)
140
+ io.stderr = options.stderr;
141
+ if (options?.writeToTerminal)
142
+ io.writeToTerminal = options.writeToTerminal;
143
+ if (options?.commandContext)
144
+ io.commandContext = options.commandContext;
145
+ if (options?.commandIdentity)
146
+ io.commandIdentity = options.commandIdentity;
147
+ if (options?.runAs)
148
+ io.runAs = options.runAs;
149
+ if (options?.signal)
150
+ io.signal = options.signal;
151
+ if (options?.commandIdentity)
152
+ io.vfs = this.config.vfs.as(options.commandIdentity.cred);
153
+ try {
154
+ const tokens = lex(input);
155
+ const script = parse(tokens);
156
+ const exitCode = await this.executeScriptWithIo(script, io);
157
+ return await this.runExitTrap(exitCode, io, options?.runExitTrap === true);
158
+ }
159
+ catch (e) {
160
+ if (e instanceof BreakSignal || e instanceof ContinueSignal || e instanceof ReturnSignal) {
161
+ throw e;
162
+ }
163
+ if (e instanceof ErrexitSignal) {
164
+ this.lastExitCode = e.exitCode;
165
+ return e.exitCode;
166
+ }
167
+ if (e instanceof Error) {
168
+ this.writeTerminal(io, `${e.message}\n`);
169
+ }
170
+ // A failed expansion aborts with 1, the way bash does; 2 is reserved for
171
+ // the shell's own usage errors (syntax, bad builtin invocation).
172
+ const exitCode = e instanceof ExpansionError ? 1 : 2;
173
+ this.lastExitCode = exitCode;
174
+ return exitCode;
175
+ }
176
+ }
177
+ async executeList(list, io = {}) {
178
+ const abortCode = this.abortExitCode(io);
179
+ if (abortCode !== null)
180
+ return abortCode;
181
+ if (list.background) {
182
+ const abortController = new AbortController();
183
+ const commandText = this.getListCommandText(list);
184
+ const backgroundIo = this.createCommandIo(io);
185
+ backgroundIo.signal = abortController.signal;
186
+ backgroundIo.registerProcess = false;
187
+ backgroundIo.positionals = this.forkPositionals(io);
188
+ const promise = (async () => {
189
+ return await this.executeListEntries(list.entries, backgroundIo);
190
+ })();
191
+ const pid = this.config.processRegistry.spawn({
192
+ command: commandText.split(' ')[0] || 'unknown',
193
+ args: commandText.split(' '),
194
+ cwd: this.config.getCwd(),
195
+ env: { ...this.config.env },
196
+ isForeground: false,
197
+ promise,
198
+ abortController,
199
+ });
200
+ const waitable = this.config.processRegistry.get(pid)?.promise ?? promise;
201
+ const jobId = this.config.jobTable.add(commandText, waitable, abortController);
202
+ this.config.env['!'] = String(pid);
203
+ this.writeTerminal(io, `[${jobId}] ${pid} (background)\n`);
204
+ // Don't auto-reap - let Shell collect zombies before next prompt
205
+ // This matches Linux behavior where zombies persist until reaped
206
+ return 0;
207
+ }
208
+ return this.executeListEntries(list.entries, io);
209
+ }
210
+ getListCommandText(list) {
211
+ return list.entries.map((e) => e.pipeline.commands.map((c) => {
212
+ if (c.type === 'simple_command') {
213
+ return c.words.map((w) => w.map((p) => p.text).join('')).join(' ');
214
+ }
215
+ return c.type;
216
+ }).join(' | ')).join(' ');
217
+ }
218
+ async executeListEntries(entries, io = {}) {
219
+ let exitCode = 0;
220
+ let skipNext = false;
221
+ for (const entry of entries) {
222
+ const abortCode = this.abortExitCode(io);
223
+ if (abortCode !== null)
224
+ return abortCode;
225
+ if (!skipNext) {
226
+ exitCode = await this.executePipeline(entry.pipeline, io);
227
+ }
228
+ skipNext = false;
229
+ this.enforceErrexit(entry.connector, exitCode);
230
+ if (entry.connector === '&&' && exitCode !== 0) {
231
+ skipNext = true;
232
+ }
233
+ else if (entry.connector === '||' && exitCode === 0) {
234
+ skipNext = true;
235
+ }
236
+ }
237
+ this.lastExitCode = exitCode;
238
+ return exitCode;
239
+ }
240
+ async executePipeline(pipeline, io = {}) {
241
+ const abortCode = this.abortExitCode(io);
242
+ if (abortCode !== null)
243
+ return abortCode;
244
+ const commands = pipeline.commands;
245
+ let exitCode;
246
+ if (commands.length === 1) {
247
+ // Single command -- no piping needed
248
+ exitCode = await this.executeCommand(commands[0], io);
249
+ }
250
+ else {
251
+ exitCode = await this.executePipelineCommands(commands, io);
252
+ }
253
+ if (pipeline.negated) {
254
+ exitCode = exitCode === 0 ? 1 : 0;
255
+ }
256
+ return exitCode;
257
+ }
258
+ async executePipelineCommands(commands, io) {
259
+ const pipes = [];
260
+ const promises = [];
261
+ const pipelineAbortController = new AbortController();
262
+ const parentSignal = io.signal ?? this.config.getAbortSignal?.();
263
+ let unlinkParentSignal;
264
+ if (parentSignal?.aborted) {
265
+ pipelineAbortController.abort(parentSignal.reason);
266
+ }
267
+ else if (parentSignal) {
268
+ unlinkParentSignal = linkAbortSignal(parentSignal, pipelineAbortController);
269
+ }
270
+ try {
271
+ for (let i = 0; i < commands.length; i++) {
272
+ const abortCode = this.abortExitCode(io);
273
+ if (abortCode !== null)
274
+ return abortCode;
275
+ const stdin = i > 0 ? pipes[i - 1].reader : undefined;
276
+ let stdout;
277
+ if (i < commands.length - 1) {
278
+ const pipe = new PipeChannel();
279
+ pipes.push(pipe);
280
+ stdout = pipe.writer;
281
+ }
282
+ const cmd = commands[i];
283
+ const isLast = i === commands.length - 1;
284
+ const commandStdin = stdin ?? (i === 0 ? io.stdin : undefined);
285
+ const commandStdout = stdout ?? (isLast ? io.stdout : undefined);
286
+ const cmdIo = this.createCommandIo(io);
287
+ if (commandStdin)
288
+ cmdIo.stdin = commandStdin;
289
+ else
290
+ delete cmdIo.stdin;
291
+ if (commandStdout)
292
+ cmdIo.stdout = commandStdout;
293
+ else
294
+ delete cmdIo.stdout;
295
+ cmdIo.terminalFds = {
296
+ stdin: stdin ? false : io.terminalFds?.stdin,
297
+ stdout: stdout ? false : io.terminalFds?.stdout,
298
+ stderr: io.terminalFds?.stderr,
299
+ };
300
+ cmdIo.signal = pipelineAbortController.signal;
301
+ cmdIo.positionals = this.forkPositionals(io);
302
+ const cmdPromise = (async () => {
303
+ try {
304
+ return await this.executeCommand(cmd, cmdIo);
305
+ }
306
+ catch (e) {
307
+ if (e instanceof ExitSignal) {
308
+ return e.exitCode;
309
+ }
310
+ throw e;
311
+ }
312
+ finally {
313
+ if (i < commands.length - 1) {
314
+ pipes[i].close();
315
+ }
316
+ if (isLast) {
317
+ pipelineAbortController.abort();
318
+ for (const pipe of pipes)
319
+ pipe.close();
320
+ }
321
+ }
322
+ })();
323
+ promises.push(cmdPromise);
324
+ }
325
+ const results = await Promise.all(promises);
326
+ if (this.config.options.pipefail) {
327
+ for (let i = results.length - 1; i >= 0; i--) {
328
+ if (results[i] !== 0)
329
+ return results[i] ?? 1;
330
+ }
331
+ }
332
+ return results[results.length - 1] ?? 0;
333
+ }
334
+ finally {
335
+ unlinkParentSignal?.();
336
+ }
337
+ }
338
+ async executeCommand(cmd, io = {}) {
339
+ const abortCode = this.abortExitCode(io);
340
+ if (abortCode !== null)
341
+ return abortCode;
342
+ switch (cmd.type) {
343
+ case 'simple_command':
344
+ return this.executeSimpleCommand(cmd, io);
345
+ case 'double_bracket':
346
+ return this.executeDoubleBracket(cmd, io);
347
+ case 'if':
348
+ return this.executeIf(cmd, io);
349
+ case 'for':
350
+ return this.executeFor(cmd, io);
351
+ case 'while':
352
+ return this.executeWhile(cmd, io);
353
+ case 'until':
354
+ return this.executeUntil(cmd, io);
355
+ case 'case':
356
+ return this.executeCase(cmd, io);
357
+ case 'group':
358
+ return this.executeGroup(cmd, io);
359
+ case 'subshell':
360
+ return this.executeSubshell(cmd, io);
361
+ case 'function_def':
362
+ return this.executeFunctionDef(cmd);
363
+ }
364
+ }
365
+ async executeIf(node, io) {
366
+ return this.executeWithRedirections(node.redirections, io, async (redirIo) => {
367
+ let exitCode = 0;
368
+ for (const clause of node.clauses) {
369
+ const condCode = await this.withErrexitSuppressed(() => this.executeCompoundList(clause.condition, redirIo));
370
+ if (condCode === 0) {
371
+ exitCode = await this.executeCompoundList(clause.body, redirIo);
372
+ this.lastExitCode = exitCode;
373
+ return exitCode;
374
+ }
375
+ }
376
+ if (node.elseBody) {
377
+ exitCode = await this.executeCompoundList(node.elseBody, redirIo);
378
+ }
379
+ this.lastExitCode = exitCode;
380
+ return exitCode;
381
+ });
382
+ }
383
+ async executeDoubleBracket(node, io) {
384
+ return this.executeWithRedirections(node.redirections, io, async (redirIo) => {
385
+ const stdout = redirIo.stdout ?? this.terminalSink(redirIo);
386
+ const stderr = redirIo.stderr ?? this.terminalSink(redirIo);
387
+ const fds = this.createCommandFds(stdout, stderr, redirIo.stdin, redirIo);
388
+ const builtinIo = this.createIoFromFds(redirIo, fds);
389
+ const exitCode = await this.withFdFlush(fds, () => evaluateDoubleBracketWords(node.words, this.createExpandContext(redirIo), redirIo.vfs ?? this.config.vfs, stderr, {
390
+ vfs: builtinIo.vfs ?? this.config.vfs,
391
+ cwd: this.config.getCwd(),
392
+ stdin: builtinIo.stdin,
393
+ stdout,
394
+ stderr,
395
+ terminalStdin: redirIo.terminalStdin,
396
+ terminalFds: {
397
+ stdin: fds.terminalInputFds.has(0),
398
+ stdout: fds.terminalOutputFds.has(1),
399
+ stderr: fds.terminalOutputFds.has(2),
400
+ },
401
+ scriptMode: redirIo.scriptMode,
402
+ isFdTerminal: (fd) => this.isFdTerminal(fds, fd),
403
+ getPositionals: () => this.readPositionals(builtinIo),
404
+ setPositionals: (nextArgs) => this.writePositionals(builtinIo, nextArgs),
405
+ executeInline: (input, options) => this.executeInline(input, builtinIo, options),
406
+ declareLocal: (name) => this.declareLocal(name),
407
+ }));
408
+ this.lastExitCode = exitCode;
409
+ return exitCode;
410
+ });
411
+ }
412
+ async executeFor(node, io) {
413
+ return this.executeWithRedirections(node.redirections, io, async (redirIo) => {
414
+ const expandCtx = this.createExpandContext(redirIo);
415
+ let exitCode = 0;
416
+ let values;
417
+ if (node.words !== null) {
418
+ values = await expandWords(node.words, expandCtx);
419
+ }
420
+ else {
421
+ values = [...this.readPositionals(redirIo)];
422
+ }
423
+ for (const val of values) {
424
+ const abortCode = this.abortExitCode(redirIo);
425
+ if (abortCode !== null)
426
+ return abortCode;
427
+ if (!this.assignEnv(node.variable, val)) {
428
+ this.writeTerminal(redirIo, `${node.variable}: readonly variable\n`);
429
+ return 1;
430
+ }
431
+ try {
432
+ exitCode = await this.executeCompoundList(node.body, redirIo);
433
+ }
434
+ catch (e) {
435
+ if (e instanceof BreakSignal) {
436
+ if (e.levels > 1)
437
+ throw new BreakSignal(e.levels - 1);
438
+ break;
439
+ }
440
+ if (e instanceof ContinueSignal) {
441
+ if (e.levels > 1)
442
+ throw new ContinueSignal(e.levels - 1);
443
+ continue;
444
+ }
445
+ throw e;
446
+ }
447
+ }
448
+ this.lastExitCode = exitCode;
449
+ return exitCode;
450
+ });
451
+ }
452
+ async executeWhile(node, io) {
453
+ return this.executeWithRedirections(node.redirections, io, async (redirIo) => {
454
+ let exitCode = 0;
455
+ while (true) {
456
+ const abortCode = this.abortExitCode(redirIo);
457
+ if (abortCode !== null)
458
+ return abortCode;
459
+ const condCode = await this.withErrexitSuppressed(() => this.executeCompoundList(node.condition, redirIo));
460
+ if (condCode !== 0)
461
+ break;
462
+ try {
463
+ exitCode = await this.executeCompoundList(node.body, redirIo);
464
+ }
465
+ catch (e) {
466
+ if (e instanceof BreakSignal) {
467
+ if (e.levels > 1)
468
+ throw new BreakSignal(e.levels - 1);
469
+ break;
470
+ }
471
+ if (e instanceof ContinueSignal) {
472
+ if (e.levels > 1)
473
+ throw new ContinueSignal(e.levels - 1);
474
+ continue;
475
+ }
476
+ throw e;
477
+ }
478
+ }
479
+ this.lastExitCode = exitCode;
480
+ return exitCode;
481
+ });
482
+ }
483
+ async executeUntil(node, io) {
484
+ return this.executeWithRedirections(node.redirections, io, async (redirIo) => {
485
+ let exitCode = 0;
486
+ while (true) {
487
+ const abortCode = this.abortExitCode(redirIo);
488
+ if (abortCode !== null)
489
+ return abortCode;
490
+ const condCode = await this.withErrexitSuppressed(() => this.executeCompoundList(node.condition, redirIo));
491
+ if (condCode === 0)
492
+ break;
493
+ try {
494
+ exitCode = await this.executeCompoundList(node.body, redirIo);
495
+ }
496
+ catch (e) {
497
+ if (e instanceof BreakSignal) {
498
+ if (e.levels > 1)
499
+ throw new BreakSignal(e.levels - 1);
500
+ break;
501
+ }
502
+ if (e instanceof ContinueSignal) {
503
+ if (e.levels > 1)
504
+ throw new ContinueSignal(e.levels - 1);
505
+ continue;
506
+ }
507
+ throw e;
508
+ }
509
+ }
510
+ this.lastExitCode = exitCode;
511
+ return exitCode;
512
+ });
513
+ }
514
+ async executeCase(node, io) {
515
+ return this.executeWithRedirections(node.redirections, io, async (redirIo) => {
516
+ const expandCtx = this.createExpandContext(redirIo);
517
+ const wordValue = await expandWord(node.word, expandCtx);
518
+ let exitCode = 0;
519
+ for (const item of node.items) {
520
+ for (const pattern of item.patterns) {
521
+ const patternValue = await expandWord(pattern, expandCtx);
522
+ if (globMatch(patternValue, wordValue)) {
523
+ exitCode = await this.executeCompoundList(item.body, redirIo);
524
+ this.lastExitCode = exitCode;
525
+ return exitCode;
526
+ }
527
+ }
528
+ }
529
+ this.lastExitCode = exitCode;
530
+ return exitCode;
531
+ });
532
+ }
533
+ async executeFunctionDef(node) {
534
+ this.functions.set(node.name, node.body);
535
+ return 0;
536
+ }
537
+ async executeGroup(node, io) {
538
+ const exitCode = await this.executeWithRedirections(node.redirections, io, (redirIo) => this.executeCompoundList(node.body, redirIo));
539
+ this.lastExitCode = exitCode;
540
+ return exitCode;
541
+ }
542
+ async executeSubshell(node, io) {
543
+ const savedCwd = this.config.getCwd();
544
+ const savedEnv = { ...this.config.env };
545
+ const savedArrays = new Map();
546
+ for (const [name, elements] of this.config.arrays)
547
+ savedArrays.set(name, [...elements]);
548
+ let exitCode = 0;
549
+ const subshellIo = this.createCommandIo(io);
550
+ subshellIo.positionals = this.forkPositionals(io);
551
+ try {
552
+ exitCode = await this.executeWithRedirections(node.redirections, subshellIo, (redirIo) => this.executeCompoundList(node.body, redirIo));
553
+ }
554
+ catch (e) {
555
+ if (e instanceof ExitSignal) {
556
+ exitCode = e.exitCode;
557
+ }
558
+ else {
559
+ throw e;
560
+ }
561
+ }
562
+ finally {
563
+ this.config.setCwd(savedCwd);
564
+ for (const key of Object.keys(this.config.env))
565
+ delete this.config.env[key];
566
+ Object.assign(this.config.env, savedEnv);
567
+ this.config.arrays.clear();
568
+ for (const [name, elements] of savedArrays)
569
+ this.config.arrays.set(name, elements);
570
+ }
571
+ this.lastExitCode = exitCode;
572
+ return exitCode;
573
+ }
574
+ async executeCompoundList(lists, io) {
575
+ let exitCode = 0;
576
+ for (const list of lists) {
577
+ const abortCode = this.abortExitCode(io);
578
+ if (abortCode !== null)
579
+ return abortCode;
580
+ exitCode = await this.executeList(list, io);
581
+ }
582
+ return exitCode;
583
+ }
584
+ async executeSimpleCommand(cmd, io) {
585
+ const abortCode = this.abortExitCode(io);
586
+ if (abortCode !== null)
587
+ return abortCode;
588
+ const expandCtx = this.createExpandContext(io);
589
+ // Expand words
590
+ const expandedArgs = await expandWords(cmd.words, expandCtx);
591
+ if (expandedArgs.length === 0 && cmd.assignments.length > 0) {
592
+ // Bare assignment -- set env vars
593
+ for (const assign of cmd.assignments) {
594
+ if (!await this.applyAssignment(assign, expandCtx)) {
595
+ this.writeTerminal(io, `${assign.name}: readonly variable\n`);
596
+ if (io.scriptMode === true)
597
+ throw new ErrexitSignal(1);
598
+ return 1;
599
+ }
600
+ }
601
+ // A command that is only assignments exits with the status of the last
602
+ // command substitution it ran, so `out="$(cmd)" || die` sees cmd fail.
603
+ return expandCtx.lastSubstitutionExitCode ?? 0;
604
+ }
605
+ if (expandedArgs.length === 0) {
606
+ return 0;
607
+ }
608
+ const [name, ...args] = expandedArgs;
609
+ // Check alias expansion
610
+ const aliases = this.config.aliases;
611
+ if (aliases) {
612
+ const aliasValue = aliases.get(name);
613
+ if (aliasValue !== undefined) {
614
+ // Rebuild the command line with the alias expanded
615
+ const expandedLine = aliasValue + (args.length > 0 ? ' ' + args.join(' ') : '');
616
+ return this.executeLineWithIo(expandedLine, io);
617
+ }
618
+ }
619
+ // Apply per-command assignments (temporary env)
620
+ const saved = new Map();
621
+ for (const assign of cmd.assignments) {
622
+ if (!saved.has(assign.name))
623
+ saved.set(assign.name, this.saveVariable(assign.name));
624
+ if (!await this.applyAssignment(assign, expandCtx)) {
625
+ (io.stderr ?? this.terminalSink(io)).write(`${assign.name}: readonly variable\n`);
626
+ return 1;
627
+ }
628
+ }
629
+ // Set up stdout/stderr (per-execution io target, then the terminal sink)
630
+ let stdout = io.stdout ?? this.terminalSink(io);
631
+ let stderr = io.stderr ?? this.terminalSink(io);
632
+ let stdin = io.stdin;
633
+ const fds = this.createCommandFds(stdout, stderr, stdin, io);
634
+ try {
635
+ await this.applyRedirections(cmd.redirections, fds, expandCtx, io, io.terminalStdin);
636
+ }
637
+ catch (error) {
638
+ const redirStderr = fds.outputFds.get(2) ?? stderr;
639
+ redirStderr.write(error instanceof RedirectionOpenError
640
+ ? redirectionDiagnostic(error)
641
+ : `${error instanceof Error ? error.message : String(error)}\n`);
642
+ this.lastExitCode = 1;
643
+ return 1;
644
+ }
645
+ stdout = fds.outputFds.get(1) ?? this.createNullWriter();
646
+ stderr = fds.outputFds.get(2) ?? this.createNullWriter();
647
+ stdin = fds.inputFds.get(0);
648
+ // If no stdin from pipe or redirect, fall back to terminal stdin
649
+ if (!stdin && io.terminalStdin) {
650
+ stdin = io.terminalStdin;
651
+ }
652
+ let exitCode;
653
+ try {
654
+ // Check for break/continue/return builtins
655
+ if (name === 'break') {
656
+ const levels = args[0] ? parseInt(args[0], 10) : 1;
657
+ throw new BreakSignal(levels);
658
+ }
659
+ if (name === 'continue') {
660
+ const levels = args[0] ? parseInt(args[0], 10) : 1;
661
+ throw new ContinueSignal(levels);
662
+ }
663
+ if (name === 'return') {
664
+ const code = args[0] ? parseInt(args[0], 10) : this.lastExitCode;
665
+ throw new ReturnSignal(code);
666
+ }
667
+ if (name === 'exec' && args.length === 0) {
668
+ this.persistFdState(fds);
669
+ exitCode = 0;
670
+ }
671
+ else {
672
+ // Check functions
673
+ const funcBody = this.functions.get(name);
674
+ if (funcBody) {
675
+ exitCode = await this.executeFunction(funcBody, args, this.createIoFromFds(io, fds));
676
+ }
677
+ else {
678
+ // Check builtins
679
+ const builtin = this.config.builtins.get(name);
680
+ if (builtin) {
681
+ const builtinIo = this.createIoFromFds(io, fds);
682
+ exitCode = await builtin(args, stdout, stderr, stdin, {
683
+ vfs: builtinIo.vfs ?? this.config.vfs,
684
+ cwd: this.config.getCwd(),
685
+ stdin,
686
+ stdout,
687
+ stderr,
688
+ terminalStdin: io.terminalStdin,
689
+ terminalFds: {
690
+ stdin: fds.terminalInputFds.has(0),
691
+ stdout: fds.terminalOutputFds.has(1),
692
+ stderr: fds.terminalOutputFds.has(2),
693
+ },
694
+ scriptMode: io.scriptMode,
695
+ isFdTerminal: (fd) => this.isFdTerminal(fds, fd),
696
+ getPositionals: () => this.readPositionals(builtinIo),
697
+ setPositionals: (nextArgs) => this.writePositionals(builtinIo, nextArgs),
698
+ executeInline: (input, options) => this.executeInline(input, builtinIo, options),
699
+ declareLocal: (name) => this.declareLocal(name),
700
+ });
701
+ }
702
+ else {
703
+ // Check registry
704
+ const command = await this.config.registry.resolve(name);
705
+ if (!command) {
706
+ stderr.write(`${name}: command not found\n`);
707
+ exitCode = 127;
708
+ }
709
+ else {
710
+ const shouldRegister = io.registerProcess !== false;
711
+ let pid;
712
+ const abortController = new AbortController();
713
+ let unlinkShellSignal;
714
+ const shellSignal = io.signal ?? this.config.getAbortSignal?.() ?? new AbortController().signal;
715
+ unlinkShellSignal = linkAbortSignal(shellSignal, abortController);
716
+ const terminalStdin = io.terminalStdin;
717
+ const identity = io.commandIdentity;
718
+ if (!identity)
719
+ throw new Error('shell command identity is unavailable');
720
+ let ctx;
721
+ ctx = {
722
+ ...io.commandContext,
723
+ pid: identity.pid,
724
+ cred: identity.cred,
725
+ args,
726
+ env: { ...this.config.env },
727
+ cwd: this.config.getCwd(),
728
+ vfs: io.vfs ?? this.config.vfs,
729
+ stdout,
730
+ stderr,
731
+ signal: abortController.signal,
732
+ stdin,
733
+ terminalStdin,
734
+ setRawMode: terminalStdin
735
+ ? (v) => { terminalStdin.rawMode = v; }
736
+ : undefined,
737
+ getRawMode: terminalStdin
738
+ ? () => terminalStdin.rawMode
739
+ : undefined,
740
+ isFdTerminal: (fd) => this.isFdTerminal(fds, fd),
741
+ setUmask: identity.setUmask,
742
+ runAs: (cred, argv) => io.runAs
743
+ ? io.runAs(ctx, cred, argv)
744
+ : Promise.resolve(126),
745
+ };
746
+ // Register process BEFORE executing so ps can see itself
747
+ let commandPromise;
748
+ if (shouldRegister) {
749
+ let resolvePromise;
750
+ let rejectPromise;
751
+ const registeredPromise = new Promise((resolve, reject) => {
752
+ resolvePromise = resolve;
753
+ rejectPromise = reject;
754
+ });
755
+ pid = this.config.processRegistry.spawn({
756
+ command: name,
757
+ args: [name, ...args],
758
+ cwd: this.config.getCwd(),
759
+ env: { ...this.config.env },
760
+ isForeground: true,
761
+ promise: registeredPromise,
762
+ abortController,
763
+ });
764
+ commandPromise = command(ctx).then((code) => {
765
+ resolvePromise?.(code);
766
+ return code;
767
+ }, (err) => {
768
+ rejectPromise?.(err);
769
+ if (err instanceof Error && err.name === 'AbortError')
770
+ return 130;
771
+ // Surface the failure: this rejection handler resolves
772
+ // commandPromise to an exit code, so the catch below
773
+ // never sees the error — without this write a throwing
774
+ // registered command dies silently at the prompt.
775
+ stderr.write(`${name}: ${err instanceof Error ? err.message : String(err)}\n`);
776
+ return 1;
777
+ });
778
+ }
779
+ else {
780
+ commandPromise = command(ctx);
781
+ }
782
+ try {
783
+ exitCode = await commandPromise;
784
+ }
785
+ catch (e) {
786
+ if (e instanceof Error && e.name === 'AbortError') {
787
+ exitCode = 130;
788
+ }
789
+ else {
790
+ stderr.write(`${name}: ${e instanceof Error ? e.message : String(e)}\n`);
791
+ exitCode = 1;
792
+ }
793
+ }
794
+ finally {
795
+ unlinkShellSignal?.();
796
+ if (shouldRegister && pid !== undefined) {
797
+ await Promise.resolve();
798
+ this.config.processRegistry.reap(pid);
799
+ }
800
+ }
801
+ // A signalled command reports the SIGNAL's status, not whatever
802
+ // code it returned on its way out: `sleep` observes only that
803
+ // ctx.signal aborted, and cannot tell SIGINT (130) from
804
+ // SIGQUIT (131). The shell holds the reason, so it decides.
805
+ const signalledCode = this.abortExitCode(io);
806
+ if (signalledCode !== null)
807
+ exitCode = signalledCode;
808
+ }
809
+ }
810
+ }
811
+ }
812
+ }
813
+ finally {
814
+ this.flushFds(fds);
815
+ // Restore env from per-command assignments
816
+ for (const [name, value] of saved)
817
+ this.restoreVariable(name, value);
818
+ }
819
+ const fatalSpecialBuiltin = io.scriptMode === true
820
+ && exitCode !== 0
821
+ && isFatalSpecialBuiltin(name);
822
+ this.lastExitCode = exitCode;
823
+ if (fatalSpecialBuiltin)
824
+ throw new ErrexitSignal(exitCode);
825
+ return exitCode;
826
+ }
827
+ assignEnv(name, value) {
828
+ if (this.config.readonlyNames.has(name))
829
+ return false;
830
+ assignScalar(this.config.env, this.config.arrays, name, value);
831
+ return true;
832
+ }
833
+ /**
834
+ * `name=value`, `name+=value`, `name[expr]=value` and `name=(word …)`.
835
+ * Returns false when the name is readonly, which the caller reports.
836
+ */
837
+ async applyAssignment(assign, ctx) {
838
+ const { name } = assign;
839
+ if (this.config.readonlyNames.has(name))
840
+ return false;
841
+ if (assign.elements !== undefined) {
842
+ const values = await expandWords(assign.elements, ctx);
843
+ const existing = assign.append ? this.config.arrays.get(name) ?? [] : [];
844
+ delete this.config.env[name];
845
+ this.config.arrays.set(name, [...existing, ...values]);
846
+ return true;
847
+ }
848
+ const value = await expandWord(assign.value, ctx);
849
+ if (assign.subscript !== undefined) {
850
+ const array = this.arrayFor(name);
851
+ const index = await evaluateSubscript(assign.subscript, array.length, ctx);
852
+ array[index] = assign.append ? (array[index] ?? '') + value : value;
853
+ return true;
854
+ }
855
+ // A plain assignment to an array name lands on its first element, and
856
+ // `arr+=x` appends to that element rather than adding one.
857
+ const array = this.config.arrays.get(name);
858
+ if (array !== undefined) {
859
+ array[0] = assign.append ? (array[0] ?? '') + value : value;
860
+ return true;
861
+ }
862
+ this.config.env[name] = assign.append ? (this.config.env[name] ?? '') + value : value;
863
+ return true;
864
+ }
865
+ /** One variable's whole binding, so a scope can put it back exactly. */
866
+ saveVariable(name) {
867
+ return { scalar: this.config.env[name], array: this.config.arrays.get(name) };
868
+ }
869
+ restoreVariable(name, saved) {
870
+ if (saved.array === undefined)
871
+ this.config.arrays.delete(name);
872
+ else
873
+ this.config.arrays.set(name, saved.array);
874
+ if (saved.scalar === undefined)
875
+ delete this.config.env[name];
876
+ else
877
+ this.config.env[name] = saved.scalar;
878
+ }
879
+ /** The array behind a subscripted assignment, promoting a scalar if needed. */
880
+ arrayFor(name) {
881
+ const existing = this.config.arrays.get(name);
882
+ if (existing !== undefined)
883
+ return existing;
884
+ const scalar = this.config.env[name];
885
+ const array = scalar === undefined ? [] : [scalar];
886
+ delete this.config.env[name];
887
+ this.config.arrays.set(name, array);
888
+ return array;
889
+ }
890
+ async executeFunction(body, args, io) {
891
+ let exitCode;
892
+ const functionIo = this.createCommandIo(io);
893
+ functionIo.positionals = { args: [...args] };
894
+ this.localFrames.push(new Map());
895
+ try {
896
+ exitCode = await this.executeCommand(body, functionIo);
897
+ }
898
+ catch (e) {
899
+ if (e instanceof ReturnSignal) {
900
+ exitCode = e.exitCode;
901
+ }
902
+ else {
903
+ throw e;
904
+ }
905
+ }
906
+ finally {
907
+ const frame = this.localFrames.pop();
908
+ if (frame !== undefined) {
909
+ for (const [name, saved] of frame)
910
+ this.restoreVariable(name, saved);
911
+ }
912
+ }
913
+ this.lastExitCode = exitCode;
914
+ return exitCode;
915
+ }
916
+ /**
917
+ * Bind a name to the running function, unset, so an assignment to it does
918
+ * not outlive the call. Shell variables are dynamically scoped, so a callee
919
+ * still sees its caller's locals — which is what bash does. Returns false
920
+ * outside a function, where `local` is an error.
921
+ */
922
+ declareLocal(name) {
923
+ const frame = this.localFrames[this.localFrames.length - 1];
924
+ if (frame === undefined)
925
+ return false;
926
+ if (!frame.has(name))
927
+ frame.set(name, this.saveVariable(name));
928
+ delete this.config.env[name];
929
+ this.config.arrays.delete(name);
930
+ return true;
931
+ }
932
+ async executeCapture(input, io = {}) {
933
+ let captured = '';
934
+ const stdout = {
935
+ write: (text) => { captured += text; },
936
+ };
937
+ const captureIo = this.createCommandIo(io);
938
+ captureIo.stdout = stdout;
939
+ captureIo.positionals = this.forkPositionals(io);
940
+ const exitCode = await this.executeLineWithIo(input, captureIo);
941
+ return { output: captured, exitCode };
942
+ }
943
+ async executeInline(input, io, options = {}) {
944
+ const inlineIo = this.createCommandIo(io);
945
+ if (options.positionals !== undefined) {
946
+ inlineIo.positionals = { args: [...options.positionals] };
947
+ }
948
+ return this.executeLineWithIo(input, inlineIo);
949
+ }
950
+ async executeLineWithIo(input, io) {
951
+ const tokens = lex(input);
952
+ const script = parse(tokens);
953
+ return this.executeScriptWithIo(script, io);
954
+ }
955
+ async runExitTrap(exitCode, io, enabled) {
956
+ if (!enabled || this.exitTrapDepth > 0)
957
+ return exitCode;
958
+ const action = this.config.traps.get('EXIT');
959
+ if (action === undefined)
960
+ return exitCode;
961
+ const savedLastExitCode = this.lastExitCode;
962
+ this.lastExitCode = exitCode;
963
+ this.exitTrapDepth++;
964
+ try {
965
+ await this.executeLineWithIo(action, io);
966
+ }
967
+ finally {
968
+ this.exitTrapDepth--;
969
+ this.lastExitCode = savedLastExitCode;
970
+ }
971
+ return exitCode;
972
+ }
973
+ createTerminalIo(terminalStdin, terminalFds, scriptMode, stdin) {
974
+ const io = {};
975
+ if (stdin)
976
+ io.stdin = stdin;
977
+ if (terminalStdin)
978
+ io.terminalStdin = terminalStdin;
979
+ if (terminalFds)
980
+ io.terminalFds = terminalFds;
981
+ if (scriptMode)
982
+ io.scriptMode = true;
983
+ return io;
984
+ }
985
+ createCommandIo(io) {
986
+ const next = {};
987
+ if (io.stdin)
988
+ next.stdin = io.stdin;
989
+ if (io.stdout)
990
+ next.stdout = io.stdout;
991
+ if (io.stderr)
992
+ next.stderr = io.stderr;
993
+ if (io.writeToTerminal)
994
+ next.writeToTerminal = io.writeToTerminal;
995
+ if (io.terminalStdin)
996
+ next.terminalStdin = io.terminalStdin;
997
+ if (io.terminalFds)
998
+ next.terminalFds = io.terminalFds;
999
+ if (io.scriptMode)
1000
+ next.scriptMode = true;
1001
+ if (io.signal)
1002
+ next.signal = io.signal;
1003
+ if (io.registerProcess === false)
1004
+ next.registerProcess = false;
1005
+ if (io.positionals)
1006
+ next.positionals = io.positionals;
1007
+ if (io.commandContext)
1008
+ next.commandContext = io.commandContext;
1009
+ if (io.commandIdentity)
1010
+ next.commandIdentity = io.commandIdentity;
1011
+ if (io.runAs)
1012
+ next.runAs = io.runAs;
1013
+ if (io.vfs)
1014
+ next.vfs = io.vfs;
1015
+ return next;
1016
+ }
1017
+ /** Per-execution direct-terminal write, isolated from a nested capture. */
1018
+ writeTerminal(io, text) {
1019
+ (io.writeToTerminal ?? this.config.writeToTerminal)(text);
1020
+ }
1021
+ /** Late-bound fallback sink for command stdout/stderr with no fd target. */
1022
+ terminalSink(io) {
1023
+ return { write: (text) => this.writeTerminal(io, text) };
1024
+ }
1025
+ forkPositionals(io) {
1026
+ return { args: [...this.readPositionals(io)] };
1027
+ }
1028
+ createExpandContext(io = {}) {
1029
+ return {
1030
+ env: this.config.env,
1031
+ arrays: this.config.arrays,
1032
+ positionals: this.readPositionals(io),
1033
+ lastExitCode: this.lastExitCode,
1034
+ cwd: this.config.getCwd(),
1035
+ vfs: io.vfs ?? this.config.vfs,
1036
+ options: this.config.options,
1037
+ executeCapture: (input) => this.executeCapture(input, io),
1038
+ };
1039
+ }
1040
+ createIoFromFds(io, fds) {
1041
+ const next = this.createCommandIo(io);
1042
+ next.stdout = fds.outputFds.get(1) ?? this.createNullWriter();
1043
+ next.stderr = fds.outputFds.get(2) ?? this.createNullWriter();
1044
+ const stdin = fds.inputFds.get(0);
1045
+ if (stdin)
1046
+ next.stdin = stdin;
1047
+ else
1048
+ delete next.stdin;
1049
+ next.terminalFds = {
1050
+ stdin: fds.terminalInputFds.has(0),
1051
+ stdout: fds.terminalOutputFds.has(1),
1052
+ stderr: fds.terminalOutputFds.has(2),
1053
+ };
1054
+ return next;
1055
+ }
1056
+ readPositionals(io) {
1057
+ if (io.positionals)
1058
+ return io.positionals.args;
1059
+ const count = Number.parseInt(this.config.env['#'] ?? '0', 10);
1060
+ const args = [];
1061
+ for (let i = 1; i <= count; i++) {
1062
+ args.push(this.config.env[String(i)] ?? '');
1063
+ }
1064
+ return args;
1065
+ }
1066
+ writePositionals(io, args) {
1067
+ if (io.positionals) {
1068
+ io.positionals.args = [...args];
1069
+ return;
1070
+ }
1071
+ for (const key of Object.keys(this.config.env)) {
1072
+ if (key === '@' || key === '#' || /^[1-9][0-9]*$/.test(key)) {
1073
+ delete this.config.env[key];
1074
+ }
1075
+ }
1076
+ this.config.env['#'] = String(args.length);
1077
+ this.config.env['@'] = args.join(' ');
1078
+ for (let i = 0; i < args.length; i++) {
1079
+ this.config.env[String(i + 1)] = args[i];
1080
+ }
1081
+ }
1082
+ createCommandFds(stdout, stderr, stdin, io) {
1083
+ const outputFds = new Map([
1084
+ [1, stdout],
1085
+ [2, stderr],
1086
+ ...this.persistentOutputFds,
1087
+ ]);
1088
+ const inputFds = new Map([
1089
+ [0, stdin],
1090
+ ...this.persistentInputFds,
1091
+ ]);
1092
+ const terminalOutputFds = new Set(this.persistentTerminalOutputFds);
1093
+ setMembership(terminalOutputFds, 1, io.terminalFds?.stdout ?? !io.stdout);
1094
+ setMembership(terminalOutputFds, 2, io.terminalFds?.stderr ?? !io.stderr);
1095
+ const terminalInputFds = new Set(this.persistentTerminalInputFds);
1096
+ setMembership(terminalInputFds, 0, io.terminalFds?.stdin ?? (!stdin && Boolean(io.terminalStdin)));
1097
+ if (io.terminalStdin) {
1098
+ for (const fd of terminalInputFds) {
1099
+ inputFds.set(fd, io.terminalStdin);
1100
+ }
1101
+ }
1102
+ return {
1103
+ outputFds,
1104
+ inputFds,
1105
+ terminalOutputFds,
1106
+ terminalInputFds,
1107
+ changedOutputFds: new Set(),
1108
+ changedInputFds: new Set(),
1109
+ };
1110
+ }
1111
+ async executeWithRedirections(redirections, io, execute) {
1112
+ if (redirections.length === 0) {
1113
+ return execute(io);
1114
+ }
1115
+ const expandCtx = this.createExpandContext(io);
1116
+ const stdout = io.stdout ?? this.terminalSink(io);
1117
+ const stderr = io.stderr ?? this.terminalSink(io);
1118
+ const fds = this.createCommandFds(stdout, stderr, io.stdin, io);
1119
+ try {
1120
+ await this.applyRedirections(redirections, fds, expandCtx, io, io.terminalStdin);
1121
+ }
1122
+ catch (error) {
1123
+ if (!(error instanceof RedirectionOpenError))
1124
+ throw error;
1125
+ const redirStderr = fds.outputFds.get(2) ?? stderr;
1126
+ redirStderr.write(redirectionDiagnostic(error));
1127
+ this.lastExitCode = 1;
1128
+ return 1;
1129
+ }
1130
+ return this.withFdFlush(fds, () => execute(this.createIoFromFds(io, fds)));
1131
+ }
1132
+ async applyRedirections(redirections, fds, expandCtx, io, terminalStdin) {
1133
+ for (const redir of redirections) {
1134
+ if (redir.operator === 'heredoc') {
1135
+ const heredoc = redir.heredoc ?? { body: '', quoted: false, stripTabs: false };
1136
+ const body = heredoc.quoted
1137
+ ? heredoc.body
1138
+ : await expandWord([{ text: heredoc.body, quoted: 'double' }], expandCtx);
1139
+ this.setInputFd(fds, redir.fd ?? 0, { stream: this.createStringReader(body), terminal: false });
1140
+ continue;
1141
+ }
1142
+ const target = await expandWord(redir.target, expandCtx);
1143
+ switch (redir.operator) {
1144
+ case 'write':
1145
+ this.setOutputFd(fds, redir.fd ?? 1, this.openOutputTarget(io, target, 'write', fds, terminalStdin));
1146
+ break;
1147
+ case 'append':
1148
+ this.setOutputFd(fds, redir.fd ?? 1, this.openOutputTarget(io, target, 'append', fds, terminalStdin));
1149
+ break;
1150
+ case 'read':
1151
+ this.setInputFd(fds, redir.fd ?? 0, this.openInputTarget(io, target, fds, terminalStdin));
1152
+ break;
1153
+ case 'readWrite': {
1154
+ const fd = redir.fd ?? 0;
1155
+ this.setInputFd(fds, fd, this.openInputTarget(io, target, fds, terminalStdin));
1156
+ this.setOutputFd(fds, fd, this.openOutputTarget(io, target, 'append', fds, terminalStdin));
1157
+ break;
1158
+ }
1159
+ case 'writeAll': {
1160
+ const writer = this.openOutputTarget(io, target, 'write', fds, terminalStdin);
1161
+ this.setOutputFd(fds, 1, writer);
1162
+ this.setOutputFd(fds, 2, writer);
1163
+ break;
1164
+ }
1165
+ case 'dupOutput':
1166
+ this.dupOutputFd(fds, redir.fd ?? 1, target);
1167
+ break;
1168
+ case 'dupInput':
1169
+ this.dupInputFd(fds, redir.fd ?? 0, target);
1170
+ break;
1171
+ }
1172
+ }
1173
+ }
1174
+ persistFdState(fds) {
1175
+ for (const fd of fds.changedOutputFds) {
1176
+ const stream = fds.outputFds.get(fd);
1177
+ if (stream)
1178
+ this.persistentOutputFds.set(fd, stream);
1179
+ else
1180
+ this.persistentOutputFds.delete(fd);
1181
+ if (fds.terminalOutputFds.has(fd))
1182
+ this.persistentTerminalOutputFds.add(fd);
1183
+ else
1184
+ this.persistentTerminalOutputFds.delete(fd);
1185
+ }
1186
+ for (const fd of fds.changedInputFds) {
1187
+ const isTerminal = fds.terminalInputFds.has(fd);
1188
+ if (fds.inputFds.has(fd)) {
1189
+ this.persistentInputFds.set(fd, isTerminal ? undefined : fds.inputFds.get(fd));
1190
+ }
1191
+ else {
1192
+ this.persistentInputFds.delete(fd);
1193
+ }
1194
+ if (isTerminal)
1195
+ this.persistentTerminalInputFds.add(fd);
1196
+ else
1197
+ this.persistentTerminalInputFds.delete(fd);
1198
+ }
1199
+ }
1200
+ setOutputFd(fds, fd, target) {
1201
+ fds.outputFds.set(fd, target.stream);
1202
+ setMembership(fds.terminalOutputFds, fd, target.terminal);
1203
+ fds.changedOutputFds.add(fd);
1204
+ }
1205
+ setInputFd(fds, fd, target) {
1206
+ fds.inputFds.set(fd, target.stream);
1207
+ setMembership(fds.terminalInputFds, fd, target.terminal);
1208
+ fds.changedInputFds.add(fd);
1209
+ }
1210
+ dupOutputFd(fds, fd, target) {
1211
+ fds.changedOutputFds.add(fd);
1212
+ if (target === '-') {
1213
+ fds.outputFds.delete(fd);
1214
+ fds.terminalOutputFds.delete(fd);
1215
+ return;
1216
+ }
1217
+ const resolved = this.resolveOutputFd(target, fds.outputFds, fds.terminalOutputFds);
1218
+ fds.outputFds.set(fd, resolved.stream);
1219
+ setMembership(fds.terminalOutputFds, fd, resolved.terminal);
1220
+ }
1221
+ dupInputFd(fds, fd, target) {
1222
+ fds.changedInputFds.add(fd);
1223
+ if (target === '-') {
1224
+ fds.inputFds.delete(fd);
1225
+ fds.terminalInputFds.delete(fd);
1226
+ return;
1227
+ }
1228
+ const resolved = this.resolveInputFd(target, fds.inputFds, fds.terminalInputFds);
1229
+ fds.inputFds.set(fd, resolved.stream);
1230
+ setMembership(fds.terminalInputFds, fd, resolved.terminal);
1231
+ }
1232
+ openOutputTarget(io, target, mode, fds, terminalStdin) {
1233
+ if (target === '/dev/null')
1234
+ return { stream: this.createNullWriter(), terminal: false };
1235
+ if (target === '/dev/tty') {
1236
+ if (!terminalStdin)
1237
+ throw new Error('/dev/tty: no controlling terminal');
1238
+ return { stream: this.terminalSink(io), terminal: true };
1239
+ }
1240
+ // /dev/stdout and /dev/stderr name the process's own descriptors, not
1241
+ // files. Writing them into the device provider would silently discard.
1242
+ if (target === '/dev/stdout')
1243
+ return this.resolveOutputFd('1', fds.outputFds, fds.terminalOutputFds);
1244
+ if (target === '/dev/stderr')
1245
+ return this.resolveOutputFd('2', fds.outputFds, fds.terminalOutputFds);
1246
+ const targetPath = resolve(this.config.getCwd(), target);
1247
+ const vfs = io.vfs ?? this.config.vfs;
1248
+ try {
1249
+ if (mode === 'write') {
1250
+ vfs.writeFile(targetPath, '');
1251
+ return { stream: this.createFileWriter(vfs, targetPath, 'truncate'), terminal: false };
1252
+ }
1253
+ if (vfs.exists(targetPath)) {
1254
+ if (vfs.stat(targetPath).type === 'directory') {
1255
+ throw Object.assign(new Error(`EISDIR: ${targetPath}`), { code: 'EISDIR' });
1256
+ }
1257
+ vfs.access(targetPath, 0o2);
1258
+ }
1259
+ else {
1260
+ vfs.writeFile(targetPath, '');
1261
+ }
1262
+ return { stream: this.createFileWriter(vfs, targetPath, 'append'), terminal: false };
1263
+ }
1264
+ catch (error) {
1265
+ throw new RedirectionOpenError(target, error);
1266
+ }
1267
+ }
1268
+ openInputTarget(io, target, fds, terminalStdin) {
1269
+ if (target === '/dev/null')
1270
+ return { stream: this.createEmptyReader(), terminal: false };
1271
+ if (target === '/dev/tty') {
1272
+ if (!terminalStdin)
1273
+ throw new Error('/dev/tty: no controlling terminal');
1274
+ return { stream: terminalStdin, terminal: true };
1275
+ }
1276
+ if (target === '/dev/stdin')
1277
+ return this.resolveInputFd('0', fds.inputFds, fds.terminalInputFds);
1278
+ try {
1279
+ return {
1280
+ stream: this.createFileReader(io.vfs ?? this.config.vfs, resolve(this.config.getCwd(), target)),
1281
+ terminal: false,
1282
+ };
1283
+ }
1284
+ catch (error) {
1285
+ throw new RedirectionOpenError(target, error);
1286
+ }
1287
+ }
1288
+ /**
1289
+ * A file-backed descriptor: an open file plus a write offset.
1290
+ *
1291
+ * Each write lands at the offset and advances it, the way write(2) does.
1292
+ * Restating the whole file per write — which is what this used to do —
1293
+ * makes every multi-write producer (`cat a b c`, a streaming `curl`, any
1294
+ * line-at-a-time filter) persist only its final write and silently drop
1295
+ * everything before it.
1296
+ *
1297
+ * Writes buffer to a block, as stdio does, so a line-at-a-time producer
1298
+ * costs one store write per block rather than one per line. `mode`
1299
+ * distinguishes `>` (a plain offset from the truncation point) from `>>`,
1300
+ * which is O_APPEND: every block lands at whatever the current end is, so
1301
+ * two descriptors appending to one file cannot overwrite each other.
1302
+ */
1303
+ createFileWriter(vfs, path, mode) {
1304
+ let offset = 0;
1305
+ let pending = [];
1306
+ let pendingBytes = 0;
1307
+ const endOfFile = () => (vfs.exists(path) ? vfs.stat(path).size : 0);
1308
+ const flush = () => {
1309
+ if (pendingBytes === 0)
1310
+ return;
1311
+ const block = pending.length === 1 ? pending[0] : concatBytes(pending, pendingBytes);
1312
+ pending = [];
1313
+ pendingBytes = 0;
1314
+ const at = mode === 'append' ? endOfFile() : offset;
1315
+ vfs.writeRange(path, at, block);
1316
+ offset = at + block.length;
1317
+ };
1318
+ const push = (bytes) => {
1319
+ if (bytes.length === 0)
1320
+ return;
1321
+ pending.push(bytes);
1322
+ pendingBytes += bytes.length;
1323
+ if (pendingBytes >= FILE_WRITE_BLOCK_BYTES)
1324
+ flush();
1325
+ };
1326
+ return {
1327
+ write: (text) => push(encode(text)),
1328
+ writeBytes: (bytes) => push(bytes),
1329
+ flush,
1330
+ };
1331
+ }
1332
+ /**
1333
+ * Run `body` and commit every file-backed descriptor it wrote through,
1334
+ * whether it returned or threw. This is the close(2) side of the buffering
1335
+ * in createFileWriter: buffered bytes must reach the store before the next
1336
+ * command can read the file.
1337
+ */
1338
+ async withFdFlush(fds, body) {
1339
+ try {
1340
+ return await body();
1341
+ }
1342
+ finally {
1343
+ this.flushFds(fds);
1344
+ }
1345
+ }
1346
+ flushFds(fds) {
1347
+ for (const stream of fds.outputFds.values())
1348
+ stream.flush?.();
1349
+ }
1350
+ createFileReader(vfs, path) {
1351
+ const content = vfs.readFileString(path);
1352
+ return this.createStringReader(content);
1353
+ }
1354
+ createStringReader(content) {
1355
+ let offset = 0;
1356
+ return {
1357
+ read: async () => {
1358
+ if (offset >= content.length)
1359
+ return null;
1360
+ const chunk = content.slice(offset);
1361
+ offset = content.length;
1362
+ return chunk;
1363
+ },
1364
+ readAll: async () => {
1365
+ if (offset >= content.length)
1366
+ return '';
1367
+ const chunk = content.slice(offset);
1368
+ offset = content.length;
1369
+ return chunk;
1370
+ },
1371
+ readLine: async () => {
1372
+ if (offset >= content.length)
1373
+ return null;
1374
+ const newline = content.indexOf('\n', offset);
1375
+ if (newline < 0) {
1376
+ const line = content.slice(offset);
1377
+ offset = content.length;
1378
+ return line;
1379
+ }
1380
+ const line = content.slice(offset, newline);
1381
+ offset = newline + 1;
1382
+ return line;
1383
+ },
1384
+ };
1385
+ }
1386
+ resolveOutputFd(target, outputFds, terminalOutputFds) {
1387
+ if (target === '-')
1388
+ return { stream: this.createNullWriter(), terminal: false };
1389
+ const fd = this.parseFdTarget(target);
1390
+ const stream = outputFds.get(fd);
1391
+ if (!stream)
1392
+ throw new Error(`bad output file descriptor: ${target}`);
1393
+ return { stream, terminal: terminalOutputFds.has(fd) };
1394
+ }
1395
+ resolveInputFd(target, inputFds, terminalInputFds) {
1396
+ if (target === '-')
1397
+ return { stream: this.createEmptyReader(), terminal: false };
1398
+ const fd = this.parseFdTarget(target);
1399
+ if (!inputFds.has(fd))
1400
+ throw new Error(`bad input file descriptor: ${target}`);
1401
+ return { stream: inputFds.get(fd), terminal: terminalInputFds.has(fd) };
1402
+ }
1403
+ parseFdTarget(target) {
1404
+ if (!isDecimalInteger(target))
1405
+ throw new Error(`bad file descriptor: ${target}`);
1406
+ return Number.parseInt(target, 10);
1407
+ }
1408
+ createNullWriter() {
1409
+ return { write: () => { }, writeBytes: () => { } };
1410
+ }
1411
+ createEmptyReader() {
1412
+ return { read: async () => null, readAll: async () => '', readLine: async () => null };
1413
+ }
1414
+ isFdTerminal(fds, fd) {
1415
+ if (fd === 0)
1416
+ return fds.terminalInputFds.has(fd);
1417
+ return fds.terminalOutputFds.has(fd);
1418
+ }
1419
+ enforceErrexit(connector, exitCode) {
1420
+ if (!this.config.options.errexit)
1421
+ return;
1422
+ if (this.errexitSuppressionDepth > 0)
1423
+ return;
1424
+ if (exitCode === 0)
1425
+ return;
1426
+ if (connector === '&&' || connector === '||')
1427
+ return;
1428
+ throw new ErrexitSignal(exitCode);
1429
+ }
1430
+ async withErrexitSuppressed(fn) {
1431
+ this.errexitSuppressionDepth++;
1432
+ try {
1433
+ return await fn();
1434
+ }
1435
+ finally {
1436
+ this.errexitSuppressionDepth--;
1437
+ }
1438
+ }
1439
+ abortExitCode(io) {
1440
+ const signal = io.signal ?? this.config.getAbortSignal?.();
1441
+ return signal?.aborted ? exitCodeForAbortSignal(signal) : null;
1442
+ }
1443
+ }
1444
+ function setMembership(set, value, present) {
1445
+ if (present)
1446
+ set.add(value);
1447
+ else
1448
+ set.delete(value);
1449
+ }
1450
+ function isDecimalInteger(value) {
1451
+ if (value.length === 0)
1452
+ return false;
1453
+ for (let i = 0; i < value.length; i++) {
1454
+ const code = value.charCodeAt(i);
1455
+ if (code < 48 || code > 57)
1456
+ return false;
1457
+ }
1458
+ return true;
1459
+ }
1460
+ function isFatalSpecialBuiltin(name) {
1461
+ switch (name) {
1462
+ case ':':
1463
+ case '.':
1464
+ case 'break':
1465
+ case 'continue':
1466
+ case 'eval':
1467
+ case 'exec':
1468
+ case 'exit':
1469
+ case 'export':
1470
+ case 'readonly':
1471
+ case 'return':
1472
+ case 'set':
1473
+ case 'shift':
1474
+ case 'times':
1475
+ case 'trap':
1476
+ case 'unset':
1477
+ return true;
1478
+ default:
1479
+ return false;
1480
+ }
1481
+ }
1482
+ function linkAbortSignal(parent, child) {
1483
+ if (parent.aborted) {
1484
+ child.abort(parent.reason);
1485
+ return () => { };
1486
+ }
1487
+ const onAbort = () => child.abort(parent.reason);
1488
+ parent.addEventListener('abort', onAbort, { once: true });
1489
+ return () => parent.removeEventListener('abort', onAbort);
1490
+ }