windows-development-sandbox 1.10.0 → 1.11.4

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 (383) hide show
  1. package/README.md +64 -17
  2. package/config.example.json +5 -1
  3. package/dist/app/features/accounts/accounts.def.d.ts +122 -0
  4. package/dist/app/features/accounts/accounts.def.js +243 -0
  5. package/dist/app/features/accounts/accounts.run.d.ts +51 -0
  6. package/dist/app/features/accounts/accounts.run.js +125 -0
  7. package/dist/app/features/accounts/index.d.ts +2 -0
  8. package/dist/app/features/accounts/index.js +3 -0
  9. package/dist/app/features/agents/agent-entry.d.ts +17 -0
  10. package/dist/app/features/agents/agent-entry.js +50 -0
  11. package/dist/app/features/agents/agents.def.d.ts +65 -0
  12. package/dist/app/features/agents/agents.def.js +142 -0
  13. package/dist/app/features/agents/agents.run.d.ts +31 -0
  14. package/dist/app/features/agents/agents.run.js +189 -0
  15. package/dist/app/features/agents/index.d.ts +3 -0
  16. package/dist/app/features/agents/index.js +4 -0
  17. package/dist/app/features/apps/apps-rows.d.ts +31 -0
  18. package/dist/app/features/apps/apps-rows.js +73 -0
  19. package/dist/app/features/apps/apps.def.d.ts +181 -0
  20. package/dist/app/features/apps/apps.def.js +264 -0
  21. package/dist/app/features/apps/apps.run.d.ts +58 -0
  22. package/dist/app/features/apps/apps.run.js +76 -0
  23. package/dist/app/features/apps/index.d.ts +3 -0
  24. package/dist/app/features/apps/index.js +4 -0
  25. package/dist/app/features/data/data.def.d.ts +154 -0
  26. package/dist/app/features/data/data.def.js +194 -0
  27. package/dist/app/features/data/data.run.d.ts +46 -0
  28. package/dist/app/features/data/data.run.js +141 -0
  29. package/dist/app/features/data/index.d.ts +2 -0
  30. package/dist/app/features/data/index.js +3 -0
  31. package/dist/app/features/defs.d.ts +959 -4
  32. package/dist/app/features/defs.js +151 -10
  33. package/dist/app/features/engine/engine.def.d.ts +228 -0
  34. package/dist/app/features/engine/engine.def.js +194 -0
  35. package/dist/app/features/engine/engine.run.d.ts +72 -0
  36. package/dist/app/features/engine/engine.run.js +77 -0
  37. package/dist/app/features/engine/index.d.ts +2 -0
  38. package/dist/app/features/engine/index.js +4 -0
  39. package/dist/app/features/files/files.def.d.ts +51 -0
  40. package/dist/app/features/files/files.def.js +38 -0
  41. package/dist/app/features/files/files.run.d.ts +20 -0
  42. package/dist/app/features/files/files.run.js +59 -0
  43. package/dist/app/features/files/index.d.ts +2 -0
  44. package/dist/app/features/files/index.js +3 -0
  45. package/dist/app/features/github/github.def.d.ts +80 -0
  46. package/dist/app/features/github/github.def.js +142 -0
  47. package/dist/app/features/github/github.run.d.ts +36 -0
  48. package/dist/app/features/github/github.run.js +59 -0
  49. package/dist/app/features/github/index.d.ts +2 -0
  50. package/dist/app/features/github/index.js +3 -0
  51. package/dist/app/features/health/health.def.d.ts +275 -0
  52. package/dist/app/features/health/health.def.js +297 -0
  53. package/dist/app/features/health/health.run.d.ts +125 -0
  54. package/dist/app/features/health/health.run.js +204 -0
  55. package/dist/app/features/health/index.d.ts +2 -0
  56. package/dist/app/features/health/index.js +3 -0
  57. package/dist/app/features/logs/index.d.ts +2 -0
  58. package/dist/app/features/logs/index.js +3 -0
  59. package/dist/app/features/logs/logs.def.d.ts +78 -0
  60. package/dist/app/features/logs/logs.def.js +115 -0
  61. package/dist/app/features/logs/logs.run.d.ts +20 -0
  62. package/dist/app/features/logs/logs.run.js +42 -0
  63. package/dist/app/features/projects/index.d.ts +2 -0
  64. package/dist/app/features/projects/index.js +3 -0
  65. package/dist/app/features/projects/projects.def.d.ts +101 -0
  66. package/dist/app/features/projects/projects.def.js +208 -0
  67. package/dist/app/features/projects/projects.run.d.ts +56 -0
  68. package/dist/app/features/projects/projects.run.js +155 -0
  69. package/dist/app/features/sandbox/sandbox.def.js +11 -5
  70. package/dist/app/features/sessions/sessions.def.js +3 -0
  71. package/dist/app/features/settings/categories.def.js +3 -2
  72. package/dist/{cli/menu/settings/share.d.ts → app/features/settings/settings-share.d.ts} +1 -1
  73. package/dist/{cli/menu/settings/share.js → app/features/settings/settings-share.js} +3 -2
  74. package/dist/app/features/settings/settings.def.d.ts +22 -5
  75. package/dist/app/features/settings/settings.def.js +81 -6
  76. package/dist/app/features/settings/settings.run.d.ts +17 -0
  77. package/dist/app/features/settings/settings.run.js +89 -4
  78. package/dist/app/features/storage/index.d.ts +2 -0
  79. package/dist/app/features/storage/index.js +3 -0
  80. package/dist/app/features/storage/storage.def.d.ts +133 -0
  81. package/dist/app/features/storage/storage.def.js +220 -0
  82. package/dist/app/features/storage/storage.run.d.ts +62 -0
  83. package/dist/app/features/storage/storage.run.js +370 -0
  84. package/dist/app/features/updates/index.d.ts +3 -0
  85. package/dist/app/features/updates/index.js +4 -0
  86. package/dist/app/features/updates/update-lines.d.ts +13 -0
  87. package/dist/app/features/updates/update-lines.js +61 -0
  88. package/dist/app/features/updates/updates.def.d.ts +89 -0
  89. package/dist/app/features/updates/updates.def.js +224 -0
  90. package/dist/app/features/updates/updates.run.d.ts +48 -0
  91. package/dist/app/features/updates/updates.run.js +154 -0
  92. package/dist/app/features/vpn/index.d.ts +2 -0
  93. package/dist/app/features/vpn/index.js +3 -0
  94. package/dist/app/features/vpn/vpn.def.d.ts +112 -0
  95. package/dist/app/features/vpn/vpn.def.js +174 -0
  96. package/dist/app/features/vpn/vpn.run.d.ts +37 -0
  97. package/dist/app/features/vpn/vpn.run.js +54 -0
  98. package/dist/app/features/web/index.d.ts +2 -0
  99. package/dist/app/features/web/index.js +3 -0
  100. package/dist/app/features/web/web.def.d.ts +33 -0
  101. package/dist/app/features/web/web.def.js +90 -0
  102. package/dist/app/features/web/web.run.d.ts +24 -0
  103. package/dist/app/features/web/web.run.js +93 -0
  104. package/dist/app/kernel/define.d.ts +10 -1
  105. package/dist/app/kernel/io.d.ts +34 -0
  106. package/dist/app/kernel/io.js +9 -0
  107. package/dist/app/kernel/rpc.d.ts +17 -0
  108. package/dist/app/kernel/text.d.ts +2 -0
  109. package/dist/app/kernel/text.js +7 -0
  110. package/dist/app/kernel/view.d.ts +24 -1
  111. package/dist/app/kernel/view.js +1 -1
  112. package/dist/app/registry.js +74 -1
  113. package/dist/cli/args.js +1 -1
  114. package/dist/cli/commands/context.d.ts +7 -0
  115. package/dist/cli/commands/context.js +29 -2
  116. package/dist/cli/commands/engine.js +5 -58
  117. package/dist/cli/commands/github.d.ts +2 -0
  118. package/dist/cli/commands/github.js +11 -0
  119. package/dist/cli/commands/index.d.ts +3 -5
  120. package/dist/cli/commands/index.js +3 -5
  121. package/dist/cli/commands/launch/launch.js +21 -4
  122. package/dist/cli/commands/launch/running.js +4 -1
  123. package/dist/cli/commands/maintenance/config.js +1 -6
  124. package/dist/cli/commands/maintenance/index.d.ts +0 -1
  125. package/dist/cli/commands/maintenance/index.js +1 -2
  126. package/dist/cli/commands/maintenance/logs.js +27 -32
  127. package/dist/cli/commands/maintenance/migrate.d.ts +0 -8
  128. package/dist/cli/commands/maintenance/migrate.js +2 -44
  129. package/dist/cli/commands/maintenance/update.d.ts +0 -19
  130. package/dist/cli/commands/maintenance/update.js +1 -99
  131. package/dist/cli/commands/projects/index.d.ts +0 -1
  132. package/dist/cli/commands/projects/index.js +0 -1
  133. package/dist/cli/commands/registry.d.ts +1 -1
  134. package/dist/cli/commands/registry.js +29 -11
  135. package/dist/cli/commands/repair/checks/data.js +1 -1
  136. package/dist/cli/commands/repair/checks/hcs.js +28 -1
  137. package/dist/cli/commands/repair/checks/sandbox.js +1 -1
  138. package/dist/cli/commands/repair/health-run.d.ts +30 -0
  139. package/dist/cli/commands/repair/health-run.js +32 -0
  140. package/dist/cli/commands/repair/printer.d.ts +2 -2
  141. package/dist/cli/commands/repair/printer.js +2 -11
  142. package/dist/cli/commands/repair/run.d.ts +1 -21
  143. package/dist/cli/commands/repair/run.js +13 -70
  144. package/dist/cli/commands/storage/index.d.ts +0 -1
  145. package/dist/cli/commands/storage/index.js +0 -1
  146. package/dist/cli/commands/storage/offer.js +6 -2
  147. package/dist/cli/commands/vpn.d.ts +1 -3
  148. package/dist/cli/commands/vpn.js +8 -89
  149. package/dist/cli/commands/web.d.ts +2 -1
  150. package/dist/cli/commands/web.js +14 -78
  151. package/dist/cli/index.js +3 -2
  152. package/dist/cli/manifest.d.ts +16 -153
  153. package/dist/cli/manifest.js +20 -50
  154. package/dist/cli/menu/command-form.js +1 -2
  155. package/dist/cli/menu/io-menu.d.ts +2 -2
  156. package/dist/cli/menu/io-menu.js +6 -4
  157. package/dist/cli/menu/menu.js +1 -1
  158. package/dist/cli/menu/pages/accounts-page.d.ts +5 -17
  159. package/dist/cli/menu/pages/accounts-page.js +28 -170
  160. package/dist/cli/menu/pages/agents-page.d.ts +17 -18
  161. package/dist/cli/menu/pages/agents-page.js +67 -124
  162. package/dist/cli/menu/pages/apps-page.d.ts +15 -8
  163. package/dist/cli/menu/pages/apps-page.js +121 -29
  164. package/dist/cli/menu/pages/list-page.js +10 -1
  165. package/dist/cli/menu/pages/maintenance-page.d.ts +51 -52
  166. package/dist/cli/menu/pages/maintenance-page.js +246 -427
  167. package/dist/cli/menu/pages/sandbox-page.d.ts +3 -5
  168. package/dist/cli/menu/pages/sandbox-page.js +34 -112
  169. package/dist/cli/menu/pages/settings-page.d.ts +21 -3
  170. package/dist/cli/menu/pages/settings-page.js +89 -17
  171. package/dist/cli/menu/render-view.js +2 -1
  172. package/dist/cli/menu/settings/index.d.ts +0 -1
  173. package/dist/cli/menu/settings/index.js +3 -3
  174. package/dist/cli/menu/views.js +28 -0
  175. package/dist/cli/operations/handler.js +7 -3
  176. package/dist/cli/operations/input.d.ts +1 -1
  177. package/dist/cli/operations/input.js +29 -5
  178. package/dist/cli/operations/io-cli.js +9 -1
  179. package/dist/cli/operations/spec.js +8 -2
  180. package/dist/cli/output/render-view.js +2 -0
  181. package/dist/cli/{commands/data/collect.js → services/data-collect.js} +2 -2
  182. package/dist/cli/{commands/data/remove.js → services/data-remove.js} +2 -2
  183. package/dist/cli/services/data-service.d.ts +1 -1
  184. package/dist/cli/services/data-service.js +2 -2
  185. package/dist/cli/services/databases-service.d.ts +5 -0
  186. package/dist/cli/services/databases-service.js +15 -0
  187. package/dist/cli/services/health-service.d.ts +8 -4
  188. package/dist/cli/services/health-service.js +10 -8
  189. package/dist/cli/services/index.d.ts +4 -1
  190. package/dist/cli/services/index.js +4 -1
  191. package/dist/cli/services/logs-service.d.ts +7 -0
  192. package/dist/cli/services/logs-service.js +13 -0
  193. package/dist/cli/services/storage-service.d.ts +19 -0
  194. package/dist/cli/services/storage-service.js +71 -0
  195. package/dist/cli/services/vpn-service.d.ts +6 -4
  196. package/dist/cli/services/vpn-service.js +5 -11
  197. package/dist/cli/services/web-service.d.ts +4 -3
  198. package/dist/cli/services/web-service.js +12 -32
  199. package/dist/core/config/defaults.js +2 -1
  200. package/dist/core/schema/config.d.ts +5 -0
  201. package/dist/core/schema/config.js +2 -0
  202. package/dist/core/schema/github.d.ts +4 -0
  203. package/dist/core/schema/github.js +7 -0
  204. package/dist/core/schema/index.d.ts +1 -0
  205. package/dist/core/schema/index.js +1 -0
  206. package/dist/core/schema/profile.d.ts +1 -0
  207. package/dist/core/schema/profile.js +3 -0
  208. package/dist/core/schema/sandbox.js +3 -3
  209. package/dist/core/schema/toolchains.js +2 -2
  210. package/dist/core/types.d.ts +6 -3
  211. package/dist/guest/boot/boot.js +8 -0
  212. package/dist/guest/daemon/daemon.js +1 -1
  213. package/dist/guest/daemon/sessions.d.ts +3 -2
  214. package/dist/guest/daemon/sessions.js +38 -7
  215. package/dist/guest/governor/core.d.ts +44 -0
  216. package/dist/guest/governor/core.js +124 -0
  217. package/dist/guest/governor/decide.d.ts +46 -18
  218. package/dist/guest/governor/decide.js +136 -82
  219. package/dist/guest/governor/governor.d.ts +2 -38
  220. package/dist/guest/governor/governor.js +33 -113
  221. package/dist/guest/governor/index.d.ts +1 -0
  222. package/dist/guest/governor/index.js +1 -0
  223. package/dist/guest/network/firewall.d.ts +2 -0
  224. package/dist/guest/network/firewall.js +3 -3
  225. package/dist/guest/sessions/viewer.js +5 -1
  226. package/dist/guest/setup/github-token.d.ts +7 -0
  227. package/dist/guest/setup/github-token.js +65 -0
  228. package/dist/guest/toolchains/languages/node.js +11 -1
  229. package/dist/guest/toolchains/native/rust-extras.js +2 -2
  230. package/dist/guest/toolchains/tools/cli.d.ts +8 -0
  231. package/dist/guest/toolchains/tools/cli.js +35 -2
  232. package/dist/guest/vpn/openvpn.d.ts +5 -0
  233. package/dist/guest/vpn/openvpn.js +14 -1
  234. package/dist/guest/vpn/vpn.js +55 -16
  235. package/dist/guest/vpn/wireguard.js +2 -0
  236. package/dist/host/channel/attach.d.ts +1 -0
  237. package/dist/host/channel/attach.js +1 -0
  238. package/dist/host/channel/channel.d.ts +1 -1
  239. package/dist/host/channel/channel.js +2 -2
  240. package/dist/host/engines/hcs/check.d.ts +1 -0
  241. package/dist/host/engines/hcs/check.js +1 -1
  242. package/dist/host/engines/hcs/engine.d.ts +1 -1
  243. package/dist/host/engines/hcs/engine.js +6 -4
  244. package/dist/host/engines/hcs/helper.d.ts +11 -0
  245. package/dist/host/engines/hcs/helper.js +31 -2
  246. package/dist/host/engines/hcs/leftovers.d.ts +42 -0
  247. package/dist/host/engines/hcs/leftovers.js +101 -0
  248. package/dist/host/engines/index.d.ts +1 -0
  249. package/dist/host/engines/index.js +1 -0
  250. package/dist/host/github/deliver.d.ts +13 -0
  251. package/dist/host/github/deliver.js +51 -0
  252. package/dist/host/github/index.d.ts +2 -0
  253. package/dist/host/github/index.js +3 -0
  254. package/dist/host/github/token.d.ts +21 -0
  255. package/dist/host/github/token.js +74 -0
  256. package/dist/host/launch/generate.js +11 -5
  257. package/dist/host/launch/index.d.ts +1 -1
  258. package/dist/host/launch/index.js +1 -1
  259. package/dist/host/launch/session-file.js +1 -2
  260. package/dist/host/launch/wsb-file.d.ts +11 -7
  261. package/dist/host/launch/wsb-file.js +30 -12
  262. package/dist/host/life/host-memory.d.ts +18 -0
  263. package/dist/host/life/host-memory.js +66 -0
  264. package/dist/host/life/watchdog.d.ts +9 -0
  265. package/dist/host/life/watchdog.js +17 -1
  266. package/dist/host/sandbox/tasklist.d.ts +6 -0
  267. package/dist/host/sandbox/tasklist.js +37 -0
  268. package/dist/host/secrets/launch-secrets.d.ts +2 -1
  269. package/dist/host/secrets/launch-secrets.js +4 -2
  270. package/dist/host/vpn/status.js +13 -3
  271. package/dist/host/web/backend.d.ts +1 -3
  272. package/dist/host/web/index.d.ts +2 -1
  273. package/dist/host/web/index.js +2 -1
  274. package/dist/host/web/live.d.ts +23 -0
  275. package/dist/host/web/live.js +107 -0
  276. package/dist/host/web/rpc.d.ts +6 -1
  277. package/dist/host/web/rpc.js +23 -31
  278. package/dist/host/web/runner.d.ts +4 -0
  279. package/dist/host/web/runner.js +12 -1
  280. package/dist/host/web/server.d.ts +30 -2
  281. package/dist/host/web/server.js +87 -29
  282. package/dist/host/web/state.d.ts +1 -0
  283. package/dist/host/web/state.js +2 -0
  284. package/dist/runtime/agent.js +30 -6
  285. package/dist/runtime/daemon.js +337 -177
  286. package/dist/runtime/db.js +30 -6
  287. package/dist/runtime/main.js +389 -77
  288. package/dist/runtime/netproxy.js +30 -6
  289. package/dist/runtime/view.js +495 -146
  290. package/dist/selftest/app.test.js +632 -12
  291. package/dist/selftest/channel.test.js +18 -1
  292. package/dist/selftest/cli.test.js +1 -1
  293. package/dist/selftest/config.test.js +1 -1
  294. package/dist/selftest/contained.test.js +1 -1
  295. package/dist/selftest/data.test.js +1 -2
  296. package/dist/selftest/engine.test.js +3 -1
  297. package/dist/selftest/github.test.d.ts +2 -0
  298. package/dist/selftest/github.test.js +243 -0
  299. package/dist/selftest/hcs.test.js +105 -8
  300. package/dist/selftest/health.test.js +71 -0
  301. package/dist/selftest/heavy-load.test.js +132 -72
  302. package/dist/selftest/index.js +4 -0
  303. package/dist/selftest/layout.test.js +8 -0
  304. package/dist/selftest/live-terminal.test.js +74 -0
  305. package/dist/selftest/menu-screens.js +171 -56
  306. package/dist/selftest/menu.test.js +54 -37
  307. package/dist/selftest/migrate.test.js +14 -12
  308. package/dist/selftest/powershell-variables.test.d.ts +2 -0
  309. package/dist/selftest/powershell-variables.test.js +61 -0
  310. package/dist/selftest/support/engine-golden.js +1 -0
  311. package/dist/selftest/support/fixtures.d.ts +4 -0
  312. package/dist/selftest/support/web-preview.d.ts +1 -0
  313. package/dist/selftest/support/web-preview.js +856 -0
  314. package/dist/selftest/update-service.test.js +15 -8
  315. package/dist/selftest/vpn.test.js +86 -2
  316. package/dist/selftest/web.test.js +58 -11
  317. package/dist/shared/channel/run-dir.d.ts +2 -0
  318. package/dist/shared/channel/run-dir.js +3 -0
  319. package/dist/shared/channel/schema.d.ts +7 -0
  320. package/dist/shared/channel/schema.js +9 -1
  321. package/dist/shared/channel/secrets.d.ts +1 -0
  322. package/dist/shared/channel/secrets.js +3 -0
  323. package/dist/shared/github/index.d.ts +1 -0
  324. package/dist/shared/github/index.js +2 -0
  325. package/dist/shared/github/token.d.ts +29 -0
  326. package/dist/shared/github/token.js +89 -0
  327. package/dist/shared/memory/policy.d.ts +33 -12
  328. package/dist/shared/memory/policy.js +50 -19
  329. package/dist/shared/pty/ctrl-c.d.ts +18 -0
  330. package/dist/shared/pty/ctrl-c.js +36 -0
  331. package/dist/shared/pty/index.d.ts +1 -0
  332. package/dist/shared/pty/index.js +1 -0
  333. package/dist/shared/pty/terminal.d.ts +2 -0
  334. package/dist/shared/pty/terminal.js +21 -2
  335. package/dist/shared/vpn/kill-switch.d.ts +13 -2
  336. package/dist/shared/vpn/kill-switch.js +88 -8
  337. package/dist/shared/web/protocol.d.ts +0 -4
  338. package/dist/sync/watcher.d.ts +2 -0
  339. package/dist/sync/watcher.js +8 -3
  340. package/dist/web/index.html +2 -2
  341. package/dist/web/{main-T5DMCHYV.css → main-MU5XWZMS.css} +1 -1
  342. package/dist/web/main-SLQNJRXD.js +219 -0
  343. package/native/csharp/HcsHost/AssemblyInfo.cs +3 -3
  344. package/native/csharp/HostTools/AssemblyInfo.cs +3 -3
  345. package/native/csharp/HostTools/MemoryStatus.cs +58 -2
  346. package/native/csharp/HostTools/Program.cs +7 -1
  347. package/package.json +10 -3
  348. package/sandbox/csharp/MemGov.cs +240 -38
  349. package/sandbox/csharp/PtyHost.cs +104 -15
  350. package/sandbox/csharp/SandboxTools/CpuCap.cs +50 -1
  351. package/sandbox/csharp/SandboxTools/Program.cs +1 -1
  352. package/sandbox/scripts/repair-wmi-services.ps1 +26 -0
  353. package/schemas/config.schema.json +19 -5
  354. package/schemas/sandbox-config.schema.json +7 -3
  355. package/dist/cli/commands/accounts.d.ts +0 -2
  356. package/dist/cli/commands/accounts.js +0 -96
  357. package/dist/cli/commands/data/clean.d.ts +0 -3
  358. package/dist/cli/commands/data/clean.js +0 -60
  359. package/dist/cli/commands/data/index.d.ts +0 -4
  360. package/dist/cli/commands/data/index.js +0 -62
  361. package/dist/cli/commands/maintenance/clean.d.ts +0 -2
  362. package/dist/cli/commands/maintenance/clean.js +0 -24
  363. package/dist/cli/commands/maintenance/config-share.d.ts +0 -12
  364. package/dist/cli/commands/maintenance/config-share.js +0 -80
  365. package/dist/cli/commands/projects/projects.d.ts +0 -2
  366. package/dist/cli/commands/projects/projects.js +0 -162
  367. package/dist/cli/commands/storage/contained.d.ts +0 -3
  368. package/dist/cli/commands/storage/contained.js +0 -179
  369. package/dist/cli/commands/storage/storage.d.ts +0 -8
  370. package/dist/cli/commands/storage/storage.js +0 -179
  371. package/dist/cli/menu/add-agent.d.ts +0 -47
  372. package/dist/cli/menu/add-agent.js +0 -168
  373. package/dist/cli/menu/apps.d.ts +0 -69
  374. package/dist/cli/menu/apps.js +0 -214
  375. package/dist/cli/menu/data-folder.d.ts +0 -18
  376. package/dist/cli/menu/data-folder.js +0 -99
  377. package/dist/cli/menu/share-settings.d.ts +0 -21
  378. package/dist/cli/menu/share-settings.js +0 -112
  379. package/dist/cli/menu/vpn-login.d.ts +0 -16
  380. package/dist/cli/menu/vpn-login.js +0 -74
  381. package/dist/web/main-NRRS5O6Z.js +0 -157
  382. /package/dist/cli/{commands/data/collect.d.ts → services/data-collect.d.ts} +0 -0
  383. /package/dist/cli/{commands/data/remove.d.ts → services/data-remove.d.ts} +0 -0
