windows-development-sandbox 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. package/config.example.json +10 -0
  2. package/dist/app/context.d.ts +8 -0
  3. package/dist/app/context.js +12 -0
  4. package/dist/app/features/defs.d.ts +322 -0
  5. package/dist/app/features/defs.js +28 -0
  6. package/dist/app/features/sandbox/index.d.ts +2 -0
  7. package/dist/app/features/sandbox/index.js +3 -0
  8. package/dist/app/features/sandbox/sandbox.def.d.ts +193 -0
  9. package/dist/app/features/sandbox/sandbox.def.js +245 -0
  10. package/dist/app/features/sandbox/sandbox.run.d.ts +72 -0
  11. package/dist/app/features/sandbox/sandbox.run.js +98 -0
  12. package/dist/app/features/sessions/index.d.ts +2 -0
  13. package/dist/app/features/sessions/index.js +3 -0
  14. package/dist/app/features/sessions/sessions.def.d.ts +141 -0
  15. package/dist/app/features/sessions/sessions.def.js +176 -0
  16. package/dist/app/features/sessions/sessions.run.d.ts +39 -0
  17. package/dist/app/features/sessions/sessions.run.js +58 -0
  18. package/dist/{cli/menu/settings/categories.d.ts → app/features/settings/categories.def.d.ts} +2 -0
  19. package/dist/{cli/menu/settings/categories.js → app/features/settings/categories.def.js} +24 -5
  20. package/dist/app/features/settings/index.d.ts +5 -0
  21. package/dist/app/features/settings/index.js +6 -0
  22. package/dist/{cli/menu/settings/config-file.d.ts → app/features/settings/settings-file.d.ts} +1 -1
  23. package/dist/{cli/menu/settings/config-file.js → app/features/settings/settings-file.js} +1 -1
  24. package/dist/app/features/settings/settings-rows.d.ts +35 -0
  25. package/dist/app/features/settings/settings-rows.js +94 -0
  26. package/dist/app/features/settings/settings.def.d.ts +157 -0
  27. package/dist/app/features/settings/settings.def.js +179 -0
  28. package/dist/app/features/settings/settings.run.d.ts +67 -0
  29. package/dist/app/features/settings/settings.run.js +84 -0
  30. package/dist/app/kernel/define.d.ts +143 -0
  31. package/dist/app/kernel/define.js +42 -0
  32. package/dist/app/kernel/errors.d.ts +34 -0
  33. package/dist/app/kernel/errors.js +45 -0
  34. package/dist/app/kernel/fields.d.ts +70 -0
  35. package/dist/app/kernel/fields.js +243 -0
  36. package/dist/app/kernel/index.d.ts +8 -0
  37. package/dist/app/kernel/index.js +10 -0
  38. package/dist/app/kernel/io.d.ts +193 -0
  39. package/dist/app/kernel/io.js +126 -0
  40. package/dist/app/kernel/rpc.d.ts +156 -0
  41. package/dist/app/kernel/rpc.js +47 -0
  42. package/dist/app/kernel/text.d.ts +6 -0
  43. package/dist/app/kernel/text.js +57 -0
  44. package/dist/app/kernel/view.d.ts +146 -0
  45. package/dist/app/kernel/view.js +28 -0
  46. package/dist/app/registry.d.ts +10 -0
  47. package/dist/app/registry.js +50 -0
  48. package/dist/cli/args.d.ts +5 -0
  49. package/dist/cli/args.js +6 -0
  50. package/dist/cli/commands/engine.d.ts +2 -0
  51. package/dist/cli/commands/engine.js +60 -0
  52. package/dist/cli/commands/index.d.ts +1 -1
  53. package/dist/cli/commands/index.js +1 -1
  54. package/dist/cli/commands/launch/launch.js +47 -7
  55. package/dist/cli/commands/launch/prepare.js +3 -3
  56. package/dist/cli/commands/launch/running.js +2 -1
  57. package/dist/cli/commands/launch/summary.d.ts +2 -0
  58. package/dist/cli/commands/maintenance/config-share.d.ts +12 -0
  59. package/dist/cli/commands/maintenance/config-share.js +80 -0
  60. package/dist/cli/commands/maintenance/config.js +8 -82
  61. package/dist/cli/commands/maintenance/logs.js +14 -0
  62. package/dist/cli/commands/registry.js +3 -7
  63. package/dist/cli/commands/repair/checks/contained.d.ts +2 -0
  64. package/dist/cli/commands/repair/checks/contained.js +139 -0
  65. package/dist/cli/commands/repair/checks/hcs.d.ts +7 -0
  66. package/dist/cli/commands/repair/checks/hcs.js +28 -0
  67. package/dist/cli/commands/repair/checks/index.js +4 -0
  68. package/dist/cli/commands/repair/checks/pc.js +32 -1
  69. package/dist/cli/commands/repair/checks/sandbox.js +16 -1
  70. package/dist/cli/commands/repair/checks/vpn.js +34 -9
  71. package/dist/cli/commands/repair/env.js +2 -1
  72. package/dist/cli/commands/sessions/index.d.ts +0 -4
  73. package/dist/cli/commands/sessions/index.js +3 -7
  74. package/dist/cli/commands/shared-use.d.ts +5 -2
  75. package/dist/cli/commands/shared-use.js +11 -8
  76. package/dist/cli/commands/storage/contained.d.ts +3 -0
  77. package/dist/cli/commands/storage/contained.js +179 -0
  78. package/dist/cli/commands/storage/offer.js +7 -1
  79. package/dist/cli/commands/storage/storage.js +10 -2
  80. package/dist/cli/commands/user-config.js +1 -1
  81. package/dist/cli/commands/vpn.js +19 -3
  82. package/dist/cli/commands/web.js +2 -0
  83. package/dist/cli/index.js +2 -1
  84. package/dist/cli/manifest.d.ts +72 -104
  85. package/dist/cli/manifest.js +64 -39
  86. package/dist/cli/menu/add-agent.d.ts +1 -1
  87. package/dist/cli/menu/add-agent.js +1 -1
  88. package/dist/cli/menu/apps.d.ts +7 -1
  89. package/dist/cli/menu/apps.js +36 -0
  90. package/dist/cli/menu/command-fields.d.ts +1 -1
  91. package/dist/cli/menu/command-form.js +2 -2
  92. package/dist/cli/menu/io-menu.d.ts +29 -0
  93. package/dist/cli/menu/io-menu.js +126 -0
  94. package/dist/cli/menu/live.d.ts +27 -0
  95. package/dist/cli/menu/live.js +69 -0
  96. package/dist/cli/menu/memory.d.ts +19 -0
  97. package/dist/cli/menu/memory.js +53 -0
  98. package/dist/cli/menu/menu.d.ts +10 -1
  99. package/dist/cli/menu/menu.js +27 -9
  100. package/dist/cli/menu/pages/agents-page.d.ts +3 -1
  101. package/dist/cli/menu/pages/agents-page.js +12 -5
  102. package/dist/cli/menu/pages/apps-page.d.ts +3 -1
  103. package/dist/cli/menu/pages/apps-page.js +19 -2
  104. package/dist/cli/menu/pages/list-page.d.ts +27 -0
  105. package/dist/cli/menu/pages/list-page.js +109 -7
  106. package/dist/cli/menu/pages/maintenance-page.d.ts +0 -5
  107. package/dist/cli/menu/pages/maintenance-page.js +17 -19
  108. package/dist/cli/menu/pages/sandbox-page.d.ts +4 -6
  109. package/dist/cli/menu/pages/sandbox-page.js +26 -118
  110. package/dist/cli/menu/pages/scopes.d.ts +1 -1
  111. package/dist/cli/menu/pages/sessions-page.d.ts +5 -11
  112. package/dist/cli/menu/pages/sessions-page.js +19 -88
  113. package/dist/cli/menu/pages/settings-page.d.ts +2 -10
  114. package/dist/cli/menu/pages/settings-page.js +64 -94
  115. package/dist/cli/menu/render-view.d.ts +28 -0
  116. package/dist/cli/menu/render-view.js +112 -0
  117. package/dist/cli/menu/settings/{path-kind.d.ts → ask-path.d.ts} +1 -7
  118. package/dist/cli/menu/settings/ask-path.js +14 -0
  119. package/dist/cli/menu/settings/collections/collection-editor.d.ts +1 -1
  120. package/dist/cli/menu/settings/collections/string-list-editor.d.ts +1 -2
  121. package/dist/cli/menu/settings/collections/string-list-editor.js +1 -1
  122. package/dist/cli/menu/settings/draft.d.ts +1 -1
  123. package/dist/cli/menu/settings/format.d.ts +1 -3
  124. package/dist/cli/menu/settings/format.js +6 -36
  125. package/dist/cli/menu/settings/index.d.ts +1 -3
  126. package/dist/cli/menu/settings/index.js +3 -3
  127. package/dist/cli/menu/settings/object-editor.d.ts +1 -1
  128. package/dist/cli/menu/settings/share.d.ts +36 -0
  129. package/dist/cli/menu/settings/share.js +131 -0
  130. package/dist/cli/menu/settings/value-editor.d.ts +5 -1
  131. package/dist/cli/menu/settings/value-editor.js +57 -54
  132. package/dist/cli/menu/several.js +1 -1
  133. package/dist/cli/menu/share-settings.d.ts +21 -0
  134. package/dist/cli/menu/share-settings.js +112 -0
  135. package/dist/cli/menu/shell.d.ts +21 -5
  136. package/dist/cli/menu/shell.js +31 -6
  137. package/dist/cli/menu/views.d.ts +7 -0
  138. package/dist/cli/menu/views.js +11 -0
  139. package/dist/cli/menu/vpn-login.js +8 -0
  140. package/dist/cli/operations/handler.d.ts +6 -0
  141. package/dist/cli/operations/handler.js +61 -0
  142. package/dist/cli/operations/index.d.ts +4 -0
  143. package/dist/cli/operations/index.js +5 -0
  144. package/dist/cli/operations/input.d.ts +6 -0
  145. package/dist/cli/operations/input.js +37 -0
  146. package/dist/cli/operations/io-cli.d.ts +7 -0
  147. package/dist/cli/operations/io-cli.js +62 -0
  148. package/dist/cli/operations/spec.d.ts +18 -0
  149. package/dist/cli/operations/spec.js +108 -0
  150. package/dist/cli/output/colors.d.ts +2 -2
  151. package/dist/cli/output/colors.js +2 -11
  152. package/dist/cli/output/index.d.ts +1 -0
  153. package/dist/cli/output/index.js +1 -0
  154. package/dist/cli/output/print.d.ts +3 -1
  155. package/dist/cli/output/print.js +7 -3
  156. package/dist/cli/output/progress.d.ts +15 -0
  157. package/dist/cli/output/progress.js +44 -0
  158. package/dist/cli/output/render-view.d.ts +4 -0
  159. package/dist/cli/output/render-view.js +63 -0
  160. package/dist/cli/services/agent-commands-service.d.ts +2 -0
  161. package/dist/cli/services/agent-commands-service.js +11 -2
  162. package/dist/cli/services/logs-service.js +4 -3
  163. package/dist/cli/tui/app.d.ts +6 -1
  164. package/dist/cli/tui/app.js +26 -4
  165. package/dist/cli/tui/list/list-screen.d.ts +14 -0
  166. package/dist/cli/tui/list/list-screen.js +64 -36
  167. package/dist/cli/tui/list/list-types.d.ts +2 -0
  168. package/dist/cli/tui/terminal.d.ts +7 -0
  169. package/dist/cli/tui/terminal.js +30 -10
  170. package/dist/core/config/defaults.js +8 -0
  171. package/dist/core/schema/config.d.ts +13 -0
  172. package/dist/core/schema/config.js +16 -1
  173. package/dist/core/schema/harness.d.ts +1 -0
  174. package/dist/core/schema/harness.js +5 -0
  175. package/dist/core/schema/sandbox.d.ts +6 -0
  176. package/dist/core/schema/sandbox.js +20 -3
  177. package/dist/core/schema/vpn.d.ts +2 -1
  178. package/dist/core/schema/vpn.js +3 -3
  179. package/dist/core/types.d.ts +23 -5
  180. package/dist/core/util/fs.d.ts +2 -0
  181. package/dist/core/util/fs.js +9 -0
  182. package/dist/core/util/index.d.ts +1 -1
  183. package/dist/core/util/index.js +1 -1
  184. package/dist/guest/agents/agent-files.d.ts +5 -0
  185. package/dist/guest/agents/agent-files.js +4 -0
  186. package/dist/guest/agents/local-state.d.ts +2 -0
  187. package/dist/guest/agents/local-state.js +21 -1
  188. package/dist/guest/boot/boot.js +2 -1
  189. package/dist/guest/daemon/daemon.js +4 -0
  190. package/dist/guest/daemon/sessions.d.ts +5 -0
  191. package/dist/guest/daemon/sessions.js +17 -3
  192. package/dist/guest/entries/daemon.js +3 -0
  193. package/dist/guest/governor/decide.d.ts +61 -0
  194. package/dist/guest/governor/decide.js +182 -0
  195. package/dist/guest/governor/governor.d.ts +42 -0
  196. package/dist/guest/governor/governor.js +214 -0
  197. package/dist/guest/governor/index.d.ts +2 -0
  198. package/dist/guest/governor/index.js +2 -0
  199. package/dist/guest/runtime/csc.d.ts +1 -0
  200. package/dist/guest/runtime/csc.js +1 -0
  201. package/dist/guest/sessions/viewer.js +3 -1
  202. package/dist/guest/toolchains/native/rust-extras.js +4 -2
  203. package/dist/guest/vpn/vpn.js +69 -21
  204. package/dist/guest/vpn/wireguard.d.ts +32 -0
  205. package/dist/guest/vpn/wireguard.js +132 -0
  206. package/dist/host/agent-commands/commands.d.ts +4 -0
  207. package/dist/host/agent-commands/commands.js +31 -7
  208. package/dist/host/audit/log.d.ts +1 -1
  209. package/dist/host/channel/attach.d.ts +3 -1
  210. package/dist/host/channel/attach.js +5 -2
  211. package/dist/host/channel/channel.d.ts +2 -0
  212. package/dist/host/channel/channel.js +4 -0
  213. package/dist/host/engines/engine.d.ts +12 -0
  214. package/dist/host/engines/engine.js +1 -0
  215. package/dist/host/engines/hcs/check.d.ts +25 -0
  216. package/dist/host/engines/hcs/check.js +95 -0
  217. package/dist/host/engines/hcs/documents.d.ts +44 -0
  218. package/dist/host/engines/hcs/documents.js +155 -0
  219. package/dist/host/engines/hcs/engine.d.ts +39 -0
  220. package/dist/host/engines/hcs/engine.js +171 -0
  221. package/dist/host/engines/hcs/helper.d.ts +43 -0
  222. package/dist/host/engines/hcs/helper.js +173 -0
  223. package/dist/host/engines/hcs/images.d.ts +37 -0
  224. package/dist/host/engines/hcs/images.js +152 -0
  225. package/dist/host/engines/index.d.ts +7 -0
  226. package/dist/host/engines/index.js +5 -0
  227. package/dist/host/engines/registry.d.ts +16 -0
  228. package/dist/host/engines/registry.js +30 -0
  229. package/dist/host/engines/types.d.ts +58 -0
  230. package/dist/host/engines/types.js +1 -0
  231. package/dist/host/engines/windows-sandbox/engine.d.ts +16 -0
  232. package/dist/host/engines/windows-sandbox/engine.js +63 -0
  233. package/dist/host/engines/windows-sandbox/wsb-text.d.ts +2 -0
  234. package/dist/host/engines/windows-sandbox/wsb-text.js +29 -0
  235. package/dist/host/launch/generate.d.ts +5 -1
  236. package/dist/host/launch/generate.js +50 -8
  237. package/dist/host/launch/index.d.ts +3 -1
  238. package/dist/host/launch/index.js +3 -1
  239. package/dist/host/launch/launch-plan.d.ts +13 -0
  240. package/dist/host/launch/launch-plan.js +26 -0
  241. package/dist/host/launch/mappings.js +2 -1
  242. package/dist/host/launch/risk-notes.d.ts +10 -0
  243. package/dist/host/launch/risk-notes.js +18 -0
  244. package/dist/host/launch/session-file.d.ts +2 -0
  245. package/dist/host/launch/session-file.js +7 -1
  246. package/dist/host/launch/wsb-file.d.ts +28 -4
  247. package/dist/host/launch/wsb-file.js +61 -42
  248. package/dist/host/life/crash-report.d.ts +27 -1
  249. package/dist/host/life/crash-report.js +173 -7
  250. package/dist/host/life/host-memory.d.ts +40 -0
  251. package/dist/host/life/host-memory.js +137 -0
  252. package/dist/host/life/index.d.ts +2 -0
  253. package/dist/host/life/index.js +2 -0
  254. package/dist/host/life/stop-events.d.ts +2 -0
  255. package/dist/host/life/stop-events.js +20 -3
  256. package/dist/host/life/stop-warning.js +1 -1
  257. package/dist/host/life/watchdog.d.ts +54 -0
  258. package/dist/host/life/watchdog.js +108 -0
  259. package/dist/host/native.d.ts +3 -2
  260. package/dist/host/native.js +22 -3
  261. package/dist/host/profile/claude-login.js +3 -2
  262. package/dist/host/sandbox/contained-deps.d.ts +2 -0
  263. package/dist/host/sandbox/contained-deps.js +17 -0
  264. package/dist/host/sandbox/index.d.ts +2 -0
  265. package/dist/host/sandbox/index.js +2 -0
  266. package/dist/host/sandbox/platform.d.ts +2 -0
  267. package/dist/host/sandbox/platform.js +7 -7
  268. package/dist/host/sandbox/tasklist.d.ts +13 -0
  269. package/dist/host/sandbox/tasklist.js +47 -0
  270. package/dist/host/secrets/launch-secrets.js +2 -1
  271. package/dist/host/sharing/current.js +2 -6
  272. package/dist/host/storage/contained/check.d.ts +9 -0
  273. package/dist/host/storage/contained/check.js +37 -0
  274. package/dist/host/storage/contained/contained-storage.d.ts +66 -0
  275. package/dist/host/storage/contained/contained-storage.js +168 -0
  276. package/dist/host/storage/contained/disk-port.d.ts +43 -0
  277. package/dist/host/storage/contained/disk-port.js +122 -0
  278. package/dist/host/storage/contained/index.d.ts +9 -0
  279. package/dist/host/storage/contained/index.js +8 -0
  280. package/dist/host/storage/contained/layout.d.ts +28 -0
  281. package/dist/host/storage/contained/layout.js +45 -0
  282. package/dist/host/storage/contained/resolve.d.ts +4 -0
  283. package/dist/host/storage/contained/resolve.js +30 -0
  284. package/dist/host/storage/contained/setting.d.ts +1 -0
  285. package/dist/host/storage/contained/setting.js +5 -0
  286. package/dist/host/storage/contained/state.d.ts +89 -0
  287. package/dist/host/storage/contained/state.js +166 -0
  288. package/dist/host/storage/contained/transfer.d.ts +24 -0
  289. package/dist/host/storage/contained/transfer.js +121 -0
  290. package/dist/host/storage/index.d.ts +2 -0
  291. package/dist/host/storage/index.js +2 -0
  292. package/dist/host/storage/providers/contained.d.ts +15 -0
  293. package/dist/host/storage/providers/contained.js +39 -0
  294. package/dist/host/storage/providers/folder.d.ts +12 -0
  295. package/dist/host/storage/providers/folder.js +20 -0
  296. package/dist/host/storage/providers/index.d.ts +4 -0
  297. package/dist/host/storage/providers/index.js +3 -0
  298. package/dist/host/storage/providers/registry.d.ts +9 -0
  299. package/dist/host/storage/providers/registry.js +14 -0
  300. package/dist/host/storage/providers/types.d.ts +33 -0
  301. package/dist/host/storage/providers/types.js +1 -0
  302. package/dist/host/tools/conpty.js +3 -2
  303. package/dist/host/tools/windows-terminal.js +8 -7
  304. package/dist/host/vpn/index.d.ts +1 -1
  305. package/dist/host/vpn/index.js +1 -1
  306. package/dist/host/vpn/prepare.d.ts +2 -0
  307. package/dist/host/vpn/prepare.js +63 -2
  308. package/dist/host/web/browser.d.ts +2 -0
  309. package/dist/host/web/browser.js +14 -1
  310. package/dist/host/web/index.d.ts +3 -2
  311. package/dist/host/web/index.js +3 -2
  312. package/dist/host/web/rpc.d.ts +24 -0
  313. package/dist/host/web/rpc.js +149 -0
  314. package/dist/host/web/runner.d.ts +2 -0
  315. package/dist/host/web/runner.js +1 -2
  316. package/dist/host/web/server.d.ts +7 -0
  317. package/dist/host/web/server.js +23 -3
  318. package/dist/runtime/agent.js +69 -8
  319. package/dist/runtime/daemon.js +1058 -624
  320. package/dist/runtime/db.js +69 -8
  321. package/dist/runtime/main.js +624 -182
  322. package/dist/runtime/netproxy.js +69 -8
  323. package/dist/runtime/view.js +87 -13
  324. package/dist/selftest/agent-paths.test.js +11 -1
  325. package/dist/selftest/app.test.d.ts +2 -0
  326. package/dist/selftest/app.test.js +324 -0
  327. package/dist/selftest/channel.test.js +13 -0
  328. package/dist/selftest/cli.test.js +2 -1
  329. package/dist/selftest/config.test.js +59 -0
  330. package/dist/selftest/contained.test.d.ts +2 -0
  331. package/dist/selftest/contained.test.js +544 -0
  332. package/dist/selftest/credentials.test.js +1 -1
  333. package/dist/selftest/engine.test.d.ts +2 -0
  334. package/dist/selftest/engine.test.js +127 -0
  335. package/dist/selftest/hcs.test.d.ts +2 -0
  336. package/dist/selftest/hcs.test.js +482 -0
  337. package/dist/selftest/heavy-load.test.d.ts +2 -0
  338. package/dist/selftest/heavy-load.test.js +329 -0
  339. package/dist/selftest/index.js +12 -0
  340. package/dist/selftest/layout.test.js +12 -0
  341. package/dist/selftest/menu-perf.test.d.ts +2 -0
  342. package/dist/selftest/menu-perf.test.js +248 -0
  343. package/dist/selftest/menu-screens.js +4 -2
  344. package/dist/selftest/menu.test.js +36 -8
  345. package/dist/selftest/support/engine-cases.d.ts +8 -0
  346. package/dist/selftest/support/engine-cases.js +65 -0
  347. package/dist/selftest/support/engine-golden.d.ts +3 -0
  348. package/dist/selftest/support/engine-golden.js +66 -0
  349. package/dist/selftest/support/fixtures.d.ts +7 -1
  350. package/dist/selftest/support/hcs-probes.d.ts +17 -0
  351. package/dist/selftest/support/hcs-probes.js +41 -0
  352. package/dist/selftest/vpn.test.js +136 -3
  353. package/dist/selftest/web.test.js +101 -3
  354. package/dist/shared/channel/run-dir.d.ts +4 -1
  355. package/dist/shared/channel/run-dir.js +7 -1
  356. package/dist/shared/channel/schema.d.ts +35 -1
  357. package/dist/shared/channel/schema.js +27 -0
  358. package/dist/shared/channel/secrets.d.ts +1 -0
  359. package/dist/shared/channel/secrets.js +6 -0
  360. package/dist/shared/memory/index.d.ts +1 -0
  361. package/dist/shared/memory/index.js +1 -0
  362. package/dist/shared/memory/policy.d.ts +33 -0
  363. package/dist/shared/memory/policy.js +55 -0
  364. package/dist/shared/pty/output-filter.d.ts +14 -1
  365. package/dist/shared/pty/output-filter.js +22 -4
  366. package/dist/shared/pty/terminal.d.ts +4 -1
  367. package/dist/shared/pty/terminal.js +4 -2
  368. package/dist/shared/system.d.ts +1 -0
  369. package/dist/shared/system.js +1 -0
  370. package/dist/shared/vpn/download.d.ts +16 -0
  371. package/dist/shared/vpn/download.js +16 -0
  372. package/dist/shared/vpn/wireguard.d.ts +51 -0
  373. package/dist/shared/vpn/wireguard.js +227 -0
  374. package/dist/sync/sync-cycle.js +5 -5
  375. package/dist/sync/watcher.d.ts +13 -0
  376. package/dist/sync/watcher.js +92 -3
  377. package/dist/web/index.html +4 -3
  378. package/dist/web/main-NRRS5O6Z.js +157 -0
  379. package/dist/web/main-T5DMCHYV.css +1 -0
  380. package/native/csharp/HcsHost/AssemblyInfo.cs +14 -0
  381. package/native/csharp/HcsHost/Guard.cs +100 -0
  382. package/native/csharp/HcsHost/Hcs.cs +256 -0
  383. package/native/csharp/HcsHost/Json.cs +78 -0
  384. package/native/csharp/HcsHost/Program.cs +185 -0
  385. package/native/csharp/HcsHost/VirtualDisk.cs +95 -0
  386. package/native/csharp/HostTools/AssemblyInfo.cs +14 -0
  387. package/native/csharp/HostTools/MemoryStatus.cs +107 -0
  388. package/native/csharp/HostTools/Program.cs +58 -17
  389. package/native/scripts/check-contained.ps1 +28 -0
  390. package/native/scripts/contained-common.ps1 +241 -0
  391. package/native/scripts/dismount-contained.ps1 +66 -0
  392. package/native/scripts/memory-status.ps1 +34 -0
  393. package/native/scripts/mount-contained.ps1 +139 -0
  394. package/native/scripts/run-elevated.ps1 +17 -4
  395. package/native/scripts/stop-events.ps1 +23 -8
  396. package/package.json +9 -2
  397. package/sandbox/csharp/MemGov.cs +398 -0
  398. package/sandbox/csharp/PtyHost.cs +111 -5
  399. package/schemas/config.schema.json +60 -6
  400. package/schemas/sandbox-config.schema.json +3 -3
  401. package/dist/cli/commands/sessions/control.d.ts +0 -4
  402. package/dist/cli/commands/sessions/control.js +0 -66
  403. package/dist/cli/commands/sessions/list.d.ts +0 -2
  404. package/dist/cli/commands/sessions/list.js +0 -48
  405. package/dist/cli/commands/sessions/status.d.ts +0 -4
  406. package/dist/cli/commands/sessions/status.js +0 -114
  407. package/dist/cli/commands/sessions/window.d.ts +0 -3
  408. package/dist/cli/commands/sessions/window.js +0 -18
  409. package/dist/cli/menu/settings/path-kind.js +0 -44
  410. package/dist/web/main-CXESL347.js +0 -45
  411. package/dist/web/main-VLR7DVQ4.css +0 -1
  412. /package/dist/{cli/menu/settings → app/kernel}/schema-node.d.ts +0 -0
  413. /package/dist/{cli/menu/settings → app/kernel}/schema-node.js +0 -0
