typescript-virtual-container 1.2.9 → 1.3.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 (281) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/README.md +141 -50
  3. package/biome.json +7 -0
  4. package/dist/SSHMimic/exec.d.ts.map +1 -1
  5. package/dist/SSHMimic/executor.d.ts.map +1 -1
  6. package/dist/SSHMimic/executor.js +32 -16
  7. package/dist/SSHMimic/index.d.ts.map +1 -1
  8. package/dist/SSHMimic/index.js +20 -6
  9. package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -1
  10. package/dist/VirtualFileSystem/binaryPack.js +29 -6
  11. package/dist/VirtualFileSystem/index.d.ts.map +1 -1
  12. package/dist/VirtualFileSystem/index.js +36 -13
  13. package/dist/VirtualPackageManager/index.d.ts.map +1 -1
  14. package/dist/VirtualPackageManager/index.js +192 -43
  15. package/dist/VirtualShell/index.d.ts +10 -4
  16. package/dist/VirtualShell/index.d.ts.map +1 -1
  17. package/dist/VirtualShell/index.js +18 -7
  18. package/dist/VirtualShell/shell.d.ts.map +1 -1
  19. package/dist/VirtualShell/shell.js +3 -1
  20. package/dist/VirtualShell/shellParser.d.ts.map +1 -1
  21. package/dist/VirtualUserManager/index.d.ts.map +1 -1
  22. package/dist/commands/adduser.d.ts +6 -0
  23. package/dist/commands/adduser.d.ts.map +1 -1
  24. package/dist/commands/adduser.js +6 -0
  25. package/dist/commands/alias.d.ts +5 -0
  26. package/dist/commands/alias.d.ts.map +1 -1
  27. package/dist/commands/alias.js +5 -0
  28. package/dist/commands/apt.d.ts +5 -0
  29. package/dist/commands/apt.d.ts.map +1 -1
  30. package/dist/commands/apt.js +32 -9
  31. package/dist/commands/awk.d.ts +11 -0
  32. package/dist/commands/awk.d.ts.map +1 -1
  33. package/dist/commands/awk.js +15 -2
  34. package/dist/commands/base64.d.ts +5 -0
  35. package/dist/commands/base64.d.ts.map +1 -1
  36. package/dist/commands/base64.js +9 -1
  37. package/dist/commands/cat.d.ts +5 -0
  38. package/dist/commands/cat.d.ts.map +1 -1
  39. package/dist/commands/cat.js +10 -2
  40. package/dist/commands/cd.d.ts +5 -0
  41. package/dist/commands/cd.d.ts.map +1 -1
  42. package/dist/commands/cd.js +5 -0
  43. package/dist/commands/chmod.d.ts +5 -0
  44. package/dist/commands/chmod.d.ts.map +1 -1
  45. package/dist/commands/chmod.js +5 -0
  46. package/dist/commands/cp.d.ts +5 -0
  47. package/dist/commands/cp.d.ts.map +1 -1
  48. package/dist/commands/cp.js +5 -0
  49. package/dist/commands/curl.d.ts +5 -0
  50. package/dist/commands/curl.d.ts.map +1 -1
  51. package/dist/commands/curl.js +34 -6
  52. package/dist/commands/cut.d.ts +5 -0
  53. package/dist/commands/cut.d.ts.map +1 -1
  54. package/dist/commands/cut.js +8 -1
  55. package/dist/commands/date.d.ts +5 -0
  56. package/dist/commands/date.d.ts.map +1 -1
  57. package/dist/commands/date.js +7 -1
  58. package/dist/commands/declare.d.ts +3 -0
  59. package/dist/commands/declare.d.ts.map +1 -0
  60. package/dist/commands/declare.js +39 -0
  61. package/dist/commands/diff.d.ts +5 -0
  62. package/dist/commands/diff.d.ts.map +1 -1
  63. package/dist/commands/diff.js +5 -0
  64. package/dist/commands/dpkg.d.ts +5 -0
  65. package/dist/commands/dpkg.d.ts.map +1 -1
  66. package/dist/commands/dpkg.js +24 -7
  67. package/dist/commands/du.d.ts.map +1 -1
  68. package/dist/commands/du.js +8 -2
  69. package/dist/commands/echo.d.ts +5 -0
  70. package/dist/commands/echo.d.ts.map +1 -1
  71. package/dist/commands/echo.js +13 -4
  72. package/dist/commands/env.d.ts +5 -0
  73. package/dist/commands/env.d.ts.map +1 -1
  74. package/dist/commands/env.js +11 -1
  75. package/dist/commands/exit.d.ts +5 -0
  76. package/dist/commands/exit.d.ts.map +1 -1
  77. package/dist/commands/exit.js +12 -2
  78. package/dist/commands/export.d.ts.map +1 -1
  79. package/dist/commands/export.js +3 -1
  80. package/dist/commands/find.d.ts +5 -0
  81. package/dist/commands/find.d.ts.map +1 -1
  82. package/dist/commands/find.js +5 -0
  83. package/dist/commands/free.d.ts +5 -0
  84. package/dist/commands/free.d.ts.map +1 -1
  85. package/dist/commands/free.js +5 -0
  86. package/dist/commands/grep.d.ts +5 -0
  87. package/dist/commands/grep.d.ts.map +1 -1
  88. package/dist/commands/grep.js +12 -2
  89. package/dist/commands/gzip.d.ts +5 -0
  90. package/dist/commands/gzip.d.ts.map +1 -1
  91. package/dist/commands/gzip.js +18 -2
  92. package/dist/commands/head.d.ts +5 -0
  93. package/dist/commands/head.d.ts.map +1 -1
  94. package/dist/commands/head.js +5 -0
  95. package/dist/commands/help.d.ts.map +1 -1
  96. package/dist/commands/help.js +98 -45
  97. package/dist/commands/history.d.ts +5 -0
  98. package/dist/commands/history.d.ts.map +1 -1
  99. package/dist/commands/history.js +5 -0
  100. package/dist/commands/hostname.d.ts +5 -0
  101. package/dist/commands/hostname.d.ts.map +1 -1
  102. package/dist/commands/hostname.js +5 -0
  103. package/dist/commands/id.d.ts.map +1 -1
  104. package/dist/commands/id.js +4 -1
  105. package/dist/commands/index.d.ts +2 -17
  106. package/dist/commands/index.d.ts.map +1 -1
  107. package/dist/commands/index.js +2 -340
  108. package/dist/commands/ls.d.ts.map +1 -1
  109. package/dist/commands/ls.js +3 -1
  110. package/dist/commands/lsb-release.d.ts.map +1 -1
  111. package/dist/commands/lsb-release.js +8 -2
  112. package/dist/commands/nano.js +1 -1
  113. package/dist/commands/neofetch.js +1 -1
  114. package/dist/commands/node.d.ts +9 -0
  115. package/dist/commands/node.d.ts.map +1 -0
  116. package/dist/commands/node.js +316 -0
  117. package/dist/commands/npm.d.ts +19 -0
  118. package/dist/commands/npm.d.ts.map +1 -0
  119. package/dist/commands/npm.js +109 -0
  120. package/dist/commands/ping.d.ts.map +1 -1
  121. package/dist/commands/ping.js +3 -1
  122. package/dist/commands/printf.d.ts +3 -0
  123. package/dist/commands/printf.d.ts.map +1 -0
  124. package/dist/commands/printf.js +113 -0
  125. package/dist/commands/ps.d.ts.map +1 -1
  126. package/dist/commands/ps.js +4 -1
  127. package/dist/commands/python.d.ts +30 -0
  128. package/dist/commands/python.d.ts.map +1 -0
  129. package/dist/commands/python.js +2058 -0
  130. package/dist/commands/read.d.ts +3 -0
  131. package/dist/commands/read.d.ts.map +1 -0
  132. package/dist/commands/read.js +34 -0
  133. package/dist/commands/registry.d.ts +8 -0
  134. package/dist/commands/registry.d.ts.map +1 -0
  135. package/dist/commands/registry.js +229 -0
  136. package/dist/commands/runtime.d.ts +6 -0
  137. package/dist/commands/runtime.d.ts.map +1 -0
  138. package/dist/commands/runtime.js +280 -0
  139. package/dist/commands/sed.d.ts.map +1 -1
  140. package/dist/commands/sed.js +11 -3
  141. package/dist/commands/set.d.ts.map +1 -1
  142. package/dist/commands/set.js +9 -3
  143. package/dist/commands/sh.d.ts.map +1 -1
  144. package/dist/commands/sh.js +57 -36
  145. package/dist/commands/shift.d.ts +5 -0
  146. package/dist/commands/shift.d.ts.map +1 -0
  147. package/dist/commands/shift.js +52 -0
  148. package/dist/commands/sleep.d.ts.map +1 -1
  149. package/dist/commands/sort.d.ts.map +1 -1
  150. package/dist/commands/sort.js +4 -2
  151. package/dist/commands/source.d.ts.map +1 -1
  152. package/dist/commands/source.js +5 -2
  153. package/dist/commands/sudo.js +1 -1
  154. package/dist/commands/tar.d.ts.map +1 -1
  155. package/dist/commands/tar.js +11 -3
  156. package/dist/commands/tee.d.ts.map +1 -1
  157. package/dist/commands/tee.js +8 -6
  158. package/dist/commands/test.d.ts.map +1 -1
  159. package/dist/commands/test.js +46 -24
  160. package/dist/commands/tr.d.ts.map +1 -1
  161. package/dist/commands/tr.js +3 -1
  162. package/dist/commands/true.d.ts +4 -0
  163. package/dist/commands/true.d.ts.map +1 -0
  164. package/dist/commands/true.js +14 -0
  165. package/dist/commands/type.d.ts.map +1 -1
  166. package/dist/commands/type.js +1 -1
  167. package/dist/commands/uname.d.ts.map +1 -1
  168. package/dist/commands/uname.js +4 -1
  169. package/dist/commands/uniq.d.ts.map +1 -1
  170. package/dist/commands/uptime.d.ts.map +1 -1
  171. package/dist/commands/uptime.js +4 -1
  172. package/dist/commands/wget.d.ts.map +1 -1
  173. package/dist/commands/wget.js +32 -7
  174. package/dist/commands/which.d.ts.map +1 -1
  175. package/dist/commands/xargs.d.ts.map +1 -1
  176. package/dist/commands/xargs.js +1 -1
  177. package/dist/index.d.ts +15 -14
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +9 -9
  180. package/dist/modules/linuxRootfs.d.ts +18 -1
  181. package/dist/modules/linuxRootfs.d.ts.map +1 -1
  182. package/dist/modules/linuxRootfs.js +160 -17
  183. package/dist/standalone-wo-sftp.d.ts +2 -0
  184. package/dist/standalone-wo-sftp.d.ts.map +1 -0
  185. package/dist/standalone-wo-sftp.js +30 -0
  186. package/dist/utils/expand.d.ts +50 -0
  187. package/dist/utils/expand.d.ts.map +1 -0
  188. package/dist/utils/expand.js +183 -0
  189. package/dist/utils/vfsDiff.d.ts +90 -0
  190. package/dist/utils/vfsDiff.d.ts.map +1 -0
  191. package/dist/utils/vfsDiff.js +177 -0
  192. package/package.json +2 -1
  193. package/src/SSHMimic/exec.ts +10 -1
  194. package/src/SSHMimic/executor.ts +104 -18
  195. package/src/SSHMimic/index.ts +49 -15
  196. package/src/VirtualFileSystem/binaryPack.ts +35 -8
  197. package/src/VirtualFileSystem/index.ts +78 -28
  198. package/src/VirtualPackageManager/index.ts +208 -49
  199. package/src/VirtualShell/index.ts +35 -7
  200. package/src/VirtualShell/shell.ts +23 -3
  201. package/src/VirtualShell/shellParser.ts +134 -36
  202. package/src/VirtualUserManager/index.ts +7 -2
  203. package/src/commands/adduser.ts +6 -0
  204. package/src/commands/alias.ts +5 -1
  205. package/src/commands/apt.ts +47 -17
  206. package/src/commands/awk.ts +20 -6
  207. package/src/commands/base64.ts +13 -2
  208. package/src/commands/cat.ts +13 -5
  209. package/src/commands/cd.ts +5 -0
  210. package/src/commands/chmod.ts +5 -0
  211. package/src/commands/cp.ts +5 -0
  212. package/src/commands/curl.ts +56 -12
  213. package/src/commands/cut.ts +8 -1
  214. package/src/commands/date.ts +7 -1
  215. package/src/commands/declare.ts +44 -0
  216. package/src/commands/diff.ts +17 -3
  217. package/src/commands/dpkg.ts +33 -11
  218. package/src/commands/du.ts +17 -5
  219. package/src/commands/echo.ts +22 -9
  220. package/src/commands/env.ts +11 -1
  221. package/src/commands/exit.ts +12 -2
  222. package/src/commands/export.ts +3 -1
  223. package/src/commands/find.ts +5 -0
  224. package/src/commands/free.ts +9 -2
  225. package/src/commands/grep.ts +12 -2
  226. package/src/commands/gzip.ts +28 -4
  227. package/src/commands/head.ts +5 -0
  228. package/src/commands/help.ts +121 -47
  229. package/src/commands/history.ts +7 -2
  230. package/src/commands/hostname.ts +5 -0
  231. package/src/commands/id.ts +4 -1
  232. package/src/commands/index.ts +9 -360
  233. package/src/commands/ls.ts +5 -3
  234. package/src/commands/lsb-release.ts +8 -2
  235. package/src/commands/nano.ts +1 -1
  236. package/src/commands/neofetch.ts +1 -1
  237. package/src/commands/node.ts +341 -0
  238. package/src/commands/npm.ts +132 -0
  239. package/src/commands/ping.ts +6 -2
  240. package/src/commands/printf.ts +112 -0
  241. package/src/commands/ps.ts +21 -9
  242. package/src/commands/python.ts +2229 -0
  243. package/src/commands/read.ts +41 -0
  244. package/src/commands/registry.ts +244 -0
  245. package/src/commands/runtime.ts +353 -0
  246. package/src/commands/sed.ts +27 -9
  247. package/src/commands/set.ts +9 -3
  248. package/src/commands/sh.ts +159 -55
  249. package/src/commands/shift.ts +53 -0
  250. package/src/commands/sleep.ts +2 -1
  251. package/src/commands/sort.ts +10 -6
  252. package/src/commands/source.ts +15 -3
  253. package/src/commands/sudo.ts +1 -1
  254. package/src/commands/tar.ts +28 -7
  255. package/src/commands/tee.ts +7 -1
  256. package/src/commands/test.ts +61 -26
  257. package/src/commands/tr.ts +3 -1
  258. package/src/commands/true.ts +17 -0
  259. package/src/commands/type.ts +6 -3
  260. package/src/commands/uname.ts +5 -1
  261. package/src/commands/uniq.ts +8 -2
  262. package/src/commands/uptime.ts +4 -1
  263. package/src/commands/wget.ts +51 -12
  264. package/src/commands/which.ts +5 -2
  265. package/src/commands/xargs.ts +11 -2
  266. package/src/index.ts +23 -24
  267. package/src/modules/linuxRootfs.ts +233 -30
  268. package/src/standalone-wo-sftp.ts +38 -0
  269. package/src/utils/expand.ts +238 -0
  270. package/src/utils/vfsDiff.ts +275 -0
  271. package/standalone-wo-sftp.js +507 -0
  272. package/standalone-wo-sftp.js.map +7 -0
  273. package/standalone.js +253 -191
  274. package/standalone.js.map +4 -4
  275. package/tests/bun-test-shim.ts +9 -1
  276. package/tests/command-helpers.test.ts +1 -5
  277. package/tests/new-features.test.ts +415 -5
  278. package/tests/parser-executor.test.ts +27 -27
  279. package/tests/sftp.test.ts +122 -42
  280. package/tests/users.test.ts +23 -5
  281. package/CHANGELOG.md +0 -150
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  import type VirtualFileSystem from "../VirtualFileSystem";
4
2
  import type { VirtualUserManager } from "../VirtualUserManager";
