windows-development-sandbox 1.10.0 → 1.11.3

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 (378) 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 +201 -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 +952 -4
  32. package/dist/app/features/defs.js +147 -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 +281 -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 +225 -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 +225 -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 +16 -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/watchdog.d.ts +9 -0
  263. package/dist/host/life/watchdog.js +17 -1
  264. package/dist/host/sandbox/tasklist.d.ts +6 -0
  265. package/dist/host/sandbox/tasklist.js +37 -0
  266. package/dist/host/secrets/launch-secrets.d.ts +2 -1
  267. package/dist/host/secrets/launch-secrets.js +4 -2
  268. package/dist/host/vpn/status.js +13 -3
  269. package/dist/host/web/backend.d.ts +1 -3
  270. package/dist/host/web/index.d.ts +2 -1
  271. package/dist/host/web/index.js +2 -1
  272. package/dist/host/web/live.d.ts +23 -0
  273. package/dist/host/web/live.js +107 -0
  274. package/dist/host/web/rpc.d.ts +6 -1
  275. package/dist/host/web/rpc.js +23 -31
  276. package/dist/host/web/runner.d.ts +4 -0
  277. package/dist/host/web/runner.js +12 -1
  278. package/dist/host/web/server.d.ts +30 -2
  279. package/dist/host/web/server.js +87 -29
  280. package/dist/host/web/state.d.ts +1 -0
  281. package/dist/host/web/state.js +2 -0
  282. package/dist/runtime/agent.js +30 -6
  283. package/dist/runtime/daemon.js +323 -176
  284. package/dist/runtime/db.js +30 -6
  285. package/dist/runtime/main.js +375 -76
  286. package/dist/runtime/netproxy.js +30 -6
  287. package/dist/runtime/view.js +495 -146
  288. package/dist/selftest/app.test.js +620 -12
  289. package/dist/selftest/channel.test.js +18 -1
  290. package/dist/selftest/cli.test.js +1 -1
  291. package/dist/selftest/config.test.js +1 -1
  292. package/dist/selftest/contained.test.js +1 -1
  293. package/dist/selftest/data.test.js +1 -2
  294. package/dist/selftest/engine.test.js +3 -1
  295. package/dist/selftest/github.test.d.ts +2 -0
  296. package/dist/selftest/github.test.js +243 -0
  297. package/dist/selftest/hcs.test.js +105 -8
  298. package/dist/selftest/health.test.js +71 -0
  299. package/dist/selftest/heavy-load.test.js +132 -72
  300. package/dist/selftest/index.js +4 -0
  301. package/dist/selftest/layout.test.js +8 -0
  302. package/dist/selftest/live-terminal.test.js +74 -0
  303. package/dist/selftest/menu-screens.js +171 -56
  304. package/dist/selftest/menu.test.js +54 -37
  305. package/dist/selftest/migrate.test.js +14 -12
  306. package/dist/selftest/powershell-variables.test.d.ts +2 -0
  307. package/dist/selftest/powershell-variables.test.js +61 -0
  308. package/dist/selftest/support/engine-golden.js +1 -0
  309. package/dist/selftest/support/fixtures.d.ts +4 -0
  310. package/dist/selftest/support/web-preview.d.ts +1 -0
  311. package/dist/selftest/support/web-preview.js +856 -0
  312. package/dist/selftest/update-service.test.js +15 -8
  313. package/dist/selftest/vpn.test.js +86 -2
  314. package/dist/selftest/web.test.js +58 -11
  315. package/dist/shared/channel/run-dir.d.ts +2 -0
  316. package/dist/shared/channel/run-dir.js +3 -0
  317. package/dist/shared/channel/schema.d.ts +7 -0
  318. package/dist/shared/channel/schema.js +9 -1
  319. package/dist/shared/channel/secrets.d.ts +1 -0
  320. package/dist/shared/channel/secrets.js +3 -0
  321. package/dist/shared/github/index.d.ts +1 -0
  322. package/dist/shared/github/index.js +2 -0
  323. package/dist/shared/github/token.d.ts +29 -0
  324. package/dist/shared/github/token.js +89 -0
  325. package/dist/shared/memory/policy.d.ts +33 -12
  326. package/dist/shared/memory/policy.js +50 -19
  327. package/dist/shared/pty/ctrl-c.d.ts +18 -0
  328. package/dist/shared/pty/ctrl-c.js +36 -0
  329. package/dist/shared/pty/index.d.ts +1 -0
  330. package/dist/shared/pty/index.js +1 -0
  331. package/dist/shared/pty/terminal.d.ts +2 -0
  332. package/dist/shared/pty/terminal.js +21 -2
  333. package/dist/shared/vpn/kill-switch.d.ts +13 -2
  334. package/dist/shared/vpn/kill-switch.js +88 -8
  335. package/dist/shared/web/protocol.d.ts +0 -4
  336. package/dist/sync/watcher.js +1 -1
  337. package/dist/web/index.html +2 -2
  338. package/dist/web/{main-T5DMCHYV.css → main-6JF3ASB5.css} +1 -1
  339. package/dist/web/main-Z645W45E.js +219 -0
  340. package/native/csharp/HcsHost/AssemblyInfo.cs +3 -3
  341. package/native/csharp/HostTools/AssemblyInfo.cs +3 -3
  342. package/package.json +10 -3
  343. package/sandbox/csharp/MemGov.cs +240 -38
  344. package/sandbox/csharp/PtyHost.cs +104 -15
  345. package/sandbox/csharp/SandboxTools/CpuCap.cs +50 -1
  346. package/sandbox/csharp/SandboxTools/Program.cs +1 -1
  347. package/sandbox/scripts/repair-wmi-services.ps1 +26 -0
  348. package/schemas/config.schema.json +19 -5
  349. package/schemas/sandbox-config.schema.json +7 -3
  350. package/dist/cli/commands/accounts.d.ts +0 -2
  351. package/dist/cli/commands/accounts.js +0 -96
  352. package/dist/cli/commands/data/clean.d.ts +0 -3
  353. package/dist/cli/commands/data/clean.js +0 -60
  354. package/dist/cli/commands/data/index.d.ts +0 -4
  355. package/dist/cli/commands/data/index.js +0 -62
  356. package/dist/cli/commands/maintenance/clean.d.ts +0 -2
  357. package/dist/cli/commands/maintenance/clean.js +0 -24
  358. package/dist/cli/commands/maintenance/config-share.d.ts +0 -12
  359. package/dist/cli/commands/maintenance/config-share.js +0 -80
  360. package/dist/cli/commands/projects/projects.d.ts +0 -2
  361. package/dist/cli/commands/projects/projects.js +0 -162
  362. package/dist/cli/commands/storage/contained.d.ts +0 -3
  363. package/dist/cli/commands/storage/contained.js +0 -179
  364. package/dist/cli/commands/storage/storage.d.ts +0 -8
  365. package/dist/cli/commands/storage/storage.js +0 -179
  366. package/dist/cli/menu/add-agent.d.ts +0 -47
  367. package/dist/cli/menu/add-agent.js +0 -168
  368. package/dist/cli/menu/apps.d.ts +0 -69
  369. package/dist/cli/menu/apps.js +0 -214
  370. package/dist/cli/menu/data-folder.d.ts +0 -18
  371. package/dist/cli/menu/data-folder.js +0 -99
  372. package/dist/cli/menu/share-settings.d.ts +0 -21
  373. package/dist/cli/menu/share-settings.js +0 -112
  374. package/dist/cli/menu/vpn-login.d.ts +0 -16
  375. package/dist/cli/menu/vpn-login.js +0 -74
  376. package/dist/web/main-NRRS5O6Z.js +0 -157
  377. /package/dist/cli/{commands/data/collect.d.ts → services/data-collect.d.ts} +0 -0
  378. /package/dist/cli/{commands/data/remove.d.ts → services/data-remove.d.ts} +0 -0