@@ -1,26 +1,6 @@
1
1
  import { UserError } from '../../../core/util/index.js';
2
2
  import type { CliOptions } from '../../args.js';
3
3
  import { type Context } from '../context.js';
4
- import { HealthPrinter } from './printer.js';
5
- import type { Check, CheckResult, RepairEnv, Summary } from './types.js';
6
- /** What both commands find, and what they do about it. */
7
- export interface HealthReport {
8
- readonly found: CheckResult[];
9
- readonly final: CheckResult[];
10
- readonly summary: Summary;
11
- /** Fixes were applied. */
12
- readonly changed: boolean;
13
- }
14
- interface Plan {
15
- /** Fix without asking. */
16
- readonly yes: boolean;
17
- /** May ask (a terminal, and not --json). */
18
- readonly ask: boolean;
19
- /** The question asked after the list of what will change. */
20
- readonly question: (n: number) => string;
21
- }
22
- /** Runs the checks, then (when allowed) the fixes. `printer` is null for --json. */
23
- export declare function runHealth(env: RepairEnv, printer: HealthPrinter | null, plan: Plan, checks?: readonly Check[], confirmFix?: (question: string) => Promise<boolean>): Promise<HealthReport>;
24
4
  /** `sandbox doctor` */
25
5
  export declare function runDoctor(ctx: Context): Promise<number>;