5
3
 
@@ -89,9 +87,21 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
89
87
  shortDesc: "Vi IMproved",
90
88
  installedSizeKb: 3812,
91
89
  files: [
92
- { path: "/usr/bin/vim", content: "#!/bin/sh\necho 'vim: use nano for editing in this environment'\n", mode: 0o755 },
93
- { path: "/usr/bin/vi", content: "#!/bin/sh\nexec vim \"$@\"\n", mode: 0o755 },
94
- { path: "/usr/share/doc/vim/README", content: "Vim editor — virtual package.\n" },
90
+ {
91
+ path: "/usr/bin/vim",
92
+ content:
93
+ "#!/bin/sh\necho 'vim: use nano for editing in this environment'\n",
94
+ mode: 0o755,
95
+ },
96
+ {
97
+ path: "/usr/bin/vi",
98
+ content: '#!/bin/sh\nexec vim "$@"\n',
99
+ mode: 0o755,
100
+ },
101
+ {
102
+ path: "/usr/share/doc/vim/README",
103
+ content: "Vim editor — virtual package.\n",
104
+ },
95
105
  ],
96
106
  },
97
107
  {
@@ -102,8 +112,15 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
102
112
  shortDesc: "fast distributed version control system",
103
113
  installedSizeKb: 11240,
104
114
  files: [
105
- { path: "/usr/bin/git", content: "#!/bin/sh\necho 'git: virtual stub — no host access'\n", mode: 0o755 },
106
- { path: "/usr/share/doc/git/README.Debian", content: "Git virtual package for Fortune GNU/Linux.\n" },
115
+ {
116
+ path: "/usr/bin/git",
117
+ content: "#!/bin/sh\necho 'git: virtual stub — no host access'\n",
118
+ mode: 0o755,
119
+ },
120
+ {
121
+ path: "/usr/share/doc/git/README.Debian",
122
+ content: "Git virtual package for Fortune GNU/Linux.\n",
123
+ },
107
124
  ],
108
125
  },