@@ -1,162 +0,0 @@
1
- // `sandbox projects`: which projects a sandbox can open without a restart. Project roots (whole folders of projects),
2
- // the projects this tool has started before, and the all-projects and exclude settings. Changes to what is mapped take
3
- // effect at the next start; a project you start while a sandbox runs joins it when it can (projects.ts in host/).
4
- import path from 'node:path';
5
- import { checkbox } from '@inquirer/prompts';
6
- import { askChoice } from '../../../core/prompt.js';
7
- import { fail } from '../../../core/util/index.js';
8
- import { isSandboxRunning } from '../../../host/sandbox/index.js';
9
- import { c, nextStep, pageSizeFor, shortenMiddle, termWidth, printJson, table } from '../../output/index.js';
10
- import { ProjectsService } from '../../services/index.js';
11
- const NEXT_START = 'This changes what is mapped from the next start.';
12
- function runningNote() {
13
- return isSandboxRunning()
14
- ? ' The running sandbox keeps what it has; start a project in it (sandbox claude there) and it joins without a restart when it can, or you are offered one.'
15
- : '';
16
- }
17
- function list(ctx, service) {
18
- const listing = service.list();
19
- const rows = listing.projects;
20
- if (printJson(ctx, { all: listing.all, roots: listing.roots, exclude: listing.exclude, projects: rows }))
21
- return 0;
22
- console.log(c.bold('All projects') +
23
- ': ' +
24
- (listing.all ? 'on (every project below is mapped at every start, except excluded ones)' : 'off') +
25
- c.dim(' sandbox projects all on|off'));
26
- console.log(c.bold('Roots') +
27
- ': ' +
28
- (listing.roots.length ? listing.roots.join(', ') : c.dim('none (sandbox projects roots add <folder>)')));
29
- if (!rows.length) {
30
- console.log('No projects yet: start one with sandbox claude in its folder.');
31
- return 0;
32
- }
33
- const width = Math.max(20, termWidth() - 46);
34
- table([
35
- ['', 'FOLDER', 'AT START', 'RUNNING SANDBOX'],
36
- ...rows.map((r) => [
37
- r.here ? '*' : '',
38
- shortenMiddle(r.folder, width),
39
- r.root ? 'root' : r.excluded ? 'excluded' : r.mappedAtStart ? 'mapped' : '-',
40
- r.running ?? '-',
41
- ]),
42
- ]);
43
- console.log(c.dim('* = this folder. Choose with: sandbox projects choose'));
44
- return 0;
45
- }
46
- /** Ticks the projects mapped at every start (any ticked turns all-projects on); the rest are excluded. */
47
- async function choose(service) {
48
- const rows = service.rows().filter((r) => !r.root);
49
- if (!rows.length) {
50
- console.log('No projects to choose from yet (projects in a root are always mapped with it). Start one with sandbox claude in its folder.');
51
- return 0;
52
- }
53
- if (!process.stdin.isTTY)
54
- fail('sandbox projects choose needs an interactive terminal.', 'Use sandbox projects include|exclude <folder> instead.');
55
- const all = service.settings().all;
56
- const picked = await checkbox({
57
- message: 'Projects mapped at every start, so they open without a restart (every agent in the sandbox can see them):',
58
- pageSize: pageSizeFor(rows.length),
59
- choices: rows.map((r) => ({
60
- value: r.folder,
61
- name: shortenMiddle(r.folder, termWidth() - 12) + (r.here ? c.dim(' (this folder)') : ''),
62
- checked: all && !r.excluded,
63
- })),
64
- });
65
- const { mapped, excluded } = service.choose(rows, picked);
66
- console.log(mapped + ' project(s) mapped at every start, ' + excluded + ' excluded. ' + NEXT_START + runningNote());
67
- return 0;
68
- }
69
- /** The folder typed, or one picked from the known projects (or this folder) when it was left out. */
70
- async function folderOf(service, action, given) {
71
- if (given)
72
- return given;
73
- const rows = service.rows();
74
- return askChoice('Which folder?', [
75
- { name: 'This folder (' + shortenMiddle(process.cwd(), termWidth() - 30) + ')', value: '.' },
76
- ...rows.filter((r) => !r.here).map((r) => ({ name: shortenMiddle(r.folder, termWidth() - 12), value: r.folder })),
77
- ], 'Usage: sandbox projects ' + action + ' <folder> (. = this folder)');
78
- }
79
- function add(service, value) {
80
- const dir = service.add(value);
81
- const all = service.settings().all;
82
- console.log('Added ' + dir + ' to your projects.' + (all ? ' ' + NEXT_START : ''));
83
- if (!all)
84
- nextStep('sandbox projects all on (map every project at every start)');
85
- return 0;
86
- }
87
- function remove(service, value) {
88
- const { dir, removed } = service.forget(value);
89
- console.log(removed
90
- ? 'Removed ' + dir + ' from your projects (nothing in the folder was touched).'
91
- : dir + ' was not in your projects.');
92
- return 0;
93
- }
94
- function includeOrExclude(service, action, value) {
95
- const changed = action === 'exclude' ? service.exclude(value) : service.include(value);
96
- console.log((changed
97
- ? (action === 'exclude' ? 'Excluded ' : 'Included ') + path.resolve(value) + '. ' + NEXT_START
98
- : 'Nothing changed.') +
99
- (action === 'include' && !service.settings().all
100
- ? ' Mapping all projects is off: sandbox projects all on maps your projects at every start.'
101
- : '') +
102
- (changed ? runningNote() : ''));
103
- return 0;
104
- }
105
- function all(service, value) {
106
- if (value === undefined) {
107
- console.log('Mapping all projects at every start is ' + (service.settings().all ? 'on' : 'off') + '.');
108
- return 0;
109
- }
110
- service.setAll(value === 'on');
111
- console.log('Mapping all projects at every start is ' +
112
- value +
113
- '. ' +
114
- NEXT_START +
115
- (value === 'on' ? ' Every agent in the sandbox can then see all of those projects.' : '') +
116
- runningNote());
117
- return 0;
118
- }
119
- function roots(service, value, folder) {
120
- if (!value || value === 'list') {
121
- const list = service.settings().roots;
122
- console.log(list.length ? list.join('\n') : 'No project roots. Add one: sandbox projects roots add <folder>');
123
- return 0;
124
- }
125
- if (value === 'add') {
126
- const { dir, added } = service.addRoot(folder);
127
- console.log(added
128
- ? 'Added the project root ' +
129
- dir +
130
- ': every project in it (also new ones) opens without a restart. Every agent in the sandbox can see all of them. ' +
131
- NEXT_START +
132
- runningNote()
133
- : dir + ' is a root already.');
134
- return 0;
135
- }
136
- const { dir, removed } = service.removeRoot(folder);
137
- console.log(removed ? 'Removed the project root ' + dir + '. ' + NEXT_START : dir + ' was not a root.');
138
- return 0;
139
- }
140
- export async function projects(ctx) {
141
- const [action = 'list', value, folder] = ctx.options.positionals;
142
- const service = new ProjectsService(ctx);
143
- switch (action) {
144
- case 'list':
145
- return list(ctx, service);
146
- case 'choose':
147
- return choose(service);
148
- case 'add':
149
- return add(service, await folderOf(service, action, value));
150
- case 'remove':
151
- return remove(service, await folderOf(service, action, value));
152
- case 'include':
153
- case 'exclude':
154
- return includeOrExclude(service, action, await folderOf(service, action, value));
155
- case 'all':
156
- return all(service, value);
157
- case 'roots':
158
- return roots(service, value, folder);
159
- default:
160
- return fail('Unknown projects action "' + action + '".', 'Use: sandbox projects list | choose | add | remove | include | exclude | all | roots');
161
- }
162
- }
@@ -1,3 +0,0 @@
1
- import type { Context } from '../context.js';
2
- /** `sandbox storage contained [status|on|off]`. */
3
- export declare function contained(ctx: Context): Promise<number>;
@@ -1,179 +0,0 @@
1
- // `sandbox storage contained on|off|status` (beta): keep the data set's tools, state and logs in a
2
- // disk image that is mounted only while a sandbox runs. The work is in host/storage/contained; this file asks, shows
3
- // size and time, and prints.
4
- import fs from 'node:fs';
5
- import { userConfigPath } from '../../../core/config/index.js';
6
- import { humanBytes } from '../../../core/disk.js';
7
- import { askRequired } from '../../../core/prompt.js';
8
- import { fail } from '../../../core/util/index.js';
9
- import { isSandboxRunning, realContainedDeps } from '../../../host/sandbox/index.js';
10
- import { assertTargetsFree, containedAvailability, ContainedStorage, describeDuration, describeSize, planTransfer, runTransfer, setStateOf, StateFile, writeContainedSetting, } from '../../../host/storage/index.js';
11
- import { c, printJson, working } from '../../output/index.js';
12
- const BETA = 'Beta, and not yet tested on a real PC. ';
13
- function storageFor(ctx) {
14
- const { config } = ctx.loaded;
15
- return new ContainedStorage(realContainedDeps(ctx.storageRoot, config.storage.containedMaxGb), config.storage.dataName);
16
- }
17
- function requireAvailable() {
18
- const check = containedAvailability();
19
- if (!check.available)
20
- fail('Contained storage cannot be used: ' + check.reasons.join(' '), check.fixes.join(' '));
21
- }
22
- function requireNoSandbox() {
23
- if (isSandboxRunning())
24
- fail('A sandbox is running.', 'Close it (sandbox stop) first: the folders in the image are in use.');
25
- }
26
- async function status(ctx) {
27
- const storage = storageFor(ctx);
28
- const check = containedAvailability();
29
- const state = new StateFile(storage.paths).read();
30
- const record = setStateOf(state, storage.set);
31
- const reality = check.available && storage.imageExists() ? await storage.reality() : null;
32
- const answer = {
33
- setting: ctx.loaded.config.storage.contained,
34
- maxGb: ctx.loaded.config.storage.containedMaxGb,
35
- available: check.available,
36
- reasons: check.reasons,
37
- image: storage.paths.image,
38
- imageExists: storage.imageExists(),
39
- imageBytes: reality?.imageBytes ?? null,
40
- mountFolder: storage.paths.mount,
41
- recordedMounted: record.mounted,
42
- holders: record.holders.length,
43
- mountedNow: reality?.mountIsMountPoint ?? null,
44
- };
45
- if (printJson(ctx, answer))
46
- return 0;
47
- console.log(c.yellow('Contained storage (beta, untested on a real PC)'));
48
- console.log(' setting: storage.contained = ' + answer.setting + ' (limit ' + answer.maxGb + ' GB)');
49
- console.log(' this PC: ' +
50
- (check.available ? 'can use it' : 'cannot use it: ' + check.reasons.join(' ') + ' ' + check.fixes.join(' ')));
51
- console.log(' image: ' +
52
- answer.image +
53
- (answer.imageExists ? ' (' + humanBytes(answer.imageBytes ?? 0) + ' on disk)' : ' (not made yet)'));
54
- console.log(' mount folder: ' + answer.mountFolder);
55
- if (reality)
56
- console.log(' mounted now: ' +
57
- (reality.mountIsMountPoint ? 'yes' : 'no') +
58
- (record.mounted !== reality.mountIsMountPoint
59
- ? ' (the record says ' + (record.mounted ? 'yes' : 'no') + '; sandbox doctor looks into it)'
60
- : ''));
61
- console.log('\nTurn it on with: sandbox storage contained on Turn it off with: sandbox storage contained off');
62
- return 0;
63
- }
64
- function printPlan(plan, to) {
65
- for (const f of plan.folders)
66
- console.log(' ' + f.name + ': ' + describeSize(f.measured));
67
- console.log(' total: ' + describeSize(plan.total) + ' to ' + to);
68
- console.log(' time: about ' + describeDuration(plan.estimate.seconds) + ' (copied, then the originals are removed)');
69
- if (!plan.estimate.fits)
70
- fail('Not enough free space for the copy.', 'Free some space on that drive and try again.');
71
- }
72
- async function turnOn(ctx) {
73
- requireAvailable();
74
- requireNoSandbox();
75
- const storage = storageFor(ctx);
76
- const { config } = ctx.loaded;
77
- const configFile = ctx.loaded.configPath ?? userConfigPath();
78
- console.log(c.yellow(BETA + 'Contained storage keeps the sandbox tools, state and logs in one disk image file.'));
79
- console.log(' image: ' + storage.paths.image + (storage.imageExists() ? ' (exists, it is used as it is)' : ''));
80
- console.log(' limit: ' + config.storage.containedMaxGb + ' GB (storage.containedMaxGb; the file grows only as it fills)');
81
- console.log(' Windows asks for permission to mount it each time a sandbox starts (and once when it closes).');
82
- if (!ctx.options.yes &&
83
- !(await askRequired('Turn contained storage on?', 'Add --yes to turn it on without asking.', true)))
84
- return fail('Nothing was changed.', 'Run sandbox storage contained on when you want it.');
85
- const mount = await working('Making and mounting the image (Windows asks for permission)', () => storage.acquire({ id: 'cli', pid: process.pid }, { create: true }));
86
- try {
87
- const plan = planTransfer(ctx.dataPath, mount, ctx.storageRoot);
88
- if (plan.folders.length > 0) {
89
- console.log('\nThese folders hold your tools, state and logs now:');
90
- printPlan(plan, 'the image');
91
- assertTargetsFree(plan);
92
- const move = ctx.options.yes || (await askRequired('Move them into the image?', 'Add --yes to move without asking.', true));
93
- if (move) {
94
- let line = 'Copying';
95
- const result = await working(() => line, () => runTransfer(plan, ctx.dataPath, (p) => {
96
- line = 'Copying: ' + p.files.toLocaleString('en-US') + ' files, ' + humanBytes(p.bytes);
97
- }));
98
- console.log('Moved ' + result.files.toLocaleString('en-US') + ' files into the image.');
99
- for (const note of result.notes)
100
- console.log(c.yellow(note));
101
- }
102
- else
103
- console.log('They stay where they are and are not used: tools are downloaded again into the image. Delete them later with sandbox data clean.');
104
- }
105
- writeContainedSetting(configFile, 'vhdx');
106
- }
107
- finally {
108
- const done = await working('Dismounting the image (Windows asks for permission)', () => storage.release('cli'));
109
- if (!done.dismounted)
110
- console.log(c.yellow('The image stays mounted (' + (done.note ?? '') + '). sandbox repair dismounts it.'));
111
- }
112
- console.log('Contained storage is on. sandbox launch mounts the image first.');
113
- return 0;
114
- }
115
- async function turnOff(ctx) {
116
- requireAvailable();
117
- requireNoSandbox();
118
- const storage = storageFor(ctx);
119
- const configFile = ctx.loaded.configPath ?? userConfigPath();
120
- console.log(c.yellow(BETA + 'Turning contained storage off moves the files back into plain folders.'));
121
- if (!storage.imageExists()) {
122
- writeContainedSetting(configFile, 'off');
123
- console.log('There is no image, so there was nothing to move. Contained storage is off.');
124
- return 0;
125
- }
126
- const mount = await working('Mounting the image (Windows asks for permission)', () => storage.acquire({ id: 'cli', pid: process.pid }));
127
- let moved = false;
128
- try {
129
- const plan = planTransfer(mount, ctx.dataPath, ctx.dataPath);
130
- if (plan.folders.length > 0) {
131
- console.log('\nIn the image:');
132
- printPlan(plan, ctx.dataPath);
133
- assertTargetsFree(plan);
134
- if (!ctx.options.yes &&
135
- !(await askRequired('Move them back out of the image?', 'Add --yes to move without asking.', true)))
136
- return fail('Nothing was moved.', 'Contained storage is still on.');
137
- let line = 'Copying';
138
- const result = await working(() => line, () => runTransfer(plan, mount, (p) => {
139
- line = 'Copying: ' + p.files.toLocaleString('en-US') + ' files, ' + humanBytes(p.bytes);
140
- }));
141
- console.log('Moved ' + result.files.toLocaleString('en-US') + ' files back.');
142
- for (const note of result.notes)
143
- console.log(c.yellow(note));
144
- }
145
- writeContainedSetting(configFile, 'off');
146
- moved = true;
147
- }
148
- finally {
149
- const done = await working('Dismounting the image (Windows asks for permission)', () => storage.release('cli'));
150
- if (!done.dismounted)
151
- console.log(c.yellow('The image stays mounted (' + (done.note ?? '') + '). sandbox repair dismounts it.'));
152
- else if (!moved)
153
- console.log('The image was dismounted; contained storage is still on.');
154
- }
155
- console.log('Contained storage is off: tools, state and logs are plain folders in ' + ctx.dataPath + '.');
156
- const bytes = fs.statSync(storage.paths.image).size;
157
- if (!ctx.options.yes &&
158
- (await askRequired('Delete the image file now (' + humanBytes(bytes) + ')? Everything in it was moved out.', 'Answer no to keep it.', false))) {
159
- await storage.deleteImage();
160
- console.log('Deleted ' + storage.paths.image + '.');
161
- }
162
- else
163
- console.log('The image file is kept: ' + storage.paths.image + ' (delete it yourself when you are sure).');
164
- return 0;
165
- }
166
- /** `sandbox storage contained [status|on|off]`. */
167
- export function contained(ctx) {
168
- const [, mode = 'status'] = ctx.options.positionals;
169
- switch (mode) {
170
- case 'status':
171
- return status(ctx);
172
- case 'on':
173
- return turnOn(ctx);
174
- case 'off':
175
- return turnOff(ctx);
176
- default:
177
- return Promise.resolve(fail('Unknown action "' + mode + '" for contained storage.', 'Use: sandbox storage contained on, off or status'));
178
- }
179
- }
@@ -1,8 +0,0 @@
1
- import { type MoveResult } from '../../../host/storage/index.js';
2
- import { type Context } from '../context.js';
3
- /** Why a move cannot start (a background sync is still on a data folder in the old storage), or null. */
4
- export declare function storageBusy(root: string): string | null;
5
- /** Moves the data with progress on the terminal; remembers both folders. Used by the command and the start offer. */
6
- export declare function performMove(ctx: Context, to: string, keepOld: boolean): Promise<MoveResult>;
7
- /** `sandbox storage [show|move <folder>|use <folder>]`. */
8
- export declare function storage(ctx: Context): number | Promise<number>;
@@ -1,179 +0,0 @@
1
- // `sandbox storage`: where everything kept between sandboxes lives, moving it to another folder (with the size, an
2
- // estimate and a warning first) and switching to a folder without moving. The work is in host/storage.
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { userConfigPath, userDir } from '../../../core/config/index.js';
6
- import { diskUsage, humanBytes } from '../../../core/disk.js';
7
- import { askChoice, askName, askRequired } from '../../../core/prompt.js';
8
- import { expandPath, fail } from '../../../core/util/index.js';
9
- import { describeDuration, describeSize, estimate, holdsData, measureFolder, mountedSets, moveWarning, otherDataFolders, sharedDefaultRoot, StorageHistory, StorageMove, } from '../../../host/storage/index.js';
10
- import { isSandboxRunning } from '../../../host/sandbox/index.js';
11
- import { protectPrivateFolder } from '../../../host/sharing/index.js';
12
- import { watcherRunning } from '../../../sync/index.js';
13
- import { printJson, working } from '../../output/index.js';
14
- import { requireOnPc } from '../context.js';
15
- import { contained } from './contained.js';
16
- /** Why a move cannot start (a background sync is still on a data folder in the old storage), or null. */
17
- export function storageBusy(root) {
18
- const mounted = mountedSets(root);
19
- if (mounted.length > 0)
20
- return ('The contained storage of "' +
21
- mounted.join('", "') +
22
- '" is mounted (a disk image; moving now would reach into it).');
23
- const data = path.join(root, 'data');
24
- try {
25
- for (const name of fs.readdirSync(data))
26
- if (watcherRunning(path.join(data, name)))
27
- return 'The background sync of "' + name + '" is still finishing.';
28
- }
29
- catch {
30
- // no data folder: nothing runs
31
- }
32
- return null;
33
- }
34
- function mover(ctx) {
35
- return new StorageMove(ctx.loaded.configPath ?? userConfigPath(), () => storageBusy(ctx.storageRoot), isSandboxRunning, protectPrivateFolder);
36
- }
37
- /** The path as typed (variables and ~ expand, relative to the current folder). */
38
- function typedPath(value) {
39
- return expandPath(value, process.cwd());
40
- }
41
- /** The folder typed, or picked from the default folder, folders that hold data and the drives (or typed in). */
42
- async function folderOf(ctx, value, what) {
43
- if (value)
44
- return typedPath(value);
45
- const fix = 'Use: sandbox storage ' + what + ' <folder>';
46
- const typed = 'type';
47
- const known = [sharedDefaultRoot(), ...otherDataFolders(ctx.storageRoot, new StorageHistory(userDir()))];
48
- const drives = diskUsage(ctx.storageRoot)
49
- .filter((d) => !d.holdsStorage)
50
- .map((d) => path.join(d.drive, 'AgentSandbox'));
51
- const choices = [...new Set([...known, ...drives])]
52
- .filter((f) => f.toLowerCase() !== ctx.storageRoot.toLowerCase())
53
- .map((f) => ({ name: f, value: f }));
54
- const picked = await askChoice('Which folder?', [...choices, { name: 'Type a path...', value: typed }], fix);
55
- if (picked !== typed)
56
- return picked;
57
- const answer = await askName('Folder:', fix, (v) => v.length > 0 || 'Type a folder path.');
58
- return typedPath(answer);
59
- }
60
- async function show(ctx) {
61
- const history = new StorageHistory(userDir());
62
- const measured = await working('Measuring your saved data (big folders take a moment)', () => measureFolder(ctx.storageRoot), !ctx.options.json);
63
- const others = otherDataFolders(ctx.storageRoot, history);
64
- const shared = sharedDefaultRoot();
65
- if (printJson(ctx, {
66
- root: ctx.storageRoot,
67
- exists: fs.existsSync(ctx.storageRoot),
68
- ...measured,
69
- defaultRoot: shared,
70
- otherFoldersWithData: others,
71
- }))
72
- return 0;
73
- const inUse = shared.toLowerCase() === ctx.storageRoot.toLowerCase() ? ' (in use)' : '';
74
- console.log('Your saved data is in: ' + ctx.storageRoot);
75
- console.log(' ' + (holdsData(ctx.storageRoot) ? describeSize(measured) : 'nothing in it yet'));
76
- console.log('The default folder is: ' + shared + inUse);
77
- for (const other of others)
78
- console.log('Another folder with data: ' + other);
79
- console.log('\nMove it with: sandbox storage move <folder> (or switch without moving: sandbox storage use <folder>)');
80
- console.log('What takes the space: sandbox data');
81
- return 0;
82
- }
83
- function printPlan(from, to, measured, copyOnly) {
84
- const est = estimate(from, to, measured, copyOnly);
85
- const time = est.sameVolume
86
- ? 'a few seconds (same drive, nothing is copied)'
87
- : describeDuration(est.seconds) + ' (copied to another drive)';
88
- console.log('Move from: ' + from);
89
- console.log(' to: ' + to);
90
- console.log(' size: ' + describeSize(measured));
91
- console.log(' time: ' + time);
92
- const warning = moveWarning(measured, est);
93
- if (warning)
94
- console.log('Warning: ' + warning);
95
- if (!est.fits)
96
- fail('Not enough free space on the target drive.', 'Free some space or pick another drive.');
97
- }
98
- /** Moves the data with progress on the terminal; remembers both folders. Used by the command and the start offer. */
99
- export async function performMove(ctx, to, keepOld) {
100
- const from = ctx.storageRoot;
101
- const history = new StorageHistory(userDir());
102
- let line = 'Moving your data';
103
- const result = await working(() => line, () => mover(ctx).move(from, to, {
104
- keepOld,
105
- onProgress: (p) => {
106
- line = 'Copying: ' + p.files.toLocaleString('en-US') + ' files, ' + humanBytes(p.bytes);
107
- },
108
- }));
109
- history.remember(from);
110
- history.remember(to);
111
- return result;
112
- }
113
- async function move(ctx) {
114
- const to = await folderOf(ctx, ctx.options.positionals[1], 'move');
115
- const from = ctx.storageRoot;
116
- if (!fs.existsSync(from))
117
- fail('There is nothing to move: ' + from + ' does not exist.', 'Use sandbox storage use ' + to + ' to switch.');
118
- mover(ctx).validate(from, to);
119
- const measured = await working('Measuring your saved data', () => measureFolder(from), !ctx.options.json);
120
- const keepOld = ctx.options.keepOld;
121
- printPlan(from, to, measured, keepOld);
122
- if (!ctx.options.yes) {
123
- if (!(await askRequired('Move your data to ' + to + '?', 'Add --yes to move without asking.', true))) {
124
- console.log('Nothing was moved.');
125
- return 1;
126
- }
127
- }
128
- const result = await performMove(ctx, to, keepOld);
129
- if (printJson(ctx, result))
130
- return 0;
131
- const left = result.removedOld ? '' : '; the old folder is still at ' + result.from;
132
- console.log('Moved ' + result.files.toLocaleString('en-US') + ' files. Your data is now in ' + result.to + left + '.');
133
- for (const note of result.notes)
134
- console.log(note);
135
- console.log('Your settings now point to ' + result.pinned + ', so older versions find the data too.');
136
- return 0;
137
- }
138
- async function use(ctx) {
139
- const to = await folderOf(ctx, ctx.options.positionals[1], 'use');
140
- if (to.toLowerCase() === ctx.storageRoot.toLowerCase()) {
141
- console.log('That folder is in use already.');
142
- return 0;
143
- }
144
- const busy = storageBusy(ctx.storageRoot);
145
- if (busy)
146
- fail(busy, 'Wait a minute, then try again.');
147
- const state = holdsData(to)
148
- ? to + ' is used as it is.'
149
- : to + ' starts empty: tools, logins and history are set up again.';
150
- console.log('Warning: your data stays in ' + ctx.storageRoot + '. ' + state);
151
- if (!ctx.options.yes) {
152
- if (!(await askRequired('Use ' + to + ' from now on, without moving your data?', 'Add --yes to switch without asking.'))) {
153
- console.log('Nothing was changed.');
154
- return 1;
155
- }
156
- }
157
- new StorageHistory(userDir()).remember(ctx.storageRoot);
158
- mover(ctx).pin(to);
159
- console.log('Your data is now looked for in ' + to + '. Move it later with: sandbox storage move <folder>');
160
- return 0;
161
- }
162
- /** `sandbox storage [show|move <folder>|use <folder>]`. */
163
- export function storage(ctx) {
164
- requireOnPc('storage');
165
- const [action = 'show'] = ctx.options.positionals;
166
- switch (action) {
167
- case 'show':
168
- case 'info':
169
- return show(ctx);
170
- case 'move':
171
- return move(ctx);
172
- case 'use':
173
- return use(ctx);
174
- case 'contained':
175
- return contained(ctx);
176
- default:
177
- return fail('Unknown storage action "' + action + '".', 'Use: sandbox storage, sandbox storage move <folder>, sandbox storage use <folder> or sandbox storage contained on|off|status');
178
- }
179
- }
@@ -1,47 +0,0 @@
1
- import type { Harness } from '../../core/types.js';
2
- import type { App } from '../tui/index.js';
3
- import type { ConfigFile } from '../../app/features/settings/index.js';
4
- import type { Draft } from './settings/draft.js';
5
- /** How a new agent gets into the sandbox. */
6
- export type AgentSource = 'npm' | 'uv' | 'host';
7
- /** Nothing wrong with the name (true), or what is wrong. Pure. */
8
- export declare function agentNameProblem(name: string, taken: readonly string[]): true | string;
9
- /** The command a package usually provides: "@scope/my-agent@latest" gives "my-agent". Pure. */
10
- export declare function commandFromPackage(pkg: string): string;
11
- /** The config entry for a new agent. Pure. */
12
- export declare function newAgent(source: AgentSource, what: string, command: string, hostDir?: string): Harness;
13
- /** What `harnesses` should say with `name` taken out. Pure. */
14
- export declare function withoutAgent(current: unknown, name: string): Record<string, unknown>;
15
- /** Writes a setting to your config file now, or adds it to the unsaved changes when it has some already. */
16
- export declare function writeOrStage(file: ConfigFile, draft: Draft, key: string[], value: unknown): {
17
- saved: boolean;
18
- };
19
- /** What `harnesses` should say with `name` added to what is staged or in the file now. Pure. */
20
- export declare function withAgent(current: unknown, name: string, harness: Harness): Record<string, unknown>;
21
- /** Makes `name` the agent that starts by default (written now, or joined to unsaved changes to that setting). */
22
- export declare function makeDefaultAgent(file: ConfigFile, draft: Draft, name: string): {
23
- saved: boolean;
24
- };
25
- /** Takes an agent you added out of your settings (the built-in ones are not removable). */
26
- export declare function removeAgent(file: ConfigFile, draft: Draft, name: string): {
27
- saved: boolean;
28
- };
29
- export interface AddedAgent {
30
- readonly name: string;
31
- /** Written to your config file now (false: waiting for Ctrl+S with the other unsaved changes). */
32
- readonly saved: boolean;
33
- }
34
- export declare class AddAgent {
35
- private readonly app;
36
- private readonly file;
37
- private readonly draft;
38
- /** Every agent that exists now (the new name must be different). */
39
- private readonly taken;
40
- constructor(app: App, file: ConfigFile, draft: Draft,
41
- /** Every agent that exists now (the new name must be different). */
42
- taken: readonly string[]);
43
- /** Asks, then adds the agent. Undefined when you backed out. */
44
- run(): Promise<AddedAgent | undefined>;
45
- /** Validates and writes (or stages) the entry. */
46
- private add;
47
- }