@@ -1363,11 +1363,11 @@ var require_lodash = __commonJS({
1363
1363
  return isFunction(object2[key]);
1364
1364
  });
1365
1365
  }
1366
- function baseGet(object2, path74) {
1367
- path74 = castPath(path74, object2);
1368
- var index = 0, length = path74.length;
1366
+ function baseGet(object2, path75) {
1367
+ path75 = castPath(path75, object2);
1368
+ var index = 0, length = path75.length;
1369
1369
  while (object2 != null && index < length) {
1370
- object2 = object2[toKey(path74[index++])];
1370
+ object2 = object2[toKey(path75[index++])];
1371
1371
  }
1372
1372
  return index && index == length ? object2 : undefined2;
1373
1373
  }
@@ -1431,10 +1431,10 @@ var require_lodash = __commonJS({
1431
1431
  });
1432
1432
  return accumulator;
1433
1433
  }
1434
- function baseInvoke(object2, path74, args) {
1435
- path74 = castPath(path74, object2);
1436
- object2 = parent(object2, path74);
1437
- var func = object2 == null ? object2 : object2[toKey(last(path74))];
1434
+ function baseInvoke(object2, path75, args) {
1435
+ path75 = castPath(path75, object2);
1436
+ object2 = parent(object2, path75);
1437
+ var func = object2 == null ? object2 : object2[toKey(last(path75))];
1438
1438
  return func == null ? undefined2 : apply(func, object2, args);
1439
1439
  }
1440
1440
  function baseIsArguments(value) {
@@ -1590,13 +1590,13 @@ var require_lodash = __commonJS({
1590
1590
  return object2 === source || baseIsMatch(object2, source, matchData);
1591
1591
  };
1592
1592
  }
1593
- function baseMatchesProperty(path74, srcValue) {
1594
- if (isKey(path74) && isStrictComparable(srcValue)) {
1595
- return matchesStrictComparable(toKey(path74), srcValue);
1593
+ function baseMatchesProperty(path75, srcValue) {
1594
+ if (isKey(path75) && isStrictComparable(srcValue)) {
1595
+ return matchesStrictComparable(toKey(path75), srcValue);
1596
1596
  }
1597
1597
  return function(object2) {
1598
- var objValue = get(object2, path74);
1599
- return objValue === undefined2 && objValue === srcValue ? hasIn(object2, path74) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1598
+ var objValue = get(object2, path75);
1599
+ return objValue === undefined2 && objValue === srcValue ? hasIn(object2, path75) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1600
1600
  };
1601
1601
  }
1602
1602
  function baseMerge(object2, source, srcIndex, customizer, stack) {
@@ -1693,23 +1693,23 @@ var require_lodash = __commonJS({
1693
1693
  });
1694
1694
  }
1695
1695
  function basePick(object2, paths) {
1696
- return basePickBy(object2, paths, function(value, path74) {
1697
- return hasIn(object2, path74);
1696
+ return basePickBy(object2, paths, function(value, path75) {
1697
+ return hasIn(object2, path75);
1698
1698
  });
1699
1699
  }
1700
1700
  function basePickBy(object2, paths, predicate) {
1701
1701
  var index = -1, length = paths.length, result2 = {};
1702
1702
  while (++index < length) {
1703
- var path74 = paths[index], value = baseGet(object2, path74);
1704
- if (predicate(value, path74)) {
1705
- baseSet(result2, castPath(path74, object2), value);
1703
+ var path75 = paths[index], value = baseGet(object2, path75);
1704
+ if (predicate(value, path75)) {
1705
+ baseSet(result2, castPath(path75, object2), value);
1706
1706
  }
1707
1707
  }
1708
1708
  return result2;
1709
1709
  }
1710
- function basePropertyDeep(path74) {
1710
+ function basePropertyDeep(path75) {
1711
1711
  return function(object2) {
1712
- return baseGet(object2, path74);
1712
+ return baseGet(object2, path75);
1713
1713
  };
1714
1714
  }
1715
1715
  function basePullAll(array2, values2, iteratee2, comparator) {
@@ -1783,14 +1783,14 @@ var require_lodash = __commonJS({
1783
1783
  var array2 = values(collection);
1784
1784
  return shuffleSelf(array2, baseClamp(n, 0, array2.length));
1785
1785
  }
1786
- function baseSet(object2, path74, value, customizer) {
1786
+ function baseSet(object2, path75, value, customizer) {
1787
1787
  if (!isObject2(object2)) {
1788
1788
  return object2;
1789
1789
  }
1790
- path74 = castPath(path74, object2);
1791
- var index = -1, length = path74.length, lastIndex = length - 1, nested = object2;
1790
+ path75 = castPath(path75, object2);
1791
+ var index = -1, length = path75.length, lastIndex = length - 1, nested = object2;
1792
1792
  while (nested != null && ++index < length) {
1793
- var key = toKey(path74[index]), newValue = value;
1793
+ var key = toKey(path75[index]), newValue = value;
1794
1794
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
1795
1795
  return object2;
1796
1796
  }
@@ -1798,7 +1798,7 @@ var require_lodash = __commonJS({
1798
1798
  var objValue = nested[key];
1799
1799
  newValue = customizer ? customizer(objValue, key, nested) : undefined2;
1800
1800
  if (newValue === undefined2) {
1801
- newValue = isObject2(objValue) ? objValue : isIndex(path74[index + 1]) ? [] : {};
1801
+ newValue = isObject2(objValue) ? objValue : isIndex(path75[index + 1]) ? [] : {};
1802
1802
  }
1803
1803
  }
1804
1804
  assignValue(nested, key, newValue);
@@ -1964,14 +1964,14 @@ var require_lodash = __commonJS({
1964
1964
  }
1965
1965
  return result2;
1966
1966
  }
1967
- function baseUnset(object2, path74) {
1968
- path74 = castPath(path74, object2);
1969
- var index = -1, length = path74.length;
1967
+ function baseUnset(object2, path75) {
1968
+ path75 = castPath(path75, object2);
1969
+ var index = -1, length = path75.length;
1970
1970
  if (!length) {
1971
1971
  return true;
1972
1972
  }
1973
1973
  while (++index < length) {
1974
- var key = toKey(path74[index]);
1974
+ var key = toKey(path75[index]);
1975
1975
  if (key === "__proto__" && !hasOwnProperty.call(object2, "__proto__")) {
1976
1976
  return false;
1977
1977
  }
@@ -1979,11 +1979,11 @@ var require_lodash = __commonJS({
1979
1979
  return false;
1980
1980
  }
1981
1981
  }
1982
- var obj = parent(object2, path74);
1983
- return obj == null || delete obj[toKey(last(path74))];
1982
+ var obj = parent(object2, path75);
1983
+ return obj == null || delete obj[toKey(last(path75))];
1984
1984
  }
1985
- function baseUpdate(object2, path74, updater, customizer) {
1986
- return baseSet(object2, path74, updater(baseGet(object2, path74)), customizer);
1985
+ function baseUpdate(object2, path75, updater, customizer) {
1986
+ return baseSet(object2, path75, updater(baseGet(object2, path75)), customizer);
1987
1987
  }
1988
1988
  function baseWhile(array2, predicate, isDrop, fromRight) {
1989
1989
  var length = array2.length, index = fromRight ? length : -1;
@@ -2866,11 +2866,11 @@ var require_lodash = __commonJS({
2866
2866
  var match = source.match(reWrapDetails);
2867
2867
  return match ? match[1].split(reSplitDetails) : [];
2868
2868
  }
2869
- function hasPath(object2, path74, hasFunc) {
2870
- path74 = castPath(path74, object2);
2871
- var index = -1, length = path74.length, result2 = false;
2869
+ function hasPath(object2, path75, hasFunc) {
2870
+ path75 = castPath(path75, object2);
2871
+ var index = -1, length = path75.length, result2 = false;
2872
2872
  while (++index < length) {
2873
- var key = toKey(path74[index]);
2873
+ var key = toKey(path75[index]);
2874
2874
  if (!(result2 = object2 != null && hasFunc(object2, key))) {
2875
2875
  break;
2876
2876
  }
@@ -3072,8 +3072,8 @@ var require_lodash = __commonJS({
3072
3072
  return apply(func, this, otherArgs);
3073
3073
  };
3074
3074
  }
3075
- function parent(object2, path74) {
3076
- return path74.length < 2 ? object2 : baseGet(object2, baseSlice(path74, 0, -1));
3075
+ function parent(object2, path75) {
3076
+ return path75.length < 2 ? object2 : baseGet(object2, baseSlice(path75, 0, -1));
3077
3077
  }
3078
3078
  function reorder(array2, indexes) {
3079
3079
  var arrLength = array2.length, length = nativeMin(indexes.length, arrLength), oldArray = copyArray(array2);
@@ -3708,10 +3708,10 @@ var require_lodash = __commonJS({
3708
3708
  }
3709
3709
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
3710
3710
  }
3711
- var invokeMap = baseRest(function(collection, path74, args) {
3712
- var index = -1, isFunc = typeof path74 == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
3711
+ var invokeMap = baseRest(function(collection, path75, args) {
3712
+ var index = -1, isFunc = typeof path75 == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
3713
3713
  baseEach(collection, function(value) {
3714
- result2[++index] = isFunc ? apply(path74, value, args) : baseInvoke(value, path74, args);
3714
+ result2[++index] = isFunc ? apply(path75, value, args) : baseInvoke(value, path75, args);
3715
3715
  });
3716
3716
  return result2;
3717
3717
  });
@@ -4363,15 +4363,15 @@ var require_lodash = __commonJS({
4363
4363
  function functionsIn(object2) {
4364
4364
  return object2 == null ? [] : baseFunctions(object2, keysIn(object2));
4365
4365
  }
4366
- function get(object2, path74, defaultValue) {
4367
- var result2 = object2 == null ? undefined2 : baseGet(object2, path74);
4366
+ function get(object2, path75, defaultValue) {
4367
+ var result2 = object2 == null ? undefined2 : baseGet(object2, path75);
4368
4368
  return result2 === undefined2 ? defaultValue : result2;
4369
4369
  }
4370
- function has(object2, path74) {
4371
- return object2 != null && hasPath(object2, path74, baseHas);
4370
+ function has(object2, path75) {
4371
+ return object2 != null && hasPath(object2, path75, baseHas);
4372
4372
  }
4373
- function hasIn(object2, path74) {
4374
- return object2 != null && hasPath(object2, path74, baseHasIn);
4373
+ function hasIn(object2, path75) {
4374
+ return object2 != null && hasPath(object2, path75, baseHasIn);
4375
4375
  }
4376
4376
  var invert = createInverter(function(result2, value, key) {
4377
4377
  if (value != null && typeof value.toString != "function") {
@@ -4424,10 +4424,10 @@ var require_lodash = __commonJS({
4424
4424
  return result2;
4425
4425
  }
4426
4426
  var isDeep = false;
4427
- paths = arrayMap(paths, function(path74) {
4428
- path74 = castPath(path74, object2);
4429
- isDeep || (isDeep = path74.length > 1);
4430
- return path74;
4427
+ paths = arrayMap(paths, function(path75) {
4428
+ path75 = castPath(path75, object2);
4429
+ isDeep || (isDeep = path75.length > 1);
4430
+ return path75;
4431
4431
  });
4432
4432
  copyObject(object2, getAllKeysIn(object2), result2);
4433
4433
  if (isDeep) {
@@ -4453,19 +4453,19 @@ var require_lodash = __commonJS({
4453
4453
  return [prop];
4454
4454
  });
4455
4455
  predicate = getIteratee(predicate);
4456
- return basePickBy(object2, props, function(value, path74) {
4457
- return predicate(value, path74[0]);
4456
+ return basePickBy(object2, props, function(value, path75) {
4457
+ return predicate(value, path75[0]);
4458
4458
  });
4459
4459
  }
4460
- function result(object2, path74, defaultValue) {
4461
- path74 = castPath(path74, object2);
4462
- var index = -1, length = path74.length;
4460
+ function result(object2, path75, defaultValue) {
4461
+ path75 = castPath(path75, object2);
4462
+ var index = -1, length = path75.length;
4463
4463
  if (!length) {
4464
4464
  length = 1;
4465
4465
  object2 = undefined2;
4466
4466
  }
4467
4467
  while (++index < length) {
4468
- var value = object2 == null ? undefined2 : object2[toKey(path74[index])];
4468
+ var value = object2 == null ? undefined2 : object2[toKey(path75[index])];
4469
4469
  if (value === undefined2) {
4470
4470
  index = length;
4471
4471
  value = defaultValue;
@@ -4474,12 +4474,12 @@ var require_lodash = __commonJS({
4474
4474
  }
4475
4475
  return object2;
4476
4476
  }
4477
- function set2(object2, path74, value) {
4478
- return object2 == null ? object2 : baseSet(object2, path74, value);
4477
+ function set2(object2, path75, value) {
4478
+ return object2 == null ? object2 : baseSet(object2, path75, value);
4479
4479
  }
4480
- function setWith(object2, path74, value, customizer) {
4480
+ function setWith(object2, path75, value, customizer) {
4481
4481
  customizer = typeof customizer == "function" ? customizer : undefined2;
4482
- return object2 == null ? object2 : baseSet(object2, path74, value, customizer);
4482
+ return object2 == null ? object2 : baseSet(object2, path75, value, customizer);
4483
4483
  }
4484
4484
  var toPairs = createToPairs(keys);
4485
4485
  var toPairsIn = createToPairs(keysIn);
@@ -4501,15 +4501,15 @@ var require_lodash = __commonJS({
4501
4501
  });
4502
4502
  return accumulator;
4503
4503
  }
4504
- function unset(object2, path74) {
4505
- return object2 == null ? true : baseUnset(object2, path74);
4504
+ function unset(object2, path75) {
4505
+ return object2 == null ? true : baseUnset(object2, path75);
4506
4506
  }
4507
- function update(object2, path74, updater) {
4508
- return object2 == null ? object2 : baseUpdate(object2, path74, castFunction(updater));
4507
+ function update(object2, path75, updater) {
4508
+ return object2 == null ? object2 : baseUpdate(object2, path75, castFunction(updater));
4509
4509
  }
4510
- function updateWith(object2, path74, updater, customizer) {
4510
+ function updateWith(object2, path75, updater, customizer) {
4511
4511
  customizer = typeof customizer == "function" ? customizer : undefined2;
4512
- return object2 == null ? object2 : baseUpdate(object2, path74, castFunction(updater), customizer);
4512
+ return object2 == null ? object2 : baseUpdate(object2, path75, castFunction(updater), customizer);
4513
4513
  }
4514
4514
  function values(object2) {
4515
4515
  return object2 == null ? [] : baseValues(object2, keys(object2));
@@ -4532,7 +4532,7 @@ var require_lodash = __commonJS({
4532
4532
  }
4533
4533
  return baseClamp(toNumber(number4), lower, upper);
4534
4534
  }
4535
- function inRange(number4, start, end) {
4535
+ function inRange2(number4, start, end) {
4536
4536
  start = toFinite(start);
4537
4537
  if (end === undefined2) {
4538
4538
  end = start;
@@ -4895,17 +4895,17 @@ var require_lodash = __commonJS({
4895
4895
  function matches(source) {
4896
4896
  return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
4897
4897
  }
4898
- function matchesProperty(path74, srcValue) {
4899
- return baseMatchesProperty(path74, baseClone(srcValue, CLONE_DEEP_FLAG));
4898
+ function matchesProperty(path75, srcValue) {
4899
+ return baseMatchesProperty(path75, baseClone(srcValue, CLONE_DEEP_FLAG));
4900
4900
  }
4901
- var method = baseRest(function(path74, args) {
4901
+ var method = baseRest(function(path75, args) {
4902
4902
  return function(object2) {
4903
- return baseInvoke(object2, path74, args);
4903
+ return baseInvoke(object2, path75, args);
4904
4904
  };
4905
4905
  });
4906
4906
  var methodOf = baseRest(function(object2, args) {
4907
- return function(path74) {
4908
- return baseInvoke(object2, path74, args);
4907
+ return function(path75) {
4908
+ return baseInvoke(object2, path75, args);
4909
4909
  };
4910
4910
  });
4911
4911
  function mixin(object2, source, options) {
@@ -4952,12 +4952,12 @@ var require_lodash = __commonJS({
4952
4952
  var over = createOver(arrayMap);
4953
4953
  var overEvery = createOver(arrayEvery);
4954
4954
  var overSome = createOver(arraySome);
4955
- function property(path74) {
4956
- return isKey(path74) ? baseProperty(toKey(path74)) : basePropertyDeep(path74);
4955
+ function property(path75) {
4956
+ return isKey(path75) ? baseProperty(toKey(path75)) : basePropertyDeep(path75);
4957
4957
  }
4958
4958
  function propertyOf(object2) {
4959
- return function(path74) {
4960
- return object2 == null ? undefined2 : baseGet(object2, path74);
4959
+ return function(path75) {
4960
+ return object2 == null ? undefined2 : baseGet(object2, path75);
4961
4961
  };
4962
4962
  }
4963
4963
  var range = createRange();
@@ -5235,7 +5235,7 @@ var require_lodash = __commonJS({
5235
5235
  lodash.identity = identity;
5236
5236
  lodash.includes = includes;
5237
5237
  lodash.indexOf = indexOf;
5238
- lodash.inRange = inRange;
5238
+ lodash.inRange = inRange2;
5239
5239
  lodash.invoke = invoke;
5240
5240
  lodash.isArguments = isArguments;
5241
5241
  lodash.isArray = isArray;
@@ -5410,12 +5410,12 @@ var require_lodash = __commonJS({
5410
5410
  LazyWrapper.prototype.findLast = function(predicate) {
5411
5411
  return this.reverse().find(predicate);
5412
5412
  };
5413
- LazyWrapper.prototype.invokeMap = baseRest(function(path74, args) {
5414
- if (typeof path74 == "function") {
5413
+ LazyWrapper.prototype.invokeMap = baseRest(function(path75, args) {
5414
+ if (typeof path75 == "function") {
5415
5415
  return new LazyWrapper(this);
5416
5416
  }
5417
5417
  return this.map(function(value) {
5418
- return baseInvoke(value, path74, args);
5418
+ return baseInvoke(value, path75, args);
5419
5419
  });
5420
5420
  });
5421
5421
  LazyWrapper.prototype.reject = function(predicate) {
@@ -5532,8 +5532,8 @@ var require_lodash = __commonJS({
5532
5532
  });
5533
5533
 
5534
5534
  // src/guest/entries/main.ts
5535
- import fs59 from "node:fs";
5536
- import path73 from "node:path";
5535
+ import fs60 from "node:fs";
5536
+ import path74 from "node:path";
5537
5537
 
5538
5538
  // src/guest/runtime/paths.ts
5539
5539
  import path7 from "node:path";
@@ -6358,10 +6358,10 @@ function mergeDefs(...defs) {
6358
6358
  function cloneDef(schema) {
6359
6359
  return mergeDefs(schema._zod.def);
6360
6360
  }
6361
- function getElementAtPath(obj, path74) {
6362
- if (!path74)
6361
+ function getElementAtPath(obj, path75) {
6362
+ if (!path75)
6363
6363
  return obj;
6364
- return path74.reduce((acc, key) => acc?.[key], obj);
6364
+ return path75.reduce((acc, key) => acc?.[key], obj);
6365
6365
  }
6366
6366
  function promiseAllObject(promisesObj) {
6367
6367
  const keys = Object.keys(promisesObj);
@@ -6701,11 +6701,11 @@ function explicitlyAborted(x, startIndex = 0) {
6701
6701
  }
6702
6702
  return false;
6703
6703
  }
6704
- function prefixIssues(path74, issues) {
6704
+ function prefixIssues(path75, issues) {
6705
6705
  return issues.map((iss) => {
6706
6706
  var _a3;
6707
6707
  (_a3 = iss).path ?? (_a3.path = []);
6708
- iss.path.unshift(path74);
6708
+ iss.path.unshift(path75);
6709
6709
  return iss;
6710
6710
  });
6711
6711
  }
@@ -7155,16 +7155,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
7155
7155
  }
7156
7156
  function formatError(error62, mapper = (issue2) => issue2.message) {
7157
7157
  const fieldErrors = { _errors: [] };
7158
- const processError = (error63, path74 = []) => {
7158
+ const processError = (error63, path75 = []) => {
7159
7159
  for (const issue2 of error63.issues) {
7160
7160
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7161
- issue2.errors.map((issues) => processError({ issues }, [...path74, ...issue2.path]));
7161
+ issue2.errors.map((issues) => processError({ issues }, [...path75, ...issue2.path]));
7162
7162
  } else if (issue2.code === "invalid_key") {
7163
- processError({ issues: issue2.issues }, [...path74, ...issue2.path]);
7163
+ processError({ issues: issue2.issues }, [...path75, ...issue2.path]);
7164
7164
  } else if (issue2.code === "invalid_element") {
7165
- processError({ issues: issue2.issues }, [...path74, ...issue2.path]);
7165
+ processError({ issues: issue2.issues }, [...path75, ...issue2.path]);
7166
7166
  } else {
7167
- const fullpath = [...path74, ...issue2.path];
7167
+ const fullpath = [...path75, ...issue2.path];
7168
7168
  if (fullpath.length === 0) {
7169
7169
  fieldErrors._errors.push(mapper(issue2));
7170
7170
  } else {
@@ -7203,17 +7203,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
7203
7203
  }
7204
7204
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
7205
7205
  const result = { errors: [] };
7206
- const processError = (error63, path74 = []) => {
7206
+ const processError = (error63, path75 = []) => {
7207
7207
  var _a3;
7208
7208
  for (const issue2 of error63.issues) {
7209
7209
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7210
- issue2.errors.map((issues) => processError({ issues }, [...path74, ...issue2.path]));
7210
+ issue2.errors.map((issues) => processError({ issues }, [...path75, ...issue2.path]));
7211
7211
  } else if (issue2.code === "invalid_key") {
7212
- processError({ issues: issue2.issues }, [...path74, ...issue2.path]);
7212
+ processError({ issues: issue2.issues }, [...path75, ...issue2.path]);
7213
7213
  } else if (issue2.code === "invalid_element") {
7214
- processError({ issues: issue2.issues }, [...path74, ...issue2.path]);
7214
+ processError({ issues: issue2.issues }, [...path75, ...issue2.path]);
7215
7215
  } else {
7216
- const fullpath = [...path74, ...issue2.path];
7216
+ const fullpath = [...path75, ...issue2.path];
7217
7217
  if (fullpath.length === 0) {
7218
7218
  result.errors.push(mapper(issue2));
7219
7219
  continue;
@@ -7252,8 +7252,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
7252
7252
  }
7253
7253
  function toDotPath(_path) {
7254
7254
  const segs = [];
7255
- const path74 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
7256
- for (const seg of path74) {
7255
+ const path75 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
7256
+ for (const seg of path75) {
7257
7257
  if (typeof seg === "number")
7258
7258
  segs.push(`[${seg}]`);
7259
7259
  else if (typeof seg === "symbol")
@@ -10030,9 +10030,9 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
10030
10030
  }
10031
10031
  const _out = def.transform(payload.value, payload);
10032
10032
  if (ctx.async) {
10033
- const output2 = _out instanceof Promise ? _out : Promise.resolve(_out);
10034
- return output2.then((output3) => {
10035
- payload.value = output3;
10033
+ const output3 = _out instanceof Promise ? _out : Promise.resolve(_out);
10034
+ return output3.then((output4) => {
10035
+ payload.value = output4;
10036
10036
  return payload;
10037
10037
  });
10038
10038
  }
@@ -10482,12 +10482,12 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
10482
10482
  output: inst._def.output
10483
10483
  });
10484
10484
  };
10485
- inst.output = (output2) => {
10485
+ inst.output = (output3) => {
10486
10486
  const F = inst.constructor;
10487
10487
  return new F({
10488
10488
  type: "function",
10489
10489
  input: inst._def.input,
10490
- output: output2
10490
+ output: output3
10491
10491
  });
10492
10492
  };
10493
10493
  return inst;
@@ -23896,14 +23896,14 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
23896
23896
  payload.issues.push(util_exports.issue(_issue));
23897
23897
  }
23898
23898
  };
23899
- const output2 = def.transform(payload.value, payload);
23900
- if (output2 instanceof Promise) {
23901
- return output2.then((output3) => {
23902
- payload.value = output3;
23899
+ const output3 = def.transform(payload.value, payload);
23900
+ if (output3 instanceof Promise) {
23901
+ return output3.then((output4) => {
23902
+ payload.value = output4;
23903
23903
  return payload;
23904
23904
  });
23905
23905
  }
23906
- payload.value = output2;
23906
+ payload.value = output3;
23907
23907
  return payload;
23908
23908
  };
23909
23909
  });
@@ -24355,13 +24355,13 @@ function resolveRef(ref, ctx) {
24355
24355
  if (!ref.startsWith("#")) {
24356
24356
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
24357
24357
  }
24358
- const path74 = ref.slice(1).split("/").filter(Boolean);
24359
- if (path74.length === 0) {
24358
+ const path75 = ref.slice(1).split("/").filter(Boolean);
24359
+ if (path75.length === 0) {
24360
24360
  return ctx.rootSchema;
24361
24361
  }
24362
24362
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
24363
- if (path74[0] === defsKey) {
24364
- const key = path74[1] === void 0 ? void 0 : decodeJSONPointerSegment(path74[1]);
24363
+ if (path75[0] === defsKey) {
24364
+ const key = path75[1] === void 0 ? void 0 : decodeJSONPointerSegment(path75[1]);
24365
24365
  if (!key || !ctx.defs[key]) {
24366
24366
  throw new Error(`Reference not found: ${ref}`);
24367
24367
  }
@@ -25372,6 +25372,9 @@ var HarnessSchema = external_exports.strictObject({
25372
25372
  localState: external_exports.record(external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/), SubfolderSchema).optional().describe(
25373
25373
  "Environment variable -> folder below the agent's own state folder (state\\<agent>) for SQLite databases. SQLite cannot run in a mapped folder, so the agent runs from a copy on the sandbox's disk (the variable points to it) that is copied from and back to that folder."
25374
25374
  ),
25375
+ bootReset: external_exports.array(SubfolderSchema).max(32).optional().describe(
25376
+ "Files and folders below the agent's own state folder (state\\<agent>) that only work on the machine that wrote them (keys sealed with Windows DPAPI, local accounts it created). Every sandbox is a new machine, so they are deleted at each boot and the agent sets them up again."
25377
+ ),
25375
25378
  resumeArguments: StringsSchema.optional().describe(
25376
25379
  "Arguments used when the agent is restarted in place (e.g. after an account switch) so it resumes the conversation."
25377
25380
  ),
@@ -25449,6 +25452,9 @@ var MappingSchema = external_exports.strictObject({
25449
25452
  optional: external_exports.boolean().optional().describe("true = skip it quietly when the host folder does not exist.")
25450
25453
  });
25451
25454
  var SandboxSchema = external_exports.strictObject({
25455
+ engine: external_exports.enum(["windows-sandbox", "hcs"]).describe(
25456
+ '(alpha) What runs the sandbox. "windows-sandbox" = Windows Sandbox (the default: desktop, Windows Terminal, GPU, clipboard, audio, printers). "hcs" = a headless Hyper-V isolated Server Core container for agents (no desktop, GPU or clipboard); it needs Windows features and an image on this PC (sandbox engine check hcs lists what is missing), and starting it is not enabled yet in this alpha. sandbox engine shows what each engine can do. Yours only: a project file (.sandbox-config.json) cannot set it.'
25457
+ ),
25452
25458
  memoryMb: external_exports.union([external_exports.literal("auto"), external_exports.number().int().min(2048)]).describe('Sandbox RAM in MB (>= 2048), or "auto": free RAM minus reserveHostMb, capped at maxMemoryMb.'),
25453
25459
  maxMemoryMb: external_exports.number().int().positive().describe('Upper limit for memoryMb "auto".'),
25454
25460
  maxMemoryPercent: external_exports.number().int().min(10).max(100).describe(`memoryMb "auto" never takes more than this share of this PC's total RAM (percent).`),
@@ -25458,10 +25464,22 @@ var SandboxSchema = external_exports.strictObject({
25458
25464
  pageFileMb: external_exports.number().int().min(0).max(262144).describe(
25459
25465
  `Size of the sandbox's paging file in MB, created at full size when it starts so it never grows while builds run (8 GB of its disk always stays free). Windows Sandbox starts with about 1 GB: parallel builds then fail with "The paging file is too small", and Windows grows the file under load. 0 = leave Windows' own.`
25460
25466
  ),
25461
- reserveHostMb: external_exports.number().int().nonnegative().describe('RAM always left for this PC when memoryMb is "auto".'),
25462
- vGpu: external_exports.boolean().describe("Virtual GPU. Off by default: Microsoft notes it widens the sandbox attack surface."),
25467
+ reserveHostMb: external_exports.number().int().nonnegative().describe(
25468
+ 'Memory always left for this PC when memoryMb is "auto": the sandbox gets at most (free RAM, and RAM plus paging file still unused) minus this.'
25469
+ ),
25470
+ agentMemoryHeadroomMb: external_exports.union([external_exports.literal("auto"), external_exports.literal("none"), external_exports.number().int().min(0)]).describe(
25471
+ 'Memory kept out of the agents reach inside the sandbox, in MB: everything the agents start (their builds, tests, tools) together may use at most the sandbox memory minus this; a runaway parallel build then gets out-of-memory errors in its own session instead of freezing or crashing the whole sandbox. "auto" = the larger of 2048 MB and 10 % of the sandbox memory; "none" = no limit. Yours only: a project file cannot change it.'
25472
+ ),
25473
+ pressureResponse: external_exports.boolean().describe(
25474
+ "When the sandbox (or this PC) runs low on memory, slow the heaviest build programs down (lower priority) and, if that is not enough, pause the biggest compiler for a few seconds at a time, so heavy parallel builds slow down instead of closing the sandbox. Never touches the agents themselves. Yours only: a project file cannot change it."
25475
+ ),
25476
+ vGpu: external_exports.boolean().describe(
25477
+ "Virtual GPU. Off by default: Microsoft notes it widens the sandbox attack surface. The sandbox then uses this PC's graphics card, and with some graphics drivers heavy use can freeze the whole PC: turn it on only when a program in the sandbox needs the GPU (the mesa toolchain gives software OpenGL without it)."
25478
+ ),
25463
25479
  networking: external_exports.boolean().describe("Internet access. false is the only hard network isolation Windows Sandbox offers."),
25464
- clipboard: external_exports.boolean().describe("Shared clipboard between this PC and the sandbox."),
25480
+ clipboard: external_exports.boolean().describe(
25481
+ "Shared clipboard between this PC and the sandbox. Also lets an agent's copy (in sandbox attach) reach this PC's clipboard."
25482
+ ),
25465
25483
  audioInput: external_exports.boolean().describe("Microphone access."),
25466
25484
  videoInput: external_exports.boolean().describe("Camera access."),
25467
25485
  printerRedirection: external_exports.boolean().describe("Printers from this PC."),
@@ -26583,18 +26601,18 @@ var WebSchema = external_exports.strictObject({
26583
26601
  });
26584
26602
 
26585
26603
  // src/core/schema/vpn.ts
26586
- var VPN_PROVIDERS = ["nordvpn", "openvpn-file"];
26604
+ var VPN_PROVIDERS = ["nordvpn", "openvpn-file", "wireguard-file"];
26587
26605
  var VpnSchema = external_exports.strictObject({
26588
26606
  enabled: external_exports.boolean().describe(
26589
26607
  "Send the sandbox's traffic through a VPN. Only the sandbox: your PC's own connection is untouched. Needs a saved login first (sandbox vpn login). The agent in the sandbox can read that login and can turn the tunnel off (it is the administrator there)."
26590
26608
  ),
26591
26609
  provider: external_exports.enum(VPN_PROVIDERS).describe(
26592
- "nordvpn: a recommended NordVPN server is picked at every launch. openvpn-file: your own .ovpn file (configFile)."
26610
+ "nordvpn: a recommended NordVPN server is picked at every launch. openvpn-file: your own .ovpn file (configFile). wireguard-file: your own WireGuard .conf (configFile), e.g. from your company."
26593
26611
  ),
26594
26612
  protocol: external_exports.enum(["udp", "tcp"]).describe("udp is faster; tcp gets through networks that block udp."),
26595
26613
  country: external_exports.string().regex(/^([A-Za-z][A-Za-z .'-]{0,39})?$/, "a country name or code like uk or Germany").describe("nordvpn: the country of the server, e.g. uk, us or Germany. Empty = the best server anywhere."),
26596
26614
  configFile: external_exports.string().describe(
26597
- "openvpn-file: the .ovpn file on this PC (its certificates inside it). Files that run programs (script-security, up, down, plugin ...) are refused. A project's file can never set this."
26615
+ "openvpn-file / wireguard-file: the .ovpn or .conf file on this PC (an .ovpn has its certificates inside it). Files that run programs (script-security, up, down, plugin, PostUp ...) are refused. A WireGuard file holds your private key: it is read when a sandbox starts and handed over in a one-shot file. A project's file can never set this."
26598
26616
  ),
26599
26617
  killSwitch: external_exports.boolean().describe(
26600
26618
  "Block all traffic that does not go through the tunnel: when the tunnel cannot start, the sandbox stays offline instead of using your normal connection. A project can only turn this on, never off."
@@ -26621,6 +26639,10 @@ var ConfigSchema = external_exports.strictObject({
26621
26639
  markSandboxFiles: external_exports.boolean().describe(
26622
26640
  `Programs and scripts (.exe, .ps1, .bat, .cmd, .msi, .lnk ...) that appear or change in your project while a sandbox runs get Windows' "downloaded from the internet" mark, so SmartScreen and PowerShell ask before they run on this PC.`
26623
26641
  ),
26642
+ contained: external_exports.enum(["off", "vhdx"]).describe(
26643
+ '(beta) Keep the sandbox tools, state and logs inside one disk image file (vhdx) instead of loose folders, so scanning programs on this PC see one file. Not yet tried on a real PC. Turn it on with sandbox storage contained on (it moves your files and asks first); Windows asks for permission to mount the image when a sandbox starts. "off" = loose folders, as always. Yours only: a project file (.sandbox-config.json) cannot set it.'
26644
+ ),
26645
+ containedMaxGb: external_exports.number().int().min(8).max(4096).describe("(beta) Largest size, in GB, the disk image of storage.contained may grow to."),
26624
26646
  warnDataGb: external_exports.number().min(0).describe(
26625
26647
  "Say at launch when the persisted data (tools, databases, logins) is bigger than this many GB; 0 = never. sandbox data shows what takes the space."
26626
26648
  )
@@ -26664,7 +26686,13 @@ var LocalOverridesSchema = external_exports.strictObject({
26664
26686
  "Scripts (.ps1 / .mjs / .cmd, relative to this file) run inside the sandbox before the agent."
26665
26687
  ),
26666
26688
  // This PC's resources are yours to share: CPU and paging file (this PC's disk) are not a project's to set.
26667
- sandbox: SandboxSchema.omit({ cpuLimit: true, pageFileMb: true }).partial(),
26689
+ sandbox: SandboxSchema.omit({
26690
+ cpuLimit: true,
26691
+ pageFileMb: true,
26692
+ engine: true,
26693
+ agentMemoryHeadroomMb: true,
26694
+ pressureResponse: true
26695
+ }).partial(),
26668
26696
  // A project may block more (the LAN, hosts); it never opens hosts, ports, DNS or a proxy.
26669
26697
  network: NetworkSchema.pick({ blockPrivateRanges: true, blockHosts: true }).partial(),
26670
26698
  // A project may turn the kill switch on, never off, and never choose a VPN, a server, a file or a login.
@@ -26773,8 +26801,34 @@ var GuestRequestSchema = external_exports.discriminatedUnion("kind", [
26773
26801
  cwd: Text().optional(),
26774
26802
  createdAt: TimeSchema
26775
26803
  }),
26776
- external_exports.strictObject({ kind: external_exports.literal("ping"), id: IdSchema, createdAt: TimeSchema })
26804
+ external_exports.strictObject({ kind: external_exports.literal("ping"), id: IdSchema, createdAt: TimeSchema }),
26805
+ /**
26806
+ * The PC's own memory or CPU is running low (the host watchdog): the sandbox slows its heaviest builds down for
26807
+ * `seconds` (it never stops them) so Windows does not have to close it. Repeated while the PC stays low.
26808
+ */
26809
+ external_exports.strictObject({
26810
+ kind: external_exports.literal("pressure"),
26811
+ id: IdSchema,
26812
+ reason: Text(300),
26813
+ seconds: external_exports.number().int().min(10).max(300),
26814
+ createdAt: TimeSchema
26815
+ })
26777
26816
  ]);
26817
+ var PressureStatusSchema = external_exports.object({
26818
+ level: external_exports.enum(["ok", "throttled", "suspending"]),
26819
+ profile: external_exports.enum(["normal", "gentle"]),
26820
+ /** Share of the sandbox's RAM still free and of its commit limit in use (percent). */
26821
+ ramFreePercent: external_exports.number().int().min(0).max(100),
26822
+ commitPercent: external_exports.number().int().min(0).max(100),
26823
+ /** Programs running at lower priority because of it. */
26824
+ lowered: external_exports.number().int().min(0).max(1024),
26825
+ /** Programs paused right now (name, process id, seconds left). */
26826
+ paused: external_exports.array(external_exports.object({ name: Text(64), pid: external_exports.number().int(), seconds: external_exports.number().int().min(0).max(60) })).max(8),
26827
+ /** The PC itself asked for slowing down (its memory or CPU is low). */
26828
+ pcLow: external_exports.boolean(),
26829
+ lastAction: Text(300),
26830
+ updatedAt: TimeSchema
26831
+ });
26778
26832
  var GuestResponseSchema = external_exports.object({
26779
26833
  id: IdSchema,
26780
26834
  ok: external_exports.boolean(),
@@ -26983,6 +27037,8 @@ var RunDir = class {
26983
27037
  root;
26984
27038
  sandboxFile;
26985
27039
  vpnFile;
27040
+ /** What the memory governor in the sandbox is doing (pressure.json). */
27041
+ pressureFile;
26986
27042
  requestsDir;
26987
27043
  responsesDir;
26988
27044
  sessionsDir;
@@ -26995,6 +27051,7 @@ var RunDir = class {
26995
27051
  this.root = path6.join(dataDir2, "run");
26996
27052
  this.sandboxFile = path6.join(this.root, "sandbox.json");
26997
27053
  this.vpnFile = path6.join(this.root, "vpn.json");
27054
+ this.pressureFile = path6.join(this.root, "pressure.json");
26998
27055
  this.requestsDir = path6.join(this.root, "requests");
26999
27056
  this.responsesDir = path6.join(this.root, "responses");
27000
27057
  this.sessionsDir = path6.join(this.root, "sessions");
@@ -27023,6 +27080,9 @@ var RunDir = class {
27023
27080
  readVpnStatus() {
27024
27081
  return readValid(VpnStatusSchema, this.vpnFile);
27025
27082
  }
27083
+ readPressure() {
27084
+ return readValid(PressureStatusSchema, this.pressureFile);
27085
+ }
27026
27086
  readSession(id) {
27027
27087
  return readValid(SessionStatusSchema, this.sessionFile(id));
27028
27088
  }
@@ -27146,6 +27206,7 @@ var SYSTEM = {
27146
27206
  shutdown: () => system32("shutdown.exe"),
27147
27207
  dism: () => system32("Dism.exe"),
27148
27208
  msiexec: () => system32("msiexec.exe"),
27209
+ sc: () => system32("sc.exe"),
27149
27210
  /** The .NET Framework C# compiler that ships with Windows (C# 5). */
27150
27211
  csc: () => path9.join(systemRoot(), "Microsoft.NET", "Framework64", "v4.0.30319", "csc.exe")
27151
27212
  };
@@ -27430,8 +27491,8 @@ function writeStatus(phase, message) {
27430
27491
  }
27431
27492
 
27432
27493
  // src/guest/boot/boot.ts
27433
- import fs58 from "node:fs";
27434
- import path72 from "node:path";
27494
+ import fs59 from "node:fs";
27495
+ import path73 from "node:path";
27435
27496
  import { spawn as spawn9 } from "node:child_process";
27436
27497
 
27437
27498
  // src/guest/boot/guide.ts
@@ -28764,7 +28825,8 @@ var SOURCES = {
28764
28825
  openssl: "OpenSsl.cs",
28765
28826
  cargoshim: "CargoShim.cs",
28766
28827
  linkgate: "LinkGate.cs",
28767
- pathsync: "PathSync.cs"
28828
+ pathsync: "PathSync.cs",
28829
+ memgov: "MemGov.cs"
28768
28830
  };
28769
28831
  function sourceOf(name) {
28770
28832
  return path30.join(launchDir, "sandbox", "csharp", SOURCES[name]);
@@ -31108,12 +31170,12 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
31108
31170
  }
31109
31171
  return result;
31110
31172
  }
31111
- function findNodeAtLocation(root, path74) {
31173
+ function findNodeAtLocation(root, path75) {
31112
31174
  if (!root) {
31113
31175
  return void 0;
31114
31176
  }
31115
31177
  let node2 = root;
31116
- for (let segment of path74) {
31178
+ for (let segment of path75) {
31117
31179
  if (typeof segment === "string") {
31118
31180
  if (node2.type !== "object" || !Array.isArray(node2.children)) {
31119
31181
  return void 0;
@@ -31467,14 +31529,14 @@ function getNodeType(value) {
31467
31529
 
31468
31530
  // node_modules/jsonc-parser/lib/esm/impl/edit.js
31469
31531
  function setProperty(text, originalPath, value, options) {
31470
- const path74 = originalPath.slice();
31532
+ const path75 = originalPath.slice();
31471
31533
  const errors = [];
31472
31534
  const root = parseTree(text, errors);
31473
31535
  let parent = void 0;
31474
31536
  let lastSegment = void 0;
31475
- while (path74.length > 0) {
31476
- lastSegment = path74.pop();
31477
- parent = findNodeAtLocation(root, path74);
31537
+ while (path75.length > 0) {
31538
+ lastSegment = path75.pop();
31539
+ parent = findNodeAtLocation(root, path75);
31478
31540
  if (parent === void 0 && value !== void 0) {
31479
31541
  if (typeof lastSegment === "string") {
31480
31542
  value = { [lastSegment]: value };
@@ -31660,8 +31722,8 @@ var ParseErrorCode;
31660
31722
  ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
31661
31723
  ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
31662
31724
  })(ParseErrorCode || (ParseErrorCode = {}));
31663
- function modify(text, path74, value, options) {
31664
- return setProperty(text, path74, value, options);
31725
+ function modify(text, path75, value, options) {
31726
+ return setProperty(text, path75, value, options);
31665
31727
  }
31666
31728
  function applyEdits(text, edits) {
31667
31729
  let sortedEdits = edits.slice(0).sort((a, b) => {
@@ -31902,6 +31964,16 @@ async function setupVscode(env, refresh) {
31902
31964
  import fs41 from "node:fs";
31903
31965
  import os8 from "node:os";
31904
31966
  import path51 from "node:path";
31967
+
31968
+ // src/shared/memory/policy.ts
31969
+ function cargoJobs(cpus, memoryGb, sessions) {
31970
+ const byCpu = Math.max(2, Math.min(4, Math.floor(cpus / 4)));
31971
+ const byMemory = Math.max(1, Math.floor(memoryGb / 4));
31972
+ const jobs = Math.min(byCpu, byMemory);
31973
+ return Math.max(1, Math.min(jobs, Math.floor(8 / Math.max(1, sessions))));
31974
+ }
31975
+
31976
+ // src/guest/toolchains/native/rust-extras.ts
31905
31977
  var cargoTarget = (targetDir) => {
31906
31978
  if (targetDir === "shared" || targetDir === "separate") return null;
31907
31979
  if (targetDir === "local") return path51.join(localDir, "cargo-target");
@@ -31936,7 +32008,7 @@ function linkGate(env, rust, host) {
31936
32008
  function cargoDefaults(host) {
31937
32009
  const file3 = tool("rust", "cargo", "config.toml");
31938
32010
  if (exists(file3) || !exists(path51.dirname(file3))) return;
31939
- const jobs = Math.max(2, Math.min(4, Math.floor(os8.cpus().length / 4)));
32011
+ const jobs = cargoJobs(os8.cpus().length, os8.totalmem() / 1024 ** 3, 1);
31940
32012
  const gnu = host.endsWith("-gnu");
31941
32013
  fs41.writeFileSync(
31942
32014
  file3,
@@ -32271,6 +32343,11 @@ function localStateEntries(agents2, stateDir2, localRoot2) {
32271
32343
  }))
32272
32344
  );
32273
32345
  }
32346
+ function bootResetPaths(agents2, stateDir2) {
32347
+ return Object.entries(agents2).flatMap(
32348
+ ([agent, harness]) => (harness.bootReset ?? []).map((rel) => ({ agent, path: path52.join(stateDir2, agent, rel) }))
32349
+ );
32350
+ }
32274
32351
  var isDatabaseFile = (name) => /\.(sqlite3?|db)(-wal|-shm)?$/i.test(name);
32275
32352
  var isCopyableDatabaseFile = (name) => isDatabaseFile(name) && !/-shm$/i.test(name);
32276
32353
 
@@ -32318,6 +32395,21 @@ function adoptLegacy(s) {
32318
32395
  for (const n of names) fs42.rmSync(path53.join(s.legacy, n), { force: true });
32319
32396
  log(s.agent + ": moved " + copyable.length + " database file(s) to " + s.store + ".");
32320
32397
  }
32398
+ function resetMachineBound() {
32399
+ if (dryRun) return;
32400
+ for (const { agent, path: target } of bootResetPaths(session.agents ?? {}, stateDir)) {
32401
+ try {
32402
+ const stat = fs42.lstatSync(target, { throwIfNoEntry: false });
32403
+ if (!stat || stat.isSymbolicLink()) continue;
32404
+ fs42.rmSync(target, { recursive: true, force: true });
32405
+ log(
32406
+ agent + ": removed " + path53.relative(path53.join(stateDir, agent), target) + " (it only worked in the last sandbox)."
32407
+ );
32408
+ } catch (e) {
32409
+ warn(agent + ": could not remove " + target + " (" + errMsg(e) + ").");
32410
+ }
32411
+ }
32412
+ }
32321
32413
  function restoreLocalState() {
32322
32414
  if (dryRun) return;
32323
32415
  for (const s of agentLocalStates()) {
@@ -33336,9 +33428,9 @@ function enableProcessAudit() {
33336
33428
 
33337
33429
  // src/guest/vpn/vpn.ts
33338
33430
  import dns2 from "node:dns";
33339
- import fs56 from "node:fs";
33340
- import os13 from "node:os";
33341
- import path70 from "node:path";
33431
+ import fs57 from "node:fs";
33432
+ import os14 from "node:os";
33433
+ import path71 from "node:path";
33342
33434
 
33343
33435
  // src/shared/vpn/ovpn.ts
33344
33436
  var PROGRAM_DIRECTIVES = [
@@ -33553,6 +33645,181 @@ function assertSafeOvpn(text, what) {
33553
33645
  );
33554
33646
  }
33555
33647
 
33648
+ // src/shared/vpn/wireguard.ts
33649
+ import net2 from "node:net";
33650
+ var MAX_WIREGUARD_BYTES = 16 * 1024;
33651
+ var MAX_LINES2 = 300;
33652
+ var MAX_PEERS = 16;
33653
+ var WIREGUARD_PROGRAM_KEYS = ["preup", "postup", "predown", "postdown", "table", "saveconfig"];
33654
+ var INTERFACE_KEYS = /* @__PURE__ */ new Set(["privatekey", "address", "dns", "mtu", "listenport"]);
33655
+ var PEER_KEYS = /* @__PURE__ */ new Set(["publickey", "presharedkey", "allowedips", "endpoint", "persistentkeepalive"]);
33656
+ var LIST_KEYS = /* @__PURE__ */ new Set(["address", "dns", "allowedips"]);
33657
+ var KEY = /^[A-Za-z0-9+/]{43}=$/;
33658
+ var HOST2 = /^(?:\d{1,3}(?:\.\d{1,3}){3}|[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?)$/;
33659
+ function validCidr(text) {
33660
+ const [addr, prefix, ...rest] = text.split("/");
33661
+ if (rest.length > 0 || !addr) return false;
33662
+ const version2 = net2.isIP(addr);
33663
+ if (version2 === 0) return false;
33664
+ if (prefix === void 0) return true;
33665
+ if (!/^\d{1,3}$/.test(prefix)) return false;
33666
+ return Number(prefix) <= (version2 === 4 ? 32 : 128);
33667
+ }
33668
+ var inRange = (text, low, high) => {
33669
+ if (!/^\d{1,5}$/.test(text)) return null;
33670
+ const n = Number(text);
33671
+ return n >= low && n <= high ? n : null;
33672
+ };
33673
+ var splitList = (text) => text.split(",").map((s) => s.trim()).filter(Boolean);
33674
+ function inspectWireguard(text) {
33675
+ const problems = [];
33676
+ const refuse = (message) => {
33677
+ if (problems.length < 20 && !problems.includes(message)) problems.push(message);
33678
+ };
33679
+ if (Buffer.byteLength(text, "utf8") > MAX_WIREGUARD_BYTES) return { ok: false, problems: ["the file is too big"] };
33680
+ if (text.includes("\0")) return { ok: false, problems: ["the file is not text"] };
33681
+ const lines = (text.charCodeAt(0) === 65279 ? text.slice(1) : text).split(/\r?\n/);
33682
+ if (lines.length > MAX_LINES2) return { ok: false, problems: ["the file has too many lines"] };
33683
+ const sections = [];
33684
+ let current = null;
33685
+ lines.forEach((raw, i) => {
33686
+ const at = "line " + (i + 1) + ": ";
33687
+ const line = raw.replace(/#.*$/, "").trim();
33688
+ if (!line) return;
33689
+ const header = /^\[([A-Za-z]{1,20})\]$/.exec(line);
33690
+ if (header) {
33691
+ const name = header[1].toLowerCase();
33692
+ if (name !== "interface" && name !== "peer") {
33693
+ current = null;
33694
+ return refuse(at + "[" + name + "] is not allowed");
33695
+ }
33696
+ current = { kind: name, values: /* @__PURE__ */ new Map() };
33697
+ sections.push(current);
33698
+ return;
33699
+ }
33700
+ const pair = /^([A-Za-z]{1,40})\s*=\s*(.*)$/.exec(line);
33701
+ if (!pair) return refuse(at + 'not a "Key = value" line');
33702
+ const key = pair[1].toLowerCase();
33703
+ if (WIREGUARD_PROGRAM_KEYS.includes(key))
33704
+ return refuse(at + pair[1] + " runs a program or changes how the tunnel is routed or saved");
33705
+ if (!current) return refuse(at + pair[1] + " is outside a section");
33706
+ if (!(current.kind === "interface" ? INTERFACE_KEYS : PEER_KEYS).has(key))
33707
+ return refuse(at + pair[1] + " is not on the list of settings that are safe to accept");
33708
+ const seen = current.values.get(key);
33709
+ if (seen && !LIST_KEYS.has(key)) return refuse(at + pair[1] + " is given twice");
33710
+ current.values.set(key, [...seen ?? [], pair[2].trim()]);
33711
+ });
33712
+ const one = (s, key) => s.values.get(key)?.[0];
33713
+ const joined = (s, key) => (s.values.get(key) ?? []).flatMap(splitList);
33714
+ const interfaces = sections.filter((s) => s.kind === "interface");
33715
+ const peers = sections.filter((s) => s.kind === "peer");
33716
+ if (interfaces.length !== 1) refuse("it needs exactly one [Interface] section");
33717
+ if (peers.length === 0) refuse("it has no [Peer] section");
33718
+ if (peers.length > MAX_PEERS) refuse("it has too many [Peer] sections");
33719
+ if (problems.length) return { ok: false, problems };
33720
+ const face = interfaces[0];
33721
+ const privateKey = one(face, "privatekey");
33722
+ if (!privateKey) refuse("[Interface] has no PrivateKey");
33723
+ else if (!KEY.test(privateKey)) refuse("PrivateKey is not a WireGuard key (44 characters of base64)");
33724
+ const addresses = joined(face, "address");
33725
+ if (addresses.length === 0 || !addresses.every(validCidr)) refuse("[Interface] needs valid Address values");
33726
+ else if (!addresses.some((a) => net2.isIPv4(a.split("/")[0])))
33727
+ refuse("Address needs an IPv4 address (the kill switch works on IPv4)");
33728
+ const dns3 = joined(face, "dns");
33729
+ if (!dns3.every((d) => net2.isIP(d) !== 0)) refuse("DNS may only list IP addresses");
33730
+ const mtuText = one(face, "mtu");
33731
+ const mtu = mtuText === void 0 ? void 0 : inRange(mtuText, 576, 1500);
33732
+ if (mtuText !== void 0 && mtu === null) refuse("MTU must be a number from 576 to 1500");
33733
+ const portText = one(face, "listenport");
33734
+ const listenPort = portText === void 0 ? void 0 : inRange(portText, 1, 65535);
33735
+ if (portText !== void 0 && listenPort === null) refuse("ListenPort must be a number from 1 to 65535");
33736
+ const checked = [];
33737
+ peers.forEach((p, n) => {
33738
+ const who = "[Peer] " + (n + 1) + ": ";
33739
+ const publicKey = one(p, "publickey");
33740
+ if (!publicKey || !KEY.test(publicKey)) return refuse(who + "PublicKey is missing or not a WireGuard key");
33741
+ const preshared = one(p, "presharedkey");
33742
+ if (preshared !== void 0 && !KEY.test(preshared)) return refuse(who + "PresharedKey is not a WireGuard key");
33743
+ const allowed = joined(p, "allowedips");
33744
+ if (allowed.length === 0 || !allowed.every(validCidr)) return refuse(who + "AllowedIPs is missing or invalid");
33745
+ const endpoint = one(p, "endpoint");
33746
+ const m = endpoint ? /^([^:[\]]+):(\d{1,5})$/.exec(endpoint) : null;
33747
+ if (!m || !HOST2.test(m[1]) || inRange(m[2], 1, 65535) === null)
33748
+ return refuse(who + "Endpoint must be host:port with a name or an IPv4 address");
33749
+ if (/^\d+\.\d+\.\d+\.\d+$/.test(m[1]) && !net2.isIPv4(m[1])) return refuse(who + "Endpoint is not a valid address");
33750
+ const keepText = one(p, "persistentkeepalive");
33751
+ let keepalive;
33752
+ if (keepText !== void 0 && keepText.toLowerCase() !== "off") {
33753
+ const k = inRange(keepText, 0, 65535);
33754
+ if (k === null) return refuse(who + "PersistentKeepalive must be a number or off");
33755
+ keepalive = k;
33756
+ }
33757
+ checked.push({
33758
+ publicKey,
33759
+ ...preshared ? { presharedKey: preshared } : {},
33760
+ allowedIps: allowed,
33761
+ endpointHost: m[1],
33762
+ endpointPort: Number(m[2]),
33763
+ ...keepalive !== void 0 ? { keepalive } : {}
33764
+ });
33765
+ });
33766
+ if (problems.length || !privateKey) return { ok: false, problems };
33767
+ return {
33768
+ ok: true,
33769
+ config: {
33770
+ privateKey,
33771
+ addresses,
33772
+ dns: dns3,
33773
+ ...typeof mtu === "number" ? { mtu } : {},
33774
+ ...typeof listenPort === "number" ? { listenPort } : {},
33775
+ peers: checked
33776
+ }
33777
+ };
33778
+ }
33779
+ function assertSafeWireguard(text, what) {
33780
+ const report = inspectWireguard(text);
33781
+ if (report.ok) return report.config;
33782
+ throw new Error(
33783
+ what + " was refused because it could run programs or is not a plain WireGuard config:\n - " + report.problems.slice(0, 5).join("\n - ")
33784
+ );
33785
+ }
33786
+ function renderWireguard(config2, endpointIps = {}) {
33787
+ const out = ["[Interface]", "PrivateKey = " + config2.privateKey, "Address = " + config2.addresses.join(", ")];
33788
+ if (config2.dns.length) out.push("DNS = " + config2.dns.join(", "));
33789
+ if (config2.mtu !== void 0) out.push("MTU = " + config2.mtu);
33790
+ if (config2.listenPort !== void 0) out.push("ListenPort = " + config2.listenPort);
33791
+ config2.peers.forEach((p, i) => {
33792
+ out.push("", "[Peer]", "PublicKey = " + p.publicKey);
33793
+ if (p.presharedKey) out.push("PresharedKey = " + p.presharedKey);
33794
+ out.push(
33795
+ "AllowedIPs = " + p.allowedIps.join(", "),
33796
+ "Endpoint = " + (endpointIps[i] ?? p.endpointHost) + ":" + p.endpointPort
33797
+ );
33798
+ if (p.keepalive !== void 0) out.push("PersistentKeepalive = " + p.keepalive);
33799
+ });
33800
+ return out.join("\r\n") + "\r\n";
33801
+ }
33802
+ function wireguardEndpoints(config2) {
33803
+ return config2.peers.map((p) => ({ host: p.endpointHost, port: p.endpointPort }));
33804
+ }
33805
+ function wireguardTunnelAddress(config2) {
33806
+ const found = config2.addresses.map((a) => a.split("/")[0]).find((a) => net2.isIPv4(a));
33807
+ if (!found) throw new Error("the config has no IPv4 address");
33808
+ return found;
33809
+ }
33810
+ function routesEverything(config2) {
33811
+ return config2.peers.some((p) => p.allowedIps.some((a) => a === "0.0.0.0/0"));
33812
+ }
33813
+ function serviceRunning(scOutput) {
33814
+ return /STATE\s*:\s*\d+\s+RUNNING/i.test(scOutput);
33815
+ }
33816
+ function handshakeDone(wgOutput) {
33817
+ return wgOutput.split(/\r?\n/).some((line) => {
33818
+ const t = /\s(\d+)\s*$/.exec(line);
33819
+ return t !== null && Number(t[1]) > 0;
33820
+ });
33821
+ }
33822
+
33556
33823
  // src/shared/vpn/kill-switch.ts
33557
33824
  var VPN_RULE_PREFIX = "AgentSandbox-VPN-";
33558
33825
  var rule = (name, extra) => [
@@ -33637,6 +33904,18 @@ var OPENVPN_MSI = {
33637
33904
  },
33638
33905
  base: "https://swupdate.openvpn.org/community/releases/"
33639
33906
  };
33907
+ var WIREGUARD_MSI = {
33908
+ version: "1.1.1",
33909
+ x64: {
33910
+ file: "wireguard-amd64-1.1.1.msi",
33911
+ sha256: "7bfed60ad61b785c914b38b61555a975488e1d3ec472dbfb2fcdf498fca75242"
33912
+ },
33913
+ arm64: {
33914
+ file: "wireguard-arm64-1.1.1.msi",
33915
+ sha256: "8336335c738d4aff040fa9d11b752da65a80b6f41d3262d6ba5e82f97ebd1bd4"
33916
+ },
33917
+ base: "https://download.wireguard.com/windows-client/"
33918
+ };
33640
33919
 
33641
33920
  // src/guest/vpn/openvpn.ts
33642
33921
  function openvpnExe(env = process.env) {
@@ -33740,6 +34019,111 @@ async function startTunnel(o) {
33740
34019
  }
33741
34020
  }
33742
34021
 
34022
+ // src/guest/vpn/wireguard.ts
34023
+ import { execFile } from "node:child_process";
34024
+ import crypto5 from "node:crypto";
34025
+ import fs56 from "node:fs";
34026
+ import os13 from "node:os";
34027
+ import path70 from "node:path";
34028
+ var WIREGUARD_TUNNEL = "sandbox";
34029
+ function wireguardDir(env = process.env) {
34030
+ return path70.join(env.ProgramFiles ?? "C:\\Program Files", "WireGuard");
34031
+ }
34032
+ function wireguardExe(env = process.env) {
34033
+ return path70.join(wireguardDir(env), "wireguard.exe");
34034
+ }
34035
+ function wireguardDownload(arch2 = process.arch) {
34036
+ const entry = arch2 === "arm64" ? WIREGUARD_MSI.arm64 : WIREGUARD_MSI.x64;
34037
+ return { ...entry, url: WIREGUARD_MSI.base + entry.file };
34038
+ }
34039
+ var hasHash2 = (file3, sha256) => crypto5.createHash("sha256").update(fs56.readFileSync(file3)).digest("hex") === sha256;
34040
+ async function ensureWireguard() {
34041
+ const exe = wireguardExe();
34042
+ if (!isWin || dryRun) return exe;
34043
+ if (exists(exe)) return exe;
34044
+ const dl = wireguardDownload();
34045
+ const msi = path70.join(mkdirp(path70.join(toolsDir, "downloads")), dl.file);
34046
+ if (!exists(msi) || !hasHash2(msi, dl.sha256)) {
34047
+ log("VPN: downloading WireGuard " + WIREGUARD_MSI.version + " (about 3 MB)");
34048
+ await downloader.file(dl.url, msi, dl.sha256);
34049
+ }
34050
+ log("VPN: installing WireGuard");
34051
+ const logFile2 = path70.join(toolsDir, "downloads", "wireguard-install.log");
34052
+ const code = await spawnAsync(
34053
+ SYSTEM.msiexec(),
34054
+ ["/i", msi, "/qn", "/norestart", "DO_NOT_LAUNCH=1", "/l*v", logFile2],
34055
+ {
34056
+ stdio: "ignore"
34057
+ }
34058
+ );
34059
+ if (code !== 0 && code !== 3010)
34060
+ throw new Error("The WireGuard installer failed (exit " + code + "). Its log: " + logFile2);
34061
+ if (!exists(exe))
34062
+ throw new Error("WireGuard was installed but " + exe + " is missing. The installer log: " + logFile2);
34063
+ return exe;
34064
+ }
34065
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
34066
+ function output2(file3, args) {
34067
+ return new Promise((resolve2) => {
34068
+ execFile(file3, args, { windowsHide: true, timeout: 15e3, maxBuffer: 1024 * 1024 }, (error62, stdout, stderr) => {
34069
+ const code = error62 ? typeof error62.code === "number" ? error62.code : -1 : 0;
34070
+ resolve2({ code, text: String(stdout) + String(stderr) });
34071
+ });
34072
+ });
34073
+ }
34074
+ var serviceName = () => "WireGuardTunnel$" + WIREGUARD_TUNNEL;
34075
+ var hasAdapter = (ip) => Object.values(os13.networkInterfaces()).some((list) => (list ?? []).some((i) => i.address === ip));
34076
+ async function removeWireguardTunnel(exe) {
34077
+ try {
34078
+ await output2(exe, ["/uninstalltunnelservice", WIREGUARD_TUNNEL]);
34079
+ } catch {
34080
+ }
34081
+ }
34082
+ async function startWireguardTunnel(o) {
34083
+ const root = path70.join(process.env.SystemRoot ?? "C:\\Windows", "Temp");
34084
+ const dir = fs56.mkdtempSync(path70.join(fs56.existsSync(root) ? root : os13.tmpdir(), "sbx-wg-"));
34085
+ const file3 = path70.join(dir, WIREGUARD_TUNNEL + ".conf");
34086
+ fs56.writeFileSync(file3, o.config, "utf8");
34087
+ const fail = async (message) => {
34088
+ await removeWireguardTunnel(o.exe);
34089
+ return { ok: false, message };
34090
+ };
34091
+ try {
34092
+ const install = await output2(o.exe, ["/installtunnelservice", file3]);
34093
+ if (install.code !== 0) return await fail("WireGuard could not install the tunnel (exit " + install.code + ")");
34094
+ const deadline = Date.now() + (o.timeoutMs ?? 6e4);
34095
+ for (; ; ) {
34096
+ const state = await output2(SYSTEM.sc(), ["query", serviceName()]);
34097
+ if (serviceRunning(state.text) && hasAdapter(o.tunnelIp)) {
34098
+ return { ok: true, message: "the tunnel service is running", tunnelIp: o.tunnelIp };
34099
+ }
34100
+ if (/STOPPED/i.test(state.text) || /1060/.test(state.text))
34101
+ return await fail("the WireGuard tunnel service stopped (check the config: keys, address, endpoint)");
34102
+ if (Date.now() > deadline)
34103
+ return await fail("the WireGuard tunnel did not start in time (the network driver may not work here)");
34104
+ await sleep(500);
34105
+ }
34106
+ } finally {
34107
+ fs56.rmSync(dir, { recursive: true, force: true });
34108
+ }
34109
+ }
34110
+ async function waitForHandshake(exe, poke, timeoutMs = 3e4) {
34111
+ const wg = path70.join(path70.dirname(exe), "wg.exe");
34112
+ if (!exists(wg)) return { ok: true, message: "the tunnel service is running (no wg.exe to check the handshake)" };
34113
+ const deadline = Date.now() + timeoutMs;
34114
+ for (; ; ) {
34115
+ await poke().catch(() => void 0);
34116
+ const shown = await output2(wg, ["show", WIREGUARD_TUNNEL, "latest-handshakes"]);
34117
+ if (shown.code === 0 && handshakeDone(shown.text)) return { ok: true, message: "the server answered" };
34118
+ if (Date.now() > deadline)
34119
+ return {
34120
+ ok: false,
34121
+ message: "the VPN server did not answer (check the endpoint, the keys and that its UDP port is reachable)"
34122
+ };
34123
+ await sleep(1e3);
34124
+ }
34125
+ }
34126
+
33743
34127
  // src/guest/vpn/vpn.ts
33744
34128
  function setVpnStatus(state, message, extra = {}) {
33745
34129
  try {
@@ -33766,6 +34150,20 @@ async function serverAddresses(remotes) {
33766
34150
  }
33767
34151
  return out;
33768
34152
  }
34153
+ async function wireguardServers(config2) {
34154
+ const endpointIps = {};
34155
+ const servers = [];
34156
+ const found = wireguardEndpoints(config2);
34157
+ for (let i = 0; i < found.length; i++) {
34158
+ const [ip] = await serverAddresses([{ host: found[i].host, port: found[i].port, proto: "udp" }]).then(
34159
+ (all) => all.map((s) => s.ip)
34160
+ );
34161
+ if (!ip) throw new Error("the VPN server address could not be found");
34162
+ endpointIps[i] = ip;
34163
+ servers.push({ ip, port: found[i].port, proto: "udp" });
34164
+ }
34165
+ return { servers, text: renderWireguard(config2, endpointIps) };
34166
+ }
33769
34167
  async function publicAddress() {
33770
34168
  try {
33771
34169
  const text = (await (await fetch("https://api.ipify.org", { signal: AbortSignal.timeout(1e4) })).text()).trim();
@@ -33774,7 +34172,7 @@ async function publicAddress() {
33774
34172
  return null;
33775
34173
  }
33776
34174
  }
33777
- var hasAdapter = (ip) => Object.values(os13.networkInterfaces()).some((list) => (list ?? []).some((i) => i.address === ip));
34175
+ var hasAdapter2 = (ip) => Object.values(os14.networkInterfaces()).some((list) => (list ?? []).some((i) => i.address === ip));
33778
34176
  async function setupVpn(secrets, ptyHostExe) {
33779
34177
  const vpn = session.vpn;
33780
34178
  if (!vpn) return true;
@@ -33788,25 +34186,53 @@ async function setupVpn(secrets, ptyHostExe) {
33788
34186
  setVpnStatus("starting", "Starting the VPN");
33789
34187
  try {
33790
34188
  if (!session.networking) throw new Error("networking is off for this sandbox");
33791
- const credentials = secrets.vpn;
33792
- if (!credentials) throw new Error("the VPN login did not arrive (start the sandbox again)");
33793
- const profile = path70.join(launchDir, "vpn", "server.ovpn");
33794
- const remotes = assertSafeOvpn(fs56.readFileSync(profile, "utf8"), vpn.server);
33795
- const exe = await ensureOpenVpn();
33796
- const servers = await serverAddresses(remotes);
33797
- if (servers.length === 0) throw new Error("the VPN server addresses could not be found");
33798
- if (killSwitch) block(servers);
33799
- if (dryRun || !isWin) {
33800
- log("(dry run) would start the VPN tunnel to " + vpn.server);
33801
- setVpnStatus("off", "dry run");
33802
- return true;
34189
+ let result;
34190
+ let wireguardExe2 = null;
34191
+ if (vpn.provider === "wireguard-file") {
34192
+ if (!secrets.wireguardConfig) throw new Error("the WireGuard config did not arrive (start the sandbox again)");
34193
+ const config2 = assertSafeWireguard(secrets.wireguardConfig, vpn.server);
34194
+ const exe = await ensureWireguard();
34195
+ const { servers, text } = await wireguardServers(config2);
34196
+ if (killSwitch && !routesEverything(config2))
34197
+ warn(
34198
+ "VPN: AllowedIPs does not include 0.0.0.0/0: with the kill switch on, only the tunnel traffic can leave the sandbox."
34199
+ );
34200
+ if (killSwitch) block(servers);
34201
+ if (dryRun || !isWin) {
34202
+ log("(dry run) would start the WireGuard tunnel " + vpn.server);
34203
+ setVpnStatus("off", "dry run");
34204
+ return true;
34205
+ }
34206
+ log("VPN: connecting with " + vpn.server);
34207
+ wireguardExe2 = exe;
34208
+ result = await startWireguardTunnel({ exe, config: text, tunnelIp: wireguardTunnelAddress(config2) });
34209
+ if (result.ok && result.tunnelIp && killSwitch) run2(tunnelCommands(result.tunnelIp));
34210
+ if (result.ok) result = await waitForHandshake(exe, publicAddress);
34211
+ } else {
34212
+ const credentials = secrets.vpn;
34213
+ if (!credentials) throw new Error("the VPN login did not arrive (start the sandbox again)");
34214
+ const profile = path71.join(launchDir, "vpn", "server.ovpn");
34215
+ const remotes = assertSafeOvpn(fs57.readFileSync(profile, "utf8"), vpn.server);
34216
+ const exe = await ensureOpenVpn();
34217
+ const servers = await serverAddresses(remotes);
34218
+ if (servers.length === 0) throw new Error("the VPN server addresses could not be found");
34219
+ if (killSwitch) block(servers);
34220
+ if (dryRun || !isWin) {
34221
+ log("(dry run) would start the VPN tunnel to " + vpn.server);
34222
+ setVpnStatus("off", "dry run");
34223
+ return true;
34224
+ }
34225
+ log("VPN: connecting to " + vpn.server);
34226
+ result = await startTunnel({ exe, profile, username: credentials.username, password: credentials.password });
34227
+ if (result.ok && result.tunnelIp && hasAdapter2(result.tunnelIp) && killSwitch)
34228
+ run2(tunnelCommands(result.tunnelIp));
33803
34229
  }
33804
- log("VPN: connecting to " + vpn.server);
33805
- const result = await startTunnel({ exe, profile, username: credentials.username, password: credentials.password });
33806
- if (!result.ok) throw new Error(result.message);
33807
- if (!result.tunnelIp || !hasAdapter(result.tunnelIp))
34230
+ if (!result.ok) {
34231
+ if (wireguardExe2) await removeWireguardTunnel(wireguardExe2);
34232
+ throw new Error(result.message);
34233
+ }
34234
+ if (!result.tunnelIp || !hasAdapter2(result.tunnelIp))
33808
34235
  throw new Error("the tunnel reported it was up, but no network adapter with its address appeared");
33809
- if (killSwitch) run2(tunnelCommands(result.tunnelIp));
33810
34236
  const publicIp = await publicAddress();
33811
34237
  log("VPN: up" + (publicIp ? " (the sandbox appears as " + publicIp + ")" : "") + ".");
33812
34238
  setVpnStatus("up", "The tunnel is up", publicIp ? { publicIp } : {});
@@ -33877,10 +34303,10 @@ var FrameReader = class {
33877
34303
  };
33878
34304
 
33879
34305
  // src/shared/pty/client.ts
33880
- import net2 from "node:net";
34306
+ import net3 from "node:net";
33881
34307
  var connectOnce = (host, port, timeoutMs) => {
33882
34308
  return new Promise((resolve2, reject) => {
33883
- const socket = net2.connect({ host, port });
34309
+ const socket = net3.connect({ host, port });
33884
34310
  const timer = setTimeout(() => {
33885
34311
  socket.destroy();
33886
34312
  reject(new Error("timed out connecting to " + host + ":" + port));
@@ -33916,7 +34342,14 @@ var KEPT_OSC = (body) => {
33916
34342
  return n <= 2 || n === 8 || n === 133 || n === 9 && body.startsWith(number4[1] + ";4;");
33917
34343
  };
33918
34344
  var MAX_KEPT_STRING = 4096;
34345
+ var MAX_CLIPBOARD_STRING = 1024 * 1024;
34346
+ var CLIPBOARD_WRITE = /^0{0,2}52;[cpqs0-7]{0,8};[A-Za-z0-9+/=]*$/;
33919
34347
  var OutputFilter = class {
34348
+ constructor(options = {}) {
34349
+ this.options = options;
34350
+ this.maxString = options.clipboardWrites ? MAX_CLIPBOARD_STRING : MAX_KEPT_STRING;
34351
+ }
34352
+ options;
33920
34353
  /**
33921
34354
  * text: normal output; esc: after ESC; c2: after a 0xC2 lead byte; string: inside an OSC/DCS/...; stringEsc /
33922
34355
  * stringC2: a possible terminator inside one.
@@ -33924,8 +34357,14 @@ var OutputFilter = class {
33924
34357
  state = "text";
33925
34358
  /** The string being read: an OSC worth keeping is collected until its terminator; null = being dropped. */
33926
34359
  body = null;
34360
+ maxString;
34361
+ /** An OSC that may pass: a short title, link, progress or mark, or (when allowed) a clipboard write. */
34362
+ kept(body) {
34363
+ if (this.options.clipboardWrites && CLIPBOARD_WRITE.test(body)) return true;
34364
+ return body.length <= MAX_KEPT_STRING && KEPT_OSC(body);
34365
+ }
33927
34366
  push(chunk) {
33928
- const out = Buffer.allocUnsafe(chunk.length + MAX_KEPT_STRING + 8);
34367
+ const out = Buffer.allocUnsafe(chunk.length + (this.body?.length ?? 0) + 8);
33929
34368
  let n = 0;
33930
34369
  const put = (...bytes) => {
33931
34370
  for (const b of bytes) out[n++] = b;
@@ -33945,7 +34384,7 @@ var OutputFilter = class {
33945
34384
  };
33946
34385
  const endString = (terminator) => {
33947
34386
  const body = this.body && Buffer.from(this.body).toString("latin1");
33948
- if (body !== null && KEPT_OSC(body)) {
34387
+ if (body !== null && this.kept(body)) {
33949
34388
  put(27, 93);
33950
34389
  out.write(body, n, "latin1");
33951
34390
  n += body.length;
@@ -33955,7 +34394,7 @@ var OutputFilter = class {
33955
34394
  this.state = "text";
33956
34395
  };
33957
34396
  const collect = (b) => {
33958
- if (this.body && this.body.push(b) > MAX_KEPT_STRING) this.body = null;
34397
+ if (this.body && this.body.push(b) > this.maxString) this.body = null;
33959
34398
  };
33960
34399
  for (const b of chunk) {
33961
34400
  switch (this.state) {
@@ -34105,7 +34544,7 @@ function runTerminalClient(socket, token, options = {}) {
34105
34544
  return new Promise((resolve2) => {
34106
34545
  let done = false;
34107
34546
  const reader = new FrameReader();
34108
- const filter = new OutputFilter();
34547
+ const filter = new OutputFilter({ clipboardWrites: options.clipboardWrites });
34109
34548
  let sent = size();
34110
34549
  let resizeTimer;
34111
34550
  let vtInput;
@@ -34222,14 +34661,14 @@ async function viewSession(id) {
34222
34661
  return 1;
34223
34662
  }
34224
34663
  const socket = await connect({ ...session2.attach, addresses: ["127.0.0.1"] });
34225
- const result = await runTerminalClient(socket, session2.attach.token);
34664
+ const result = await runTerminalClient(socket, session2.attach.token, { clipboardWrites: true });
34226
34665
  if (result.reason === "exit") console.log(session2.harness + " exited with code " + result.exitCode + ".");
34227
34666
  else if (result.reason === "error") console.log("Session error: " + result.message);
34228
34667
  return result.reason === "exit" ? result.exitCode : 1;
34229
34668
  }
34230
34669
 
34231
34670
  // src/guest/boot/boot-env.ts
34232
- import path71 from "node:path";
34671
+ import path72 from "node:path";
34233
34672
 
34234
34673
  // src/guest/boot/project-env.ts
34235
34674
  var EnvSchema = external_exports.object({
@@ -34248,7 +34687,7 @@ var BootEnvSchema = external_exports.object({
34248
34687
  });
34249
34688
 
34250
34689
  // src/guest/boot/boot-env.ts
34251
- var file2 = () => path71.join(localDir, "boot-env.json");
34690
+ var file2 = () => path72.join(localDir, "boot-env.json");
34252
34691
  function saveBootEnv(value) {
34253
34692
  try {
34254
34693
  writeJsonAtomic(file2(), value);
@@ -34277,7 +34716,7 @@ function saveProjectStatus(name, workspace2, phase, message, databases, summary)
34277
34716
  }
34278
34717
 
34279
34718
  // src/guest/runtime/secrets.ts
34280
- import fs57 from "node:fs";
34719
+ import fs58 from "node:fs";
34281
34720
 
34282
34721
  // src/shared/channel/secrets.ts
34283
34722
  var Environment = external_exports.record(external_exports.string().max(256), external_exports.string().max(65536));
@@ -34291,7 +34730,9 @@ var SecretsFileSchema = external_exports.strictObject({
34291
34730
  /** The login of this PC's Claude (claudeProfile.copyCredentials): the text of .credentials.json. */
34292
34731
  claudeCredentials: external_exports.string().max(1024 * 1024).optional(),
34293
34732
  /** VPN service credentials (vpn.provider's login), only for the launch's own sandbox. */
34294
- vpn: external_exports.strictObject({ username: external_exports.string().min(1).max(256), password: external_exports.string().min(1).max(1024) }).optional()
34733
+ vpn: external_exports.strictObject({ username: external_exports.string().min(1).max(256), password: external_exports.string().min(1).max(1024) }).optional(),
34734
+ /** The checked WireGuard config of vpn.provider wireguard-file (holds the private key). */
34735
+ wireguardConfig: external_exports.string().min(1).max(32 * 1024).optional()
34295
34736
  });
34296
34737
 
34297
34738
  // src/guest/runtime/secrets.ts
@@ -34301,12 +34742,12 @@ function takeSecrets(id) {
34301
34742
  const file3 = run.secretFile(id);
34302
34743
  let text;
34303
34744
  try {
34304
- if (fs57.statSync(file3).size > MAX_BYTES) throw new Error("too big");
34305
- text = fs57.readFileSync(file3, "utf8").replace(/^\uFEFF/, "");
34745
+ if (fs58.statSync(file3).size > MAX_BYTES) throw new Error("too big");
34746
+ text = fs58.readFileSync(file3, "utf8").replace(/^\uFEFF/, "");
34306
34747
  } catch {
34307
34748
  return {};
34308
34749
  } finally {
34309
- fs57.rmSync(file3, { force: true });
34750
+ fs58.rmSync(file3, { force: true });
34310
34751
  }
34311
34752
  try {
34312
34753
  const parsed = SecretsFileSchema.safeParse(JSON.parse(text));
@@ -34344,7 +34785,7 @@ async function soft(what, work) {
34344
34785
  }
34345
34786
  }
34346
34787
  function startDaemon(env, secrets) {
34347
- spawn9(process.execPath, [path72.join(path72.dirname(process.argv[1]), "daemon.js")], {
34788
+ spawn9(process.execPath, [path73.join(path73.dirname(process.argv[1]), "daemon.js")], {
34348
34789
  detached: true,
34349
34790
  stdio: "ignore",
34350
34791
  windowsHide: true,
@@ -34357,20 +34798,20 @@ function startDaemon(env, secrets) {
34357
34798
  }).unref();
34358
34799
  }
34359
34800
  function writeDbCommand() {
34360
- const dir = mkdirp(path72.join(localDir, "bin"));
34361
- const db = path72.join(path72.dirname(process.argv[1]), "db.js");
34362
- fs58.writeFileSync(
34363
- path72.join(dir, "sbx-db.cmd"),
34801
+ const dir = mkdirp(path73.join(localDir, "bin"));
34802
+ const db = path73.join(path73.dirname(process.argv[1]), "db.js");
34803
+ fs59.writeFileSync(
34804
+ path73.join(dir, "sbx-db.cmd"),
34364
34805
  '@setlocal\r\n@set AGENT_LOG_PREFIX=db\r\n@"' + process.execPath + '" "' + db + '" %*\r\n'
34365
34806
  );
34366
34807
  writeAgentCommands(dir);
34367
34808
  return dir;
34368
34809
  }
34369
34810
  function writeAgentCommands(dir) {
34370
- const install = { node: process.execPath, script: path72.join(path72.dirname(process.argv[1]), "agent.js") };
34811
+ const install = { node: process.execPath, script: path73.join(path73.dirname(process.argv[1]), "agent.js") };
34371
34812
  for (const shim3 of agentShims(toolsDir, session.agents ?? {}))
34372
- fs58.writeFileSync(path72.join(dir, shim3.command + ".cmd"), shimText(shim3, install));
34373
- fs58.writeFileSync(path72.join(dir, "sbx-agent.cmd"), sbxAgentText(install));
34813
+ fs59.writeFileSync(path73.join(dir, shim3.command + ".cmd"), shimText(shim3, install));
34814
+ fs59.writeFileSync(path73.join(dir, "sbx-agent.cmd"), sbxAgentText(install));
34374
34815
  }
34375
34816
  async function waitForPrimary() {
34376
34817
  for (let i = 0; i < PRIMARY_POLLS; i++) {
@@ -34398,7 +34839,7 @@ var Boot = class {
34398
34839
  log(
34399
34840
  "Agent sandbox: " + session.project + " | workspace " + workspace + " | agent " + session.harnessName + " | log " + logPath
34400
34841
  );
34401
- if (!fs58.statSync(workspace, { throwIfNoEntry: false })?.isDirectory())
34842
+ if (!fs59.statSync(workspace, { throwIfNoEntry: false })?.isDirectory())
34402
34843
  throw new Error("Workspace folder is missing in the sandbox: " + workspace);
34403
34844
  mkdirp(toolsDir);
34404
34845
  mkdirp(run.root);
@@ -34491,6 +34932,7 @@ var Boot = class {
34491
34932
  if (session.harnessName === "claude")
34492
34933
  await soft("Claude settings", () => syncClaudeProfile(this.secrets.claudeCredentials));
34493
34934
  await soft("claude-mem restore", restoreClaudeMem);
34935
+ await soft("Agent files of the last sandbox", resetMachineBound);
34494
34936
  await soft("Agent databases restore", restoreLocalState);
34495
34937
  await soft("Sandbox guide for the agent", () => writeGuides(tools.summary, this.lan));
34496
34938
  await soft("Claude managed settings", () => writeManagedSettings2(this.gitAccess));
@@ -34545,11 +34987,11 @@ runBoot().catch((e) => {
34545
34987
  const message = errMsg(e) + (e instanceof Error && e.stack ? "\n" + e.stack : "");
34546
34988
  try {
34547
34989
  setSandboxStatus("failed", errMsg(e));
34548
- fs59.writeFileSync(path73.join(logsDir, "guest-error.txt"), message);
34990
+ fs60.writeFileSync(path74.join(logsDir, "guest-error.txt"), message);
34549
34991
  } catch {
34550
34992
  }
34551
34993
  console.error(
34552
- "\n\x1B[31mThe sandbox could not start: " + errMsg(e) + "\x1B[0m\nDetails: " + path73.join(logsDir, "guest-error.txt")
34994
+ "\n\x1B[31mThe sandbox could not start: " + errMsg(e) + "\x1B[0m\nDetails: " + path74.join(logsDir, "guest-error.txt")
34553
34995
  );
34554
34996
  process.exitCode = 1;
34555
34997
  });