109
126
  {
@@ -115,8 +132,16 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
115
132
  installedSizeKb: 512,
116
133
  depends: ["python3-minimal"],
117
134
  files: [
118
- { path: "/usr/bin/python3", content: "#!/bin/sh\necho 'Python 3.11.2 (virtual)'\n", mode: 0o755 },
119
- { path: "/usr/bin/python3.11", content: "#!/bin/sh\nexec python3 \"$@\"\n", mode: 0o755 },
135
+ {
136
+ path: "/usr/bin/python3",
137
+ content: "#!/bin/sh\necho 'Python 3.11.2 (virtual)'\n",
138
+ mode: 0o755,
139
+ },
140
+ {
141
+ path: "/usr/bin/python3.11",
142
+ content: '#!/bin/sh\nexec python3 "$@"\n',
143
+ mode: 0o755,
144
+ },
120
145
  { path: "/usr/lib/python3.11/.keep", content: "" },
121
146
  ],
122
147
  },
@@ -127,9 +152,7 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
127
152
  description: "Minimal subset of the Python language (version 3)",
128
153
  shortDesc: "minimal subset of Python language",
129
154
  installedSizeKb: 196,
130
- files: [
131
- { path: "/usr/lib/python3-minimal/.keep", content: "" },
132
- ],
155
+ files: [{ path: "/usr/lib/python3-minimal/.keep", content: "" }],
133
156
  },