26
6
  /** `sandbox repair` for a loaded context. */
@@ -30,4 +10,4 @@ export declare function runRepair(ctx: Context, configError?: UserError | null):
30
10
  * defaults so the other checks still run, and reports the settings problem as a check of its own.
31
11
  */
32
12
  export declare function repairCommand(packageRoot: string, entry: string, options: CliOptions): Promise<number>;
33
- export {};
13
+ export { runHealth } from './health-run.js';
@@ -1,66 +1,31 @@
1
- // `sandbox doctor` and `sandbox repair`: both run the same checks through the same engine, a line each as it ends.
2
- // doctor only looks (and offers to fix, or fixes with --fix); repair looks, lists what it would change, asks once, then
3
- // fixes and writes a log. --json prints the results instead and never asks.
4
- import path from 'node:path';
1
+ // `sandbox doctor` and `sandbox repair`: the command line's renderers of the health feature's run (healthWith): lines
2
+ // as each check ends, the summary, the details, the log path. doctor only looks (and offers to fix, or fixes with
3
+ // --fix); repair looks, lists what it would change, asks once, then fixes and writes a log. --json prints the results
4
+ // instead and never asks.
5
5
  import { confirm } from '@inquirer/prompts';
6
- import { DEFAULTS, userDir } from '../../../core/config/index.js';
7
- import { packageVersion } from '../../../core/package-info.js';
8
- import { expandPath, UserError } from '../../../core/util/index.js';
6
+ import { UserError } from '../../../core/util/index.js';
9
7
  import { insideSandbox } from '../../../host/sandbox/index.js';
