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
@@ -0,0 +1,77 @@
1
+ // The engine feature's work: what each engine can do and whether this PC can run it (engineReports, which runs a few
2
+ // Windows programs, so it is read on purpose and never live). Nothing is run or changed for the check's fixes.
3
+ import { fail, safeText } from '../../../core/util/index.js';
4
+ import { engineReports, lookForLeftovers, stopLeftovers } from '../../../host/engines/index.js';
5
+ import { implement } from '../../context.js';
6
+ import { cancelled, plural } from '../../kernel/index.js';
7
+ import { checkEngine, cleanEngine, engineLeftovers, engineStatus, } from './engine.def.js';
8
+ /** The report as the definitions describe it (the host's arrays are readonly; the output is plain data). */
9
+ function reportRow(r) {
10
+ return {
11
+ id: r.id,
12
+ inUse: r.inUse,
13
+ capabilities: { ...r.capabilities },
14
+ check: { available: r.check.available, reasons: [...r.check.reasons], fixes: [...r.check.fixes] },
15
+ };
16
+ }
17
+ export const engineStatusRun = implement(engineStatus, async (ctx) => {
18
+ const reports = await engineReports(ctx.loaded.config);
19
+ const using = reports.find((r) => r.inUse);
20
+ return {
21
+ engine: using?.id ?? ctx.loaded.config.sandbox.engine,
22
+ engines: reports.map(reportRow),
23
+ };
24
+ });
25
+ export const checkEngineRun = implement(checkEngine, async (ctx, input) => {
26
+ const report = (await engineReports(ctx.loaded.config)).find((r) => r.id === input.engine);
27
+ if (!report)
28
+ return fail('Unknown engine: ' + input.engine, 'Use windows-sandbox or hcs.');
29
+ return reportRow(report);
30
+ });
31
+ export const engineLeftoversRun = implement(engineLeftovers, (ctx) => {
32
+ const look = lookForLeftovers(ctx.loaded.config.storage.root);
33
+ if (!look.available)
34
+ return { available: false, message: look.reason, systems: [] };
35
+ const systems = look.systems.map((s) => ({
36
+ id: s.id,
37
+ kind: safeText(s.kind),
38
+ state: safeText(s.state),
39
+ since: s.since,
40
+ }));
41
+ return {
42
+ available: true,
43
+ message: systems.length
44
+ ? plural(systems.length, 'HCS system') + ' of ours left running.'
45
+ : 'No HCS system of ours is running.',
46
+ systems,
47
+ };
48
+ });
49
+ export const cleanEngineRun = implement(cleanEngine, async (ctx, _input, io) => {
50
+ const root = ctx.loaded.config.storage.root;
51
+ const look = lookForLeftovers(root);
52
+ if (!look.available)
53
+ return { available: false, stopped: 0, failed: 0, message: look.reason + ' Nothing to clean.' };
54
+ if (!look.systems.length)
55
+ return { available: true, stopped: 0, failed: 0, message: 'No HCS system of ours is running. Nothing to clean.' };
56
+ const yes = await io.confirm({
57
+ title: 'Stop ' + plural(look.systems.length, 'HCS system') + '?',
58
+ lines: [
59
+ ...look.systems.map((s) => s.id + ' (' + safeText(s.kind) + ', ' + safeText(s.state) + ')'),
60
+ 'A sandbox of yours that is running on purpose is listed too: stopping it ends its sessions.',
61
+ "No file is deleted, and other programs and other Windows users' sandboxes are not touched.",
62
+ ],
63
+ yes: 'Stop them',
64
+ danger: true,
65
+ });
66
+ if (!yes)
67
+ cancelled();
68
+ io.progress('Stopping HCS systems');
69
+ const results = stopLeftovers(root, look.systems.map((s) => s.id));
70
+ for (const r of results)
71
+ io.log(r.stopped ? 'Stopped ' + r.id : 'Could not stop ' + r.id + ': ' + safeText(r.problem ?? ''), r.stopped ? 'ok' : 'danger');
72
+ const stopped = results.filter((r) => r.stopped).length;
73
+ const failed = results.length - stopped;
74
+ if (failed)
75
+ fail(plural(failed, 'HCS system') + ' could not be stopped.', 'Run it again from an administrator terminal: sandbox engine clean');
76
+ return { available: true, stopped, failed, message: 'Stopped ' + plural(stopped, 'HCS system') + '.' };
77
+ });
@@ -0,0 +1,2 @@
1
+ export * from './engine.def.js';
2
+ export * from './engine.run.js';
@@ -0,0 +1,4 @@
1
+ // The engine feature: the engine in use and what each engine can do, with each engine's check (sandbox engine and
2
+ // sandbox engine check). The definitions are pure; engine.run.ts does the work.
3
+ export * from './engine.def.js';
4
+ export * from './engine.run.js';
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ /** Folders show at most this many entries (a folder with more says so). */
3
+ export declare const MAX_ENTRIES = 2000;
4
+ declare const EntrySchema: z.ZodObject<{
5
+ name: z.ZodString;
6
+ path: z.ZodString;
7
+ kind: z.ZodEnum<{
8
+ file: "file";
9
+ dir: "dir";
10
+ }>;
11
+ }, z.core.$strip>;
12
+ export type FolderEntry = z.output<typeof EntrySchema>;
13
+ export declare const FolderListingSchema: z.ZodObject<{
14
+ path: z.ZodString;
15
+ parent: z.ZodNullable<z.ZodString>;
16
+ entries: z.ZodArray<z.ZodObject<{
17
+ name: z.ZodString;
18
+ path: z.ZodString;
19
+ kind: z.ZodEnum<{
20
+ file: "file";
21
+ dir: "dir";
22
+ }>;
23
+ }, z.core.$strip>>;
24
+ truncated: z.ZodBoolean;
25
+ places: z.ZodArray<z.ZodObject<{
26
+ label: z.ZodString;
27
+ path: z.ZodString;
28
+ }, z.core.$strip>>;
29
+ }, z.core.$strip>;
30
+ export type FolderListing = z.output<typeof FolderListingSchema>;
31
+ export declare const browseFolder: import("../../kernel/define.js").QueryDef<z.ZodObject<{
32
+ path: z.ZodOptional<z.ZodString>;
33
+ files: z.ZodDefault<z.ZodBoolean>;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ path: z.ZodString;
36
+ parent: z.ZodNullable<z.ZodString>;
37
+ entries: z.ZodArray<z.ZodObject<{
38
+ name: z.ZodString;
39
+ path: z.ZodString;
40
+ kind: z.ZodEnum<{
41
+ file: "file";
42
+ dir: "dir";
43
+ }>;
44
+ }, z.core.$strip>>;
45
+ truncated: z.ZodBoolean;
46
+ places: z.ZodArray<z.ZodObject<{
47
+ label: z.ZodString;
48
+ path: z.ZodString;
49
+ }, z.core.$strip>>;
50
+ }, z.core.$strip>, "files.browse">;
51
+ export {};
@@ -0,0 +1,38 @@
1
+ // Picking a folder or a file of this PC: what is in a folder, and where to start (the drives, this folder's project,
2
+ // the data folder). The browser cannot see full paths, so the web's folder picker reads this. Pure: schemas only.
3
+ import { z } from 'zod';
4
+ import { defineQuery } from '../../kernel/index.js';
5
+ /** Folders show at most this many entries (a folder with more says so). */
6
+ export const MAX_ENTRIES = 2000;
7
+ const EntrySchema = z.object({
8
+ name: z.string(),
9
+ path: z.string(),
10
+ kind: z.enum(['dir', 'file']),
11
+ });
12
+ export const FolderListingSchema = z.object({
13
+ /** The folder listed ('' when only the places are listed). */
14
+ path: z.string(),
15
+ /** The folder above it, or null at a drive (or with no folder). */
16
+ parent: z.string().nullable(),
17
+ entries: z.array(EntrySchema),
18
+ /** More entries than MAX_ENTRIES: the rest are left out. */
19
+ truncated: z.boolean(),
20
+ /** Where to start: the drives and a few folders that matter here. */
21
+ places: z.array(z.object({ label: z.string(), path: z.string() })),
22
+ });
23
+ export const browseFolder = defineQuery({
24
+ id: 'files.browse',
25
+ title: 'Browse folders',
26
+ summary: 'list what is in a folder of this PC, to pick a folder or a file',
27
+ input: z.object({
28
+ path: z.string().max(1024).optional().describe('The folder (none: only the places to start from)'),
29
+ files: z.boolean().default(false).describe('List files too, not only folders'),
30
+ }),
31
+ output: FolderListingSchema,
32
+ surfaces: {
33
+ except: {
34
+ cli: 'a path is typed on the command line',
35
+ menu: 'the menu asks for a path as text and checks it',
36
+ },
37
+ },
38
+ });
@@ -0,0 +1,20 @@
1
+ export declare const browseFolderRun: import("../../kernel/define.js").Implementation<import("../../kernel/define.js").QueryDef<import("zod").ZodObject<{
2
+ path: import("zod").ZodOptional<import("zod").ZodString>;
3
+ files: import("zod").ZodDefault<import("zod").ZodBoolean>;
4
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
5
+ path: import("zod").ZodString;
6
+ parent: import("zod").ZodNullable<import("zod").ZodString>;
7
+ entries: import("zod").ZodArray<import("zod").ZodObject<{
8
+ name: import("zod").ZodString;
9
+ path: import("zod").ZodString;
10
+ kind: import("zod").ZodEnum<{
11
+ file: "file";
12
+ dir: "dir";
13
+ }>;
14
+ }, import("zod/v4/core").$strip>>;
15
+ truncated: import("zod").ZodBoolean;
16
+ places: import("zod").ZodArray<import("zod").ZodObject<{
17
+ label: import("zod").ZodString;
18
+ path: import("zod").ZodString;
19
+ }, import("zod/v4/core").$strip>>;
20
+ }, import("zod/v4/core").$strip>, "files.browse">, import("../../../cli/commands/context.js").Context>;
@@ -0,0 +1,59 @@
1
+ // The folder picker's listing: names in one folder (folders first), read once with a cap, and the places to start
2
+ // from. Only names and paths of this PC go to the signed-in browser of this PC's user; nothing is opened or followed.
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { fail } from '../../../core/util/index.js';
6
+ import { hereDir } from '../../../cli/commands/projects/here.js';
7
+ import { implement } from '../../context.js';
8
+ import { browseFolder, MAX_ENTRIES } from './files.def.js';
9
+ const DRIVES = 'CDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
10
+ function places(ctx) {
11
+ const drives = DRIVES.filter((d) => {
12
+ try {
13
+ return fs.statSync(d + ':\\').isDirectory();
14
+ }
15
+ catch {
16
+ return false; // no such drive, or an empty card reader
17
+ }
18
+ }).map((d) => ({ label: d + ':', path: d + ':\\' }));
19
+ const folders = [
20
+ { label: "This folder's project", path: hereDir(ctx) },
21
+ { label: 'Data folder', path: ctx.storageRoot },
22
+ ].filter((p) => p.path && fs.existsSync(p.path));
23
+ return [...folders, ...drives];
24
+ }
25
+ function listing(folder, files) {
26
+ let dirents;
27
+ try {
28
+ dirents = fs.readdirSync(folder, { withFileTypes: true });
29
+ }
30
+ catch {
31
+ return fail('Cannot open ' + folder + '.', 'Pick another folder, or check that you may read this one.');
32
+ }
33
+ const entries = [];
34
+ for (const d of dirents) {
35
+ // A link to a folder is offered as a folder (it is still a path you can type); system folders like $Recycle.Bin
36
+ // are left out.
37
+ const dir = d.isDirectory() || d.isSymbolicLink();
38
+ if (d.name.startsWith('$') || (!dir && !files))
39
+ continue;
40
+ entries.push({ name: d.name, path: path.join(folder, d.name), kind: dir ? 'dir' : 'file' });
41
+ }
42
+ entries.sort((a, b) => a.kind === b.kind ? a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }) : a.kind === 'dir' ? -1 : 1);
43
+ return { entries: entries.slice(0, MAX_ENTRIES), truncated: entries.length > MAX_ENTRIES };
44
+ }
45
+ export const browseFolderRun = implement(browseFolder, (ctx, input) => {
46
+ const start = places(ctx);
47
+ if (!input.path)
48
+ return { path: '', parent: null, entries: [], truncated: false, places: start };
49
+ if (!path.isAbsolute(input.path) || input.path.includes('\0'))
50
+ fail('"' + input.path + '" is not a full path.', 'Use a path like C:\\Projects.');
51
+ const folder = path.resolve(input.path);
52
+ const parent = path.dirname(folder);
53
+ return {
54
+ path: folder,
55
+ parent: parent === folder ? null : parent,
56
+ ...listing(folder, input.files),
57
+ places: start,
58
+ };
59
+ });
@@ -0,0 +1,2 @@
1
+ export * from './files.def.js';
2
+ export * from './files.run.js';
@@ -0,0 +1,3 @@
1
+ // The files feature: listing a folder of this PC for the folder picker.
2
+ export * from './files.def.js';
3
+ export * from './files.run.js';
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ import { type Page } from '../../kernel/index.js';
3
+ /** Where GitHub makes a fine-grained token. */
4
+ export declare const NEW_TOKEN_URL = "https://github.com/settings/personal-access-tokens/new";
5
+ /** The steps to make a token for sandboxes (shown before asking for it). */
6
+ export declare const GITHUB_STEPS: readonly string[];
7
+ /** What everyone who shares a token must know: on every surface. */
8
+ export declare const GITHUB_WARNINGS: readonly string[];
9
+ export declare const GithubStatusSchema: z.ZodObject<{
10
+ shareToken: z.ZodBoolean;
11
+ gitAccess: z.ZodEnum<{
12
+ readonly: "readonly";
13
+ none: "none";
14
+ full: "full";
15
+ }>;
16
+ token: z.ZodEnum<{
17
+ none: "none";
18
+ saved: "saved";
19
+ unreadable: "unreadable";
20
+ }>;
21
+ kind: z.ZodNullable<z.ZodEnum<{
22
+ "fine-grained": "fine-grained";
23
+ classic: "classic";
24
+ }>>;
25
+ savedAt: z.ZodNullable<z.ZodString>;
26
+ }, z.core.$strip>;
27
+ export type GithubStatus = z.output<typeof GithubStatusSchema>;
28
+ export declare const githubStatus: import("../../kernel/define.js").QueryDef<z.ZodObject<{}, z.core.$strict>, z.ZodObject<{
29
+ shareToken: z.ZodBoolean;
30
+ gitAccess: z.ZodEnum<{
31
+ readonly: "readonly";
32
+ none: "none";
33
+ full: "full";
34
+ }>;
35
+ token: z.ZodEnum<{
36
+ none: "none";
37
+ saved: "saved";
38
+ unreadable: "unreadable";
39
+ }>;
40
+ kind: z.ZodNullable<z.ZodEnum<{
41
+ "fine-grained": "fine-grained";
42
+ classic: "classic";
43
+ }>>;
44
+ savedAt: z.ZodNullable<z.ZodString>;
45
+ }, z.core.$strip>, "github.status">;
46
+ export declare const githubLogin: import("../../kernel/define.js").OperationDef<z.ZodObject<{}, z.core.$strict>, z.ZodObject<{
47
+ message: z.ZodString;
48
+ }, z.core.$strip>, "github.login">;
49
+ export declare const githubLogout: import("../../kernel/define.js").OperationDef<z.ZodObject<{}, z.core.$strict>, z.ZodObject<{
50
+ deleted: z.ZodBoolean;
51
+ message: z.ZodString;
52
+ }, z.core.$strip>, "github.logout">;
53
+ /** The Settings row of the menu (label, hint, description), from the status. Pure. */
54
+ export declare function githubTokenRowOf(s: GithubStatus): {
55
+ label: string;
56
+ hint: string;
57
+ description: string;
58
+ };
59
+ /** The status page: the facts, the next step (command line only), the warnings and the token actions. */
60
+ export declare function githubPage(s: GithubStatus): Page;
61
+ export declare const githubView: import("../../kernel/define.js").ViewDef<{
62
+ status: import("../../kernel/define.js").QueryDef<z.ZodObject<{}, z.core.$strict>, z.ZodObject<{
63
+ shareToken: z.ZodBoolean;
64
+ gitAccess: z.ZodEnum<{
65
+ readonly: "readonly";
66
+ none: "none";
67
+ full: "full";
68
+ }>;
69
+ token: z.ZodEnum<{
70
+ none: "none";
71
+ saved: "saved";
72
+ unreadable: "unreadable";
73
+ }>;
74
+ kind: z.ZodNullable<z.ZodEnum<{
75
+ "fine-grained": "fine-grained";
76
+ classic: "classic";
77
+ }>>;
78
+ savedAt: z.ZodNullable<z.ZodString>;
79
+ }, z.core.$strip>, "github.status">;
80
+ }, Record<string, never>, "github">;
@@ -0,0 +1,142 @@
1
+ // The GitHub token for sandboxes: whether sharing is on, whether a token is saved (its kind and date, never its value),
2
+ // and saving or deleting it. Pure: schemas, labels and the view; github.run.ts does the work. The token itself is never
3
+ // an input or an output.
4
+ import { z } from 'zod';
5
+ import { action, defineOperation, defineQuery, defineView, } from '../../kernel/index.js';
6
+ /** Where GitHub makes a fine-grained token. */
7
+ export const NEW_TOKEN_URL = 'https://github.com/settings/personal-access-tokens/new';
8
+ /** The steps to make a token for sandboxes (shown before asking for it). */
9
+ export const GITHUB_STEPS = [
10
+ 'Open ' + NEW_TOKEN_URL + ' (a fine-grained personal access token).',
11
+ 'Under "Repository access" choose "Only select repositories" and pick only the ones the agent should reach.',
12
+ 'Give only the permissions it needs, for example Contents (read and write), Pull requests (read and write) and Actions (read).',
13
+ 'Set an expiry date, then generate the token and copy it.',
14
+ ];
15
+ /** What everyone who shares a token must know: on every surface. */
16
+ export const GITHUB_WARNINGS = [
17
+ 'The agent in the sandbox can read the token and use it for everything it allows: limit it to some repositories and permissions.',
18
+ 'It is handed over only with github.shareToken on and git access "full". Revoke it on GitHub whenever you like.',
19
+ ];
20
+ const TokenStateSchema = z
21
+ .enum(['none', 'saved', 'unreadable'])
22
+ .describe('Whether a token is saved and can be opened by you');
23
+ export const GithubStatusSchema = z.object({
24
+ shareToken: z.boolean().describe('Sandboxes get the token (setting github.shareToken)'),
25
+ gitAccess: z.enum(['full', 'readonly', 'none']).describe('Git access in your settings (provisioning.git.access)'),
26
+ token: TokenStateSchema,
27
+ kind: z.enum(['fine-grained', 'classic']).nullable().describe('What kind of token is saved (never the token)'),
28
+ savedAt: z.string().nullable().describe('When the token was saved (the date and time, never the token)'),
29
+ });
30
+ export const githubStatus = defineQuery({
31
+ id: 'github.status',
32
+ title: 'GitHub',
33
+ summary: 'whether sandboxes get your GitHub token, and whether one is saved (never the token)',
34
+ input: z.object({}).strict(),
35
+ output: GithubStatusSchema,
36
+ cli: { name: 'github', action: 'status', json: true },
37
+ });
38
+ export const githubLogin = defineOperation({
39
+ id: 'github.login',
40
+ title: 'Save the GitHub token…',
41
+ summary: 'save a GitHub token for sandboxes (typed hidden, kept encrypted, never printed)',
42
+ input: z.object({}).strict(),
43
+ output: z.object({ message: z.string().describe('What happened') }),
44
+ text: (o) => o.message,
45
+ cli: { name: 'github', action: 'login' },
46
+ });
47
+ export const githubLogout = defineOperation({
48
+ id: 'github.logout',
49
+ title: 'Delete the GitHub token',
50
+ summary: 'delete the saved GitHub token',
51
+ input: z.object({}).strict(),
52
+ output: z.object({
53
+ deleted: z.boolean().describe('A token was saved and is gone'),
54
+ message: z.string().describe('What happened'),
55
+ }),
56
+ danger: true,
57
+ text: (o) => o.message,
58
+ cli: { name: 'github', action: 'logout' },
59
+ });
60
+ const TOKEN_TEXT = {
61
+ none: 'not saved',
62
+ saved: 'saved (encrypted)',
63
+ unreadable: 'cannot be read',
64
+ };
65
+ const TOKEN_TONE = {
66
+ none: 'warn',
67
+ saved: 'ok',
68
+ unreadable: 'danger',
69
+ };
70
+ const KIND_TEXT = {
71
+ 'fine-grained': 'fine-grained',
72
+ classic: 'classic (reaches every repository you can: a fine-grained token is safer)',
73
+ };
74
+ /** The Settings row of the menu (label, hint, description), from the status. Pure. */
75
+ export function githubTokenRowOf(s) {
76
+ return {
77
+ label: 'Set GitHub token…',
78
+ hint: s.token === 'saved' ? 'saved' : s.token === 'unreadable' ? 'cannot be read' : 'not saved',
79
+ description: 'A GitHub token you made for sandboxes (best a fine-grained one, limited to some repositories and permissions). Typed hidden, kept encrypted for your Windows user, never shown. Sandboxes get it only with github.shareToken on. ' +
80
+ GITHUB_WARNINGS.join(' '),
81
+ };
82
+ }
83
+ /** The status page: the facts, the next step (command line only), the warnings and the token actions. */
84
+ export function githubPage(s) {
85
+ const savedDate = s.savedAt ? ' ' + s.savedAt.slice(0, 10) : '';
86
+ const facts = [
87
+ s.shareToken
88
+ ? { id: 'share', label: 'Share with sandboxes', value: 'on', tone: 'ok' }
89
+ : {
90
+ id: 'share',
91
+ label: 'Share with sandboxes',
92
+ value: 'off (turn on: sandbox config set github.shareToken true)',
93
+ },
94
+ s.gitAccess === 'full'
95
+ ? { id: 'gitAccess', label: 'Git access', value: 'full' }
96
+ : {
97
+ id: 'gitAccess',
98
+ label: 'Git access',
99
+ value: s.gitAccess + ' (the token is only handed over with "full")',
100
+ tone: 'warn',
101
+ },
102
+ { id: 'token', label: 'Token', value: TOKEN_TEXT[s.token] + savedDate, tone: TOKEN_TONE[s.token] },
103
+ ...(s.kind
104
+ ? [
105
+ {
106
+ id: 'kind',
107
+ label: 'Kind',
108
+ value: KIND_TEXT[s.kind],
109
+ ...(s.kind === 'classic' ? { tone: 'warn' } : {}),
110
+ },
111
+ ]
112
+ : []),
113
+ ];
114
+ const notes = [
115
+ ...(s.token === 'none'
116
+ ? [{ text: 'Next: sandbox github login', tone: 'muted', only: 'cli' }]
117
+ : []),
118
+ ...(s.token === 'unreadable'
119
+ ? [
120
+ {
121
+ text: 'Only the Windows user that saved it can read it. Save it again: sandbox github login',
122
+ tone: 'muted',
123
+ },
124
+ ]
125
+ : []),
126
+ ...GITHUB_WARNINGS.map((text) => ({ text, tone: 'muted' })),
127
+ ];
128
+ const actions = [
129
+ action(githubLogin, {}, { key: 'g', verb: 'save token' }),
130
+ ...(s.token !== 'none' ? [action(githubLogout, {}, { key: 'x', verb: 'delete token' })] : []),
131
+ ];
132
+ const section = { id: 'github', facts, notes, actions };
133
+ return { title: 'GitHub', sections: [section] };
134
+ }
135
+ export const githubView = defineView({
136
+ id: 'github',
137
+ title: 'GitHub',
138
+ summary: 'A GitHub token for sandboxes: whether they get it, and the saved token.',
139
+ queries: { status: githubStatus },
140
+ operations: [githubLogin, githubLogout],
141
+ build: ({ status }) => githubPage(status),
142
+ });
@@ -0,0 +1,36 @@
1
+ import { GithubToken } from '../../../host/github/index.js';
2
+ import { type OperationIO } from '../../kernel/index.js';
3
+ /** Asks for the token (one hidden question) and saves it. The validator answers with fixed texts only. */
4
+ export declare function saveGithubTokenFlow(io: OperationIO, store: GithubToken): Promise<{
5
+ message: string;
6
+ }>;
7
+ /** Deletes the saved token after asking (the CLI's typed logout is the answer). */
8
+ export declare function deleteGithubTokenFlow(io: OperationIO, store: GithubToken): Promise<{
9
+ deleted: boolean;
10
+ message: string;
11
+ }>;
12
+ export declare const githubStatusRun: import("../../kernel/define.js").Implementation<import("../../kernel/define.js").QueryDef<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
13
+ shareToken: import("zod").ZodBoolean;
14
+ gitAccess: import("zod").ZodEnum<{
15
+ readonly: "readonly";
16
+ none: "none";
17
+ full: "full";
18
+ }>;
19
+ token: import("zod").ZodEnum<{
20
+ none: "none";
21
+ saved: "saved";
22
+ unreadable: "unreadable";
23
+ }>;
24
+ kind: import("zod").ZodNullable<import("zod").ZodEnum<{
25
+ "fine-grained": "fine-grained";
26
+ classic: "classic";
27
+ }>>;
28
+ savedAt: import("zod").ZodNullable<import("zod").ZodString>;
29
+ }, import("zod/v4/core").$strip>, "github.status">, import("../../../cli/commands/context.js").Context>;
30
+ export declare const githubLoginRun: import("../../kernel/define.js").Implementation<import("../../kernel/define.js").OperationDef<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
31
+ message: import("zod").ZodString;
32
+ }, import("zod/v4/core").$strip>, "github.login">, import("../../../cli/commands/context.js").Context>;
33
+ export declare const githubLogoutRun: import("../../kernel/define.js").Implementation<import("../../kernel/define.js").OperationDef<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
34
+ deleted: import("zod").ZodBoolean;
35
+ message: import("zod").ZodString;
36
+ }, import("zod/v4/core").$strip>, "github.logout">, import("../../../cli/commands/context.js").Context>;
@@ -0,0 +1,59 @@
1
+ // The GitHub feature's work: its status, saving the token through io.secret (kept only for the save, never returned,
2
+ // logged or shown), and deleting it after a confirmation. The flows take the store, so the self-test runs them with a
3
+ // store of its own.
4
+ import { requireOnPc } from '../../../cli/commands/context.js';
5
+ import { GithubToken } from '../../../host/github/index.js';
6
+ import { githubTokenProblem } from '../../../shared/github/index.js';
7
+ import { implement } from '../../context.js';
8
+ import { cancelled } from '../../kernel/index.js';
9
+ import { GITHUB_STEPS, GITHUB_WARNINGS, githubLogin, githubLogout, githubStatus } from './github.def.js';
10
+ /** Asks for the token (one hidden question) and saves it. The validator answers with fixed texts only. */
11
+ export async function saveGithubTokenFlow(io, store) {
12
+ io.log('Make a GitHub token only for sandboxes:');
13
+ GITHUB_STEPS.forEach((s, i) => io.log(' ' + (i + 1) + '. ' + s));
14
+ io.log('What you type is not shown. It is kept encrypted for your Windows user and never printed.', 'muted');
15
+ const token = await io.secret({
16
+ title: 'GitHub token',
17
+ validate: (v) => githubTokenProblem(v.trim())?.message ?? true,
18
+ });
19
+ if (token === undefined)
20
+ cancelled();
21
+ const kind = store.save(token.trim());
22
+ GITHUB_WARNINGS.forEach((w) => io.log(w, 'warn'));
23
+ if (kind === 'classic')
24
+ io.log('This is a classic token: it reaches every repository you can. A fine-grained one is safer.', 'warn');
25
+ return { message: 'Saved. Sandboxes get it once you turn it on: sandbox config set github.shareToken true' };
26
+ }
27
+ /** Deletes the saved token after asking (the CLI's typed logout is the answer). */
28
+ export async function deleteGithubTokenFlow(io, store) {
29
+ if (store.state() === 'none')
30
+ return { deleted: false, message: 'No GitHub token was saved.' };
31
+ const yes = await io.confirm({ title: 'Delete the saved GitHub token?', yes: 'Delete', danger: true, implied: true });
32
+ if (!yes)
33
+ cancelled();
34
+ store.remove();
35
+ return {
36
+ deleted: true,
37
+ message: 'The saved GitHub token is deleted. Revoke it on GitHub too if you no longer use it.',
38
+ };
39
+ }
40
+ export const githubStatusRun = implement(githubStatus, async (ctx) => {
41
+ const { config } = ctx.loaded;
42
+ const store = new GithubToken(ctx.storageRoot);
43
+ const token = store.state();
44
+ return {
45
+ shareToken: config.github.shareToken,
46
+ gitAccess: config.provisioning.git.access,
47
+ token,
48
+ kind: token === 'none' ? null : store.kind(),
49
+ savedAt: token === 'none' ? null : store.savedAt(),
50
+ };
51
+ });
52
+ export const githubLoginRun = implement(githubLogin, async (ctx, _input, io) => {
53
+ requireOnPc('github login');
54
+ return saveGithubTokenFlow(io, new GithubToken(ctx.storageRoot));
55
+ });
56
+ export const githubLogoutRun = implement(githubLogout, async (ctx, _input, io) => {
57
+ requireOnPc('github logout');
58
+ return deleteGithubTokenFlow(io, new GithubToken(ctx.storageRoot));
59
+ });
@@ -0,0 +1,2 @@
1
+ export * from './github.def.js';
2
+ export * from './github.run.js';
@@ -0,0 +1,3 @@
1
+ // The GitHub feature: whether sandboxes get your token, saving and deleting it.
2
+ export * from './github.def.js';
3
+ export * from './github.run.js';