134
157
  {
135
158
  name: "nodejs",
@@ -139,9 +162,20 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
139
162
  shortDesc: "Node.js JavaScript runtime",
140
163
  installedSizeKb: 15360,
141
164
  files: [
142
- { path: "/usr/bin/node", content: "#!/bin/sh\necho 'node v18.19.0 (virtual)'\n", mode: 0o755 },
143
- { path: "/usr/bin/nodejs", content: "#!/bin/sh\nexec node \"$@\"\n", mode: 0o755 },
144
- { path: "/usr/share/doc/nodejs/README", content: "Node.js virtual package.\n" },
165
+ {
166
+ path: "/usr/bin/node",
167
+ content: "#!/bin/sh\necho 'node v18.19.0 (virtual)'\n",
168
+ mode: 0o755,
169
+ },
170
+ {
171
+ path: "/usr/bin/nodejs",
172
+ content: '#!/bin/sh\nexec node "$@"\n',
173
+ mode: 0o755,
174
+ },
175
+ {
176
+ path: "/usr/share/doc/nodejs/README",
177
+ content: "Node.js virtual package.\n",
178
+ },
145
179
  ],
146
180
  },
147
181
  {
@@ -153,7 +187,16 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
153
187
  installedSizeKb: 9814,
154
188
  depends: ["nodejs"],
155
189
  files: [
156
- { path: "/usr/bin/npm", content: "#!/bin/sh\necho 'npm 9.2.0 (virtual)'\n", mode: 0o755 },
190
+ {
191
+ path: "/usr/bin/npm",
192
+ content: '#!/bin/sh\nexec builtin npm "$@"\n',
193
+ mode: 0o755,
194
+ },
195
+ {
196
+ path: "/usr/bin/npx",
197
+ content: '#!/bin/sh\nexec builtin npx "$@"\n',
198
+ mode: 0o755,
199
+ },
157
200
  ],
158
201
  },
