windows-development-sandbox 1.7.0 → 1.10.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 (432) hide show
  1. package/config.example.json +12 -1
  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 +49 -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 +20 -3
  82. package/dist/cli/commands/web.d.ts +5 -0
  83. package/dist/cli/commands/web.js +40 -0
  84. package/dist/cli/index.js +2 -1
  85. package/dist/cli/manifest.d.ts +72 -104
  86. package/dist/cli/manifest.js +64 -39
  87. package/dist/cli/menu/add-agent.d.ts +1 -1
  88. package/dist/cli/menu/add-agent.js +1 -1
  89. package/dist/cli/menu/apps.d.ts +7 -1
  90. package/dist/cli/menu/apps.js +36 -0
  91. package/dist/cli/menu/command-fields.d.ts +1 -1
  92. package/dist/cli/menu/command-form.js +2 -2
  93. package/dist/cli/menu/io-menu.d.ts +29 -0
  94. package/dist/cli/menu/io-menu.js +126 -0
  95. package/dist/cli/menu/live.d.ts +27 -0
  96. package/dist/cli/menu/live.js +69 -0
  97. package/dist/cli/menu/memory.d.ts +19 -0
  98. package/dist/cli/menu/memory.js +53 -0
  99. package/dist/cli/menu/menu.d.ts +10 -1
  100. package/dist/cli/menu/menu.js +27 -9
  101. package/dist/cli/menu/pages/agents-page.d.ts +3 -1
  102. package/dist/cli/menu/pages/agents-page.js +12 -5
  103. package/dist/cli/menu/pages/apps-page.d.ts +3 -1
  104. package/dist/cli/menu/pages/apps-page.js +19 -2
  105. package/dist/cli/menu/pages/list-page.d.ts +27 -0
  106. package/dist/cli/menu/pages/list-page.js +109 -7
  107. package/dist/cli/menu/pages/maintenance-page.d.ts +0 -5
  108. package/dist/cli/menu/pages/maintenance-page.js +17 -19
  109. package/dist/cli/menu/pages/sandbox-page.d.ts +4 -6
  110. package/dist/cli/menu/pages/sandbox-page.js +26 -118
  111. package/dist/cli/menu/pages/scopes.d.ts +1 -1
  112. package/dist/cli/menu/pages/sessions-page.d.ts +5 -11
  113. package/dist/cli/menu/pages/sessions-page.js +19 -88
  114. package/dist/cli/menu/pages/settings-page.d.ts +2 -10
  115. package/dist/cli/menu/pages/settings-page.js +64 -94
  116. package/dist/cli/menu/render-view.d.ts +28 -0
  117. package/dist/cli/menu/render-view.js +112 -0
  118. package/dist/cli/menu/settings/{path-kind.d.ts → ask-path.d.ts} +1 -7
  119. package/dist/cli/menu/settings/ask-path.js +14 -0
  120. package/dist/cli/menu/settings/collections/collection-editor.d.ts +1 -1
  121. package/dist/cli/menu/settings/collections/string-list-editor.d.ts +1 -2
  122. package/dist/cli/menu/settings/collections/string-list-editor.js +1 -1
  123. package/dist/cli/menu/settings/draft.d.ts +1 -1
  124. package/dist/cli/menu/settings/format.d.ts +1 -3
  125. package/dist/cli/menu/settings/format.js +6 -36
  126. package/dist/cli/menu/settings/index.d.ts +1 -3
  127. package/dist/cli/menu/settings/index.js +3 -3
  128. package/dist/cli/menu/settings/object-editor.d.ts +1 -1
  129. package/dist/cli/menu/settings/share.d.ts +36 -0
  130. package/dist/cli/menu/settings/share.js +131 -0
  131. package/dist/cli/menu/settings/value-editor.d.ts +5 -1
  132. package/dist/cli/menu/settings/value-editor.js +57 -54
  133. package/dist/cli/menu/several.js +1 -1
  134. package/dist/cli/menu/share-settings.d.ts +21 -0
  135. package/dist/cli/menu/share-settings.js +112 -0
  136. package/dist/cli/menu/shell.d.ts +21 -5
  137. package/dist/cli/menu/shell.js +31 -6
  138. package/dist/cli/menu/views.d.ts +7 -0
  139. package/dist/cli/menu/views.js +11 -0
  140. package/dist/cli/menu/vpn-login.js +8 -0
  141. package/dist/cli/operations/handler.d.ts +6 -0
  142. package/dist/cli/operations/handler.js +61 -0
  143. package/dist/cli/operations/index.d.ts +4 -0
  144. package/dist/cli/operations/index.js +5 -0
  145. package/dist/cli/operations/input.d.ts +6 -0
  146. package/dist/cli/operations/input.js +37 -0
  147. package/dist/cli/operations/io-cli.d.ts +7 -0
  148. package/dist/cli/operations/io-cli.js +62 -0
  149. package/dist/cli/operations/spec.d.ts +18 -0
  150. package/dist/cli/operations/spec.js +108 -0
  151. package/dist/cli/output/colors.d.ts +2 -2
  152. package/dist/cli/output/colors.js +2 -11
  153. package/dist/cli/output/index.d.ts +1 -0
  154. package/dist/cli/output/index.js +1 -0
  155. package/dist/cli/output/print.d.ts +3 -1
  156. package/dist/cli/output/print.js +7 -3
  157. package/dist/cli/output/progress.d.ts +15 -0
  158. package/dist/cli/output/progress.js +44 -0
  159. package/dist/cli/output/render-view.d.ts +4 -0
  160. package/dist/cli/output/render-view.js +63 -0
  161. package/dist/cli/services/agent-commands-service.d.ts +2 -0
  162. package/dist/cli/services/agent-commands-service.js +11 -2
  163. package/dist/cli/services/logs-service.js +4 -3
  164. package/dist/cli/tui/app.d.ts +6 -1
  165. package/dist/cli/tui/app.js +26 -4
  166. package/dist/cli/tui/list/list-screen.d.ts +14 -0
  167. package/dist/cli/tui/list/list-screen.js +64 -36
  168. package/dist/cli/tui/list/list-types.d.ts +2 -0
  169. package/dist/cli/tui/terminal.d.ts +7 -0
  170. package/dist/cli/tui/terminal.js +30 -10
  171. package/dist/core/config/defaults.js +9 -1
  172. package/dist/core/schema/config.d.ts +14 -0
  173. package/dist/core/schema/config.js +16 -1
  174. package/dist/core/schema/harness.d.ts +1 -0
  175. package/dist/core/schema/harness.js +5 -0
  176. package/dist/core/schema/sandbox.d.ts +6 -0
  177. package/dist/core/schema/sandbox.js +20 -3
  178. package/dist/core/schema/vpn.d.ts +2 -1
  179. package/dist/core/schema/vpn.js +4 -4
  180. package/dist/core/schema/web.d.ts +1 -0
  181. package/dist/core/schema/web.js +4 -1
  182. package/dist/core/types.d.ts +23 -5
  183. package/dist/core/util/fs.d.ts +2 -0
  184. package/dist/core/util/fs.js +9 -0
  185. package/dist/core/util/index.d.ts +1 -1
  186. package/dist/core/util/index.js +1 -1
  187. package/dist/guest/agents/agent-files.d.ts +5 -0
  188. package/dist/guest/agents/agent-files.js +4 -0
  189. package/dist/guest/agents/local-state.d.ts +2 -0
  190. package/dist/guest/agents/local-state.js +21 -1
  191. package/dist/guest/boot/boot.js +5 -2
  192. package/dist/guest/daemon/daemon.js +4 -0
  193. package/dist/guest/daemon/sessions.d.ts +5 -0
  194. package/dist/guest/daemon/sessions.js +17 -3
  195. package/dist/guest/entries/daemon.js +3 -0
  196. package/dist/guest/governor/decide.d.ts +71 -0
  197. package/dist/guest/governor/decide.js +211 -0
  198. package/dist/guest/governor/governor.d.ts +45 -0
  199. package/dist/guest/governor/governor.js +230 -0
  200. package/dist/guest/governor/index.d.ts +2 -0
  201. package/dist/guest/governor/index.js +2 -0
  202. package/dist/guest/network/firewall.d.ts +1 -0
  203. package/dist/guest/network/firewall.js +65 -23
  204. package/dist/guest/runtime/csc.d.ts +1 -0
  205. package/dist/guest/runtime/csc.js +1 -0
  206. package/dist/guest/runtime/process.js +53 -5
  207. package/dist/guest/sessions/viewer.js +3 -1
  208. package/dist/guest/setup/claude-mem.js +12 -4
  209. package/dist/guest/toolchains/languages/node.js +29 -3
  210. package/dist/guest/toolchains/native/rust-extras.js +4 -2
  211. package/dist/guest/vpn/vpn.js +69 -21
  212. package/dist/guest/vpn/wireguard.d.ts +32 -0
  213. package/dist/guest/vpn/wireguard.js +132 -0
  214. package/dist/host/agent-commands/commands.d.ts +4 -0
  215. package/dist/host/agent-commands/commands.js +31 -7
  216. package/dist/host/audit/log.d.ts +1 -1
  217. package/dist/host/channel/attach.d.ts +3 -1
  218. package/dist/host/channel/attach.js +5 -2
  219. package/dist/host/channel/channel.d.ts +2 -0
  220. package/dist/host/channel/channel.js +4 -0
  221. package/dist/host/engines/engine.d.ts +12 -0
  222. package/dist/host/engines/engine.js +1 -0
  223. package/dist/host/engines/hcs/check.d.ts +25 -0
  224. package/dist/host/engines/hcs/check.js +95 -0
  225. package/dist/host/engines/hcs/documents.d.ts +44 -0
  226. package/dist/host/engines/hcs/documents.js +155 -0
  227. package/dist/host/engines/hcs/engine.d.ts +39 -0
  228. package/dist/host/engines/hcs/engine.js +171 -0
  229. package/dist/host/engines/hcs/helper.d.ts +43 -0
  230. package/dist/host/engines/hcs/helper.js +173 -0
  231. package/dist/host/engines/hcs/images.d.ts +37 -0
  232. package/dist/host/engines/hcs/images.js +152 -0
  233. package/dist/host/engines/index.d.ts +7 -0
  234. package/dist/host/engines/index.js +5 -0
  235. package/dist/host/engines/registry.d.ts +16 -0
  236. package/dist/host/engines/registry.js +30 -0
  237. package/dist/host/engines/types.d.ts +58 -0
  238. package/dist/host/engines/types.js +1 -0
  239. package/dist/host/engines/windows-sandbox/engine.d.ts +16 -0
  240. package/dist/host/engines/windows-sandbox/engine.js +63 -0
  241. package/dist/host/engines/windows-sandbox/wsb-text.d.ts +2 -0
  242. package/dist/host/engines/windows-sandbox/wsb-text.js +29 -0
  243. package/dist/host/launch/generate.d.ts +5 -1
  244. package/dist/host/launch/generate.js +50 -8
  245. package/dist/host/launch/index.d.ts +3 -1
  246. package/dist/host/launch/index.js +3 -1
  247. package/dist/host/launch/launch-plan.d.ts +13 -0
  248. package/dist/host/launch/launch-plan.js +26 -0
  249. package/dist/host/launch/mappings.js +2 -1
  250. package/dist/host/launch/risk-notes.d.ts +10 -0
  251. package/dist/host/launch/risk-notes.js +18 -0
  252. package/dist/host/launch/session-file.d.ts +2 -0
  253. package/dist/host/launch/session-file.js +7 -1
  254. package/dist/host/launch/wsb-file.d.ts +28 -4
  255. package/dist/host/launch/wsb-file.js +61 -42
  256. package/dist/host/life/crash-report.d.ts +27 -1
  257. package/dist/host/life/crash-report.js +173 -7
  258. package/dist/host/life/host-memory.d.ts +41 -0
  259. package/dist/host/life/host-memory.js +140 -0
  260. package/dist/host/life/index.d.ts +2 -0
  261. package/dist/host/life/index.js +2 -0
  262. package/dist/host/life/stop-events.d.ts +2 -0
  263. package/dist/host/life/stop-events.js +20 -3
  264. package/dist/host/life/stop-warning.js +1 -1
  265. package/dist/host/life/watchdog.d.ts +56 -0
  266. package/dist/host/life/watchdog.js +124 -0
  267. package/dist/host/native.d.ts +3 -2
  268. package/dist/host/native.js +22 -3
  269. package/dist/host/profile/claude-login.js +3 -2
  270. package/dist/host/sandbox/contained-deps.d.ts +2 -0
  271. package/dist/host/sandbox/contained-deps.js +17 -0
  272. package/dist/host/sandbox/index.d.ts +2 -0
  273. package/dist/host/sandbox/index.js +2 -0
  274. package/dist/host/sandbox/platform.d.ts +2 -0
  275. package/dist/host/sandbox/platform.js +7 -7
  276. package/dist/host/sandbox/tasklist.d.ts +13 -0
  277. package/dist/host/sandbox/tasklist.js +47 -0
  278. package/dist/host/secrets/launch-secrets.js +2 -1
  279. package/dist/host/sharing/current.js +2 -6
  280. package/dist/host/storage/contained/check.d.ts +9 -0
  281. package/dist/host/storage/contained/check.js +37 -0
  282. package/dist/host/storage/contained/contained-storage.d.ts +66 -0
  283. package/dist/host/storage/contained/contained-storage.js +168 -0
  284. package/dist/host/storage/contained/disk-port.d.ts +43 -0
  285. package/dist/host/storage/contained/disk-port.js +122 -0
  286. package/dist/host/storage/contained/index.d.ts +9 -0
  287. package/dist/host/storage/contained/index.js +8 -0
  288. package/dist/host/storage/contained/layout.d.ts +28 -0
  289. package/dist/host/storage/contained/layout.js +45 -0
  290. package/dist/host/storage/contained/resolve.d.ts +4 -0
  291. package/dist/host/storage/contained/resolve.js +30 -0
  292. package/dist/host/storage/contained/setting.d.ts +1 -0
  293. package/dist/host/storage/contained/setting.js +5 -0
  294. package/dist/host/storage/contained/state.d.ts +89 -0
  295. package/dist/host/storage/contained/state.js +166 -0
  296. package/dist/host/storage/contained/transfer.d.ts +24 -0
  297. package/dist/host/storage/contained/transfer.js +121 -0
  298. package/dist/host/storage/index.d.ts +2 -0
  299. package/dist/host/storage/index.js +2 -0
  300. package/dist/host/storage/providers/contained.d.ts +15 -0
  301. package/dist/host/storage/providers/contained.js +39 -0
  302. package/dist/host/storage/providers/folder.d.ts +12 -0
  303. package/dist/host/storage/providers/folder.js +20 -0
  304. package/dist/host/storage/providers/index.d.ts +4 -0
  305. package/dist/host/storage/providers/index.js +3 -0
  306. package/dist/host/storage/providers/registry.d.ts +9 -0
  307. package/dist/host/storage/providers/registry.js +14 -0
  308. package/dist/host/storage/providers/types.d.ts +33 -0
  309. package/dist/host/storage/providers/types.js +1 -0
  310. package/dist/host/tools/conpty.js +3 -2
  311. package/dist/host/tools/windows-terminal.js +8 -7
  312. package/dist/host/vpn/index.d.ts +1 -1
  313. package/dist/host/vpn/index.js +1 -1
  314. package/dist/host/vpn/prepare.d.ts +2 -0
  315. package/dist/host/vpn/prepare.js +63 -2
  316. package/dist/host/web/browser.d.ts +2 -0
  317. package/dist/host/web/browser.js +14 -1
  318. package/dist/host/web/index.d.ts +3 -2
  319. package/dist/host/web/index.js +3 -2
  320. package/dist/host/web/rpc.d.ts +24 -0
  321. package/dist/host/web/rpc.js +149 -0
  322. package/dist/host/web/runner.d.ts +2 -0
  323. package/dist/host/web/runner.js +1 -2
  324. package/dist/host/web/server.d.ts +7 -0
  325. package/dist/host/web/server.js +23 -3
  326. package/dist/runtime/agent.js +83 -18
  327. package/dist/runtime/daemon.js +1805 -1221
  328. package/dist/runtime/db.js +83 -18
  329. package/dist/runtime/main.js +779 -219
  330. package/dist/runtime/netproxy.js +73 -11
  331. package/dist/runtime/view.js +91 -16
  332. package/dist/selftest/agent-paths.test.js +11 -1
  333. package/dist/selftest/app.test.d.ts +2 -0
  334. package/dist/selftest/app.test.js +324 -0
  335. package/dist/selftest/channel.test.js +13 -0
  336. package/dist/selftest/cli.test.js +2 -1
  337. package/dist/selftest/config.test.js +59 -0
  338. package/dist/selftest/contained.test.d.ts +2 -0
  339. package/dist/selftest/contained.test.js +544 -0
  340. package/dist/selftest/credentials.test.js +1 -1
  341. package/dist/selftest/engine.test.d.ts +2 -0
  342. package/dist/selftest/engine.test.js +127 -0
  343. package/dist/selftest/guest-boot.test.js +47 -1
  344. package/dist/selftest/hcs.test.d.ts +2 -0
  345. package/dist/selftest/hcs.test.js +482 -0
  346. package/dist/selftest/heavy-load.test.d.ts +2 -0
  347. package/dist/selftest/heavy-load.test.js +355 -0
  348. package/dist/selftest/index.js +12 -0
  349. package/dist/selftest/layout.test.js +12 -0
  350. package/dist/selftest/menu-perf.test.d.ts +2 -0
  351. package/dist/selftest/menu-perf.test.js +248 -0
  352. package/dist/selftest/menu-screens.js +4 -2
  353. package/dist/selftest/menu.test.js +36 -8
  354. package/dist/selftest/network.test.js +20 -1
  355. package/dist/selftest/support/engine-cases.d.ts +8 -0
  356. package/dist/selftest/support/engine-cases.js +65 -0
  357. package/dist/selftest/support/engine-golden.d.ts +3 -0
  358. package/dist/selftest/support/engine-golden.js +66 -0
  359. package/dist/selftest/support/fixtures.d.ts +8 -1
  360. package/dist/selftest/support/hcs-probes.d.ts +17 -0
  361. package/dist/selftest/support/hcs-probes.js +41 -0
  362. package/dist/selftest/vpn.test.js +136 -3
  363. package/dist/selftest/web.test.js +101 -3
  364. package/dist/shared/channel/run-dir.d.ts +4 -1
  365. package/dist/shared/channel/run-dir.js +7 -1
  366. package/dist/shared/channel/schema.d.ts +35 -1
  367. package/dist/shared/channel/schema.js +27 -0
  368. package/dist/shared/channel/secrets.d.ts +1 -0
  369. package/dist/shared/channel/secrets.js +6 -0
  370. package/dist/shared/io/copy-tree.d.ts +7 -0
  371. package/dist/shared/io/copy-tree.js +45 -0
  372. package/dist/shared/io/index.d.ts +2 -0
  373. package/dist/shared/io/index.js +2 -0
  374. package/dist/shared/io/robocopy-result.d.ts +6 -0
  375. package/dist/shared/io/robocopy-result.js +23 -0
  376. package/dist/shared/memory/index.d.ts +1 -0
  377. package/dist/shared/memory/index.js +1 -0
  378. package/dist/shared/memory/policy.d.ts +38 -0
  379. package/dist/shared/memory/policy.js +63 -0
  380. package/dist/shared/network/firewall-rules.d.ts +8 -0
  381. package/dist/shared/network/firewall-rules.js +28 -0
  382. package/dist/shared/pty/output-filter.d.ts +14 -1
  383. package/dist/shared/pty/output-filter.js +22 -4
  384. package/dist/shared/pty/terminal.d.ts +4 -1
  385. package/dist/shared/pty/terminal.js +4 -2
  386. package/dist/shared/system.d.ts +1 -0
  387. package/dist/shared/system.js +1 -0
  388. package/dist/shared/vpn/download.d.ts +16 -0
  389. package/dist/shared/vpn/download.js +16 -0
  390. package/dist/shared/vpn/wireguard.d.ts +51 -0
  391. package/dist/shared/vpn/wireguard.js +227 -0
  392. package/dist/sync/sync-cycle.js +5 -5
  393. package/dist/sync/watcher.d.ts +13 -0
  394. package/dist/sync/watcher.js +92 -3
  395. package/dist/web/index.html +4 -3
  396. package/dist/web/main-NRRS5O6Z.js +157 -0
  397. package/dist/web/main-T5DMCHYV.css +1 -0
  398. package/native/csharp/HcsHost/AssemblyInfo.cs +14 -0
  399. package/native/csharp/HcsHost/Guard.cs +100 -0
  400. package/native/csharp/HcsHost/Hcs.cs +256 -0
  401. package/native/csharp/HcsHost/Json.cs +78 -0
  402. package/native/csharp/HcsHost/Program.cs +185 -0
  403. package/native/csharp/HcsHost/VirtualDisk.cs +95 -0
  404. package/native/csharp/HostTools/AssemblyInfo.cs +14 -0
  405. package/native/csharp/HostTools/MemoryStatus.cs +128 -0
  406. package/native/csharp/HostTools/Program.cs +58 -17
  407. package/native/scripts/check-contained.ps1 +28 -0
  408. package/native/scripts/contained-common.ps1 +241 -0
  409. package/native/scripts/dismount-contained.ps1 +66 -0
  410. package/native/scripts/memory-status.ps1 +42 -0
  411. package/native/scripts/mount-contained.ps1 +139 -0
  412. package/native/scripts/run-elevated.ps1 +17 -4
  413. package/native/scripts/stop-events.ps1 +23 -8
  414. package/package.json +9 -2
  415. package/sandbox/csharp/MemGov.cs +466 -0
  416. package/sandbox/csharp/PtyHost.cs +111 -5
  417. package/sandbox/scripts/new-shortcuts.ps1 +3 -1
  418. package/schemas/config.schema.json +66 -8
  419. package/schemas/sandbox-config.schema.json +3 -3
  420. package/dist/cli/commands/sessions/control.d.ts +0 -4
  421. package/dist/cli/commands/sessions/control.js +0 -66
  422. package/dist/cli/commands/sessions/list.d.ts +0 -2
  423. package/dist/cli/commands/sessions/list.js +0 -48
  424. package/dist/cli/commands/sessions/status.d.ts +0 -4
  425. package/dist/cli/commands/sessions/status.js +0 -114
  426. package/dist/cli/commands/sessions/window.d.ts +0 -3
  427. package/dist/cli/commands/sessions/window.js +0 -18
  428. package/dist/cli/menu/settings/path-kind.js +0 -44
  429. package/dist/web/main-CXESL347.js +0 -45
  430. package/dist/web/main-VLR7DVQ4.css +0 -1
  431. /package/dist/{cli/menu/settings → app/kernel}/schema-node.d.ts +0 -0
  432. /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."),