10
8
  import { printJson, table } from '../../output/index.js';
11
9
  import { HealthService } from '../../services/index.js';
12
- import { createContext, requireOnPc } from '../context.js';
13
- import { ALL_CHECKS } from './checks/index.js';
14
- import { buildEnv } from './env.js';
15
- import { HealthRun, summarize } from './engine.js';
16
- import { logText, writeRepairLog } from './log.js';
10
+ import { createContext, defaultsContext, requireOnPc } from '../context.js';
11
+ import { healthWith } from '../../../app/features/health/index.js';
17
12
  import { HealthPrinter } from './printer.js';
18
13
  const interactive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
19
14
  const stdout = { write: (text) => void process.stdout.write(text) };
20
- /** Runs the checks, then (when allowed) the fixes. `printer` is null for --json. */
21
- export async function runHealth(env, printer, plan, checks = ALL_CHECKS, confirmFix = (q) => confirm({ message: q, default: true })) {
22
- const run = new HealthRun(checks, env, printer?.hooks());
23
- const found = await run.look();
24
- const fixable = found.filter((r) => r.fixable);
25
- let final = found;
26
- let changed = false;
27
- if (fixable.length) {
28
- let go = plan.yes;
29
- if (!go && plan.ask) {
30
- printer?.plan(fixable);
31
- go = await confirmFix(plan.question(fixable.length));
32
- }
33
- if (go) {
34
- if (plan.yes)
35
- printer?.plan(fixable);
36
- final = await run.fix(found);
37
- changed = true;
38
- }
39
- else
40
- printer?.line('\nNothing was changed.');
41
- }
42
- return { found, final, summary: summarize(final), changed };
43
- }
15
+ const askFix = (question) => confirm({ message: question, default: true });
44
16
  function quote(n, what) {
45
17
  return n + ' ' + what + (n === 1 ? '' : 's');
46
18
  }