159
202
  {
@@ -164,7 +207,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
164
207
  shortDesc: "command line tool for transferring data",
165
208
  installedSizeKb: 368,
166
209
  files: [
167
- { path: "/usr/bin/curl", content: "#!/bin/sh\nexec builtin curl \"$@\"\n", mode: 0o755 },
210
+ {
211
+ path: "/usr/bin/curl",
212
+ content: '#!/bin/sh\nexec builtin curl "$@"\n',
213
+ mode: 0o755,
214
+ },
168
215
  ],
169
216
  },
170
217
  {
@@ -175,7 +222,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
175
222
  shortDesc: "retrieves files from the web",
176
223
  installedSizeKb: 952,
177
224
  files: [
178
- { path: "/usr/bin/wget", content: "#!/bin/sh\nexec builtin wget \"$@\"\n", mode: 0o755 },
225
+ {
226
+ path: "/usr/bin/wget",
227
+ content: '#!/bin/sh\nexec builtin wget "$@"\n',
228
+ mode: 0o755,
229
+ },
179
230
  ],
180
231
  },
181
232
  {
@@ -186,7 +237,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
186
237
  shortDesc: "interactive process viewer",
187
238
  installedSizeKb: 412,
188
239
  files: [
189
- { path: "/usr/bin/htop", content: "#!/bin/sh\nexec builtin htop\n", mode: 0o755 },
240
+ {
241
+ path: "/usr/bin/htop",
242
+ content: "#!/bin/sh\nexec builtin htop\n",
243
+ mode: 0o755,
244
+ },
190
245
  ],
191
246
  },
192
247
  {
@@ -197,9 +252,20 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
197
252
  shortDesc: "secure shell (SSH) client",
198
253
  installedSizeKb: 4540,
199
254
  files: [
200
- { path: "/usr/bin/ssh", content: "#!/bin/sh\necho 'ssh: virtual stub'\n", mode: 0o755 },
201
- { path: "/usr/bin/ssh-keygen", content: "#!/bin/sh\necho 'ssh-keygen: virtual stub'\n", mode: 0o755 },
202
- { path: "/etc/ssh/ssh_config", content: "Host *\n StrictHostKeyChecking ask\n" },
255
+ {
256
+ path: "/usr/bin/ssh",
257
+ content: "#!/bin/sh\necho 'ssh: virtual stub'\n",
258
+ mode: 0o755,
259
+ },
260
+ {
261
+ path: "/usr/bin/ssh-keygen",
262
+ content: "#!/bin/sh\necho 'ssh-keygen: virtual stub'\n",
263
+ mode: 0o755,
264
+ },
265
+ {
266
+ path: "/etc/ssh/ssh_config",
267
+ content: "Host *\n StrictHostKeyChecking ask\n",
268
+ },
203
269
  ],
204
270
  },
205
271
  {
@@ -211,8 +277,15 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
211
277
  installedSizeKb: 1732,
212
278
  depends: ["openssh-client"],
213
279
  files: [
214
- { path: "/usr/sbin/sshd", content: "#!/bin/sh\necho 'sshd: virtual — server already running'\n", mode: 0o755 },
215
- { path: "/etc/ssh/sshd_config", content: "Port 22\nPermitRootLogin yes\nPasswordAuthentication yes\n" },
280
+ {
281
+ path: "/usr/sbin/sshd",
282
+ content: "#!/bin/sh\necho 'sshd: virtual — server already running'\n",
283
+ mode: 0o755,
284
+ },
285
+ {
286
+ path: "/etc/ssh/sshd_config",
287
+ content: "Port 22\nPermitRootLogin yes\nPasswordAuthentication yes\n",
288
+ },
216
289
  ],
217
290
  },
218
291
  {
@@ -223,9 +296,24 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
223
296
  shortDesc: "networking toolkit",
224
297
  installedSizeKb: 988,
225
298
  files: [
226
- { path: "/usr/bin/ifconfig", content: "#!/bin/sh\necho 'eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500'\necho ' inet 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255'\necho ' ether 02:42:0a:00:00:02 txqueuelen 0 (Ethernet)'\n", mode: 0o755 },
227
- { path: "/usr/bin/netstat", content: "#!/bin/sh\necho 'Active Internet connections (only servers)'\necho 'Proto Recv-Q Send-Q Local Address Foreign Address State'\n", mode: 0o755 },
228
- { path: "/usr/bin/route", content: "#!/bin/sh\necho 'Kernel IP routing table'\necho 'Destination Gateway Genmask Flags Metric Ref Use Iface'\necho '0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0'\n", mode: 0o755 },
299
+ {
300
+ path: "/usr/bin/ifconfig",
301
+ content:
302
+ "#!/bin/sh\necho 'eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500'\necho ' inet 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255'\necho ' ether 02:42:0a:00:00:02 txqueuelen 0 (Ethernet)'\n",
303
+ mode: 0o755,
304
+ },
305
+ {
306
+ path: "/usr/bin/netstat",
307
+ content:
308
+ "#!/bin/sh\necho 'Active Internet connections (only servers)'\necho 'Proto Recv-Q Send-Q Local Address Foreign Address State'\n",
309
+ mode: 0o755,
310
+ },
311
+ {
312
+ path: "/usr/bin/route",
313
+ content:
314
+ "#!/bin/sh\necho 'Kernel IP routing table'\necho 'Destination Gateway Genmask Flags Metric Ref Use Iface'\necho '0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0'\n",
315
+ mode: 0o755,
316
+ },
229
317
  ],
230
318
  },