@@ -26577,24 +26595,25 @@ var ResumeSchema = external_exports.strictObject({
26577
26595
  // src/core/schema/web.ts
26578
26596
  var WebSchema = external_exports.strictObject({
26579
26597
  enabled: external_exports.boolean().describe(
26580
- "(Beta) Allow the web UI: your sandbox sessions in a browser on this PC. Off by default, and nothing starts it by itself yet: sandbox web start works either way and runs it until sandbox web stop (or a restart of the PC)."
26598
+ "(Beta) The web UI: your sandbox sessions in a browser on this PC (http://127.0.0.1:<port>, this PC only). On: every sandbox start also starts it in the background (it keeps running until sandbox web stop or a restart of the PC). Off: only sandbox web start runs it. Open it signed in with sandbox web open."
26581
26599
  ),
26582
- port: external_exports.number().int().min(1024).max(65535).describe("Port of the web UI on 127.0.0.1 (this PC only). Pick another when it is taken.")
26600
+ port: external_exports.number().int().min(1024).max(65535).describe("Port of the web UI on 127.0.0.1 (this PC only). Pick another when it is taken."),
26601
+ openOnLaunch: external_exports.boolean().describe("(Beta) With the web UI on: open it in your browser, already signed in, every time a sandbox starts.")
26583
26602
  });
26584
26603
 
26585
26604
  // src/core/schema/vpn.ts
26586
- var VPN_PROVIDERS = ["nordvpn", "openvpn-file"];
26605
+ var VPN_PROVIDERS = ["nordvpn", "openvpn-file", "wireguard-file"];
26587
26606
  var VpnSchema = external_exports.strictObject({
26588
26607
  enabled: external_exports.boolean().describe(
26589
- "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)."
26608
+ "(Alpha: not yet tried on a real PC) 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
26609
  ),
26591
26610
  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)."
26611
+ "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
26612
  ),
26594
26613
  protocol: external_exports.enum(["udp", "tcp"]).describe("udp is faster; tcp gets through networks that block udp."),
26595
26614
  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
26615
  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."
26616
+ "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
26617
  ),
26599
26618
  killSwitch: external_exports.boolean().describe(
26600
26619
  "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 +26640,10 @@ var ConfigSchema = external_exports.strictObject({
26621
26640
  markSandboxFiles: external_exports.boolean().describe(
26622
26641
  `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
26642
  ),
26643
+ contained: external_exports.enum(["off", "vhdx"]).describe(
26644
+ '(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.'
26645
+ ),
26646
+ 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
26647
  warnDataGb: external_exports.number().min(0).describe(
26625
26648
  "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
26649
  )
@@ -26664,7 +26687,13 @@ var LocalOverridesSchema = external_exports.strictObject({
26664
26687
  "Scripts (.ps1 / .mjs / .cmd, relative to this file) run inside the sandbox before the agent."
26665
26688
  ),
26666
26689
  // 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(),
26690
+ sandbox: SandboxSchema.omit({
26691
+ cpuLimit: true,
26692
+ pageFileMb: true,
26693
+ engine: true,
26694
+ agentMemoryHeadroomMb: true,
26695
+ pressureResponse: true
26696
+ }).partial(),
26668
26697
  // A project may block more (the LAN, hosts); it never opens hosts, ports, DNS or a proxy.
26669
26698
  network: NetworkSchema.pick({ blockPrivateRanges: true, blockHosts: true }).partial(),
26670
26699
  // A project may turn the kill switch on, never off, and never choose a VPN, a server, a file or a login.
@@ -26773,8 +26802,34 @@ var GuestRequestSchema = external_exports.discriminatedUnion("kind", [
26773
26802
  cwd: Text().optional(),
26774
26803
  createdAt: TimeSchema
26775
26804
  }),
26776
- external_exports.strictObject({ kind: external_exports.literal("ping"), id: IdSchema, createdAt: TimeSchema })
26805
+ external_exports.strictObject({ kind: external_exports.literal("ping"), id: IdSchema, createdAt: TimeSchema }),
26806
+ /**
26807
+ * The PC's own memory or CPU is running low (the host watchdog): the sandbox slows its heaviest builds down for
26808
+ * `seconds` (it never stops them) so Windows does not have to close it. Repeated while the PC stays low.
26809
+ */
26810
+ external_exports.strictObject({
26811
+ kind: external_exports.literal("pressure"),
26812
+ id: IdSchema,
26813
+ reason: Text(300),
26814
+ seconds: external_exports.number().int().min(10).max(300),
26815
+ createdAt: TimeSchema
26816
+ })
26777
26817
  ]);
26818
+ var PressureStatusSchema = external_exports.object({
26819
+ level: external_exports.enum(["ok", "throttled", "suspending"]),
26820
+ profile: external_exports.enum(["normal", "gentle"]),
26821
+ /** Share of the sandbox's RAM still free and of its commit limit in use (percent). */
26822
+ ramFreePercent: external_exports.number().int().min(0).max(100),
26823
+ commitPercent: external_exports.number().int().min(0).max(100),
26824
+ /** Programs running at lower priority because of it. */
26825
+ lowered: external_exports.number().int().min(0).max(1024),
26826
+ /** Programs paused right now (name, process id, seconds left). */
26827
+ 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),
26828
+ /** The PC itself asked for slowing down (its memory or CPU is low). */
26829
+ pcLow: external_exports.boolean(),
26830
+ lastAction: Text(300),
26831
+ updatedAt: TimeSchema
26832
+ });
26778
26833
  var GuestResponseSchema = external_exports.object({
26779
26834
  id: IdSchema,
26780
26835
  ok: external_exports.boolean(),
@@ -26960,6 +27015,21 @@ function safeRemove(target, root) {
26960
27015
  fs3.rmSync(target, { recursive: true, force: true, maxRetries: 2 });
26961
27016
  }
26962
27017
 
27018
+ // src/shared/io/robocopy-result.ts
27019
+ function robocopyFailed(code) {
27020
+ return code === null || code >= 8;
27021
+ }
27022
+ function robocopyMeaning(code) {
27023
+ if (code === null) return "robocopy did not finish";
27024
+ if (code >= 16) return "robocopy stopped with a fatal error (bad path or no access)";
27025
+ if (code >= 8) return code & 1 ? "some files were copied and some could not be" : "files could not be copied";
27026
+ return code === 0 ? "nothing to copy" : "copied";
27027
+ }
27028
+ function robocopyErrors(output3, max = 3) {
27029
+ const lines = output3.split(/\r?\n/).map((l) => l.trim()).filter((l) => /\bERROR\b/.test(l) || /^The (process|system) cannot/i.test(l));
27030
+ return lines.slice(0, max).map((l) => l.length > 220 ? l.slice(0, 217) + "..." : l);
27031
+ }
27032
+
26963
27033
  // src/shared/channel/run-dir.ts
26964
27034
  function safeId(id) {
26965
27035
  return IdSchema.parse(id);
@@ -26983,6 +27053,8 @@ var RunDir = class {
26983
27053
  root;
26984
27054
  sandboxFile;
26985
27055
  vpnFile;
27056
+ /** What the memory governor in the sandbox is doing (pressure.json). */
27057
+ pressureFile;
26986
27058
  requestsDir;
26987
27059
  responsesDir;
26988
27060
  sessionsDir;
@@ -26995,6 +27067,7 @@ var RunDir = class {
26995
27067
  this.root = path6.join(dataDir2, "run");
26996
27068
  this.sandboxFile = path6.join(this.root, "sandbox.json");
26997
27069
  this.vpnFile = path6.join(this.root, "vpn.json");
27070
+ this.pressureFile = path6.join(this.root, "pressure.json");
26998
27071
  this.requestsDir = path6.join(this.root, "requests");
26999
27072
  this.responsesDir = path6.join(this.root, "responses");
27000
27073
  this.sessionsDir = path6.join(this.root, "sessions");
@@ -27023,6 +27096,9 @@ var RunDir = class {
27023
27096
  readVpnStatus() {
27024
27097
  return readValid(VpnStatusSchema, this.vpnFile);
27025
27098
  }
27099
+ readPressure() {
27100
+ return readValid(PressureStatusSchema, this.pressureFile);
27101
+ }
27026
27102
  readSession(id) {
27027
27103
  return readValid(SessionStatusSchema, this.sessionFile(id));
27028
27104
  }
@@ -27146,6 +27222,7 @@ var SYSTEM = {
27146
27222
  shutdown: () => system32("shutdown.exe"),
27147
27223
  dism: () => system32("Dism.exe"),
27148
27224
  msiexec: () => system32("msiexec.exe"),
27225
+ sc: () => system32("sc.exe"),
27149
27226
  /** The .NET Framework C# compiler that ships with Windows (C# 5). */
27150
27227
  csc: () => path9.join(systemRoot(), "Microsoft.NET", "Framework64", "v4.0.30319", "csc.exe")
27151
27228
  };
@@ -27430,8 +27507,8 @@ function writeStatus(phase, message) {
27430
27507
  }
27431
27508
 
27432
27509
  // src/guest/boot/boot.ts
27433
- import fs58 from "node:fs";
27434
- import path72 from "node:path";
27510
+ import fs59 from "node:fs";
27511
+ import path73 from "node:path";
27435
27512
  import { spawn as spawn9 } from "node:child_process";
27436
27513
 
27437
27514
  // src/guest/boot/guide.ts
@@ -27535,7 +27612,16 @@ function execOutput(file3, args, options = {}) {
27535
27612
  return result.status === 0 ? String(result.stdout ?? "").trim() : "";
27536
27613
  }
27537
27614
  function runScript(name, args = []) {
27538
- exec(SYSTEM.powershell(), scriptArgs(name, args));
27615
+ const result = spawnSync(SYSTEM.powershell(), scriptArgs(name, args), {
27616
+ stdio: ["inherit", "inherit", "pipe"],
27617
+ encoding: "utf8",
27618
+ windowsHide: true
27619
+ });
27620
+ if (result.error) throw result.error;
27621
+ const errors = String(result.stderr ?? "").trim();
27622
+ if (errors) process.stderr.write(errors + "\n");
27623
+ if (result.status !== 0)
27624
+ throw new Error(name + " failed with exit code " + result.status + (errors ? ": " + errors.slice(0, 400) : ""));
27539
27625
  }
27540
27626
  function scriptOutput(name, args = [], options = {}) {
27541
27627
  return execOutput(SYSTEM.powershell(), scriptArgs(name, args), options);
@@ -27561,14 +27647,40 @@ function robocopy(from, to, files = []) {
27561
27647
  fs12.copyFileSync(path15.join(from, f), path15.join(to, f));
27562
27648
  return;
27563
27649
  }
27564
- const what = files.length ? files : ["/E", "/MT:16"];
27565
- const result = spawnSync(
27566
- SYSTEM.robocopy(),
27567
- [from, to, ...what, "/NFL", "/NDL", "/NJH", "/NJS", "/NP", "/R:1", "/W:1", "/XJ"],
27568
- { stdio: "ignore", windowsHide: true }
27650
+ const what = files.length ? files : ["/E"];
27651
+ const passes = [
27652
+ ["/MT:16", "/R:1", "/W:1"],
27653
+ ["/MT:1", "/R:4", "/W:3"]
27654
+ ];
27655
+ let code = null;
27656
+ let output3 = "";
27657
+ for (const pass of passes) {
27658
+ const result = spawnSync(
27659
+ SYSTEM.robocopy(),
27660
+ [
27661
+ from,
27662
+ to,
27663
+ ...what,
27664
+ ...files.length ? [] : [pass[0]],
27665
+ pass[1],
27666
+ pass[2],
27667
+ "/NFL",
27668
+ "/NDL",
27669
+ "/NJH",
27670
+ "/NJS",
27671
+ "/NP",
27672
+ "/XJ"
27673
+ ],
27674
+ { encoding: "utf8", windowsHide: true }
27675
+ );
27676
+ code = result.status;
27677
+ output3 = String(result.stdout ?? "") + String(result.stderr ?? "");
27678
+ if (!robocopyFailed(code)) return;
27679
+ }
27680
+ const why = robocopyErrors(output3);
27681
+ throw new Error(
27682
+ "robocopy " + from + " -> " + to + " failed (exit " + code + ": " + robocopyMeaning(code) + ")" + (why.length ? ": " + why.join(" | ") : "")
27569
27683
  );
27570
- if ((result.status ?? 16) >= 8)
27571
- throw new Error("robocopy " + from + " -> " + to + " failed (exit " + result.status + ")");
27572
27684
  }
27573
27685
  function copyNode(from, to) {
27574
27686
  const work = stagingFolder(to);
@@ -28764,7 +28876,8 @@ var SOURCES = {
28764
28876
  openssl: "OpenSsl.cs",
28765
28877
  cargoshim: "CargoShim.cs",
28766
28878
  linkgate: "LinkGate.cs",
28767
- pathsync: "PathSync.cs"
28879
+ pathsync: "PathSync.cs",
28880
+ memgov: "MemGov.cs"
28768
28881
  };
28769
28882
  function sourceOf(name) {
28770
28883
  return path30.join(launchDir, "sandbox", "csharp", SOURCES[name]);
@@ -29928,6 +30041,10 @@ var ensureNvm = async () => {
29928
30041
  log("Downloading nvm-windows (" + asset.url.split("/").slice(-2, -1)[0] + ") ...");
29929
30042
  await downloader.archive(asset.url, NVM_HOME, { sha256: asset.sha256, locate: "nvm.exe", fileName: asset.name });
29930
30043
  };
30044
+ var hostNodeFolder = (version2) => {
30045
+ const dir = path45.join(hostToolsDir, "node");
30046
+ return session.hostTools.nodeVersion?.replace(/^v/, "") === version2 && exists(path45.join(dir, "node.exe")) ? dir : null;
30047
+ };
29931
30048
  var installNodeVersion = async (version2) => {
29932
30049
  const dir = path45.join(NVM_HOME, "v" + version2);
29933
30050
  const fromHost = path45.join(HOST_NVM, "v" + version2);
@@ -29937,6 +30054,12 @@ var installNodeVersion = async (version2) => {
29937
30054
  copyNode(fromHost, dir);
29938
30055
  return;
29939
30056
  }
30057
+ const hostNode = hostNodeFolder(version2);
30058
+ if (hostNode) {
30059
+ log("Copying Node " + version2 + " from this PC (without global packages) ...");
30060
+ copyNode(hostNode, dir);
30061
+ return;
30062
+ }
29940
30063
  log("Downloading Node " + version2 + " (~30 MB once) ...");
29941
30064
  mkdirp(NVM_TEMP);
29942
30065
  let out;
@@ -29945,8 +30068,13 @@ var installNodeVersion = async (version2) => {
29945
30068
  } finally {
29946
30069
  safeRemove(NVM_TEMP, NVM_HOME);
29947
30070
  }
29948
- if (!exists(path45.join(dir, "node.exe")))
29949
- throw new Error("nvm install " + version2 + " failed: " + out.trim().split("\n").slice(-2).join(" "));
30071
+ if (!exists(path45.join(dir, "node.exe"))) {
30072
+ const tail2 = out.trim().split(/\r?\n/).filter(Boolean).slice(-3).join(" ");
30073
+ const why = /complete/i.test(out) ? "nvm said it finished, but its move into the data folder did not happen" : "nvm could not download or unpack it: check the internet connection and the free disk space";
30074
+ throw new Error(
30075
+ "nvm install " + version2 + " did not leave " + path45.join(dir, "node.exe") + " (" + why + ")" + (tail2 ? ". nvm printed: " + tail2 : "")
30076
+ );
30077
+ }
29950
30078
  };
29951
30079
  var activate = async (version2) => {
29952
30080
  await nvm(["use", version2]);
@@ -31108,12 +31236,12 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
31108
31236
  }
31109
31237
  return result;
31110
31238
  }
31111
- function findNodeAtLocation(root, path74) {
31239
+ function findNodeAtLocation(root, path75) {
31112
31240
  if (!root) {
31113
31241
  return void 0;
31114
31242
  }
31115
31243
  let node2 = root;
31116
- for (let segment of path74) {
31244
+ for (let segment of path75) {
31117
31245
  if (typeof segment === "string") {
31118
31246
  if (node2.type !== "object" || !Array.isArray(node2.children)) {
31119
31247
  return void 0;
@@ -31467,14 +31595,14 @@ function getNodeType(value) {
31467
31595
 
31468
31596
  // node_modules/jsonc-parser/lib/esm/impl/edit.js
31469
31597
  function setProperty(text, originalPath, value, options) {
31470
- const path74 = originalPath.slice();
31598
+ const path75 = originalPath.slice();
31471
31599
  const errors = [];
31472
31600
  const root = parseTree(text, errors);
31473
31601
  let parent = void 0;
31474
31602
  let lastSegment = void 0;
31475
- while (path74.length > 0) {
31476
- lastSegment = path74.pop();
31477
- parent = findNodeAtLocation(root, path74);
31603
+ while (path75.length > 0) {
31604
+ lastSegment = path75.pop();
31605
+ parent = findNodeAtLocation(root, path75);
31478
31606
  if (parent === void 0 && value !== void 0) {
31479
31607
  if (typeof lastSegment === "string") {
31480
31608
  value = { [lastSegment]: value };
@@ -31660,8 +31788,8 @@ var ParseErrorCode;
31660
31788
  ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
31661
31789
  ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
31662
31790
  })(ParseErrorCode || (ParseErrorCode = {}));
31663
- function modify(text, path74, value, options) {
31664
- return setProperty(text, path74, value, options);
31791
+ function modify(text, path75, value, options) {
31792
+ return setProperty(text, path75, value, options);
31665
31793
  }
31666
31794
  function applyEdits(text, edits) {
31667
31795
  let sortedEdits = edits.slice(0).sort((a, b) => {
@@ -31902,6 +32030,16 @@ async function setupVscode(env, refresh) {
31902
32030
  import fs41 from "node:fs";
31903
32031
  import os8 from "node:os";
31904
32032
  import path51 from "node:path";
32033
+
32034
+ // src/shared/memory/policy.ts
32035
+ function cargoJobs(cpus, memoryGb, sessions) {
32036
+ const byCpu = Math.max(2, Math.min(4, Math.floor(cpus / 4)));
32037
+ const byMemory = Math.max(1, Math.floor(memoryGb / 4));
32038
+ const jobs = Math.min(byCpu, byMemory);
32039
+ return Math.max(1, Math.min(jobs, Math.floor(8 / Math.max(1, sessions))));
32040
+ }
32041
+
32042
+ // src/guest/toolchains/native/rust-extras.ts
31905
32043
  var cargoTarget = (targetDir) => {
31906
32044
  if (targetDir === "shared" || targetDir === "separate") return null;
31907
32045
  if (targetDir === "local") return path51.join(localDir, "cargo-target");
@@ -31936,7 +32074,7 @@ function linkGate(env, rust, host) {
31936
32074
  function cargoDefaults(host) {
31937
32075
  const file3 = tool("rust", "cargo", "config.toml");
31938
32076
  if (exists(file3) || !exists(path51.dirname(file3))) return;
31939
- const jobs = Math.max(2, Math.min(4, Math.floor(os8.cpus().length / 4)));
32077
+ const jobs = cargoJobs(os8.cpus().length, os8.totalmem() / 1024 ** 3, 1);
31940
32078
  const gnu = host.endsWith("-gnu");
31941
32079
  fs41.writeFileSync(
31942
32080
  file3,
@@ -32271,6 +32409,11 @@ function localStateEntries(agents2, stateDir2, localRoot2) {
32271
32409
  }))
32272
32410
  );
32273
32411
  }
32412
+ function bootResetPaths(agents2, stateDir2) {
32413
+ return Object.entries(agents2).flatMap(
32414
+ ([agent, harness]) => (harness.bootReset ?? []).map((rel) => ({ agent, path: path52.join(stateDir2, agent, rel) }))
32415
+ );
32416
+ }
32274
32417
  var isDatabaseFile = (name) => /\.(sqlite3?|db)(-wal|-shm)?$/i.test(name);
32275
32418
  var isCopyableDatabaseFile = (name) => isDatabaseFile(name) && !/-shm$/i.test(name);
32276
32419
 
@@ -32318,6 +32461,21 @@ function adoptLegacy(s) {
32318
32461
  for (const n of names) fs42.rmSync(path53.join(s.legacy, n), { force: true });
32319
32462
  log(s.agent + ": moved " + copyable.length + " database file(s) to " + s.store + ".");
32320
32463
  }
32464
+ function resetMachineBound() {
32465
+ if (dryRun) return;
32466
+ for (const { agent, path: target } of bootResetPaths(session.agents ?? {}, stateDir)) {
32467
+ try {
32468
+ const stat = fs42.lstatSync(target, { throwIfNoEntry: false });
32469
+ if (!stat || stat.isSymbolicLink()) continue;
32470
+ fs42.rmSync(target, { recursive: true, force: true });
32471
+ log(
32472
+ agent + ": removed " + path53.relative(path53.join(stateDir, agent), target) + " (it only worked in the last sandbox)."
32473
+ );
32474
+ } catch (e) {
32475
+ warn(agent + ": could not remove " + target + " (" + errMsg(e) + ").");
32476
+ }
32477
+ }
32478
+ }
32321
32479
  function restoreLocalState() {
32322
32480
  if (dryRun) return;
32323
32481
  for (const s of agentLocalStates()) {
@@ -32950,9 +33108,31 @@ function buildFirewallCommands(exemptIps) {
32950
33108
  }
32951
33109
  return commands;
32952
33110
  }
33111
+ var ATTACH_RULE = "AgentSandbox-Attach";
33112
+ function hasShortName(file3) {
33113
+ return file3.split(/[/\\]/).some((part) => /~\d/.test(part));
33114
+ }
33115
+ function attachRuleCommands(ptyHostExe) {
33116
+ return [
33117
+ ["advfirewall", "firewall", "delete", "rule", "name=" + ATTACH_RULE],
33118
+ [
33119
+ "advfirewall",
33120
+ "firewall",
33121
+ "add",
33122
+ "rule",
33123
+ "name=" + ATTACH_RULE,
33124
+ "dir=in",
33125
+ "action=allow",
33126
+ "enable=yes",
33127
+ "profile=any",
33128
+ "protocol=tcp",
33129
+ "remoteip=LocalSubnet",
33130
+ "program=" + ptyHostExe
33131
+ ]
33132
+ ];
33133
+ }
32953
33134
 
32954
33135
  // src/guest/network/firewall.ts
32955
- var ATTACH_RULE = "AgentSandbox-Attach";
32956
33136
  var netsh = (args) => {
32957
33137
  const r = spawnSync5(SYSTEM.netsh(), args, { encoding: "utf8", windowsHide: true });
32958
33138
  return { status: r.status, out: (r.stdout ?? "") + (r.stderr ?? "") };
@@ -32986,23 +33166,38 @@ var waitForInternet = async (seconds) => {
32986
33166
  }
32987
33167
  return false;
32988
33168
  };
32989
- var attachRule = (ptyHostExe) => [
32990
- ["advfirewall", "firewall", "delete", "rule", "name=" + ATTACH_RULE],
32991
- [
32992
- "advfirewall",
32993
- "firewall",
32994
- "add",
32995
- "rule",
32996
- "name=" + ATTACH_RULE,
32997
- "dir=in",
32998
- "action=allow",
32999
- "enable=yes",
33000
- "profile=any",
33001
- "protocol=tcp",
33002
- "remoteip=LocalSubnet",
33003
- "program=" + ptyHostExe
33004
- ]
33005
- ];
33169
+ var problems = [];
33170
+ function networkProblems() {
33171
+ return problems;
33172
+ }
33173
+ var longPath = (file3) => {
33174
+ if (!hasShortName(file3)) return file3;
33175
+ try {
33176
+ return fs48.realpathSync.native(file3);
33177
+ } catch {
33178
+ return file3;
33179
+ }
33180
+ };
33181
+ async function applyAttachRule(ptyHostExe) {
33182
+ if (!session.attach.enabled) return;
33183
+ if (!ptyHostExe) {
33184
+ problems.push("attach: the session host was not built, so the firewall rule for it was not created");
33185
+ warn(problems[problems.length - 1]);
33186
+ return;
33187
+ }
33188
+ let last = "";
33189
+ for (let attempt = 1; attempt <= 3; attempt++) {
33190
+ try {
33191
+ run2(attachRuleCommands(longPath(ptyHostExe)));
33192
+ return;
33193
+ } catch (e) {
33194
+ last = errMsg(e);
33195
+ if (attempt < 3) await new Promise((r) => setTimeout(r, 1e3));
33196
+ }
33197
+ }
33198
+ problems.push("attach: the firewall rule for the session host could not be created (" + last + ")");
33199
+ warn("PROTECTION MISSING: " + problems[problems.length - 1]);
33200
+ }
33006
33201
  function run2(commands) {
33007
33202
  for (const c of commands) {
33008
33203
  const r = netsh(c);
@@ -33018,10 +33213,11 @@ async function applyNetworkPolicy(ptyHostExe) {
33018
33213
  const block = session.network.blockPrivateRanges;
33019
33214
  const exempt = block ? discoverExemptIps() : [];
33020
33215
  const lanRules = block ? buildFirewallCommands(exempt) : [];
33216
+ const forwardRules = forwardRule();
33021
33217
  const commands = [
33022
33218
  ...lanRules,
33023
- ...ptyHostExe && session.attach.enabled ? attachRule(ptyHostExe) : [],
33024
- ...forwardRule()
33219
+ ...ptyHostExe && session.attach.enabled ? attachRuleCommands(ptyHostExe) : [],
33220
+ ...forwardRules
33025
33221
  ];
33026
33222
  if (isWin && !dryRun) {
33027
33223
  try {
@@ -33047,7 +33243,20 @@ async function applyNetworkPolicy(ptyHostExe) {
33047
33243
  }
33048
33244
  if (commands.length === 0) return "open";
33049
33245
  const online = block ? await waitForInternet(30) : true;
33050
- run2(commands);
33246
+ const failures = [];
33247
+ try {
33248
+ run2(lanRules);
33249
+ } catch (e) {
33250
+ failures.push(errMsg(e));
33251
+ }
33252
+ await applyAttachRule(ptyHostExe);
33253
+ try {
33254
+ run2(forwardRules);
33255
+ } catch (e) {
33256
+ problems.push("forwardPorts: the firewall rule for the relays could not be created (" + errMsg(e) + ")");
33257
+ warn("PROTECTION MISSING: " + problems[problems.length - 1]);
33258
+ }
33259
+ if (failures.length) throw new Error(failures[0]);
33051
33260
  if (!block) return "open";
33052
33261
  if (online && !await waitForInternet(15)) {
33053
33262
  run2(lanRules.filter((c) => c[2] === "delete"));
@@ -33336,9 +33545,9 @@ function enableProcessAudit() {
33336
33545
 
33337
33546
  // src/guest/vpn/vpn.ts
33338
33547
  import dns2 from "node:dns";
33339
- import fs56 from "node:fs";
33340
- import os13 from "node:os";
33341
- import path70 from "node:path";
33548
+ import fs57 from "node:fs";
33549
+ import os14 from "node:os";
33550
+ import path71 from "node:path";
33342
33551
 
33343
33552
  // src/shared/vpn/ovpn.ts
33344
33553
  var PROGRAM_DIRECTIVES = [
@@ -33492,10 +33701,10 @@ function directiveOf(line) {
33492
33701
  return { name: parts2[0].toLowerCase(), args: parts2.slice(1) };
33493
33702
  }
33494
33703
  function inspectOvpn(text) {
33495
- const problems = [];
33704
+ const problems2 = [];
33496
33705
  const found = [];
33497
33706
  const refuse = (message) => {
33498
- if (problems.length < 20 && !problems.includes(message)) problems.push(message);
33707
+ if (problems2.length < 20 && !problems2.includes(message)) problems2.push(message);
33499
33708
  };
33500
33709
  if (Buffer.byteLength(text, "utf8") > MAX_OVPN_BYTES) return { ok: false, problems: ["the file is too big"] };
33501
33710
  if (text.includes("\0")) return { ok: false, problems: ["the file is not text"] };
@@ -33543,7 +33752,7 @@ function inspectOvpn(text) {
33543
33752
  if (block) refuse("a <" + block + "> section is never closed");
33544
33753
  if (remotes.length === 0) refuse("it names no remote server");
33545
33754
  if (remotes.length > 64) refuse("it names too many servers");
33546
- return problems.length ? { ok: false, problems } : { ok: true, remotes };
33755
+ return problems2.length ? { ok: false, problems: problems2 } : { ok: true, remotes };
33547
33756
  }
33548
33757
  function assertSafeOvpn(text, what) {
33549
33758
  const report = inspectOvpn(text);
@@ -33553,6 +33762,181 @@ function assertSafeOvpn(text, what) {
33553
33762
  );
33554
33763
  }
33555
33764
 
33765
+ // src/shared/vpn/wireguard.ts
33766
+ import net2 from "node:net";
33767
+ var MAX_WIREGUARD_BYTES = 16 * 1024;
33768
+ var MAX_LINES2 = 300;
33769
+ var MAX_PEERS = 16;
33770
+ var WIREGUARD_PROGRAM_KEYS = ["preup", "postup", "predown", "postdown", "table", "saveconfig"];
33771
+ var INTERFACE_KEYS = /* @__PURE__ */ new Set(["privatekey", "address", "dns", "mtu", "listenport"]);
33772
+ var PEER_KEYS = /* @__PURE__ */ new Set(["publickey", "presharedkey", "allowedips", "endpoint", "persistentkeepalive"]);
33773
+ var LIST_KEYS = /* @__PURE__ */ new Set(["address", "dns", "allowedips"]);
33774
+ var KEY = /^[A-Za-z0-9+/]{43}=$/;
33775
+ var HOST2 = /^(?:\d{1,3}(?:\.\d{1,3}){3}|[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?)$/;
33776
+ function validCidr(text) {
33777
+ const [addr, prefix, ...rest] = text.split("/");
33778
+ if (rest.length > 0 || !addr) return false;
33779
+ const version2 = net2.isIP(addr);
33780
+ if (version2 === 0) return false;
33781
+ if (prefix === void 0) return true;
33782
+ if (!/^\d{1,3}$/.test(prefix)) return false;
33783
+ return Number(prefix) <= (version2 === 4 ? 32 : 128);
33784
+ }
33785
+ var inRange = (text, low, high) => {
33786
+ if (!/^\d{1,5}$/.test(text)) return null;
33787
+ const n = Number(text);
33788
+ return n >= low && n <= high ? n : null;
33789
+ };
33790
+ var splitList = (text) => text.split(",").map((s) => s.trim()).filter(Boolean);
33791
+ function inspectWireguard(text) {
33792
+ const problems2 = [];
33793
+ const refuse = (message) => {
33794
+ if (problems2.length < 20 && !problems2.includes(message)) problems2.push(message);
33795
+ };
33796
+ if (Buffer.byteLength(text, "utf8") > MAX_WIREGUARD_BYTES) return { ok: false, problems: ["the file is too big"] };
33797
+ if (text.includes("\0")) return { ok: false, problems: ["the file is not text"] };
33798
+ const lines = (text.charCodeAt(0) === 65279 ? text.slice(1) : text).split(/\r?\n/);
33799
+ if (lines.length > MAX_LINES2) return { ok: false, problems: ["the file has too many lines"] };
33800
+ const sections = [];
33801
+ let current = null;
33802
+ lines.forEach((raw, i) => {
33803
+ const at = "line " + (i + 1) + ": ";
33804
+ const line = raw.replace(/#.*$/, "").trim();
33805
+ if (!line) return;
33806
+ const header = /^\[([A-Za-z]{1,20})\]$/.exec(line);
33807
+ if (header) {
33808
+ const name = header[1].toLowerCase();
33809
+ if (name !== "interface" && name !== "peer") {
33810
+ current = null;
33811
+ return refuse(at + "[" + name + "] is not allowed");
33812
+ }
33813
+ current = { kind: name, values: /* @__PURE__ */ new Map() };
33814
+ sections.push(current);
33815
+ return;
33816
+ }
33817
+ const pair = /^([A-Za-z]{1,40})\s*=\s*(.*)$/.exec(line);
33818
+ if (!pair) return refuse(at + 'not a "Key = value" line');
33819
+ const key = pair[1].toLowerCase();
33820
+ if (WIREGUARD_PROGRAM_KEYS.includes(key))
33821
+ return refuse(at + pair[1] + " runs a program or changes how the tunnel is routed or saved");
33822
+ if (!current) return refuse(at + pair[1] + " is outside a section");
33823
+ if (!(current.kind === "interface" ? INTERFACE_KEYS : PEER_KEYS).has(key))
33824
+ return refuse(at + pair[1] + " is not on the list of settings that are safe to accept");
33825
+ const seen = current.values.get(key);
33826
+ if (seen && !LIST_KEYS.has(key)) return refuse(at + pair[1] + " is given twice");
33827
+ current.values.set(key, [...seen ?? [], pair[2].trim()]);
33828
+ });
33829
+ const one = (s, key) => s.values.get(key)?.[0];
33830
+ const joined = (s, key) => (s.values.get(key) ?? []).flatMap(splitList);
33831
+ const interfaces = sections.filter((s) => s.kind === "interface");
33832
+ const peers = sections.filter((s) => s.kind === "peer");
33833
+ if (interfaces.length !== 1) refuse("it needs exactly one [Interface] section");
33834
+ if (peers.length === 0) refuse("it has no [Peer] section");
33835
+ if (peers.length > MAX_PEERS) refuse("it has too many [Peer] sections");
33836
+ if (problems2.length) return { ok: false, problems: problems2 };
33837
+ const face = interfaces[0];
33838
+ const privateKey = one(face, "privatekey");
33839
+ if (!privateKey) refuse("[Interface] has no PrivateKey");
33840
+ else if (!KEY.test(privateKey)) refuse("PrivateKey is not a WireGuard key (44 characters of base64)");
33841
+ const addresses = joined(face, "address");
33842
+ if (addresses.length === 0 || !addresses.every(validCidr)) refuse("[Interface] needs valid Address values");
33843
+ else if (!addresses.some((a) => net2.isIPv4(a.split("/")[0])))
33844
+ refuse("Address needs an IPv4 address (the kill switch works on IPv4)");
33845
+ const dns3 = joined(face, "dns");
33846
+ if (!dns3.every((d) => net2.isIP(d) !== 0)) refuse("DNS may only list IP addresses");
33847
+ const mtuText = one(face, "mtu");
33848
+ const mtu = mtuText === void 0 ? void 0 : inRange(mtuText, 576, 1500);
33849
+ if (mtuText !== void 0 && mtu === null) refuse("MTU must be a number from 576 to 1500");
33850
+ const portText = one(face, "listenport");
33851
+ const listenPort = portText === void 0 ? void 0 : inRange(portText, 1, 65535);
33852
+ if (portText !== void 0 && listenPort === null) refuse("ListenPort must be a number from 1 to 65535");
33853
+ const checked = [];
33854
+ peers.forEach((p, n) => {
33855
+ const who = "[Peer] " + (n + 1) + ": ";
33856
+ const publicKey = one(p, "publickey");
33857
+ if (!publicKey || !KEY.test(publicKey)) return refuse(who + "PublicKey is missing or not a WireGuard key");
33858
+ const preshared = one(p, "presharedkey");
33859
+ if (preshared !== void 0 && !KEY.test(preshared)) return refuse(who + "PresharedKey is not a WireGuard key");
33860
+ const allowed = joined(p, "allowedips");
33861
+ if (allowed.length === 0 || !allowed.every(validCidr)) return refuse(who + "AllowedIPs is missing or invalid");
33862
+ const endpoint = one(p, "endpoint");
33863
+ const m = endpoint ? /^([^:[\]]+):(\d{1,5})$/.exec(endpoint) : null;
33864
+ if (!m || !HOST2.test(m[1]) || inRange(m[2], 1, 65535) === null)
33865
+ return refuse(who + "Endpoint must be host:port with a name or an IPv4 address");
33866
+ if (/^\d+\.\d+\.\d+\.\d+$/.test(m[1]) && !net2.isIPv4(m[1])) return refuse(who + "Endpoint is not a valid address");
33867
+ const keepText = one(p, "persistentkeepalive");
33868
+ let keepalive;
33869
+ if (keepText !== void 0 && keepText.toLowerCase() !== "off") {
33870
+ const k = inRange(keepText, 0, 65535);
33871
+ if (k === null) return refuse(who + "PersistentKeepalive must be a number or off");
33872
+ keepalive = k;
33873
+ }
33874
+ checked.push({
33875
+ publicKey,
33876
+ ...preshared ? { presharedKey: preshared } : {},
33877
+ allowedIps: allowed,
33878
+ endpointHost: m[1],
33879
+ endpointPort: Number(m[2]),
33880
+ ...keepalive !== void 0 ? { keepalive } : {}
33881
+ });
33882
+ });
33883
+ if (problems2.length || !privateKey) return { ok: false, problems: problems2 };
33884
+ return {
33885
+ ok: true,
33886
+ config: {
33887
+ privateKey,
33888
+ addresses,
33889
+ dns: dns3,
33890
+ ...typeof mtu === "number" ? { mtu } : {},
33891
+ ...typeof listenPort === "number" ? { listenPort } : {},
33892
+ peers: checked
33893
+ }
33894
+ };
33895
+ }
33896
+ function assertSafeWireguard(text, what) {
33897
+ const report = inspectWireguard(text);
33898
+ if (report.ok) return report.config;
33899
+ throw new Error(
33900
+ what + " was refused because it could run programs or is not a plain WireGuard config:\n - " + report.problems.slice(0, 5).join("\n - ")
33901
+ );
33902
+ }
33903
+ function renderWireguard(config2, endpointIps = {}) {
33904
+ const out = ["[Interface]", "PrivateKey = " + config2.privateKey, "Address = " + config2.addresses.join(", ")];
33905
+ if (config2.dns.length) out.push("DNS = " + config2.dns.join(", "));
33906
+ if (config2.mtu !== void 0) out.push("MTU = " + config2.mtu);
33907
+ if (config2.listenPort !== void 0) out.push("ListenPort = " + config2.listenPort);
33908
+ config2.peers.forEach((p, i) => {
33909
+ out.push("", "[Peer]", "PublicKey = " + p.publicKey);
33910
+ if (p.presharedKey) out.push("PresharedKey = " + p.presharedKey);
33911
+ out.push(
33912
+ "AllowedIPs = " + p.allowedIps.join(", "),
33913
+ "Endpoint = " + (endpointIps[i] ?? p.endpointHost) + ":" + p.endpointPort
33914
+ );
33915
+ if (p.keepalive !== void 0) out.push("PersistentKeepalive = " + p.keepalive);
33916
+ });
33917
+ return out.join("\r\n") + "\r\n";
33918
+ }
33919
+ function wireguardEndpoints(config2) {
33920
+ return config2.peers.map((p) => ({ host: p.endpointHost, port: p.endpointPort }));
33921
+ }
33922
+ function wireguardTunnelAddress(config2) {
33923
+ const found = config2.addresses.map((a) => a.split("/")[0]).find((a) => net2.isIPv4(a));
33924
+ if (!found) throw new Error("the config has no IPv4 address");
33925
+ return found;
33926
+ }
33927
+ function routesEverything(config2) {
33928
+ return config2.peers.some((p) => p.allowedIps.some((a) => a === "0.0.0.0/0"));
33929
+ }
33930
+ function serviceRunning(scOutput) {
33931
+ return /STATE\s*:\s*\d+\s+RUNNING/i.test(scOutput);
33932
+ }
33933
+ function handshakeDone(wgOutput) {
33934
+ return wgOutput.split(/\r?\n/).some((line) => {
33935
+ const t = /\s(\d+)\s*$/.exec(line);
33936
+ return t !== null && Number(t[1]) > 0;
33937
+ });
33938
+ }
33939
+
33556
33940
  // src/shared/vpn/kill-switch.ts
33557
33941
  var VPN_RULE_PREFIX = "AgentSandbox-VPN-";
33558
33942
  var rule = (name, extra) => [
@@ -33637,6 +34021,18 @@ var OPENVPN_MSI = {
33637
34021
  },
33638
34022
  base: "https://swupdate.openvpn.org/community/releases/"
33639
34023
  };
34024
+ var WIREGUARD_MSI = {
34025
+ version: "1.1.1",
34026
+ x64: {
34027
+ file: "wireguard-amd64-1.1.1.msi",
34028
+ sha256: "7bfed60ad61b785c914b38b61555a975488e1d3ec472dbfb2fcdf498fca75242"
34029
+ },
34030
+ arm64: {
34031
+ file: "wireguard-arm64-1.1.1.msi",
34032
+ sha256: "8336335c738d4aff040fa9d11b752da65a80b6f41d3262d6ba5e82f97ebd1bd4"
34033
+ },
34034
+ base: "https://download.wireguard.com/windows-client/"
34035
+ };
33640
34036
 
33641
34037
  // src/guest/vpn/openvpn.ts
33642
34038
  function openvpnExe(env = process.env) {
@@ -33740,6 +34136,111 @@ async function startTunnel(o) {
33740
34136
  }
33741
34137
  }
33742
34138
 
34139
+ // src/guest/vpn/wireguard.ts
34140
+ import { execFile } from "node:child_process";
34141
+ import crypto5 from "node:crypto";
34142
+ import fs56 from "node:fs";
34143
+ import os13 from "node:os";
34144
+ import path70 from "node:path";
34145
+ var WIREGUARD_TUNNEL = "sandbox";
34146
+ function wireguardDir(env = process.env) {
34147
+ return path70.join(env.ProgramFiles ?? "C:\\Program Files", "WireGuard");
34148
+ }
34149
+ function wireguardExe(env = process.env) {
34150
+ return path70.join(wireguardDir(env), "wireguard.exe");
34151
+ }
34152
+ function wireguardDownload(arch2 = process.arch) {
34153
+ const entry = arch2 === "arm64" ? WIREGUARD_MSI.arm64 : WIREGUARD_MSI.x64;
34154
+ return { ...entry, url: WIREGUARD_MSI.base + entry.file };
34155
+ }
34156
+ var hasHash2 = (file3, sha256) => crypto5.createHash("sha256").update(fs56.readFileSync(file3)).digest("hex") === sha256;
34157
+ async function ensureWireguard() {
34158
+ const exe = wireguardExe();
34159
+ if (!isWin || dryRun) return exe;
34160
+ if (exists(exe)) return exe;
34161
+ const dl = wireguardDownload();
34162
+ const msi = path70.join(mkdirp(path70.join(toolsDir, "downloads")), dl.file);
34163
+ if (!exists(msi) || !hasHash2(msi, dl.sha256)) {
34164
+ log("VPN: downloading WireGuard " + WIREGUARD_MSI.version + " (about 3 MB)");
34165
+ await downloader.file(dl.url, msi, dl.sha256);
34166
+ }
34167
+ log("VPN: installing WireGuard");
34168
+ const logFile2 = path70.join(toolsDir, "downloads", "wireguard-install.log");
34169
+ const code = await spawnAsync(
34170
+ SYSTEM.msiexec(),
34171
+ ["/i", msi, "/qn", "/norestart", "DO_NOT_LAUNCH=1", "/l*v", logFile2],
34172
+ {
34173
+ stdio: "ignore"
34174
+ }
34175
+ );
34176
+ if (code !== 0 && code !== 3010)
34177
+ throw new Error("The WireGuard installer failed (exit " + code + "). Its log: " + logFile2);
34178
+ if (!exists(exe))
34179
+ throw new Error("WireGuard was installed but " + exe + " is missing. The installer log: " + logFile2);
34180
+ return exe;
34181
+ }
34182
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
34183
+ function output2(file3, args) {
34184
+ return new Promise((resolve2) => {
34185
+ execFile(file3, args, { windowsHide: true, timeout: 15e3, maxBuffer: 1024 * 1024 }, (error62, stdout, stderr) => {
34186
+ const code = error62 ? typeof error62.code === "number" ? error62.code : -1 : 0;
34187
+ resolve2({ code, text: String(stdout) + String(stderr) });
34188
+ });
34189
+ });
34190
+ }
34191
+ var serviceName = () => "WireGuardTunnel$" + WIREGUARD_TUNNEL;
34192
+ var hasAdapter = (ip) => Object.values(os13.networkInterfaces()).some((list) => (list ?? []).some((i) => i.address === ip));
34193
+ async function removeWireguardTunnel(exe) {
34194
+ try {
34195
+ await output2(exe, ["/uninstalltunnelservice", WIREGUARD_TUNNEL]);
34196
+ } catch {
34197
+ }
34198
+ }
34199
+ async function startWireguardTunnel(o) {
34200
+ const root = path70.join(process.env.SystemRoot ?? "C:\\Windows", "Temp");
34201
+ const dir = fs56.mkdtempSync(path70.join(fs56.existsSync(root) ? root : os13.tmpdir(), "sbx-wg-"));
34202
+ const file3 = path70.join(dir, WIREGUARD_TUNNEL + ".conf");
34203
+ fs56.writeFileSync(file3, o.config, "utf8");
34204
+ const fail = async (message) => {
34205
+ await removeWireguardTunnel(o.exe);
34206
+ return { ok: false, message };
34207
+ };
34208
+ try {
34209
+ const install = await output2(o.exe, ["/installtunnelservice", file3]);
34210
+ if (install.code !== 0) return await fail("WireGuard could not install the tunnel (exit " + install.code + ")");
34211
+ const deadline = Date.now() + (o.timeoutMs ?? 6e4);
34212
+ for (; ; ) {
34213
+ const state = await output2(SYSTEM.sc(), ["query", serviceName()]);
34214
+ if (serviceRunning(state.text) && hasAdapter(o.tunnelIp)) {
34215
+ return { ok: true, message: "the tunnel service is running", tunnelIp: o.tunnelIp };
34216
+ }
34217
+ if (/STOPPED/i.test(state.text) || /1060/.test(state.text))
34218
+ return await fail("the WireGuard tunnel service stopped (check the config: keys, address, endpoint)");
34219
+ if (Date.now() > deadline)
34220
+ return await fail("the WireGuard tunnel did not start in time (the network driver may not work here)");
34221
+ await sleep(500);
34222
+ }
34223
+ } finally {
34224
+ fs56.rmSync(dir, { recursive: true, force: true });
34225
+ }
34226
+ }
34227
+ async function waitForHandshake(exe, poke, timeoutMs = 3e4) {
34228
+ const wg = path70.join(path70.dirname(exe), "wg.exe");
34229
+ if (!exists(wg)) return { ok: true, message: "the tunnel service is running (no wg.exe to check the handshake)" };
34230
+ const deadline = Date.now() + timeoutMs;
34231
+ for (; ; ) {
34232
+ await poke().catch(() => void 0);
34233
+ const shown = await output2(wg, ["show", WIREGUARD_TUNNEL, "latest-handshakes"]);
34234
+ if (shown.code === 0 && handshakeDone(shown.text)) return { ok: true, message: "the server answered" };
34235
+ if (Date.now() > deadline)
34236
+ return {
34237
+ ok: false,
34238
+ message: "the VPN server did not answer (check the endpoint, the keys and that its UDP port is reachable)"
34239
+ };
34240
+ await sleep(1e3);
34241
+ }
34242
+ }
34243
+
33743
34244
  // src/guest/vpn/vpn.ts
33744
34245
  function setVpnStatus(state, message, extra = {}) {
33745
34246
  try {
@@ -33766,6 +34267,20 @@ async function serverAddresses(remotes) {
33766
34267
  }
33767
34268
  return out;
33768
34269
  }
34270
+ async function wireguardServers(config2) {
34271
+ const endpointIps = {};
34272
+ const servers = [];
34273
+ const found = wireguardEndpoints(config2);
34274
+ for (let i = 0; i < found.length; i++) {
34275
+ const [ip] = await serverAddresses([{ host: found[i].host, port: found[i].port, proto: "udp" }]).then(
34276
+ (all) => all.map((s) => s.ip)
34277
+ );
34278
+ if (!ip) throw new Error("the VPN server address could not be found");
34279
+ endpointIps[i] = ip;
34280
+ servers.push({ ip, port: found[i].port, proto: "udp" });
34281
+ }
34282
+ return { servers, text: renderWireguard(config2, endpointIps) };
34283
+ }
33769
34284
  async function publicAddress() {
33770
34285
  try {
33771
34286
  const text = (await (await fetch("https://api.ipify.org", { signal: AbortSignal.timeout(1e4) })).text()).trim();
@@ -33774,7 +34289,7 @@ async function publicAddress() {
33774
34289
  return null;
33775
34290
  }
33776
34291
  }
33777
- var hasAdapter = (ip) => Object.values(os13.networkInterfaces()).some((list) => (list ?? []).some((i) => i.address === ip));
34292
+ var hasAdapter2 = (ip) => Object.values(os14.networkInterfaces()).some((list) => (list ?? []).some((i) => i.address === ip));
33778
34293
  async function setupVpn(secrets, ptyHostExe) {
33779
34294
  const vpn = session.vpn;
33780
34295
  if (!vpn) return true;
@@ -33788,25 +34303,53 @@ async function setupVpn(secrets, ptyHostExe) {
33788
34303
  setVpnStatus("starting", "Starting the VPN");
33789
34304
  try {
33790
34305
  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;
34306
+ let result;
34307
+ let wireguardExe2 = null;
34308
+ if (vpn.provider === "wireguard-file") {
34309
+ if (!secrets.wireguardConfig) throw new Error("the WireGuard config did not arrive (start the sandbox again)");
34310
+ const config2 = assertSafeWireguard(secrets.wireguardConfig, vpn.server);
34311
+ const exe = await ensureWireguard();
34312
+ const { servers, text } = await wireguardServers(config2);
34313
+ if (killSwitch && !routesEverything(config2))
34314
+ warn(
34315
+ "VPN: AllowedIPs does not include 0.0.0.0/0: with the kill switch on, only the tunnel traffic can leave the sandbox."
34316
+ );
34317
+ if (killSwitch) block(servers);
34318
+ if (dryRun || !isWin) {
34319
+ log("(dry run) would start the WireGuard tunnel " + vpn.server);
34320
+ setVpnStatus("off", "dry run");
34321
+ return true;
34322
+ }
34323
+ log("VPN: connecting with " + vpn.server);
34324
+ wireguardExe2 = exe;
34325
+ result = await startWireguardTunnel({ exe, config: text, tunnelIp: wireguardTunnelAddress(config2) });
34326
+ if (result.ok && result.tunnelIp && killSwitch) run2(tunnelCommands(result.tunnelIp));
34327
+ if (result.ok) result = await waitForHandshake(exe, publicAddress);
34328
+ } else {
34329
+ const credentials = secrets.vpn;
34330
+ if (!credentials) throw new Error("the VPN login did not arrive (start the sandbox again)");
34331
+ const profile = path71.join(launchDir, "vpn", "server.ovpn");
34332
+ const remotes = assertSafeOvpn(fs57.readFileSync(profile, "utf8"), vpn.server);
34333
+ const exe = await ensureOpenVpn();
34334
+ const servers = await serverAddresses(remotes);
34335
+ if (servers.length === 0) throw new Error("the VPN server addresses could not be found");
34336
+ if (killSwitch) block(servers);
34337
+ if (dryRun || !isWin) {
34338
+ log("(dry run) would start the VPN tunnel to " + vpn.server);
34339
+ setVpnStatus("off", "dry run");
34340
+ return true;
34341
+ }
34342
+ log("VPN: connecting to " + vpn.server);
34343
+ result = await startTunnel({ exe, profile, username: credentials.username, password: credentials.password });
34344
+ if (result.ok && result.tunnelIp && hasAdapter2(result.tunnelIp) && killSwitch)
34345
+ run2(tunnelCommands(result.tunnelIp));
34346
+ }
34347
+ if (!result.ok) {
34348
+ if (wireguardExe2) await removeWireguardTunnel(wireguardExe2);
34349
+ throw new Error(result.message);
33803
34350
  }
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))
34351
+ if (!result.tunnelIp || !hasAdapter2(result.tunnelIp))
33808
34352
  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
34353
  const publicIp = await publicAddress();
33811
34354
  log("VPN: up" + (publicIp ? " (the sandbox appears as " + publicIp + ")" : "") + ".");
33812
34355
  setVpnStatus("up", "The tunnel is up", publicIp ? { publicIp } : {});
@@ -33877,10 +34420,10 @@ var FrameReader = class {
33877
34420
  };
33878
34421
 
33879
34422
  // src/shared/pty/client.ts
33880
- import net2 from "node:net";
34423
+ import net3 from "node:net";
33881
34424
  var connectOnce = (host, port, timeoutMs) => {
33882
34425
  return new Promise((resolve2, reject) => {
33883
- const socket = net2.connect({ host, port });
34426
+ const socket = net3.connect({ host, port });
33884
34427
  const timer = setTimeout(() => {
33885
34428
  socket.destroy();
33886
34429
  reject(new Error("timed out connecting to " + host + ":" + port));
@@ -33916,7 +34459,14 @@ var KEPT_OSC = (body) => {
33916
34459
  return n <= 2 || n === 8 || n === 133 || n === 9 && body.startsWith(number4[1] + ";4;");
33917
34460
  };
33918
34461
  var MAX_KEPT_STRING = 4096;
34462
+ var MAX_CLIPBOARD_STRING = 1024 * 1024;
34463
+ var CLIPBOARD_WRITE = /^0{0,2}52;[cpqs0-7]{0,8};[A-Za-z0-9+/=]*$/;
33919
34464
  var OutputFilter = class {
34465
+ constructor(options = {}) {
34466
+ this.options = options;
34467
+ this.maxString = options.clipboardWrites ? MAX_CLIPBOARD_STRING : MAX_KEPT_STRING;
34468
+ }
34469
+ options;
33920
34470
  /**
33921
34471
  * text: normal output; esc: after ESC; c2: after a 0xC2 lead byte; string: inside an OSC/DCS/...; stringEsc /
33922
34472
  * stringC2: a possible terminator inside one.
@@ -33924,8 +34474,14 @@ var OutputFilter = class {
33924
34474
  state = "text";
33925
34475
  /** The string being read: an OSC worth keeping is collected until its terminator; null = being dropped. */
33926
34476
  body = null;
34477
+ maxString;
34478
+ /** An OSC that may pass: a short title, link, progress or mark, or (when allowed) a clipboard write. */
34479
+ kept(body) {
34480
+ if (this.options.clipboardWrites && CLIPBOARD_WRITE.test(body)) return true;
34481
+ return body.length <= MAX_KEPT_STRING && KEPT_OSC(body);
34482
+ }
33927
34483
  push(chunk) {
33928
- const out = Buffer.allocUnsafe(chunk.length + MAX_KEPT_STRING + 8);
34484
+ const out = Buffer.allocUnsafe(chunk.length + (this.body?.length ?? 0) + 8);
33929
34485
  let n = 0;
33930
34486
  const put = (...bytes) => {
33931
34487
  for (const b of bytes) out[n++] = b;
@@ -33945,7 +34501,7 @@ var OutputFilter = class {
33945
34501
  };
33946
34502
  const endString = (terminator) => {
33947
34503
  const body = this.body && Buffer.from(this.body).toString("latin1");
33948
- if (body !== null && KEPT_OSC(body)) {
34504
+ if (body !== null && this.kept(body)) {
33949
34505
  put(27, 93);
33950
34506
  out.write(body, n, "latin1");
33951
34507
  n += body.length;
@@ -33955,7 +34511,7 @@ var OutputFilter = class {
33955
34511
  this.state = "text";
33956
34512
  };
33957
34513
  const collect = (b) => {
33958
- if (this.body && this.body.push(b) > MAX_KEPT_STRING) this.body = null;
34514
+ if (this.body && this.body.push(b) > this.maxString) this.body = null;
33959
34515
  };
33960
34516
  for (const b of chunk) {
33961
34517
  switch (this.state) {
@@ -34105,7 +34661,7 @@ function runTerminalClient(socket, token, options = {}) {
34105
34661
  return new Promise((resolve2) => {
34106
34662
  let done = false;
34107
34663
  const reader = new FrameReader();
34108
- const filter = new OutputFilter();
34664
+ const filter = new OutputFilter({ clipboardWrites: options.clipboardWrites });
34109
34665
  let sent = size();
34110
34666
  let resizeTimer;
34111
34667
  let vtInput;
@@ -34222,14 +34778,14 @@ async function viewSession(id) {
34222
34778
  return 1;
34223
34779
  }
34224
34780
  const socket = await connect({ ...session2.attach, addresses: ["127.0.0.1"] });
34225
- const result = await runTerminalClient(socket, session2.attach.token);
34781
+ const result = await runTerminalClient(socket, session2.attach.token, { clipboardWrites: true });
34226
34782
  if (result.reason === "exit") console.log(session2.harness + " exited with code " + result.exitCode + ".");
34227
34783
  else if (result.reason === "error") console.log("Session error: " + result.message);
34228
34784
  return result.reason === "exit" ? result.exitCode : 1;
34229
34785
  }
34230
34786
 
34231
34787
  // src/guest/boot/boot-env.ts
34232
- import path71 from "node:path";
34788
+ import path72 from "node:path";
34233
34789
 
34234
34790
  // src/guest/boot/project-env.ts
34235
34791
  var EnvSchema = external_exports.object({
@@ -34248,7 +34804,7 @@ var BootEnvSchema = external_exports.object({
34248
34804
  });
34249
34805
 
34250
34806
  // src/guest/boot/boot-env.ts
34251
- var file2 = () => path71.join(localDir, "boot-env.json");
34807
+ var file2 = () => path72.join(localDir, "boot-env.json");
34252
34808
  function saveBootEnv(value) {
34253
34809
  try {
34254
34810
  writeJsonAtomic(file2(), value);
@@ -34277,7 +34833,7 @@ function saveProjectStatus(name, workspace2, phase, message, databases, summary)
34277
34833
  }
34278
34834
 
34279
34835
  // src/guest/runtime/secrets.ts
34280
- import fs57 from "node:fs";
34836
+ import fs58 from "node:fs";
34281
34837
 
34282
34838
  // src/shared/channel/secrets.ts
34283
34839
  var Environment = external_exports.record(external_exports.string().max(256), external_exports.string().max(65536));
@@ -34291,7 +34847,9 @@ var SecretsFileSchema = external_exports.strictObject({
34291
34847
  /** The login of this PC's Claude (claudeProfile.copyCredentials): the text of .credentials.json. */
34292
34848
  claudeCredentials: external_exports.string().max(1024 * 1024).optional(),
34293
34849
  /** 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()
34850
+ vpn: external_exports.strictObject({ username: external_exports.string().min(1).max(256), password: external_exports.string().min(1).max(1024) }).optional(),
34851
+ /** The checked WireGuard config of vpn.provider wireguard-file (holds the private key). */
34852
+ wireguardConfig: external_exports.string().min(1).max(32 * 1024).optional()
34295
34853
  });
34296
34854
 
34297
34855
  // src/guest/runtime/secrets.ts
@@ -34301,12 +34859,12 @@ function takeSecrets(id) {
34301
34859
  const file3 = run.secretFile(id);
34302
34860
  let text;
34303
34861
  try {
34304
- if (fs57.statSync(file3).size > MAX_BYTES) throw new Error("too big");
34305
- text = fs57.readFileSync(file3, "utf8").replace(/^\uFEFF/, "");
34862
+ if (fs58.statSync(file3).size > MAX_BYTES) throw new Error("too big");
34863
+ text = fs58.readFileSync(file3, "utf8").replace(/^\uFEFF/, "");
34306
34864
  } catch {
34307
34865
  return {};
34308
34866
  } finally {
34309
- fs57.rmSync(file3, { force: true });
34867
+ fs58.rmSync(file3, { force: true });
34310
34868
  }
34311
34869
  try {
34312
34870
  const parsed = SecretsFileSchema.safeParse(JSON.parse(text));
@@ -34344,7 +34902,7 @@ async function soft(what, work) {
34344
34902
  }
34345
34903
  }
34346
34904
  function startDaemon(env, secrets) {
34347
- spawn9(process.execPath, [path72.join(path72.dirname(process.argv[1]), "daemon.js")], {
34905
+ spawn9(process.execPath, [path73.join(path73.dirname(process.argv[1]), "daemon.js")], {
34348
34906
  detached: true,
34349
34907
  stdio: "ignore",
34350
34908
  windowsHide: true,
@@ -34357,20 +34915,20 @@ function startDaemon(env, secrets) {
34357
34915
  }).unref();
34358
34916
  }
34359
34917
  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"),
34918
+ const dir = mkdirp(path73.join(localDir, "bin"));
34919
+ const db = path73.join(path73.dirname(process.argv[1]), "db.js");
34920
+ fs59.writeFileSync(
34921
+ path73.join(dir, "sbx-db.cmd"),
34364
34922
  '@setlocal\r\n@set AGENT_LOG_PREFIX=db\r\n@"' + process.execPath + '" "' + db + '" %*\r\n'
34365
34923
  );
34366
34924
  writeAgentCommands(dir);
34367
34925
  return dir;
34368
34926
  }
34369
34927
  function writeAgentCommands(dir) {
34370
- const install = { node: process.execPath, script: path72.join(path72.dirname(process.argv[1]), "agent.js") };
34928
+ const install = { node: process.execPath, script: path73.join(path73.dirname(process.argv[1]), "agent.js") };
34371
34929
  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));
34930
+ fs59.writeFileSync(path73.join(dir, shim3.command + ".cmd"), shimText(shim3, install));
34931
+ fs59.writeFileSync(path73.join(dir, "sbx-agent.cmd"), sbxAgentText(install));
34374
34932
  }
34375
34933
  async function waitForPrimary() {
34376
34934
  for (let i = 0; i < PRIMARY_POLLS; i++) {
@@ -34398,7 +34956,7 @@ var Boot = class {
34398
34956
  log(
34399
34957
  "Agent sandbox: " + session.project + " | workspace " + workspace + " | agent " + session.harnessName + " | log " + logPath
34400
34958
  );
34401
- if (!fs58.statSync(workspace, { throwIfNoEntry: false })?.isDirectory())
34959
+ if (!fs59.statSync(workspace, { throwIfNoEntry: false })?.isDirectory())
34402
34960
  throw new Error("Workspace folder is missing in the sandbox: " + workspace);
34403
34961
  mkdirp(toolsDir);
34404
34962
  mkdirp(run.root);
@@ -34442,6 +35000,7 @@ var Boot = class {
34442
35000
  databases: session.databases ?? [],
34443
35001
  apps: session.apps
34444
35002
  });
35003
+ for (const p of networkProblems()) tools.summary.push("PROTECTION MISSING: " + p);
34445
35004
  if (!dryRun) tools.prepend.push(writeDbCommand());
34446
35005
  Object.assign(tools.vars, proxyEnv());
34447
35006
  await soft("Network: allow only some hosts", async () => {
@@ -34491,6 +35050,7 @@ var Boot = class {
34491
35050
  if (session.harnessName === "claude")
34492
35051
  await soft("Claude settings", () => syncClaudeProfile(this.secrets.claudeCredentials));
34493
35052
  await soft("claude-mem restore", restoreClaudeMem);
35053
+ await soft("Agent files of the last sandbox", resetMachineBound);
34494
35054
  await soft("Agent databases restore", restoreLocalState);
34495
35055
  await soft("Sandbox guide for the agent", () => writeGuides(tools.summary, this.lan));
34496
35056
  await soft("Claude managed settings", () => writeManagedSettings2(this.gitAccess));
@@ -34545,11 +35105,11 @@ runBoot().catch((e) => {
34545
35105
  const message = errMsg(e) + (e instanceof Error && e.stack ? "\n" + e.stack : "");
34546
35106
  try {
34547
35107
  setSandboxStatus("failed", errMsg(e));
34548
- fs59.writeFileSync(path73.join(logsDir, "guest-error.txt"), message);
35108
+ fs60.writeFileSync(path74.join(logsDir, "guest-error.txt"), message);
34549
35109
  } catch {
34550
35110
  }
34551
35111
  console.error(
34552
- "\n\x1B[31mThe sandbox could not start: " + errMsg(e) + "\x1B[0m\nDetails: " + path73.join(logsDir, "guest-error.txt")
35112
+ "\n\x1B[31mThe sandbox could not start: " + errMsg(e) + "\x1B[0m\nDetails: " + path74.join(logsDir, "guest-error.txt")
34553
35113
  );
34554
35114
  process.exitCode = 1;
34555
35115
  });