47
19
  /** `sandbox doctor` */
48
20
  export async function runDoctor(ctx) {
49
- const health = new HealthService(ctx);
50
21
  if (insideSandbox()) {
51
- table(health.doctor());
22
+ table(new HealthService(ctx).doctor());
52
23
  return 0;
53
24
  }
54
25
  const json = ctx.options.json;
55
26
  const printer = json ? null : new HealthPrinter(stdout);
56
27
  printer?.title('Checking this PC, the install, your settings and the sandbox...');
57
- const env = buildEnv(ctx);
58
- const report = await runHealth(env, printer, {
59
- yes: ctx.options.fix,
60
- ask: !json && interactive(),
61
- question: (n) => quote(n, 'problem') + ' can be fixed. Fix ' + (n === 1 ? 'it' : 'them') + ' now?',
62
- });
63
- const details = health.doctor();
28
+ const { report, details } = await healthWith(ctx, { mode: 'doctor', yes: ctx.options.fix, harness: ctx.options.harness }, { events: printer, mayAsk: !json && interactive(), confirmFix: askFix });
64
29
  if (printJson(ctx, { checks: report.final, summary: report.summary, details }))
65
30
  return 0;
66
31
  printer?.summary(report.final, report.summary);
@@ -77,23 +42,9 @@ export async function runRepair(ctx, configError = null) {
77
42
  const json = ctx.options.json;
78
43
  const printer = json ? null : new HealthPrinter(stdout);
79
44
  printer?.title('Checking this PC, the install, your settings and the sandbox...');
80
- const env = buildEnv(ctx, configError);
81
45
  const yes = ctx.options.yes;
82
46
  const ask = !json && interactive();
83
- const report = await runHealth(env, printer, {
84
- yes,
85
- ask,
86
- question: (n) => 'Fix ' + (n === 1 ? 'this problem' : 'these ' + n + ' problems') + '?',
87
- });
88
- const when = new Date();
89
- const log = writeRepairLog(ctx.storageRoot, logText({
90
- when,
91
- version: packageVersion(),
92
- command: 'sandbox repair' + (yes ? ' --yes' : ''),
93
- found: report.found,
94
- final: report.final,
95
- summary: report.summary,
96
- }), when);
47
+ const { report, log } = await healthWith(ctx, { mode: 'repair', yes, configError }, { events: printer, mayAsk: ask, confirmFix: askFix });
97
48
  const stillFixable = report.final.filter((r) => r.fixable).length;
98
49
  if (printJson(ctx, { checks: report.final, summary: report.summary, changed: report.changed, log })) {
99
50
  return report.summary.needsYou ? 1 : 0;
@@ -118,16 +69,8 @@ export function repairCommand(packageRoot, entry, options) {
118
69
  catch (e) {
119
70
  if (!(e instanceof UserError))
120
71
  throw e;
121
- const loaded = { config: structuredClone(DEFAULTS), configPath: null, base: userDir() };
122
- const storageRoot = expandPath(loaded.config.storage.root, loaded.base);
123
- return runRepair({
124
- packageRoot,
125
- entry,
126
- options,
127
- loaded,
128
- storageRoot,
129
- dataPath: path.join(storageRoot, 'data', loaded.config.storage.dataName),
130
- }, e);
72
+ return runRepair(defaultsContext(packageRoot, entry, options), e);
131
73
  }
132
74
  return runRepair(ctx);
133
75
  }
76
+ export { runHealth } from './health-run.js';
@@ -1,2 +1 @@
1
- export { storage, storageBusy, performMove } from './storage.js';
2
1
  export { storageBeforeCommand } from './offer.js';
@@ -1,2 +1 @@
1
- export { storage, storageBusy, performMove } from './storage.js';
2
1
  export { storageBeforeCommand } from './offer.js';
@@ -6,9 +6,10 @@ import { errMsg } from '../../../core/util/index.js';
6
6
  import { isSandboxRunning, insideSandbox } from '../../../host/sandbox/index.js';
7
7
  import { protectPrivateFolder } from '../../../host/sharing/index.js';
8
8
  import { describeDuration, describeSize, ensureStorageRoot, estimate, measureFolder, moveWarning, planOffer, staleMountNote, StorageHistory, } from '../../../host/storage/index.js';
9
+ import { humanBytes } from '../../../core/disk.js';
10
+ import { StorageService } from '../../services/index.js';
9
11
  import { c, working } from '../../output/index.js';
10
12
  import { refreshStorage } from '../context.js';
11
- import { performMove } from './storage.js';
12
13
  /** Commands that do not touch the storage folder, or must work whatever state it is in. */
13
14
  const NO_STORAGE = ['self-test', '_watch', '_web', 'update', 'storage', 'migrate', 'repair'];
14
15
  /** Commands that start something the user is sitting in front of: the offer is shown before them. */
@@ -59,7 +60,10 @@ async function offerMove(ctx, history) {
59
60
  history.setNotNow();
60
61
  if (answer !== 'now')
61
62
  return;
62
- const result = await performMove({ ...ctx, storageRoot: offer.from }, offer.to, false);
63
+ let line = 'Moving your data';
64
+ const result = await working(() => line, () => new StorageService({ ...ctx, storageRoot: offer.from }).move(offer.to, false, (p) => {
65
+ line = 'Copying: ' + p.files.toLocaleString('en-US') + ' files, ' + humanBytes(p.bytes);
66
+ }));
63
67
  console.error('Moved. Your data is now in ' + result.to + '.');
64
68
  for (const note of result.notes)
65
69
  console.error(c.dim(note));
@@ -1,4 +1,2 @@
1
1
  import { type Context } from './context.js';
2
- /** The warnings every VPN user must see. */
3
- export declare const VPN_WARNINGS: readonly string[];
4
- export declare function vpn(ctx: Context): Promise<number> | number;
2
+ export declare function vpn(ctx: Context): number | Promise<number | void>;
@@ -1,92 +1,11 @@
1
- // `sandbox vpn [status|login|logout]`: the VPN login (kept encrypted on this PC, never printed) and what the VPN is
2
- // doing.
3
- import { askSecret } from '../../core/prompt.js';
1
+ // `sandbox vpn [status|login|logout]`: the actions are the VPN feature's operations (src/app/features/vpn); with no
2
+ // action the command shows the status page.
4
3
  import { fail } from '../../core/util/index.js';
5
- import { c, nextStep, printJson, table } from '../output/index.js';
6
- import { NORD_STEPS, VpnService } from '../services/vpn-service.js';
7
- import { requireOnPc } from './context.js';
8
- const LOGIN_TEXT = {
9
- none: c.yellow('not saved'),
10
- saved: c.green('saved (encrypted)'),
11
- unreadable: c.red('cannot be read'),
12
- };
13
- /** The warnings every VPN user must see. */
14
- export const VPN_WARNINGS = [
15
- 'The VPN is an alpha: not yet tried on a real PC (docs/vpn.md lists what still needs checking).',
16
- 'The agent in the sandbox can read the VPN login (a service login you can revoke) and can turn the tunnel off, because it is the administrator there.',
17
- 'Free VPNs see all your traffic: use one you trust.',
18
- ];
19
- async function status(ctx) {
20
- const report = await new VpnService(ctx).report();
21
- if (printJson(ctx, report))
22
- return 0;
23
- table([
24
- ['VPN', report.enabled ? c.green('on') : 'off (turn on: sandbox config set vpn.enabled true)'],
25
- [
26
- 'Provider',
27
- report.provider === 'nordvpn'
28
- ? 'NordVPN'
29
- : report.provider === 'wireguard-file'
30
- ? 'your own WireGuard .conf'
31
- : 'your own .ovpn file',
32
- ],
33
- ['Protocol', report.protocol],
34
- ['Country', report.country || 'best available'],
35
- ['Kill switch', report.killSwitch ? 'on (no internet if the tunnel fails)' : c.yellow('off')],
36
- [
37
- 'Login',
38
- report.provider === 'wireguard-file'
39
- ? c.dim('not needed (the keys are in your config)')
40
- : LOGIN_TEXT[report.login] + (report.loginSavedAt ? c.dim(' ' + report.loginSavedAt.slice(0, 10)) : ''),
41
- ],
42
- ...(report.running ? [['Running now', report.running.text]] : []),
43
- ]);
44
- if (report.provider !== 'wireguard-file' && report.login === 'none')
45
- nextStep('sandbox vpn login');
46
- if (report.login === 'unreadable')
47
- console.log(c.dim('Only the Windows user that saved it can read it. Save it again: sandbox vpn login'));
48
- for (const w of VPN_WARNINGS)
49
- console.log(c.dim(w));
50
- return 0;
51
- }
52
- async function login(ctx) {
53
- requireOnPc('vpn login');
54
- const service = new VpnService(ctx);
55
- if (service.provider === 'wireguard-file') {
56
- console.log('A WireGuard config needs no login: the keys are in the file vpn.configFile points to.');
57
- return 0;
58
- }
59
- const nord = service.provider === 'nordvpn';
60
- console.log(nord
61
- ? 'NordVPN needs its service credentials, not your usual login. To get them:'
62
- : 'Type the user name and password your VPN profile asks for.');
63
- if (nord)
64
- NORD_STEPS.forEach((s, i) => console.log(' ' + (i + 1) + '. ' + s));
65
- console.log(c.dim('What you type is not shown. It is kept encrypted for your Windows user and never printed.\n'));
66
- const fix = 'Run sandbox vpn login in a terminal.';
67
- const username = await askSecret(nord ? 'Service user name' : 'User name', fix);
68
- const password = await askSecret(nord ? 'Service password' : 'Password', fix);
69
- service.save({ username, password });
70
- console.log(c.green('Saved.') + ' Turn the VPN on with: sandbox config set vpn.enabled true');
71
- for (const w of VPN_WARNINGS)
72
- console.log(c.dim(w));
73
- return 0;
74
- }
75
- function logout(ctx) {
76
- requireOnPc('vpn logout');
77
- console.log(new VpnService(ctx).remove() ? 'The saved VPN login is deleted.' : 'No VPN login was saved.');
78
- return 0;
79
- }
4
+ import { vpnStatus } from '../../app/features/vpn/index.js';
5
+ import { definitionHandler } from '../operations/index.js';
80
6
  export function vpn(ctx) {
81
- const action = ctx.options.positionals[0] ?? 'status';
82
- switch (action) {
83
- case 'status':
84
- return status(ctx);
85
- case 'login':
86
- return login(ctx);
87
- case 'logout':
88
- return logout(ctx);
89
- default:
90
- return fail('Unknown VPN action "' + action + '".', 'Use: sandbox vpn status | login | logout');
91
- }
7
+ const action = ctx.options.positionals[0];
8
+ if (action === undefined)
9
+ return definitionHandler(vpnStatus)(ctx);
10
+ return fail('Unknown VPN action "' + action + '".', 'Use: sandbox vpn status | login | logout');
92
11
  }
@@ -1,9 +1,10 @@
1
- import { type Context } from './context.js';
1
+ import type { Context } from './context.js';
2
2
  /**
3
3
  * At a sandbox start, with web.enabled: the web UI is started in the background when it is not running, and with
4
4
  * web.openOnLaunch opened in the browser, signed in. Never stops the launch: a problem is one line.
5
5
  */
6
6
  export declare function startWebOnLaunch(ctx: Context): Promise<void>;
7
+ /** `sandbox web` with no action is `sandbox web status` (the actions run as definitions). */
7
8
  export declare function web(ctx: Context): Promise<number>;
8
9
  /** Body of the background process (`sandbox _web`): runs until stopped. */
9
10
  export declare function webServer(ctx: Context): Promise<void>;
@@ -1,42 +1,19 @@
1
- // `sandbox web start | stop | status | open`: the web UI's server runs in the background (as `_web`, like the sync
2
- // watcher) and keeps running when no sandbox does. The work is in host/web.
1
+ // `sandbox web` (the actions run as definitions in src/app/features/web) and the hidden `sandbox _web`, which is the
2
+ // server process itself. The web UI's server runs in the background (as `_web`, like the sync watcher) and keeps
3
+ // running when no sandbox does. startWebOnLaunch is the sandbox start's hook.
3
4
  import fs from 'node:fs';
4
5
  import path from 'node:path';
5
- import { fail, sleep } from '../../core/util/index.js';
6
- import { spawnDetached } from '../../host/sandbox/index.js';
7
- import { openBrowser, WebControl, WebRunner, WebStore } from '../../host/web/index.js';
8
- import { printJson } from '../output/index.js';
6
+ import { currentServer, START_WAIT_MS, webStatus } from '../../app/features/web/index.js';
9
7
  import { createRpcHost } from '../../app/registry.js';
8
+ import { packageVersion } from '../../core/package-info.js';
9
+ import { sleep, fail } from '../../core/util/index.js';
10
+ import { IDLE_EXIT_MS, openBrowser, WebControl, WebRunner, WebStore } from '../../host/web/index.js';
11
+ import { spawnDetached } from '../../host/sandbox/index.js';
10
12
  import { WebService } from '../services/index.js';
11
- import { requireOnPc } from './context.js';
12
- const START_WAIT_MS = 15000;
13
+ import { definitionHandler } from '../operations/index.js';
13
14
  function controlOf(ctx) {
14
15
  return new WebControl(new WebStore(ctx.storageRoot));
15
16
  }
16
- /** Starts the background server (when it is not running) and waits until it answers. */
17
- async function startServer(ctx, control) {
18
- const before = await control.status();
19
- if (before.running && before.state) {
20
- console.log('The web UI is already running on port ' + before.state.port + '.');
21
- return before.state.port;
22
- }
23
- if (before.state)
24
- control.clear();
25
- const { config } = ctx.loaded;
26
- if (!config.web.enabled)
27
- console.log('web.enabled is off: this starts the web UI for now only. Set it to true in Settings to keep it allowed.');
28
- const configFile = ctx.options.config;
29
- spawnDetached(ctx.entry, ['_web', ...(configFile ? ['--config', path.resolve(configFile)] : [])]);
30
- for (const started = Date.now(); Date.now() - started < START_WAIT_MS; await sleep(300)) {
31
- const now = await control.status();
32
- if (now.running && now.state) {
33
- console.log('The web UI is running at http://127.0.0.1:' + now.state.port + '/ (this PC only).');
34
- console.log('Open it already signed in with: sandbox web open');
35
- return now.state.port;
36
- }
37
- }
38
- return fail('The web UI did not start.', 'Run sandbox _web to see why (the port ' + config.web.port + ' may be taken: change web.port).');
39
- }
40
17
  /**
41
18
  * At a sandbox start, with web.enabled: the web UI is started in the background when it is not running, and with
42
19
  * web.openOnLaunch opened in the browser, signed in. Never stops the launch: a problem is one line.
@@ -47,11 +24,8 @@ export async function startWebOnLaunch(ctx) {
47
24
  return;
48
25
  try {
49
26
  const control = controlOf(ctx);
50
- const before = await control.status();
51
- let state = before.running ? before.state : null;
27
+ let state = await currentServer(control);
52
28
  if (!state) {
53
- if (before.state)
54
- control.clear();
55
29
  const configFile = ctx.options.config;
56
30
  spawnDetached(ctx.entry, ['_web', ...(configFile ? ['--config', path.resolve(configFile)] : [])]);
57
31
  for (const started = Date.now(); !state && Date.now() - started < START_WAIT_MS; await sleep(300)) {
@@ -75,49 +49,9 @@ export async function startWebOnLaunch(ctx) {
75
49
  console.log('The web UI could not be started: ' + (e instanceof Error ? e.message : String(e)));
76
50
  }
77
51
  }
52
+ /** `sandbox web` with no action is `sandbox web status` (the actions run as definitions). */
78
53
  export async function web(ctx) {
79
- requireOnPc('web');
80
- const action = ctx.options.positionals[0] ?? 'status';
81
- const control = controlOf(ctx);
82
- switch (action) {
83
- case 'start':
84
- await startServer(ctx, control);
85
- return 0;
86
- case 'open': {
87
- await startServer(ctx, control);
88
- const { state } = await control.status();
89
- if (!state)
90
- return fail('The web UI stopped right away.', 'Run sandbox web start again.');
91
- openBrowser(control.url(state));
92
- console.log('Opened in your browser.');
93
- return 0;
94
- }
95
- case 'stop': {
96
- const { running, state } = await control.status();
97
- if (!state) {
98
- console.log('The web UI is not running.');
99
- return 0;
100
- }
101
- if (!running || (await control.stop(state)))
102
- control.clear();
103
- else
104
- return fail('The web UI did not stop.', 'End the process ' + state.pid + ' in Task Manager.');
105
- console.log('The web UI stopped.');
106
- return 0;
107
- }
108
- case 'status': {
109
- const { running, state } = await control.status();
110
- const port = running && state ? state.port : null;
111
- if (printJson(ctx, { running, port, address: port ? 'http://127.0.0.1:' + port + '/' : null }))
112
- return 0;
113
- console.log(running && port
114
- ? 'The web UI is running at http://127.0.0.1:' + port + '/ (sandbox web open signs you in).'
115
- : 'The web UI is not running (sandbox web start).');
116
- return 0;
117
- }
118
- default:
119
- return fail('Unknown action "' + action + '".', 'Use start, stop, status or open.');
120
- }
54
+ return (await definitionHandler(webStatus)(ctx)) ?? 0;
121
55
  }
122
56
  /** Body of the background process (`sandbox _web`): runs until stopped. */
123
57
  export async function webServer(ctx) {
@@ -130,6 +64,8 @@ export async function webServer(ctx) {
130
64
  backend: new WebService(ctx),
131
65
  rpc: createRpcHost(ctx),
132
66
  staticRoot,
67
+ version: packageVersion(),
68
+ idleExitMs: IDLE_EXIT_MS,
133
69
  }).run();
134
70
  process.exit(0);
135
71
  }
package/dist/cli/index.js CHANGED
@@ -15,7 +15,8 @@ import { withConfig, hoistConfig, withoutConfig } from './argv.js';
15
15
  import { report } from './report.js';
16
16
  import { versionText } from './version.js';
17
17
  import { HANDLERS } from './commands/index.js';
18
- import { operationHandler } from './operations/index.js';
18
+ import { definitionHandler, operationHandler } from './operations/index.js';
19
+ import { runUpdate } from '../app/features/updates/index.js';
19
20
  const entry = path.join(PACKAGE_ROOT, 'dist', 'bin', 'agent-sandbox.js');
20
21
  /** A first word that is no command and no agent, but close to one: "Did you mean: sandbox status?". */
21
22
  function failOnTypo(word, agents) {
@@ -103,7 +104,7 @@ export async function main(rawArgv, preset = {}) {
103
104
  }
104
105
  // update works on the install, not on a sandbox: it needs no settings (and a broken file must not stop it).
105
106
  if (options.command === 'update')
106
- return commands.update(options);
107
+ return (await definitionHandler(runUpdate)(commands.contextOrDefaults(PACKAGE_ROOT, entry, options))) ?? 0;
107
108
  const handler = operationHandler(options.command, options.positionals) ?? HANDLERS[options.command];
108
109
  if (!handler)
109
110
  return fail('Unknown command "' + options.command + '".', 'Run sandbox --help for the list of commands, or sandbox for the menu.');