231
319
  {
@@ -236,7 +324,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
236
324
  shortDesc: "test reachability of network hosts",
237
325
  installedSizeKb: 164,
238
326
  files: [
239
- { path: "/usr/bin/ping", content: "#!/bin/sh\nexec builtin ping \"$@\"\n", mode: 0o755 },
327
+ {
328
+ path: "/usr/bin/ping",
329
+ content: '#!/bin/sh\nexec builtin ping "$@"\n',
330
+ mode: 0o755,
331
+ },
240
332
  ],
241
333
  },
242
334
  {
@@ -247,7 +339,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
247
339
  shortDesc: "command-line JSON processor",
248
340
  installedSizeKb: 296,
249
341
  files: [
250
- { path: "/usr/bin/jq", content: "#!/bin/sh\necho 'jq: virtual stub — pipe JSON here'\n", mode: 0o755 },
342
+ {
343
+ path: "/usr/bin/jq",
344
+ content: "#!/bin/sh\necho 'jq: virtual stub — pipe JSON here'\n",
345
+ mode: 0o755,
346
+ },
251
347
  ],
252
348
  },
253
349
  {
@@ -259,7 +355,10 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
259
355
  installedSizeKb: 12,
260
356
  depends: ["gcc", "g++", "make"],
261
357
  files: [
262
- { path: "/usr/share/doc/build-essential/README", content: "Build-essential virtual meta-package.\n" },
358
+ {
359
+ path: "/usr/share/doc/build-essential/README",
360
+ content: "Build-essential virtual meta-package.\n",
361
+ },
263
362
  ],
264
363
  },
265
364
  {
@@ -270,8 +369,16 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
270
369
  shortDesc: "GNU C compiler",
271
370
  installedSizeKb: 24448,
272
371
  files: [
273
- { path: "/usr/bin/gcc", content: "#!/bin/sh\necho 'gcc (Fortune GNU/Linux) 12.2.0 (virtual)'\n", mode: 0o755 },
274
- { path: "/usr/bin/gcc-12", content: "#!/bin/sh\nexec gcc \"$@\"\n", mode: 0o755 },
372
+ {
373
+ path: "/usr/bin/gcc",
374
+ content: "#!/bin/sh\necho 'gcc (Fortune GNU/Linux) 12.2.0 (virtual)'\n",
375
+ mode: 0o755,
376
+ },
377
+ {
378
+ path: "/usr/bin/gcc-12",
379
+ content: '#!/bin/sh\nexec gcc "$@"\n',
380
+ mode: 0o755,
381
+ },
275
382
  ],
276
383
  },
277
384
  {
@@ -283,7 +390,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
283
390
  installedSizeKb: 1024,
284
391
  depends: ["gcc"],
285
392
  files: [
286
- { path: "/usr/bin/g++", content: "#!/bin/sh\necho 'g++ (Fortune GNU/Linux) 12.2.0 (virtual)'\n", mode: 0o755 },
393
+ {
394
+ path: "/usr/bin/g++",
395
+ content: "#!/bin/sh\necho 'g++ (Fortune GNU/Linux) 12.2.0 (virtual)'\n",
396
+ mode: 0o755,
397
+ },
287
398
  ],
288
399
  },
289
400
  {
@@ -294,7 +405,12 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
294
405
  shortDesc: "build utility",
295
406
  installedSizeKb: 504,
296
407
  files: [
297
- { path: "/usr/bin/make", content: "#!/bin/sh\necho 'make: *** No targets specified and no makefile found. Stop.'\nexit 2\n", mode: 0o755 },
408
+ {
409
+ path: "/usr/bin/make",
410
+ content:
411
+ "#!/bin/sh\necho 'make: *** No targets specified and no makefile found. Stop.'\nexit 2\n",
412
+ mode: 0o755,
413
+ },
298
414
  ],
299
415
  },
300
416
  {
@@ -305,7 +421,7 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
305
421
  shortDesc: "pager program",
306
422
  installedSizeKb: 328,
307
423
  files: [
308
- { path: "/usr/bin/less", content: "#!/bin/sh\ncat \"$@\"\n", mode: 0o755 },
424
+ { path: "/usr/bin/less", content: '#!/bin/sh\ncat "$@"\n', mode: 0o755 },
309
425
  ],
310
426
  },
311
427
  {
@@ -316,7 +432,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
316
432
  shortDesc: "de-archiver for .zip files",
317
433
  installedSizeKb: 464,
318
434
  files: [
319
- { path: "/usr/bin/unzip", content: "#!/bin/sh\necho 'unzip: virtual stub'\n", mode: 0o755 },
435
+ {
436
+ path: "/usr/bin/unzip",
437
+ content: "#!/bin/sh\necho 'unzip: virtual stub'\n",
438
+ mode: 0o755,
439
+ },
320
440
  ],
321
441
  },
322
442
  {
@@ -327,7 +447,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
327
447
  shortDesc: "fast remote file copy program",
328
448
  installedSizeKb: 716,
329
449
  files: [
330
- { path: "/usr/bin/rsync", content: "#!/bin/sh\necho 'rsync: virtual stub'\n", mode: 0o755 },
450
+ {
451
+ path: "/usr/bin/rsync",
452
+ content: "#!/bin/sh\necho 'rsync: virtual stub'\n",
453
+ mode: 0o755,
454
+ },
331
455
  ],
332
456
  },
333
457
  {
@@ -338,7 +462,12 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
338
462
  shortDesc: "terminal multiplexer",
339
463
  installedSizeKb: 812,
340
464
  files: [
341
- { path: "/usr/bin/tmux", content: "#!/bin/sh\necho 'tmux: terminal multiplexer (virtual stub)'\n", mode: 0o755 },
465
+ {
466
+ path: "/usr/bin/tmux",
467
+ content:
468
+ "#!/bin/sh\necho 'tmux: terminal multiplexer (virtual stub)'\n",
469
+ mode: 0o755,
470
+ },
342
471
  ],
343
472
  },
344
473
  {
@@ -349,7 +478,11 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
349
478
  shortDesc: "list files in tree format",
350
479
  installedSizeKb: 108,
351
480
  files: [
352
- { path: "/usr/bin/tree", content: "#!/bin/sh\nexec builtin tree \"$@\"\n", mode: 0o755 },
481
+ {
482
+ path: "/usr/bin/tree",
483
+ content: '#!/bin/sh\nexec builtin tree "$@"\n',
484
+ mode: 0o755,
485
+ },
353
486
  ],
354
487
  },
355
488
  {
@@ -378,7 +511,10 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
378
511
  installedSizeKb: 16484,
379
512
  files: [
380
513
  { path: "/etc/locale.gen", content: "en_US.UTF-8 UTF-8\n" },
381
- { path: "/etc/default/locale", content: "LANG=en_US.UTF-8\nLANGUAGE=en_US:en\n" },
514
+ {
515
+ path: "/etc/default/locale",
516
+ content: "LANG=en_US.UTF-8\nLANGUAGE=en_US:en\n",
517
+ },
382
518
  ],
383
519
  },
384
520
  {
@@ -389,8 +525,15 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
389
525
  shortDesc: "super user privilege execution",
390
526
  installedSizeKb: 2304,
391
527
  files: [
392
- { path: "/usr/bin/sudo", content: "#!/bin/sh\nexec builtin sudo \"$@\"\n", mode: 0o755 },
393
- { path: "/etc/sudoers", content: "root ALL=(ALL:ALL) ALL\n%sudo ALL=(ALL:ALL) ALL\n" },
528
+ {
529
+ path: "/usr/bin/sudo",
530
+ content: '#!/bin/sh\nexec builtin sudo "$@"\n',
531
+ mode: 0o755,
532
+ },
533
+ {
534
+ path: "/etc/sudoers",
535
+ content: "root ALL=(ALL:ALL) ALL\n%sudo ALL=(ALL:ALL) ALL\n",
536
+ },
394
537
  ],
395
538
  },
396
539
  {
@@ -401,8 +544,17 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
401
544
  shortDesc: "system and service manager",
402
545
  installedSizeKb: 26624,
403
546
  files: [
404
- { path: "/usr/bin/systemctl", content: "#!/bin/sh\necho 'systemd is not running in this virtual container.'\nexit 1\n", mode: 0o755 },
405
- { path: "/usr/bin/journalctl", content: "#!/bin/sh\necho 'journalctl: virtual stub'\n", mode: 0o755 },
547
+ {
548
+ path: "/usr/bin/systemctl",
549
+ content:
550
+ "#!/bin/sh\necho 'systemd is not running in this virtual container.'\nexit 1\n",
551
+ mode: 0o755,
552
+ },
553
+ {
554
+ path: "/usr/bin/journalctl",
555
+ content: "#!/bin/sh\necho 'journalctl: virtual stub'\n",
556
+ mode: 0o755,
557
+ },
406
558
  ],
407
559
  },
408
560
  ];
@@ -626,7 +778,9 @@ export class VirtualPackageManager {
626
778
 
627
779
  if (toInstall.length === 0) {
628
780
  return {
629
- output: names.map((n) => `${n} is already the newest version.`).join("\n"),
781
+ output: names
782
+ .map((n) => `${n} is already the newest version.`)
783
+ .join("\n"),
630
784
  exitCode: 0,
631
785
  };
632
786
  }
@@ -692,7 +846,10 @@ export class VirtualPackageManager {
692
846
  this.log(`install ${def.name} ${def.version}`);
693
847
  }
694
848
 
695
- this.aptLog("install", toInstall.map((p) => p.name));
849
+ this.aptLog(
850
+ "install",
851
+ toInstall.map((p) => p.name),
852
+ );
696
853
  this.persist();
697
854
 
698
855
  if (!opts.quiet) {
@@ -746,8 +903,7 @@ export class VirtualPackageManager {
746
903
  }
747
904
 
748
905
  for (const pkg of toRemove) {
749
- if (!opts.quiet)
750
- lines.push(`Removing ${pkg.name} (${pkg.version}) ...`);
906
+ if (!opts.quiet) lines.push(`Removing ${pkg.name} (${pkg.version}) ...`);
751
907
 
752
908
  // Remove files (if purge, include config files)
753
909
  for (const filePath of pkg.files) {
@@ -770,7 +926,10 @@ export class VirtualPackageManager {
770
926
  this.log(`remove ${pkg.name} ${pkg.version}`);
771
927
  }
772
928
 
773
- this.aptLog("remove", toRemove.map((p) => p.name));
929
+ this.aptLog(
930
+ "remove",
931
+ toRemove.map((p) => p.name),
932
+ );
774
933
  this.persist();
775
934
 
776
935
  return { output: lines.join("\n"), exitCode: 0 };
@@ -1,13 +1,18 @@
1
1
  import { EventEmitter } from "node:events";
2
- import { createCustomCommand, registerCommand, runCommand } from "../commands";
2
+ import { createCustomCommand, registerCommand } from "../commands/registry";
3
+ import { runCommand } from "../commands/runtime";
4
+ import {
5
+ bootstrapLinuxRootfs,
6
+ refreshProc,
7
+ syncEtcPasswd,
8
+ } from "../modules/linuxRootfs";
3
9
  import type { CommandContext, CommandResult } from "../types/commands";
4
10
  import type { ShellStream } from "../types/streams";
5
11
  import type { PerfLogger } from "../utils/perfLogger";
6
12
  import { createPerfLogger } from "../utils/perfLogger";
7
13
  import VirtualFileSystem, { type VfsOptions } from "../VirtualFileSystem";
8
- import { VirtualUserManager } from "../VirtualUserManager";
9
14
  import { VirtualPackageManager } from "../VirtualPackageManager";
10
- import { bootstrapLinuxRootfs, refreshProc, syncEtcPasswd } from "../modules/linuxRootfs";
15
+ import { VirtualUserManager } from "../VirtualUserManager";
11
16
  import { startShell } from "./shell";
12
17
 
13
18
  /**
@@ -211,20 +216,43 @@ class VirtualShell extends EventEmitter {
211
216
  terminalSize,
212
217
  this,
213
218
  );
219
+ // Refresh /proc/<pid> and /proc/self after session is registered
220
+ this.refreshProcSessions();
214
221
  }
215
222
 
216
223
  /**
217
224
  * Refreshes the `/proc` virtual filesystem with current system state.
218
225
  *
219
226
  * Updates `/proc/uptime`, `/proc/meminfo`, `/proc/cpuinfo`,
220
- * `/proc/version`, and `/proc/loadavg` from live host data.
227
+ * `/proc/version`, `/proc/loadavg`, `/proc/self`, and per-session
228
+ * `/proc/<pid>` entries from live session and host data.
221
229
  *
222
230
  * Called automatically during `bootstrapLinuxRootfs`. Call again before
223
- * reading `/proc` files for up-to-date values (e.g. before `neofetch`
224
- * or `free` in long-running processes).
231
+ * reading `/proc` files for up-to-date values.
225
232
  */
226
233
  public refreshProcFs(): void {
227
- refreshProc(this.vfs, this.properties, this.hostname, this.startTime);
234
+ refreshProc(
235
+ this.vfs,
236
+ this.properties,
237
+ this.hostname,
238
+ this.startTime,
239
+ this.users.listActiveSessions(),
240
+ );
241
+ }
242
+
243
+ /**
244
+ * Updates only the session-dependent `/proc` entries (`/proc/<pid>`,
245
+ * `/proc/self`). Cheaper than a full `refreshProcFs()` — call this
246
+ * whenever a session is registered or unregistered.
247
+ */
248
+ public refreshProcSessions(): void {
249
+ refreshProc(
250
+ this.vfs,
251
+ this.properties,
252
+ this.hostname,
253
+ this.startTime,
254
+ this.users.listActiveSessions(),
255
+ );
228
256
  }
229
257
 
230
258
  /**
@@ -73,9 +73,20 @@ export function startShell(
73
73
  for (const line of bashrc.split("\n")) {
74
74
  const l = line.trim();
75
75
  if (!l || l.startsWith("#")) continue;
76
- await runCommand(l, authUser, hostname, "shell", cwd, shell, undefined, shellEnv);
76
+ await runCommand(
77
+ l,
78
+ authUser,
79
+ hostname,
80
+ "shell",
81
+ cwd,
82
+ shell,
83
+ undefined,
84
+ shellEnv,
85
+ );
77
86
  }
78
- } catch { /* ignore bashrc errors */ }
87
+ } catch {
88
+ /* ignore bashrc errors */
89
+ }
79
90
  }
80
91
  })();
81
92
 
@@ -585,7 +596,16 @@ export function startShell(
585
596
 
586
597
  if (line.length > 0) {
587
598
  const result = await Promise.resolve(
588
- runCommand(line, authUser, hostname, "shell", cwd, shell, undefined, shellEnv),
599
+ runCommand(
600
+ line,
601
+ authUser,
602
+ hostname,
603
+ "shell",
604
+ cwd,
605
+ shell,
606
+ undefined,
607
+ shellEnv,
608
+ ),
589
609
  );
590
610
 
591
611
  pushHistory(line);