windows-development-sandbox 1.4.0 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (877) hide show
  1. package/.sandbox-config.example.json +2 -1
  2. package/config.example.json +4 -1
  3. package/dist/api.js +27 -16
  4. package/dist/cli/args.d.ts +4 -6
  5. package/dist/cli/args.js +67 -34
  6. package/dist/cli/argv.d.ts +9 -0
  7. package/dist/cli/argv.js +22 -0
  8. package/dist/cli/commands/accounts.d.ts +1 -1
  9. package/dist/cli/commands/accounts.js +42 -27
  10. package/dist/cli/commands/agent-commands.d.ts +3 -3
  11. package/dist/cli/commands/agent-commands.js +27 -18
  12. package/dist/cli/commands/context.d.ts +9 -11
  13. package/dist/cli/commands/context.js +35 -32
  14. package/dist/cli/commands/data/clean.d.ts +2 -2
  15. package/dist/cli/commands/data/clean.js +27 -11
  16. package/dist/cli/commands/data/collect.d.ts +6 -3
  17. package/dist/cli/commands/data/collect.js +46 -15
  18. package/dist/cli/commands/data/index.d.ts +2 -2
  19. package/dist/cli/commands/data/index.js +30 -12
  20. package/dist/cli/commands/data/remove.d.ts +1 -1
  21. package/dist/cli/commands/data/remove.js +4 -4
  22. package/dist/cli/commands/index.d.ts +5 -4
  23. package/dist/cli/commands/index.js +5 -4
  24. package/dist/cli/commands/launch/add-root.d.ts +7 -0
  25. package/dist/cli/commands/launch/add-root.js +64 -0
  26. package/dist/cli/commands/launch/boot-progress.d.ts +7 -0
  27. package/dist/cli/commands/launch/boot-progress.js +48 -0
  28. package/dist/cli/commands/launch/boot-wants.d.ts +11 -0
  29. package/dist/cli/commands/launch/boot-wants.js +48 -0
  30. package/dist/cli/commands/launch/first-start.d.ts +10 -0
  31. package/dist/cli/commands/launch/first-start.js +53 -0
  32. package/dist/cli/commands/launch/index.d.ts +6 -0
  33. package/dist/cli/commands/launch/index.js +6 -0
  34. package/dist/cli/commands/launch/launch.d.ts +8 -0
  35. package/dist/cli/commands/launch/launch.js +211 -0
  36. package/dist/cli/commands/launch/prepare.d.ts +23 -0
  37. package/dist/cli/commands/launch/prepare.js +109 -0
  38. package/dist/cli/commands/launch/running.d.ts +45 -0
  39. package/dist/cli/commands/launch/running.js +218 -0
  40. package/dist/cli/commands/launch/summary.d.ts +8 -0
  41. package/dist/cli/commands/launch/summary.js +98 -0
  42. package/dist/cli/commands/maintenance/audit.d.ts +3 -0
  43. package/dist/cli/commands/maintenance/audit.js +58 -0
  44. package/dist/cli/commands/maintenance/clean.d.ts +2 -0
  45. package/dist/cli/commands/maintenance/clean.js +10 -0
  46. package/dist/cli/commands/maintenance/config.d.ts +2 -0
  47. package/dist/cli/commands/maintenance/config.js +145 -0
  48. package/dist/cli/commands/maintenance/doctor.d.ts +2 -0
  49. package/dist/cli/commands/maintenance/doctor.js +52 -0
  50. package/dist/cli/commands/maintenance/host-claude.d.ts +2 -0
  51. package/dist/cli/commands/maintenance/host-claude.js +4 -0
  52. package/dist/cli/commands/maintenance/index.d.ts +8 -0
  53. package/dist/cli/commands/maintenance/index.js +9 -0
  54. package/dist/cli/commands/maintenance/logs.d.ts +2 -0
  55. package/dist/cli/commands/maintenance/logs.js +44 -0
  56. package/dist/cli/commands/maintenance/sync.d.ts +2 -0
  57. package/dist/cli/commands/maintenance/sync.js +12 -0
  58. package/dist/cli/commands/maintenance/watch.d.ts +3 -0
  59. package/dist/cli/commands/maintenance/watch.js +6 -0
  60. package/dist/cli/commands/projects/describe-sessions.d.ts +3 -0
  61. package/dist/cli/commands/projects/describe-sessions.js +15 -0
  62. package/dist/cli/commands/projects/here.d.ts +38 -0
  63. package/dist/cli/commands/projects/here.js +145 -0
  64. package/dist/cli/commands/projects/index.d.ts +4 -0
  65. package/dist/cli/commands/projects/index.js +4 -0
  66. package/dist/cli/commands/projects/projects.d.ts +14 -0
  67. package/dist/cli/commands/projects/projects.js +213 -0
  68. package/dist/cli/commands/projects/restart.d.ts +15 -0
  69. package/dist/cli/commands/projects/restart.js +149 -0
  70. package/dist/cli/commands/registry.d.ts +3 -0
  71. package/dist/cli/commands/registry.js +34 -0
  72. package/dist/cli/commands/repair/checks.js +105 -29
  73. package/dist/cli/commands/repair/finders.d.ts +13 -10
  74. package/dist/cli/commands/repair/finders.js +63 -43
  75. package/dist/cli/commands/repair/index.d.ts +4 -4
  76. package/dist/cli/commands/repair/index.js +47 -21
  77. package/dist/cli/commands/repair/types.d.ts +2 -2
  78. package/dist/cli/commands/repair/types.js +7 -2
  79. package/dist/cli/commands/sessions/attach.d.ts +2 -0
  80. package/dist/cli/commands/sessions/attach.js +45 -0
  81. package/dist/cli/commands/sessions/control.d.ts +4 -0
  82. package/dist/cli/commands/sessions/control.js +62 -0
  83. package/dist/cli/commands/sessions/exec.d.ts +6 -0
  84. package/dist/cli/commands/sessions/exec.js +72 -0
  85. package/dist/cli/commands/sessions/index.d.ts +6 -0
  86. package/dist/cli/commands/sessions/index.js +9 -0
  87. package/dist/cli/commands/sessions/list.d.ts +15 -0
  88. package/dist/cli/commands/sessions/list.js +65 -0
  89. package/dist/cli/commands/sessions/status.d.ts +2 -0
  90. package/dist/cli/commands/sessions/status.js +153 -0
  91. package/dist/cli/commands/sessions/window.d.ts +3 -0
  92. package/dist/cli/commands/sessions/window.js +18 -0
  93. package/dist/cli/commands/setup/checks.d.ts +4 -4
  94. package/dist/cli/commands/setup/checks.js +36 -19
  95. package/dist/cli/commands/setup/facts.d.ts +6 -6
  96. package/dist/cli/commands/setup/facts.js +23 -11
  97. package/dist/cli/commands/setup/index.d.ts +1 -1
  98. package/dist/cli/commands/setup/index.js +25 -12
  99. package/dist/cli/commands/user-config.d.ts +5 -5
  100. package/dist/cli/commands/user-config.js +14 -12
  101. package/dist/cli/history.d.ts +5 -4
  102. package/dist/cli/history.js +23 -11
  103. package/dist/cli/index.d.ts +4 -14
  104. package/dist/cli/index.js +27 -77
  105. package/dist/cli/manifest.d.ts +464 -10
  106. package/dist/cli/manifest.js +328 -54
  107. package/dist/cli/menu/apps.d.ts +7 -5
  108. package/dist/cli/menu/apps.js +64 -16
  109. package/dist/cli/menu/command-fields.d.ts +15 -0
  110. package/dist/cli/menu/command-fields.js +23 -0
  111. package/dist/cli/menu/command-form.d.ts +3 -5
  112. package/dist/cli/menu/command-form.js +116 -48
  113. package/dist/cli/menu/home.d.ts +22 -0
  114. package/dist/cli/menu/home.js +72 -0
  115. package/dist/cli/menu/index.d.ts +2 -24
  116. package/dist/cli/menu/index.js +4 -178
  117. package/dist/cli/menu/menu.d.ts +23 -0
  118. package/dist/cli/menu/menu.js +185 -0
  119. package/dist/cli/menu/settings/categories.d.ts +2 -2
  120. package/dist/cli/menu/settings/categories.js +123 -20
  121. package/dist/cli/menu/settings/collections/collection-editor.d.ts +23 -0
  122. package/dist/cli/menu/settings/collections/collection-editor.js +89 -0
  123. package/dist/cli/menu/settings/collections/map-editor.d.ts +10 -0
  124. package/dist/cli/menu/settings/collections/map-editor.js +34 -0
  125. package/dist/cli/menu/settings/collections/object-list-editor.d.ts +10 -0
  126. package/dist/cli/menu/settings/collections/object-list-editor.js +23 -0
  127. package/dist/cli/menu/settings/collections/object-map-editor.d.ts +10 -0
  128. package/dist/cli/menu/settings/collections/object-map-editor.js +35 -0
  129. package/dist/cli/menu/settings/collections/string-list-editor.d.ts +12 -0
  130. package/dist/cli/menu/settings/collections/string-list-editor.js +39 -0
  131. package/dist/cli/menu/settings/config-file.d.ts +2 -2
  132. package/dist/cli/menu/settings/config-file.js +42 -19
  133. package/dist/cli/menu/settings/editor-actions.d.ts +2 -0
  134. package/dist/cli/menu/settings/editor-actions.js +2 -0
  135. package/dist/cli/menu/settings/format.d.ts +5 -0
  136. package/dist/cli/menu/settings/format.js +39 -0
  137. package/dist/cli/menu/settings/index.d.ts +1 -29
  138. package/dist/cli/menu/settings/index.js +1 -133
  139. package/dist/cli/menu/settings/object-editor.d.ts +12 -0
  140. package/dist/cli/menu/settings/object-editor.js +86 -0
  141. package/dist/cli/menu/settings/schema-node.d.ts +3 -1
  142. package/dist/cli/menu/settings/schema-node.js +71 -24
  143. package/dist/cli/menu/settings/settings-editor.d.ts +30 -0
  144. package/dist/cli/menu/settings/settings-editor.js +176 -0
  145. package/dist/cli/menu/settings/{editors.d.ts → value-editor.d.ts} +2 -13
  146. package/dist/cli/menu/settings/value-editor.js +137 -0
  147. package/dist/cli/menu/several.d.ts +4 -4
  148. package/dist/cli/menu/several.js +61 -20
  149. package/dist/cli/{colors.d.ts → output/colors.d.ts} +8 -8
  150. package/dist/cli/{colors.js → output/colors.js} +32 -14
  151. package/dist/cli/output/index.d.ts +3 -0
  152. package/dist/cli/output/index.js +3 -0
  153. package/dist/cli/output/print.d.ts +5 -0
  154. package/dist/cli/output/print.js +14 -0
  155. package/dist/cli/output/progress.d.ts +24 -0
  156. package/dist/cli/output/progress.js +124 -0
  157. package/dist/cli/report.d.ts +2 -0
  158. package/dist/cli/report.js +20 -0
  159. package/dist/cli/tui/app.d.ts +6 -16
  160. package/dist/cli/tui/app.js +28 -8
  161. package/dist/cli/tui/dialogs/confirm-screen.d.ts +20 -0
  162. package/dist/cli/tui/dialogs/confirm-screen.js +50 -0
  163. package/dist/cli/tui/dialogs/message-screen.d.ts +17 -0
  164. package/dist/cli/tui/dialogs/message-screen.js +55 -0
  165. package/dist/cli/tui/dialogs/paragraphs.d.ts +2 -0
  166. package/dist/cli/tui/dialogs/paragraphs.js +5 -0
  167. package/dist/cli/tui/dialogs/text-screen.d.ts +26 -0
  168. package/dist/cli/tui/dialogs/text-screen.js +107 -0
  169. package/dist/cli/tui/frame.js +3 -1
  170. package/dist/cli/tui/index.d.ts +7 -3
  171. package/dist/cli/tui/index.js +4 -2
  172. package/dist/cli/tui/list/list-screen.d.ts +29 -0
  173. package/dist/cli/tui/{list-screen.js → list/list-screen.js} +86 -23
  174. package/dist/cli/tui/{list-screen.d.ts → list/list-types.d.ts} +0 -28
  175. package/dist/cli/tui/screen.d.ts +14 -0
  176. package/dist/cli/tui/terminal.js +34 -10
  177. package/dist/cli/tui/text.d.ts +2 -1
  178. package/dist/cli/tui/text.js +37 -7
  179. package/dist/cli/tui/theme.js +27 -9
  180. package/dist/cli/validate.d.ts +8 -8
  181. package/dist/cli/validate.js +32 -21
  182. package/dist/core/config/defaults.d.ts +2 -0
  183. package/dist/core/config/defaults.js +203 -0
  184. package/dist/core/config/index.d.ts +2 -0
  185. package/dist/core/config/index.js +3 -0
  186. package/dist/core/{config.d.ts → config/loader.d.ts} +1 -2
  187. package/dist/core/config/loader.js +47 -0
  188. package/dist/core/{detect-databases.js → detect/databases.js} +111 -23
  189. package/dist/core/detect/index.d.ts +4 -0
  190. package/dist/core/detect/index.js +4 -0
  191. package/dist/core/{detect-pwsh.d.ts → detect/pwsh.d.ts} +1 -1
  192. package/dist/core/{detect-pwsh.js → detect/pwsh.js} +25 -11
  193. package/dist/core/{detect-toolchains.d.ts → detect/toolchains.d.ts} +1 -1
  194. package/dist/core/{detect-toolchains.js → detect/toolchains.js} +42 -5
  195. package/dist/{guest/toolchains → core/detect}/versions.js +28 -12
  196. package/dist/core/disk.d.ts +2 -0
  197. package/dist/core/disk.js +46 -3
  198. package/dist/core/local-config/boot-wants.d.ts +45 -0
  199. package/dist/core/local-config/boot-wants.js +120 -0
  200. package/dist/core/local-config/file.d.ts +3 -0
  201. package/dist/core/local-config/file.js +16 -0
  202. package/dist/core/local-config/index.d.ts +5 -0
  203. package/dist/core/local-config/index.js +7 -0
  204. package/dist/core/{local-config.d.ts → local-config/overrides.d.ts} +11 -11
  205. package/dist/core/{local-config.js → local-config/overrides.js} +53 -54
  206. package/dist/core/{project-policy.d.ts → local-config/policy.d.ts} +7 -3
  207. package/dist/core/{project-policy.js → local-config/policy.js} +16 -6
  208. package/dist/core/local-config/trust.d.ts +13 -0
  209. package/dist/core/local-config/trust.js +43 -0
  210. package/dist/core/package-info.d.ts +4 -0
  211. package/dist/core/package-info.js +13 -0
  212. package/dist/core/run/guest-workspace.d.ts +23 -0
  213. package/dist/core/run/guest-workspace.js +47 -0
  214. package/dist/core/run/index.d.ts +3 -0
  215. package/dist/core/run/index.js +3 -0
  216. package/dist/core/run/resolve-run.d.ts +3 -0
  217. package/dist/core/run/resolve-run.js +202 -0
  218. package/dist/core/run/versions.d.ts +13 -0
  219. package/dist/core/run/versions.js +65 -0
  220. package/dist/core/safe-paths.js +17 -5
  221. package/dist/core/schema/apps.d.ts +4 -4
  222. package/dist/core/schema/apps.js +55 -21
  223. package/dist/core/schema/common.d.ts +13 -10
  224. package/dist/core/schema/common.js +16 -10
  225. package/dist/core/schema/config.d.ts +18 -12
  226. package/dist/core/schema/config.js +78 -53
  227. package/dist/core/schema/databases.d.ts +4 -3
  228. package/dist/core/schema/databases.js +16 -12
  229. package/dist/core/schema/harness.d.ts +1 -1
  230. package/dist/core/schema/harness.js +17 -7
  231. package/dist/core/schema/index.d.ts +6 -0
  232. package/dist/core/schema/index.js +8 -0
  233. package/dist/core/schema/json-schema.js +10 -5
  234. package/dist/core/schema/profile.d.ts +4 -4
  235. package/dist/core/schema/profile.js +37 -17
  236. package/dist/core/schema/projects.d.ts +2 -1
  237. package/dist/core/schema/projects.js +16 -5
  238. package/dist/core/schema/sandbox.d.ts +12 -12
  239. package/dist/core/schema/sandbox.js +101 -37
  240. package/dist/core/schema/toolchains.d.ts +6 -1
  241. package/dist/core/schema/toolchains.js +84 -34
  242. package/dist/core/types.d.ts +36 -9
  243. package/dist/core/util/errors.d.ts +8 -0
  244. package/dist/core/util/errors.js +14 -0
  245. package/dist/core/util/fs.d.ts +8 -0
  246. package/dist/core/util/fs.js +40 -0
  247. package/dist/core/util/index.d.ts +7 -0
  248. package/dist/core/util/index.js +7 -0
  249. package/dist/core/util/jsonc.d.ts +6 -0
  250. package/dist/core/util/jsonc.js +25 -0
  251. package/dist/core/util/links.d.ts +10 -0
  252. package/dist/core/util/links.js +39 -0
  253. package/dist/core/util/paths.d.ts +7 -0
  254. package/dist/core/util/paths.js +33 -0
  255. package/dist/core/util/process.d.ts +15 -0
  256. package/dist/core/util/process.js +54 -0
  257. package/dist/core/util/text.d.ts +8 -0
  258. package/dist/core/util/text.js +8 -0
  259. package/dist/guest/{setup/agents.js → agents/agent-installer.js} +24 -4
  260. package/dist/guest/apps/after-install.d.ts +3 -0
  261. package/dist/guest/apps/after-install.js +47 -0
  262. package/dist/guest/apps/app-installer.d.ts +22 -0
  263. package/dist/guest/apps/app-installer.js +116 -0
  264. package/dist/guest/apps/find-exe.d.ts +5 -0
  265. package/dist/guest/apps/find-exe.js +41 -0
  266. package/dist/guest/apps/index.d.ts +3 -10
  267. package/dist/guest/apps/index.js +6 -206
  268. package/dist/guest/apps/resolvers.js +37 -9
  269. package/dist/guest/apps/shortcuts.d.ts +6 -0
  270. package/dist/guest/apps/shortcuts.js +28 -0
  271. package/dist/guest/apps/sources.d.ts +4 -0
  272. package/dist/guest/apps/sources.js +17 -0
  273. package/dist/guest/apps/unpack.d.ts +3 -0
  274. package/dist/guest/apps/unpack.js +47 -0
  275. package/dist/guest/{audit-parse.js → audit/parse.js} +39 -3
  276. package/dist/guest/{audit.d.ts → audit/process-audit.d.ts} +3 -1
  277. package/dist/guest/{audit.js → audit/process-audit.js} +33 -8
  278. package/dist/guest/boot/boot-env.d.ts +4 -0
  279. package/dist/guest/{boot-env.js → boot/boot-env.js} +7 -5
  280. package/dist/guest/boot/boot.d.ts +1 -0
  281. package/dist/guest/{main.js → boot/boot.js} +100 -50
  282. package/dist/guest/{guide.js → boot/guide.js} +32 -7
  283. package/dist/guest/{project-env.d.ts → boot/project-env.d.ts} +3 -3
  284. package/dist/guest/{project-env.js → boot/project-env.js} +12 -4
  285. package/dist/guest/boot/project-status.d.ts +5 -0
  286. package/dist/guest/boot/project-status.js +28 -0
  287. package/dist/guest/daemon/daemon.d.ts +1 -0
  288. package/dist/guest/daemon/daemon.js +51 -0
  289. package/dist/guest/daemon/exec.js +18 -6
  290. package/dist/guest/daemon/{shutdown.js → idle-shutdown.js} +5 -4
  291. package/dist/guest/daemon/{project.d.ts → project-provisioner.d.ts} +3 -3
  292. package/dist/guest/daemon/{project.js → project-provisioner.js} +60 -22
  293. package/dist/guest/daemon/relays.js +5 -3
  294. package/dist/guest/daemon/{session.js → sessions.js} +84 -24
  295. package/dist/guest/daemon/state.d.ts +4 -1
  296. package/dist/guest/daemon/state.js +34 -20
  297. package/dist/guest/databases/database-server.d.ts +13 -0
  298. package/dist/guest/databases/database-server.js +35 -0
  299. package/dist/guest/databases/dynamodb.d.ts +12 -0
  300. package/dist/guest/databases/dynamodb.js +81 -0
  301. package/dist/guest/databases/index.d.ts +2 -0
  302. package/dist/guest/databases/index.js +2 -0
  303. package/dist/guest/databases/mongodb.d.ts +7 -0
  304. package/dist/guest/databases/mongodb.js +46 -0
  305. package/dist/guest/databases/mysql.d.ts +7 -0
  306. package/dist/guest/databases/mysql.js +59 -0
  307. package/dist/guest/databases/names.d.ts +5 -0
  308. package/dist/guest/databases/names.js +8 -0
  309. package/dist/guest/databases/postgres.d.ts +9 -0
  310. package/dist/guest/databases/postgres.js +85 -0
  311. package/dist/guest/databases/redis.d.ts +7 -0
  312. package/dist/guest/databases/redis.js +25 -0
  313. package/dist/guest/databases/registry.d.ts +5 -0
  314. package/dist/guest/databases/registry.js +51 -0
  315. package/dist/guest/databases/sbx-db.d.ts +1 -0
  316. package/dist/guest/{db.js → databases/sbx-db.js} +13 -13
  317. package/dist/guest/{toolchains/databases → databases}/server.d.ts +5 -5
  318. package/dist/guest/{toolchains/databases → databases}/server.js +18 -13
  319. package/dist/guest/entries/daemon.js +16 -0
  320. package/dist/guest/entries/db.js +10 -0
  321. package/dist/guest/entries/gitguard.js +20 -0
  322. package/dist/guest/entries/main.d.ts +1 -0
  323. package/dist/guest/entries/main.js +24 -0
  324. package/dist/guest/entries/netproxy.d.ts +1 -0
  325. package/dist/guest/entries/netproxy.js +7 -0
  326. package/dist/guest/entries/view.d.ts +1 -0
  327. package/dist/guest/entries/view.js +11 -0
  328. package/dist/guest/{gitguard.js → git/decision.js} +49 -26
  329. package/dist/guest/network/addresses.d.ts +2 -0
  330. package/dist/guest/network/addresses.js +6 -0
  331. package/dist/guest/{setup/network.d.ts → network/allow-only.d.ts} +0 -10
  332. package/dist/guest/network/allow-only.js +84 -0
  333. package/dist/guest/network/firewall.d.ts +9 -0
  334. package/dist/guest/{setup/network.js → network/firewall.js} +58 -63
  335. package/dist/guest/network/proxy-server.d.ts +2 -0
  336. package/dist/guest/{netproxy.js → network/proxy-server.js} +37 -18
  337. package/dist/guest/{helpers.d.ts → runtime/csc.d.ts} +1 -1
  338. package/dist/guest/{helpers.js → runtime/csc.js} +7 -2
  339. package/dist/guest/runtime/fs.d.ts +2 -0
  340. package/dist/guest/runtime/fs.js +6 -0
  341. package/dist/guest/runtime/log.d.ts +3 -0
  342. package/dist/guest/runtime/log.js +22 -0
  343. package/dist/guest/runtime/paths.d.ts +13 -0
  344. package/dist/guest/runtime/paths.js +14 -0
  345. package/dist/guest/{ports.js → runtime/ports.js} +8 -2
  346. package/dist/guest/runtime/process.d.ts +15 -0
  347. package/dist/guest/runtime/process.js +59 -0
  348. package/dist/guest/{project-context.js → runtime/project-context.js} +1 -1
  349. package/dist/guest/runtime/session.d.ts +5 -0
  350. package/dist/guest/runtime/session.js +10 -0
  351. package/dist/guest/runtime/status.d.ts +7 -0
  352. package/dist/guest/runtime/status.js +57 -0
  353. package/dist/guest/{cmdline.js → sessions/cmdline.js} +10 -4
  354. package/dist/guest/{ptyhost.js → sessions/pty-host.js} +12 -5
  355. package/dist/guest/{view.js → sessions/viewer.js} +8 -11
  356. package/dist/guest/setup/claude-mem.d.ts +10 -0
  357. package/dist/guest/setup/{claude.js → claude-mem.js} +18 -78
  358. package/dist/guest/setup/{claude.d.ts → claude-profile.d.ts} +0 -10
  359. package/dist/guest/setup/claude-profile.js +89 -0
  360. package/dist/guest/setup/desktop.d.ts +2 -0
  361. package/dist/guest/setup/desktop.js +32 -0
  362. package/dist/guest/setup/environment.js +28 -5
  363. package/dist/guest/setup/{user.d.ts → git-identity.d.ts} +0 -2
  364. package/dist/guest/setup/git-identity.js +34 -0
  365. package/dist/guest/{gitrules.d.ts → setup/git-rules.d.ts} +1 -1
  366. package/dist/guest/setup/git-rules.js +50 -0
  367. package/dist/guest/setup/hooks.js +22 -5
  368. package/dist/guest/setup/{policy.js → managed-policy.js} +2 -2
  369. package/dist/guest/toolchains/catalogue.d.ts +4 -4
  370. package/dist/guest/toolchains/catalogue.js +30 -7
  371. package/dist/guest/toolchains/detect.d.ts +12 -0
  372. package/dist/guest/toolchains/detect.js +54 -0
  373. package/dist/guest/toolchains/index.d.ts +3 -17
  374. package/dist/guest/toolchains/index.js +1 -80
  375. package/dist/guest/toolchains/install.d.ts +20 -0
  376. package/dist/guest/toolchains/install.js +29 -0
  377. package/dist/guest/toolchains/languages/go.d.ts +3 -0
  378. package/dist/guest/toolchains/{go.js → languages/go.js} +27 -9
  379. package/dist/guest/toolchains/languages/java.d.ts +8 -0
  380. package/dist/guest/toolchains/{java.js → languages/java.js} +57 -18
  381. package/dist/guest/toolchains/languages/node.d.ts +3 -0
  382. package/dist/guest/toolchains/{node.js → languages/node.js} +51 -18
  383. package/dist/guest/toolchains/languages/php.d.ts +3 -0
  384. package/dist/guest/toolchains/{scripting → languages}/php.js +36 -11
  385. package/dist/guest/toolchains/languages/python-tools.d.ts +3 -0
  386. package/dist/guest/toolchains/languages/python-tools.js +12 -0
  387. package/dist/guest/toolchains/languages/python.d.ts +3 -0
  388. package/dist/guest/toolchains/{python.js → languages/python.js} +29 -16
  389. package/dist/guest/toolchains/languages/ruby.d.ts +3 -0
  390. package/dist/guest/toolchains/{scripting → languages}/ruby.js +28 -10
  391. package/dist/guest/toolchains/leftovers.d.ts +1 -1
  392. package/dist/guest/toolchains/leftovers.js +13 -11
  393. package/dist/guest/toolchains/managers.d.ts +6 -6
  394. package/dist/guest/toolchains/managers.js +38 -17
  395. package/dist/guest/toolchains/native/binstall.d.ts +3 -2
  396. package/dist/guest/toolchains/native/binstall.js +20 -8
  397. package/dist/guest/toolchains/native/cpp.d.ts +2 -2
  398. package/dist/guest/toolchains/native/cpp.js +23 -8
  399. package/dist/guest/toolchains/native/dotnet.d.ts +5 -3
  400. package/dist/guest/toolchains/native/dotnet.js +72 -24
  401. package/dist/guest/toolchains/native/mesa.d.ts +2 -2
  402. package/dist/guest/toolchains/native/mesa.js +27 -10
  403. package/dist/guest/toolchains/native/msvc/environment.d.ts +4 -4
  404. package/dist/guest/toolchains/native/msvc/environment.js +30 -16
  405. package/dist/guest/toolchains/native/msvc/index.d.ts +3 -3
  406. package/dist/guest/toolchains/native/msvc/index.js +10 -8
  407. package/dist/guest/toolchains/native/msvc/packages.d.ts +1 -1
  408. package/dist/guest/toolchains/native/msvc/packages.js +69 -23
  409. package/dist/guest/toolchains/native/msvc/tree.d.ts +6 -6
  410. package/dist/guest/toolchains/native/msvc/tree.js +15 -9
  411. package/dist/guest/toolchains/native/rust-extras.d.ts +23 -0
  412. package/dist/guest/toolchains/native/rust-extras.js +100 -0
  413. package/dist/guest/toolchains/native/rust.d.ts +2 -2
  414. package/dist/guest/toolchains/native/rust.js +41 -10
  415. package/dist/guest/toolchains/{scripting → native}/vcruntime.d.ts +2 -2
  416. package/dist/guest/toolchains/{scripting → native}/vcruntime.js +17 -7
  417. package/dist/guest/toolchains/package-ledger.d.ts +17 -0
  418. package/dist/guest/toolchains/package-ledger.js +54 -0
  419. package/dist/guest/toolchains/plan.d.ts +3 -24
  420. package/dist/guest/toolchains/plan.js +99 -111
  421. package/dist/guest/toolchains/runtimes.d.ts +6 -6
  422. package/dist/guest/toolchains/runtimes.js +31 -13
  423. package/dist/guest/toolchains/scheduler.d.ts +22 -0
  424. package/dist/guest/toolchains/scheduler.js +123 -0
  425. package/dist/guest/toolchains/setup.d.ts +10 -0
  426. package/dist/guest/toolchains/setup.js +22 -0
  427. package/dist/guest/toolchains/state-file.d.ts +3 -0
  428. package/dist/guest/toolchains/state-file.js +10 -0
  429. package/dist/guest/toolchains/step.d.ts +24 -0
  430. package/dist/guest/toolchains/step.js +1 -0
  431. package/dist/guest/toolchains/tool-env.d.ts +12 -0
  432. package/dist/guest/toolchains/tool-env.js +16 -0
  433. package/dist/guest/toolchains/tools/cli.d.ts +10 -0
  434. package/dist/guest/toolchains/{cli.js → tools/cli.js} +35 -15
  435. package/dist/guest/toolchains/tools/git.d.ts +3 -0
  436. package/dist/guest/toolchains/{git.js → tools/git.js} +38 -15
  437. package/dist/guest/toolchains/tools/pwsh.d.ts +4 -0
  438. package/dist/guest/toolchains/{pwsh.js → tools/pwsh.js} +14 -7
  439. package/dist/guest/toolchains/{vscode-profile.d.ts → tools/vscode-profile.d.ts} +6 -6
  440. package/dist/guest/toolchains/{vscode-profile.js → tools/vscode-profile.js} +28 -12
  441. package/dist/guest/toolchains/{vscode.d.ts → tools/vscode.d.ts} +6 -6
  442. package/dist/guest/toolchains/{vscode.js → tools/vscode.js} +67 -21
  443. package/dist/guest/toolchains/version-cache.d.ts +16 -0
  444. package/dist/guest/toolchains/version-cache.js +67 -0
  445. package/dist/host/agent-commands/commands.d.ts +13 -0
  446. package/dist/host/agent-commands/commands.js +33 -0
  447. package/dist/host/agent-commands/forwarders.d.ts +7 -0
  448. package/dist/host/agent-commands/forwarders.js +31 -0
  449. package/dist/host/agent-commands/index.d.ts +4 -0
  450. package/dist/host/agent-commands/index.js +4 -0
  451. package/dist/host/agent-commands/reconcile.d.ts +12 -0
  452. package/dist/host/agent-commands/reconcile.js +69 -0
  453. package/dist/host/agent-commands/user-path.d.ts +2 -0
  454. package/dist/host/agent-commands/user-path.js +33 -0
  455. package/dist/host/audit/collect.d.ts +2 -2
  456. package/dist/host/audit/collect.js +59 -22
  457. package/dist/host/audit/log.d.ts +2 -2
  458. package/dist/host/audit/log.js +24 -8
  459. package/dist/host/{attach.d.ts → channel/attach.d.ts} +2 -2
  460. package/dist/host/{attach.js → channel/attach.js} +33 -15
  461. package/dist/host/channel/channel.d.ts +51 -0
  462. package/dist/host/channel/channel.js +196 -0
  463. package/dist/host/channel/index.d.ts +2 -0
  464. package/dist/host/channel/index.js +2 -0
  465. package/dist/host/guard/agent-files.d.ts +7 -0
  466. package/dist/host/guard/agent-files.js +103 -0
  467. package/dist/host/guard/commands.d.ts +10 -0
  468. package/dist/host/guard/commands.js +123 -0
  469. package/dist/host/guard/file-hash.d.ts +4 -0
  470. package/dist/host/guard/file-hash.js +37 -0
  471. package/dist/host/guard/git-config.d.ts +5 -0
  472. package/dist/host/guard/git-config.js +62 -0
  473. package/dist/host/guard/git-dirs.d.ts +12 -0
  474. package/dist/host/guard/git-dirs.js +53 -0
  475. package/dist/host/guard/index.d.ts +5 -0
  476. package/dist/host/guard/index.js +4 -0
  477. package/dist/host/guard/mark-of-the-web.d.ts +8 -0
  478. package/dist/host/guard/mark-of-the-web.js +74 -0
  479. package/dist/host/guard/nested-repos.d.ts +14 -0
  480. package/dist/host/guard/nested-repos.js +88 -0
  481. package/dist/host/guard/quarantine.d.ts +3 -0
  482. package/dist/host/guard/quarantine.js +24 -0
  483. package/dist/host/guard/repo-guard.d.ts +10 -0
  484. package/dist/host/guard/repo-guard.js +36 -0
  485. package/dist/host/guard/store.d.ts +40 -0
  486. package/dist/host/guard/store.js +145 -0
  487. package/dist/host/guard/types.d.ts +27 -0
  488. package/dist/host/guard/types.js +3 -0
  489. package/dist/host/guard/watch-state.d.ts +9 -0
  490. package/dist/host/guard/watch-state.js +26 -0
  491. package/dist/host/launch/boot-projects.d.ts +17 -0
  492. package/dist/host/launch/{projects.js → boot-projects.js} +27 -12
  493. package/dist/host/{database-plan.d.ts → launch/database-plan.d.ts} +5 -5
  494. package/dist/host/{database-plan.js → launch/database-plan.js} +24 -13
  495. package/dist/host/launch/generate.d.ts +4 -0
  496. package/dist/host/launch/generate.js +77 -0
  497. package/dist/host/launch/index.d.ts +10 -0
  498. package/dist/host/launch/index.js +10 -0
  499. package/dist/host/launch/mappings.d.ts +7 -2
  500. package/dist/host/launch/mappings.js +83 -24
  501. package/dist/host/launch/pc-scan.d.ts +5 -0
  502. package/dist/host/{pc-scan.js → launch/pc-scan.js} +20 -13
  503. package/dist/host/launch/project-scan.d.ts +7 -0
  504. package/dist/host/{project-scan.js → launch/project-scan.js} +29 -21
  505. package/dist/host/launch/session-file.d.ts +23 -0
  506. package/dist/host/launch/session-file.js +73 -0
  507. package/dist/host/launch/stage.d.ts +5 -5
  508. package/dist/host/launch/stage.js +14 -13
  509. package/dist/host/launch/toolchains.d.ts +4 -0
  510. package/dist/host/launch/toolchains.js +11 -0
  511. package/dist/host/launch/{wsb.d.ts → wsb-file.d.ts} +4 -2
  512. package/dist/host/launch/wsb-file.js +56 -0
  513. package/dist/host/life/crash-report.d.ts +8 -0
  514. package/dist/host/life/crash-report.js +87 -0
  515. package/dist/host/life/index.d.ts +6 -0
  516. package/dist/host/life/index.js +6 -0
  517. package/dist/host/life/keep-awake.d.ts +10 -0
  518. package/dist/host/life/keep-awake.js +29 -0
  519. package/dist/host/life/life-record.d.ts +48 -0
  520. package/dist/host/life/life-record.js +76 -0
  521. package/dist/host/life/stop-events.d.ts +27 -0
  522. package/dist/host/life/stop-events.js +96 -0
  523. package/dist/host/life/stop-warning.d.ts +4 -0
  524. package/dist/host/life/stop-warning.js +25 -0
  525. package/dist/host/life/windows-update.d.ts +3 -0
  526. package/dist/host/life/windows-update.js +11 -0
  527. package/dist/host/native.d.ts +4 -0
  528. package/dist/host/native.js +11 -0
  529. package/dist/host/network/index.d.ts +1 -0
  530. package/dist/host/network/index.js +1 -0
  531. package/dist/host/{port-forward.d.ts → network/port-forward.d.ts} +1 -1
  532. package/dist/host/{port-forward.js → network/port-forward.js} +16 -10
  533. package/dist/host/profile/accounts.d.ts +37 -0
  534. package/dist/host/profile/accounts.js +146 -0
  535. package/dist/host/profile/claude-login.d.ts +22 -0
  536. package/dist/host/profile/claude-login.js +57 -0
  537. package/dist/host/{claude-profile.d.ts → profile/claude-profile.d.ts} +9 -9
  538. package/dist/host/{claude-profile.js → profile/claude-profile.js} +32 -22
  539. package/dist/host/profile/index.d.ts +7 -0
  540. package/dist/host/profile/index.js +7 -0
  541. package/dist/host/profile/personalize.d.ts +2 -0
  542. package/dist/host/profile/personalize.js +127 -0
  543. package/dist/host/profile/reg-file.d.ts +8 -0
  544. package/dist/host/profile/reg-file.js +45 -0
  545. package/dist/host/profile/secret-files.d.ts +2 -0
  546. package/dist/host/profile/secret-files.js +25 -0
  547. package/dist/host/profile/secret-patterns.d.ts +6 -0
  548. package/dist/host/profile/secret-patterns.js +128 -0
  549. package/dist/host/profile/secrets.d.ts +12 -0
  550. package/dist/host/profile/secrets.js +100 -0
  551. package/dist/host/projects/index.d.ts +4 -0
  552. package/dist/host/projects/index.js +4 -0
  553. package/dist/host/projects/join.d.ts +38 -0
  554. package/dist/host/projects/join.js +119 -0
  555. package/dist/host/projects/known.d.ts +28 -0
  556. package/dist/host/projects/known.js +55 -0
  557. package/dist/host/projects/mapper.d.ts +29 -0
  558. package/dist/host/projects/mapper.js +88 -0
  559. package/dist/host/projects/registry.d.ts +83 -0
  560. package/dist/host/projects/registry.js +136 -0
  561. package/dist/host/sandbox/doctor.d.ts +2 -0
  562. package/dist/host/sandbox/doctor.js +42 -0
  563. package/dist/host/sandbox/host-claude.d.ts +1 -0
  564. package/dist/host/sandbox/host-claude.js +26 -0
  565. package/dist/host/sandbox/index.d.ts +6 -0
  566. package/dist/host/sandbox/index.js +6 -0
  567. package/dist/host/{platform.d.ts → sandbox/platform.d.ts} +0 -5
  568. package/dist/host/sandbox/platform.js +60 -0
  569. package/dist/host/sandbox/probe.d.ts +3 -0
  570. package/dist/host/sandbox/probe.js +47 -0
  571. package/dist/host/{window.js → sandbox/window.js} +7 -5
  572. package/dist/host/{wsb.js → sandbox/wsb-cli.js} +31 -8
  573. package/dist/host/{cleanup.js → storage/cleanup.js} +27 -12
  574. package/dist/host/storage/index.d.ts +2 -0
  575. package/dist/host/storage/index.js +2 -0
  576. package/dist/host/storage/state-files.d.ts +4 -0
  577. package/dist/host/storage/state-files.js +10 -0
  578. package/dist/host/test-guard.js +1 -1
  579. package/dist/host/tools/conpty.d.ts +8 -0
  580. package/dist/host/tools/conpty.js +58 -0
  581. package/dist/host/tools/index.d.ts +2 -0
  582. package/dist/host/tools/index.js +2 -0
  583. package/dist/host/{terminal.d.ts → tools/windows-terminal.d.ts} +2 -10
  584. package/dist/host/{terminal.js → tools/windows-terminal.js} +33 -57
  585. package/dist/host/workspace-view/active-views.d.ts +3 -0
  586. package/dist/host/workspace-view/active-views.js +22 -0
  587. package/dist/host/workspace-view/index.d.ts +2 -18
  588. package/dist/host/workspace-view/index.js +2 -49
  589. package/dist/host/workspace-view/plan.d.ts +16 -0
  590. package/dist/host/workspace-view/plan.js +50 -0
  591. package/dist/host/workspace-view/rules.js +10 -3
  592. package/dist/host/workspace-view/view-state.d.ts +10 -0
  593. package/dist/host/workspace-view/view-state.js +31 -0
  594. package/dist/host/workspace-view/view.d.ts +1 -0
  595. package/dist/host/workspace-view/view.js +51 -55
  596. package/dist/runtime/daemon.js +4232 -1918
  597. package/dist/runtime/db.js +2145 -830
  598. package/dist/runtime/gitguard.js +29 -11
  599. package/dist/runtime/main.js +4760 -2155
  600. package/dist/runtime/netproxy.js +1654 -418
  601. package/dist/runtime/view.js +1515 -453
  602. package/dist/selftest/accounts.test.d.ts +1 -1
  603. package/dist/selftest/accounts.test.js +20 -17
  604. package/dist/selftest/agent-commands.test.d.ts +1 -1
  605. package/dist/selftest/agent-commands.test.js +9 -5
  606. package/dist/selftest/audit.test.d.ts +1 -1
  607. package/dist/selftest/audit.test.js +46 -13
  608. package/dist/selftest/channel.test.d.ts +1 -1
  609. package/dist/selftest/channel.test.js +91 -8
  610. package/dist/selftest/cli.test.d.ts +1 -1
  611. package/dist/selftest/cli.test.js +68 -16
  612. package/dist/selftest/cmdline.test.d.ts +1 -1
  613. package/dist/selftest/cmdline.test.js +36 -7
  614. package/dist/selftest/config.test.d.ts +1 -1
  615. package/dist/selftest/config.test.js +12 -5
  616. package/dist/selftest/data.test.d.ts +1 -1
  617. package/dist/selftest/data.test.js +35 -6
  618. package/dist/selftest/detect.test.d.ts +1 -1
  619. package/dist/selftest/detect.test.js +22 -9
  620. package/dist/selftest/generate.test.d.ts +1 -1
  621. package/dist/selftest/generate.test.js +33 -9
  622. package/dist/selftest/git-access.test.d.ts +1 -1
  623. package/dist/selftest/git-access.test.js +42 -4
  624. package/dist/selftest/guest-boot.test.d.ts +1 -1
  625. package/dist/selftest/guest-boot.test.js +25 -7
  626. package/dist/selftest/host-sim.test.d.ts +1 -1
  627. package/dist/selftest/host-sim.test.js +27 -3
  628. package/dist/selftest/hostile-input.test.d.ts +1 -1
  629. package/dist/selftest/hostile-input.test.js +5 -5
  630. package/dist/selftest/index.d.ts +1 -1
  631. package/dist/selftest/index.js +73 -16
  632. package/dist/selftest/layout.test.d.ts +2 -0
  633. package/dist/selftest/layout.test.js +131 -0
  634. package/dist/selftest/links.test.d.ts +1 -1
  635. package/dist/selftest/links.test.js +16 -11
  636. package/dist/selftest/live-daemon.test.d.ts +1 -1
  637. package/dist/selftest/live-daemon.test.js +20 -8
  638. package/dist/selftest/live-git.test.d.ts +1 -1
  639. package/dist/selftest/live-git.test.js +13 -4
  640. package/dist/selftest/live-network.test.d.ts +1 -1
  641. package/dist/selftest/live-network.test.js +24 -9
  642. package/dist/selftest/live-projects.test.d.ts +1 -1
  643. package/dist/selftest/live-projects.test.js +47 -20
  644. package/dist/selftest/live-terminal.test.d.ts +2 -0
  645. package/dist/selftest/live-terminal.test.js +195 -0
  646. package/dist/selftest/local-config.test.d.ts +1 -1
  647. package/dist/selftest/local-config.test.js +88 -15
  648. package/dist/selftest/mirror.test.d.ts +1 -1
  649. package/dist/selftest/mirror.test.js +118 -19
  650. package/dist/selftest/network.test.d.ts +1 -1
  651. package/dist/selftest/network.test.js +17 -8
  652. package/dist/selftest/personalization.test.d.ts +1 -1
  653. package/dist/selftest/personalization.test.js +12 -5
  654. package/dist/selftest/projects.test.d.ts +1 -1
  655. package/dist/selftest/projects.test.js +336 -72
  656. package/dist/selftest/repair.test.d.ts +1 -1
  657. package/dist/selftest/repair.test.js +17 -5
  658. package/dist/selftest/repo-guard.test.d.ts +1 -1
  659. package/dist/selftest/repo-guard.test.js +21 -20
  660. package/dist/selftest/secrets.test.d.ts +1 -1
  661. package/dist/selftest/secrets.test.js +57 -13
  662. package/dist/selftest/setup.test.d.ts +1 -1
  663. package/dist/selftest/setup.test.js +25 -5
  664. package/dist/selftest/{fixtures.d.ts → support/fixtures.d.ts} +7 -4
  665. package/dist/selftest/{fixtures.js → support/fixtures.js} +95 -17
  666. package/dist/selftest/{harness.js → support/harness.js} +24 -7
  667. package/dist/selftest/{live.d.ts → support/live.d.ts} +2 -2
  668. package/dist/selftest/{live.js → support/live.js} +34 -10
  669. package/dist/selftest/support/suite.js +1 -0
  670. package/dist/selftest/sync.test.d.ts +1 -1
  671. package/dist/selftest/sync.test.js +64 -26
  672. package/dist/selftest/test-guard.test.d.ts +1 -1
  673. package/dist/selftest/test-guard.test.js +43 -15
  674. package/dist/selftest/toolchains.test.d.ts +1 -1
  675. package/dist/selftest/toolchains.test.js +135 -36
  676. package/dist/selftest/workspace-view.test.d.ts +1 -1
  677. package/dist/selftest/workspace-view.test.js +48 -11
  678. package/dist/selftest/workspace.test.d.ts +1 -1
  679. package/dist/selftest/workspace.test.js +13 -4
  680. package/dist/shared/{apps.d.ts → apps/catalogue.d.ts} +1 -11
  681. package/dist/shared/apps/catalogue.js +768 -0
  682. package/dist/shared/apps/index.d.ts +2 -0
  683. package/dist/shared/apps/index.js +2 -0
  684. package/dist/shared/apps/selection.d.ts +11 -0
  685. package/dist/shared/apps/selection.js +40 -0
  686. package/dist/shared/channel/index.d.ts +2 -0
  687. package/dist/shared/channel/index.js +2 -0
  688. package/dist/shared/channel/run-dir.d.ts +30 -0
  689. package/dist/shared/channel/run-dir.js +84 -0
  690. package/dist/shared/{schema.d.ts → channel/schema.d.ts} +60 -19
  691. package/dist/shared/channel/schema.js +131 -0
  692. package/dist/shared/download/archive.d.ts +13 -0
  693. package/dist/shared/download/archive.js +57 -0
  694. package/dist/shared/download/downloader.d.ts +35 -0
  695. package/dist/shared/download/downloader.js +110 -0
  696. package/dist/shared/download/github.d.ts +16 -0
  697. package/dist/shared/download/github.js +74 -0
  698. package/dist/shared/download/http.d.ts +5 -0
  699. package/dist/shared/download/http.js +30 -0
  700. package/dist/shared/download/index.d.ts +5 -0
  701. package/dist/shared/download/index.js +5 -0
  702. package/dist/shared/download/spawn.d.ts +2 -0
  703. package/dist/shared/download/spawn.js +7 -0
  704. package/dist/shared/io/index.d.ts +3 -0
  705. package/dist/shared/io/index.js +3 -0
  706. package/dist/shared/io/json-file.d.ts +10 -0
  707. package/dist/shared/io/json-file.js +21 -0
  708. package/dist/shared/io/json.d.ts +13 -0
  709. package/dist/shared/io/json.js +49 -0
  710. package/dist/shared/{safe-remove.js → io/safe-remove.js} +32 -7
  711. package/dist/shared/{netrules.js → network/firewall-rules.js} +36 -5
  712. package/dist/shared/network/index.d.ts +2 -0
  713. package/dist/shared/network/index.js +2 -0
  714. package/dist/shared/{netpolicy.js → network/policy.js} +66 -11
  715. package/dist/shared/{paths.js → paths/claude-paths.js} +12 -2
  716. package/dist/shared/{guest-paths.d.ts → paths/guest-paths.d.ts} +21 -0
  717. package/dist/shared/paths/guest-paths.js +146 -0
  718. package/dist/shared/paths/index.d.ts +3 -0
  719. package/dist/shared/paths/index.js +3 -0
  720. package/dist/shared/{projects.d.ts → paths/projects.d.ts} +27 -4
  721. package/dist/shared/paths/projects.js +136 -0
  722. package/dist/shared/pty/client.d.ts +21 -0
  723. package/dist/shared/pty/client.js +79 -0
  724. package/dist/shared/pty/console-input.d.ts +11 -0
  725. package/dist/shared/pty/console-input.js +81 -0
  726. package/dist/shared/pty/index.d.ts +6 -0
  727. package/dist/shared/pty/index.js +6 -0
  728. package/dist/shared/pty/input-joiner.d.ts +15 -0
  729. package/dist/shared/pty/input-joiner.js +44 -0
  730. package/dist/shared/pty/output-filter.d.ts +13 -0
  731. package/dist/shared/pty/output-filter.js +140 -0
  732. package/dist/shared/pty/protocol.d.ts +36 -0
  733. package/dist/shared/pty/protocol.js +60 -0
  734. package/dist/shared/pty/terminal.d.ts +24 -0
  735. package/dist/shared/pty/terminal.js +147 -0
  736. package/dist/shared/test-guard.js +3 -1
  737. package/dist/sync/claude-mem.d.ts +1 -1
  738. package/dist/sync/claude-mem.js +9 -4
  739. package/dist/sync/history.d.ts +1 -29
  740. package/dist/sync/history.js +57 -45
  741. package/dist/sync/index.d.ts +5 -0
  742. package/dist/sync/index.js +5 -0
  743. package/dist/sync/sync-cycle.d.ts +18 -0
  744. package/dist/sync/sync-cycle.js +85 -0
  745. package/dist/sync/sync-state.d.ts +32 -0
  746. package/dist/sync/sync-state.js +37 -0
  747. package/dist/sync/watcher.d.ts +0 -18
  748. package/dist/sync/watcher.js +66 -100
  749. package/native/keep-awake.ps1 +8 -0
  750. package/native/power.cs +23 -0
  751. package/native/stop-events.ps1 +38 -0
  752. package/package.json +11 -3
  753. package/sandbox/linkgate.cs +98 -0
  754. package/sandbox/memlog.ps1 +15 -6
  755. package/sandbox/ptyhost.cs +60 -3
  756. package/schemas/config.schema.json +48 -1
  757. package/schemas/sandbox-config.schema.json +37 -3
  758. package/dist/cli/commands/launch.d.ts +0 -29
  759. package/dist/cli/commands/launch.js +0 -366
  760. package/dist/cli/commands/maintenance.d.ts +0 -10
  761. package/dist/cli/commands/maintenance.js +0 -187
  762. package/dist/cli/commands/project.d.ts +0 -29
  763. package/dist/cli/commands/project.js +0 -63
  764. package/dist/cli/commands/projects.d.ts +0 -14
  765. package/dist/cli/commands/projects.js +0 -146
  766. package/dist/cli/commands/restart.d.ts +0 -6
  767. package/dist/cli/commands/restart.js +0 -85
  768. package/dist/cli/commands/sessions.d.ts +0 -12
  769. package/dist/cli/commands/sessions.js +0 -257
  770. package/dist/cli/menu/settings/editors.js +0 -305
  771. package/dist/cli/progress.d.ts +0 -9
  772. package/dist/cli/progress.js +0 -49
  773. package/dist/cli/tui/dialogs.d.ts +0 -57
  774. package/dist/cli/tui/dialogs.js +0 -162
  775. package/dist/core/config.js +0 -109
  776. package/dist/core/schema.d.ts +0 -6
  777. package/dist/core/schema.js +0 -8
  778. package/dist/core/util.d.ts +0 -62
  779. package/dist/core/util.js +0 -156
  780. package/dist/core/workspace.d.ts +0 -18
  781. package/dist/core/workspace.js +0 -145
  782. package/dist/guest/boot-env.d.ts +0 -4
  783. package/dist/guest/daemon.js +0 -57
  784. package/dist/guest/env.d.ts +0 -52
  785. package/dist/guest/env.js +0 -103
  786. package/dist/guest/gitrules.js +0 -11
  787. package/dist/guest/project-status.d.ts +0 -5
  788. package/dist/guest/project-status.js +0 -17
  789. package/dist/guest/setup/user.js +0 -51
  790. package/dist/guest/toolchains/cli.d.ts +0 -10
  791. package/dist/guest/toolchains/common.d.ts +0 -54
  792. package/dist/guest/toolchains/common.js +0 -147
  793. package/dist/guest/toolchains/databases/dynamodb.d.ts +0 -8
  794. package/dist/guest/toolchains/databases/dynamodb.js +0 -52
  795. package/dist/guest/toolchains/databases/index.d.ts +0 -6
  796. package/dist/guest/toolchains/databases/index.js +0 -62
  797. package/dist/guest/toolchains/databases/mongodb.d.ts +0 -3
  798. package/dist/guest/toolchains/databases/mongodb.js +0 -31
  799. package/dist/guest/toolchains/databases/mysql.d.ts +0 -3
  800. package/dist/guest/toolchains/databases/mysql.js +0 -38
  801. package/dist/guest/toolchains/databases/postgres.d.ts +0 -5
  802. package/dist/guest/toolchains/databases/postgres.js +0 -38
  803. package/dist/guest/toolchains/databases/redis.d.ts +0 -3
  804. package/dist/guest/toolchains/databases/redis.js +0 -16
  805. package/dist/guest/toolchains/git.d.ts +0 -3
  806. package/dist/guest/toolchains/go.d.ts +0 -3
  807. package/dist/guest/toolchains/java.d.ts +0 -8
  808. package/dist/guest/toolchains/node.d.ts +0 -3
  809. package/dist/guest/toolchains/pwsh.d.ts +0 -4
  810. package/dist/guest/toolchains/python.d.ts +0 -3
  811. package/dist/guest/toolchains/scripting/php.d.ts +0 -3
  812. package/dist/guest/toolchains/scripting/ruby.d.ts +0 -3
  813. package/dist/host/accounts.d.ts +0 -32
  814. package/dist/host/accounts.js +0 -128
  815. package/dist/host/agent-commands.d.ts +0 -25
  816. package/dist/host/agent-commands.js +0 -145
  817. package/dist/host/channel.d.ts +0 -38
  818. package/dist/host/channel.js +0 -162
  819. package/dist/host/generate.d.ts +0 -13
  820. package/dist/host/generate.js +0 -108
  821. package/dist/host/join.d.ts +0 -28
  822. package/dist/host/join.js +0 -76
  823. package/dist/host/launch/projects.d.ts +0 -15
  824. package/dist/host/launch/wsb.js +0 -34
  825. package/dist/host/motw.d.ts +0 -17
  826. package/dist/host/motw.js +0 -74
  827. package/dist/host/pc-scan.d.ts +0 -6
  828. package/dist/host/personalize.d.ts +0 -10
  829. package/dist/host/personalize.js +0 -97
  830. package/dist/host/platform.js +0 -129
  831. package/dist/host/project-scan.d.ts +0 -7
  832. package/dist/host/projects.d.ts +0 -100
  833. package/dist/host/projects.js +0 -147
  834. package/dist/host/repo-guard.d.ts +0 -43
  835. package/dist/host/repo-guard.js +0 -347
  836. package/dist/host/secrets.d.ts +0 -14
  837. package/dist/host/secrets.js +0 -133
  838. package/dist/host/stops.d.ts +0 -67
  839. package/dist/host/stops.js +0 -126
  840. package/dist/shared/apps.js +0 -114
  841. package/dist/shared/download.d.ts +0 -60
  842. package/dist/shared/download.js +0 -215
  843. package/dist/shared/guest-paths.js +0 -61
  844. package/dist/shared/projects.js +0 -67
  845. package/dist/shared/pty-client.d.ts +0 -91
  846. package/dist/shared/pty-client.js +0 -349
  847. package/dist/shared/rundir.d.ts +0 -41
  848. package/dist/shared/rundir.js +0 -96
  849. package/dist/shared/schema.js +0 -92
  850. /package/dist/{guest/daemon.d.ts → cli/tui/list/list-types.js} +0 -0
  851. /package/dist/{guest/db.d.ts → cli/tui/screen.js} +0 -0
  852. /package/dist/core/{detect-databases.d.ts → detect/databases.d.ts} +0 -0
  853. /package/dist/{guest/toolchains → core/detect}/versions.d.ts +0 -0
  854. /package/dist/guest/{setup/agents.d.ts → agents/agent-installer.d.ts} +0 -0
  855. /package/dist/guest/{audit-parse.d.ts → audit/parse.d.ts} +0 -0
  856. /package/dist/guest/{guide.d.ts → boot/guide.d.ts} +0 -0
  857. /package/dist/guest/daemon/{shutdown.d.ts → idle-shutdown.d.ts} +0 -0
  858. /package/dist/guest/daemon/{session.d.ts → sessions.d.ts} +0 -0
  859. /package/dist/guest/{main.d.ts → entries/daemon.d.ts} +0 -0
  860. /package/dist/guest/{netproxy.d.ts → entries/db.d.ts} +0 -0
  861. /package/dist/{selftest/suite.js → guest/entries/gitguard.d.ts} +0 -0
  862. /package/dist/guest/{gitguard.d.ts → git/decision.d.ts} +0 -0
  863. /package/dist/guest/{ports.d.ts → runtime/ports.d.ts} +0 -0
  864. /package/dist/guest/{project-context.d.ts → runtime/project-context.d.ts} +0 -0
  865. /package/dist/guest/{cmdline.d.ts → sessions/cmdline.d.ts} +0 -0
  866. /package/dist/guest/{ptyhost.d.ts → sessions/pty-host.d.ts} +0 -0
  867. /package/dist/guest/{view.d.ts → sessions/viewer.d.ts} +0 -0
  868. /package/dist/guest/setup/{policy.d.ts → managed-policy.d.ts} +0 -0
  869. /package/dist/host/{window.d.ts → sandbox/window.d.ts} +0 -0
  870. /package/dist/host/{wsb.d.ts → sandbox/wsb-cli.d.ts} +0 -0
  871. /package/dist/host/{cleanup.d.ts → storage/cleanup.d.ts} +0 -0
  872. /package/dist/selftest/{harness.d.ts → support/harness.d.ts} +0 -0
  873. /package/dist/selftest/{suite.d.ts → support/suite.d.ts} +0 -0
  874. /package/dist/shared/{safe-remove.d.ts → io/safe-remove.d.ts} +0 -0
  875. /package/dist/shared/{netrules.d.ts → network/firewall-rules.d.ts} +0 -0
  876. /package/dist/shared/{netpolicy.d.ts → network/policy.d.ts} +0 -0
  877. /package/dist/shared/{paths.d.ts → paths/claude-paths.d.ts} +0 -0
@@ -1,67 +0,0 @@
1
- // Several projects in one running sandbox. Windows Sandbox fixes its mapped folders at boot, so a project can only
2
- // join a running sandbox when it is already visible inside:
3
- // - the launch folder (mapped directly, as always);
4
- // - a folder inside a project root (projects.roots: whole folders of projects, mapped at every start), including
5
- // projects created after boot;
6
- // - projects mapped at boot because they were in use when the sandbox was restarted to add them;
7
- // - a folder shared into the running sandbox with `wsb share` (Windows 11 24H2+, untested).
8
- // Roots, boot-mapped projects and shares appear under C:\Projects (roots at their PC path with guestWorkspace "mirror").
9
- // Pure functions only: used by the host (registration, commands), the guest (daemon checks) and the tests.
10
- import path from 'node:path';
11
- import { isValidGuestPath } from './guest-paths.js';
12
- /** Where roots, boot-mapped projects and shared folders appear inside the sandbox. */
13
- export const PROJECTS_GUEST = 'C:\\Projects';
14
- const norm = (p) => path.win32.resolve(p).replace(/[\\/]+$/, '').toLowerCase();
15
- /** `child` is `parent` or somewhere below it (Windows paths, case-insensitive). */
16
- export const isWithin = (parent, child) => {
17
- const a = norm(parent);
18
- const b = norm(child);
19
- return a === b || b.startsWith(a.endsWith('\\') ? a : a + '\\');
20
- };
21
- /**
22
- * A project id (also its folder name under C:\Projects) for a folder: its name with only letters, digits, '-' and
23
- * '_' (ids become file names on both sides), at most 48 characters, made unique against `taken` with -2, -3, ...
24
- */
25
- export const hubName = (hostDir, taken) => {
26
- const base = path.win32.basename(path.win32.resolve(hostDir)).replace(/[^A-Za-z0-9_-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 48) || 'project';
27
- const used = new Set([...taken].map((t) => t.toLowerCase()));
28
- if (!used.has(base.toLowerCase()))
29
- return base;
30
- for (let i = 2;; i++)
31
- if (!used.has((base + '-' + i).toLowerCase()))
32
- return base + '-' + i;
33
- };
34
- /** The project a folder on this PC belongs to: the most specific one that contains it (a project inside another wins). */
35
- export const projectForHostDir = (projects, hostDir) => projects.filter((p) => isWithin(p.host, hostDir)).sort((a, b) => b.host.length - a.host.length)[0] ?? null;
36
- /** The same for a folder inside the sandbox. */
37
- export const projectForGuestDir = (projects, guestDir) => projects.filter((p) => isWithin(p.guest, guestDir)).sort((a, b) => b.guest.length - a.guest.length)[0] ?? null;
38
- /** Where a folder on this PC appears inside the sandbox, given the mapped folder (project or root) that contains it. */
39
- export const guestDirFor = (mapped, hostDir) => {
40
- const rel = path.win32.relative(path.win32.resolve(mapped.host), path.win32.resolve(hostDir));
41
- return rel ? path.win32.join(mapped.guest, rel) : mapped.guest;
42
- };
43
- /** The other way: where a folder inside the sandbox is on this PC, given the mapped folder that contains it. */
44
- export const hostDirFor = (mapped, guestDir) => {
45
- const rel = path.win32.relative(path.win32.resolve(mapped.guest), path.win32.resolve(guestDir));
46
- return rel ? path.win32.join(mapped.host, rel) : mapped.host;
47
- };
48
- /** Strictly below `parent` (never `parent` itself). */
49
- export const isBelow = (parent, child) => isWithin(parent, child) && norm(parent) !== norm(child);
50
- /** A guest folder some project can be in: below C:\Projects, or inside one of the roots (their guest paths). */
51
- export const insideProjects = (guestDir, roots = [], projectsDir = PROJECTS_GUEST) => isBelow(projectsDir, guestDir) || roots.some((r) => isWithin(r, guestDir));
52
- /**
53
- * Guest folders for the project roots and the projects mapped at boot: C:\Projects\<name>, unique; with
54
- * guestWorkspace "mirror" a root appears at its PC path when the sandbox can show it there.
55
- */
56
- export const planProjectMappings = (roots, projects, mirror, taken = []) => {
57
- const names = [...taken];
58
- const place = (host, tryMirror) => {
59
- const resolved = path.win32.resolve(host).replace(/[\\/]+$/, '');
60
- if (tryMirror && isValidGuestPath(resolved) && !isWithin(PROJECTS_GUEST, resolved))
61
- return { host: resolved, guest: resolved };
62
- const name = hubName(resolved, names);
63
- names.push(name);
64
- return { host: resolved, guest: path.win32.join(PROJECTS_GUEST, name) };
65
- };
66
- return { roots: roots.map((r) => place(r, mirror)), projects: projects.map((p) => place(p, false)) };
67
- };
@@ -1,91 +0,0 @@
1
- import net from 'node:net';
2
- export declare const FrameType: {
3
- readonly Hello: 1;
4
- readonly Input: 2;
5
- readonly Resize: 3;
6
- readonly Restart: 4;
7
- readonly Ping: 5;
8
- readonly Output: 16;
9
- readonly Exit: 17;
10
- readonly Error: 18;
11
- readonly Restarting: 19;
12
- readonly Status: 20;
13
- readonly Console: 21;
14
- };
15
- /** HELLO flags: control-only connections get no output and never size the console; a query only asks for STATUS. */
16
- export declare const HelloFlag: {
17
- readonly ControlOnly: 1;
18
- readonly Query: 2;
19
- };
20
- /** Viewers ping this often; ptyhost counts a viewer as gone after 15 s of silence (e.g. its terminal tab was closed). */
21
- export declare const PING_INTERVAL_MS = 5000;
22
- export interface Frame {
23
- type: number;
24
- payload: Buffer;
25
- }
26
- export interface Endpoint {
27
- addresses: string[];
28
- port: number;
29
- token: string;
30
- }
31
- export type ClientResult = {
32
- reason: 'exit';
33
- exitCode: number;
34
- } | {
35
- reason: 'detach' | 'closed';
36
- } | {
37
- reason: 'error';
38
- message: string;
39
- };
40
- /** Ctrl+] — the same detach key telnet uses; Claude Code does not bind it. */
41
- export declare const DETACH_KEY = 29;
42
- export declare const encodeFrame: (type: number, payload?: Buffer) => Buffer;
43
- export declare const helloFrame: (token: string, cols: number, rows: number, flags?: number) => Buffer;
44
- export declare const resizeFrame: (cols: number, rows: number) => Buffer;
45
- /** Same limit as ptyhost.cs; a peer announcing more is broken or hostile. */
46
- export declare const MAX_FRAME_BYTES: number;
47
- /** Splits a TCP byte stream back into frames. */
48
- export declare class FrameReader {
49
- private pending;
50
- push(chunk: Buffer): Frame[];
51
- }
52
- /**
53
- * Removes the terminal "strings" an untrusted program could abuse from the sandbox's output before it reaches your
54
- * terminal: clipboard writes (OSC 52), terminal macros (ConEmu's OSC 9), DCS / APC / PM / SOS, and their C1 forms.
55
- * Titles, links, progress and colours pass. A byte-level state machine, so no split across chunks, leading zero
56
- * (ESC]052) or huge payload slips through: a dropped string stays dropped until its terminator, however long it is.
57
- */
58
- export declare class OutputFilter {
59
- /** text: normal output; esc: after ESC; c2: after a 0xC2 lead byte; string: inside an OSC/DCS/...; stringEsc / stringC2: a possible terminator inside one. */
60
- private state;
61
- /** The string being read: an OSC worth keeping is collected until its terminator; null = being dropped. */
62
- private body;
63
- push(chunk: Buffer): Buffer;
64
- }
65
- /** Tries every address the sandbox published and returns the first one that answers. */
66
- export declare const connect: (endpoint: Endpoint, timeoutMs?: number) => Promise<net.Socket>;
67
- /** Sends one control frame (e.g. RESTART) without taking over the screen. */
68
- export declare const sendControl: (endpoint: Endpoint, type: number) => Promise<void>;
69
- /** Who is watching a session right now: `remote` counts viewers on the PC (not the sandbox's own tabs). */
70
- export interface Viewers {
71
- viewers: number;
72
- remote: number;
73
- }
74
- /**
75
- * Asks a session's ptyhost who is attached. Only viewers heard from in the last few seconds count, so a terminal that
76
- * was closed (or a PC that went to sleep) is not reported. null when the session does not answer: an older ptyhost
77
- * treats the query as a silent control connection, so the caller must not assume anything.
78
- */
79
- export declare const queryViewers: (endpoint: Endpoint, timeoutMs?: number) => Promise<Viewers | null>;
80
- /**
81
- * Node on Windows reads keys through the console API, where Backspace is ^H and Ctrl+Backspace is DEL: the reverse of
82
- * what terminals send. ConPTY reads ^H as Ctrl+Backspace (delete a word), so swap them back.
83
- */
84
- export declare const fixWindowsKeys: (chunk: Buffer) => Buffer;
85
- /**
86
- * Bridges this process's terminal to the remote program until it exits, the connection drops, or the user presses
87
- * the detach key. Restores the terminal before resolving.
88
- */
89
- export declare const runTerminalClient: (socket: net.Socket, token: string, options?: {
90
- detachKey?: number;
91
- }) => Promise<ClientResult>;
@@ -1,349 +0,0 @@
1
- // Client side of the ptyhost protocol (see sandbox/ptyhost.cs). Used by the window inside the sandbox and by
2
- // `--terminal` / `attach` on the host, so it only depends on Node built-ins.
3
- import net from 'node:net';
4
- export const FrameType = { Hello: 1, Input: 2, Resize: 3, Restart: 4, Ping: 5, Output: 16, Exit: 17, Error: 18, Restarting: 19, Status: 20, Console: 21 };
5
- /** HELLO flags: control-only connections get no output and never size the console; a query only asks for STATUS. */
6
- export const HelloFlag = { ControlOnly: 1, Query: 2 };
7
- /** Viewers ping this often; ptyhost counts a viewer as gone after 15 s of silence (e.g. its terminal tab was closed). */
8
- export const PING_INTERVAL_MS = 5000;
9
- /** Ctrl+] — the same detach key telnet uses; Claude Code does not bind it. */
10
- export const DETACH_KEY = 0x1d;
11
- export const encodeFrame = (type, payload = Buffer.alloc(0)) => {
12
- const header = Buffer.alloc(5);
13
- header.writeUInt8(type, 0);
14
- header.writeUInt32LE(payload.length, 1);
15
- return Buffer.concat([header, payload]);
16
- };
17
- export const helloFrame = (token, cols, rows, flags = 0) => {
18
- const head = Buffer.alloc(5);
19
- head.writeInt16LE(cols, 0);
20
- head.writeInt16LE(rows, 2);
21
- head.writeUInt8(flags, 4);
22
- return encodeFrame(FrameType.Hello, Buffer.concat([head, Buffer.from(token, 'utf8')]));
23
- };
24
- export const resizeFrame = (cols, rows) => {
25
- const payload = Buffer.alloc(4);
26
- payload.writeInt16LE(cols, 0);
27
- payload.writeInt16LE(rows, 2);
28
- return encodeFrame(FrameType.Resize, payload);
29
- };
30
- /** Same limit as ptyhost.cs; a peer announcing more is broken or hostile. */
31
- export const MAX_FRAME_BYTES = 1 << 20;
32
- /** Splits a TCP byte stream back into frames. */
33
- export class FrameReader {
34
- pending = Buffer.alloc(0);
35
- push(chunk) {
36
- this.pending = Buffer.concat([this.pending, chunk]);
37
- const frames = [];
38
- while (this.pending.length >= 5) {
39
- const length = this.pending.readUInt32LE(1);
40
- if (length > MAX_FRAME_BYTES)
41
- throw new Error('frame too large (' + length + ' bytes)');
42
- if (this.pending.length < 5 + length)
43
- break;
44
- frames.push({ type: this.pending[0], payload: this.pending.subarray(5, 5 + length) });
45
- this.pending = this.pending.subarray(5 + length);
46
- }
47
- return frames;
48
- }
49
- }
50
- /** OSC commands that may reach your terminal: window title (0, 1, 2), links (8), progress (9;4), shell marks (133). */
51
- const KEPT_OSC = (body) => {
52
- const number = /^(\d{1,4})(;|$)/.exec(body);
53
- if (!number)
54
- return false;
55
- const n = Number(number[1]);
56
- return n <= 2 || n === 8 || n === 133 || (n === 9 && body.startsWith(number[1] + ';4;'));
57
- };
58
- /** Longest OSC kept (a title or a link); anything longer is dropped whole. */
59
- const MAX_KEPT_STRING = 4096;
60
- /**
61
- * Removes the terminal "strings" an untrusted program could abuse from the sandbox's output before it reaches your
62
- * terminal: clipboard writes (OSC 52), terminal macros (ConEmu's OSC 9), DCS / APC / PM / SOS, and their C1 forms.
63
- * Titles, links, progress and colours pass. A byte-level state machine, so no split across chunks, leading zero
64
- * (ESC]052) or huge payload slips through: a dropped string stays dropped until its terminator, however long it is.
65
- */
66
- export class OutputFilter {
67
- /** text: normal output; esc: after ESC; c2: after a 0xC2 lead byte; string: inside an OSC/DCS/...; stringEsc / stringC2: a possible terminator inside one. */
68
- state = 'text';
69
- /** The string being read: an OSC worth keeping is collected until its terminator; null = being dropped. */
70
- body = null;
71
- push(chunk) {
72
- const out = Buffer.allocUnsafe(chunk.length + MAX_KEPT_STRING + 8);
73
- let n = 0;
74
- const put = (...bytes) => { for (const b of bytes)
75
- out[n++] = b; };
76
- /** After ESC (or the C1 form): ] opens an OSC (maybe kept), P X ^ _ open DCS / SOS / PM / APC (dropped). */
77
- const opens = (b, c1) => {
78
- if (b === (c1 ? 0x9d : 0x5d)) {
79
- this.body = c1 ? null : [];
80
- this.state = 'string';
81
- return true;
82
- }
83
- if ((c1 ? [0x90, 0x98, 0x9e, 0x9f] : [0x50, 0x58, 0x5e, 0x5f]).includes(b)) {
84
- this.body = null;
85
- this.state = 'string';
86
- return true;
87
- }
88
- return false;
89
- };
90
- const endString = (terminator) => {
91
- const body = this.body && Buffer.from(this.body).toString('latin1');
92
- if (body !== null && KEPT_OSC(body)) {
93
- put(0x1b, 0x5d);
94
- out.write(body, n, 'latin1');
95
- n += body.length;
96
- put(...terminator);
97
- }
98
- this.body = null;
99
- this.state = 'text';
100
- };
101
- const collect = (b) => { if (this.body && this.body.push(b) > MAX_KEPT_STRING)
102
- this.body = null; };
103
- for (const b of chunk) {
104
- switch (this.state) {
105
- case 'text':
106
- if (b === 0x1b)
107
- this.state = 'esc';
108
- else if (b === 0xc2)
109
- this.state = 'c2';
110
- else
111
- put(b);
112
- break;
113
- case 'esc':
114
- if (opens(b, false))
115
- break;
116
- if (b !== 0x1b) {
117
- put(0x1b, b);
118
- this.state = 'text';
119
- }
120
- else
121
- put(0x1b);
122
- break;
123
- case 'c2':
124
- if (opens(b, true))
125
- break;
126
- if (b === 0x1b) {
127
- put(0xc2);
128
- this.state = 'esc';
129
- }
130
- else if (b === 0xc2)
131
- put(0xc2);
132
- else {
133
- put(0xc2, b);
134
- this.state = 'text';
135
- }
136
- break;
137
- case 'string':
138
- if (b === 0x07)
139
- endString([0x07]);
140
- else if (b === 0x1b)
141
- this.state = 'stringEsc';
142
- else if (b === 0xc2)
143
- this.state = 'stringC2';
144
- else if (b === 0x18 || b === 0x1a) {
145
- this.body = null;
146
- this.state = 'text';
147
- }
148
- else
149
- collect(b);
150
- break;
151
- case 'stringC2':
152
- // U+009C is the C1 string terminator; any other character is part of the string.
153
- if (b === 0x9c)
154
- endString([0x1b, 0x5c]);
155
- else {
156
- collect(0xc2);
157
- this.state = 'string';
158
- if (b === 0x07)
159
- endString([0x07]);
160
- else if (b === 0x1b)
161
- this.state = 'stringEsc';
162
- else if (b !== 0xc2)
163
- collect(b);
164
- else
165
- this.state = 'stringC2';
166
- }
167
- break;
168
- case 'stringEsc':
169
- if (b === 0x5c) {
170
- endString([0x1b, 0x5c]);
171
- break;
172
- }
173
- // ESC inside a string ends it (dropped) and starts a new sequence.
174
- this.body = null;
175
- this.state = 'esc';
176
- if (!opens(b, false) && b !== 0x1b) {
177
- put(0x1b, b);
178
- this.state = 'text';
179
- }
180
- break;
181
- }
182
- }
183
- return out.subarray(0, n);
184
- }
185
- }
186
- const connectOnce = (host, port, timeoutMs) => {
187
- return new Promise((resolve, reject) => {
188
- const socket = net.connect({ host, port });
189
- const timer = setTimeout(() => { socket.destroy(); reject(new Error('timed out connecting to ' + host + ':' + port)); }, timeoutMs);
190
- socket.once('connect', () => { clearTimeout(timer); socket.setNoDelay(true); resolve(socket); });
191
- socket.once('error', (e) => { clearTimeout(timer); reject(e); });
192
- });
193
- };
194
- /** Tries every address the sandbox published and returns the first one that answers. */
195
- export const connect = async (endpoint, timeoutMs = 3000) => {
196
- const errors = [];
197
- for (const address of endpoint.addresses) {
198
- try {
199
- return await connectOnce(address, endpoint.port, timeoutMs);
200
- }
201
- catch (e) {
202
- errors.push(address + ': ' + (e instanceof Error ? e.message : String(e)));
203
- }
204
- }
205
- throw new Error('Could not reach the sandbox session (' + errors.join('; ') + ')');
206
- };
207
- /** Sends one control frame (e.g. RESTART) without taking over the screen. */
208
- export const sendControl = async (endpoint, type) => {
209
- const socket = await connect(endpoint);
210
- await new Promise((resolve) => socket.end(Buffer.concat([helloFrame(endpoint.token, 80, 24, HelloFlag.ControlOnly), encodeFrame(type)]), resolve));
211
- };
212
- /**
213
- * Asks a session's ptyhost who is attached. Only viewers heard from in the last few seconds count, so a terminal that
214
- * was closed (or a PC that went to sleep) is not reported. null when the session does not answer: an older ptyhost
215
- * treats the query as a silent control connection, so the caller must not assume anything.
216
- */
217
- export const queryViewers = async (endpoint, timeoutMs = 2000) => {
218
- let socket;
219
- try {
220
- socket = await connect(endpoint, timeoutMs);
221
- }
222
- catch {
223
- return null;
224
- }
225
- return new Promise((resolve) => {
226
- const reader = new FrameReader();
227
- const done = (value) => { clearTimeout(timer); socket.destroy(); resolve(value); };
228
- const timer = setTimeout(() => done(null), timeoutMs);
229
- socket.on('data', (chunk) => {
230
- let frames;
231
- try {
232
- frames = reader.push(chunk);
233
- }
234
- catch {
235
- done(null);
236
- return;
237
- }
238
- const status = frames.find((f) => f.type === FrameType.Status && f.payload.length >= 4);
239
- if (status)
240
- done({ viewers: status.payload.readInt16LE(0), remote: status.payload.readInt16LE(2) });
241
- else if (frames.some((f) => f.type === FrameType.Error))
242
- done(null);
243
- });
244
- socket.on('error', () => done(null));
245
- socket.on('close', () => done(null));
246
- socket.write(helloFrame(endpoint.token, 80, 24, HelloFlag.Query));
247
- });
248
- };
249
- /**
250
- * Node on Windows reads keys through the console API, where Backspace is ^H and Ctrl+Backspace is DEL: the reverse of
251
- * what terminals send. ConPTY reads ^H as Ctrl+Backspace (delete a word), so swap them back.
252
- */
253
- export const fixWindowsKeys = (chunk) => {
254
- if (!chunk.includes(0x08) && !chunk.includes(0x7f))
255
- return chunk;
256
- return Buffer.from(chunk.map((b) => (b === 0x08 ? 0x7f : b === 0x7f ? 0x08 : b)));
257
- };
258
- /**
259
- * Bridges this process's terminal to the remote program until it exits, the connection drops, or the user presses
260
- * the detach key. Restores the terminal before resolving.
261
- */
262
- export const runTerminalClient = (socket, token, options = {}) => {
263
- const stdin = process.stdin;
264
- const stdout = process.stdout;
265
- // getWindowSize asks the console every time; columns/rows only change when Node noticed a resize.
266
- const size = () => { const [c, r] = stdout.isTTY ? stdout.getWindowSize() : [0, 0]; return [c || 120, r || 30]; };
267
- const swapKeys = process.platform === 'win32' && stdin.isTTY;
268
- return new Promise((resolve) => {
269
- let done = false;
270
- const reader = new FrameReader();
271
- const filter = new OutputFilter();
272
- let sent = size();
273
- let resizeTimer;
274
- const finish = (result) => {
275
- if (done)
276
- return;
277
- done = true;
278
- stdin.off('data', onInput);
279
- stdout.off('resize', onResize);
280
- clearTimeout(resizeTimer);
281
- clearInterval(heartbeat);
282
- clearInterval(sizeWatch);
283
- if (stdin.isTTY)
284
- stdin.setRawMode(false);
285
- stdin.pause();
286
- socket.destroy();
287
- stdout.write('\x1b[0m\x1b[?25h\r\n');
288
- resolve(result);
289
- };
290
- const onInput = (chunk) => {
291
- if (options.detachKey !== undefined && chunk.includes(options.detachKey)) {
292
- finish({ reason: 'detach' });
293
- return;
294
- }
295
- socket.write(encodeFrame(FrameType.Input, swapKeys ? fixWindowsKeys(chunk) : chunk));
296
- };
297
- // Windows' own ConPTY repaints the whole screen on every resize; dragging a window edge fires dozens of them, and
298
- // repaints racing each other left the screen garbled. Wait until the size settles, clear what this terminal
299
- // reflowed on its own, then let ptyhost repaint everything once at the new size. With conpty.dll (passthrough)
300
- // nothing is repainted: this terminal's own reflow and scrollback stay, and the program redraws what it needs.
301
- let passthrough = false;
302
- const sendSize = () => {
303
- const [c, r] = size();
304
- if (c === sent[0] && r === sent[1])
305
- return;
306
- sent = [c, r];
307
- if (!passthrough)
308
- stdout.write('\x1b[H\x1b[J');
309
- socket.write(resizeFrame(c, r));
310
- };
311
- const onResize = () => { clearTimeout(resizeTimer); resizeTimer = setTimeout(() => { resizeTimer = undefined; sendSize(); }, 120); };
312
- const heartbeat = setInterval(() => socket.write(encodeFrame(FrameType.Ping)), PING_INTERVAL_MS);
313
- // Windows does not always report a resize in raw mode, so the size is also checked twice a second.
314
- const sizeWatch = setInterval(() => { if (!resizeTimer)
315
- sendSize(); }, 500);
316
- socket.on('data', (chunk) => {
317
- let frames;
318
- try {
319
- frames = reader.push(chunk);
320
- }
321
- catch {
322
- finish({ reason: 'error', message: 'invalid data from the sandbox' });
323
- return;
324
- }
325
- for (const frame of frames) {
326
- if (frame.type === FrameType.Output)
327
- stdout.write(filter.push(frame.payload));
328
- else if (frame.type === FrameType.Console)
329
- passthrough = frame.payload.toString('latin1') === 'conpty.dll';
330
- else if (frame.type === FrameType.Restarting)
331
- stdout.write('\x1b[2J\x1b[3J\x1b[H');
332
- else if (frame.type === FrameType.Exit)
333
- finish({ reason: 'exit', exitCode: frame.payload.length >= 4 ? frame.payload.readInt32LE(0) : 1 });
334
- else if (frame.type === FrameType.Error)
335
- finish({ reason: 'error', message: frame.payload.toString('utf8').slice(0, 500).replace(/[\x00-\x1f\x7f]/g, ' ') });
336
- }
337
- });
338
- socket.on('close', () => finish({ reason: 'closed' }));
339
- socket.on('error', () => finish({ reason: 'closed' }));
340
- const [c, r] = size();
341
- stdout.write('\x1b[2J\x1b[3J\x1b[H');
342
- socket.write(helloFrame(token, c, r));
343
- if (stdin.isTTY)
344
- stdin.setRawMode(true);
345
- stdin.on('data', onInput);
346
- stdin.resume();
347
- stdout.on('resize', onResize);
348
- });
349
- };
@@ -1,41 +0,0 @@
1
- import type { z } from 'zod';
2
- import type { GuestRequestT, GuestResponseT, ProjectStatusT, SandboxStatusT, SessionStatusT } from './schema.js';
3
- /** Anything bigger than this from the other side is ignored (a compromised sandbox must not exhaust the host). */
4
- export declare const MAX_MESSAGE_BYTES: number;
5
- /** Ids become file names, so only a strict alphabet is allowed (no separators, no dots). */
6
- export declare const safeId: (id: string) => string;
7
- export declare const runPaths: (dataDir: string) => {
8
- run: string;
9
- sandbox: string;
10
- requests: string;
11
- responses: string;
12
- sessions: string;
13
- projects: string;
14
- /** audit.processes: programs the sandbox started, in small .jsonl files the host takes in and deletes. */
15
- audit: string;
16
- request: (id: string) => string;
17
- response: (id: string) => string;
18
- session: (id: string) => string;
19
- project: (id: string) => string;
20
- };
21
- export declare const readJsonFile: <T>(file: string) => T | null;
22
- /** Reads and validates; a missing, oversized or malformed file is simply absent. */
23
- export declare const readValid: <S extends z.ZodType>(schema: S, file: string) => z.output<S> | null;
24
- /**
25
- * Write to a uniquely named temp file and rename, so a reader on the other side of the mapped folder never sees half a
26
- * file. The rename is retried briefly: antivirus or the other side's reader can hold the target for a moment.
27
- */
28
- export declare const writeJsonAtomic: (file: string, value: unknown) => void;
29
- /** Same for any text file (two commands at once, or a watcher and a command, never leave a half-written file). */
30
- export declare const writeFileAtomic: (file: string, text: string) => void;
31
- export declare const readSandboxStatus: (dataDir: string) => SandboxStatusT | null;
32
- export declare const readSession: (dataDir: string, id: string) => SessionStatusT | null;
33
- export declare const readResponse: (dataDir: string, id: string) => GuestResponseT | null;
34
- export declare const listSessions: (dataDir: string) => SessionStatusT[];
35
- export declare const readProjectStatus: (dataDir: string, name: string) => ProjectStatusT | null;
36
- export declare const listProjectStatus: (dataDir: string) => ProjectStatusT[];
37
- export declare const scanRequests: (dataDir: string) => {
38
- valid: GuestRequestT[];
39
- invalid: string[];
40
- };
41
- export declare const now: () => string;
@@ -1,96 +0,0 @@
1
- // The run folder (<data>\run on the host, C:\AgentData\run in the sandbox) is the host <-> sandbox channel. No
2
- // network needed: boot status, requests (host -> guest) and responses/status (guest -> host) are small JSON files,
3
- // written atomically and parsed with the channel schemas on read. Anything that does not parse is ignored.
4
- import fs from 'node:fs';
5
- import path from 'node:path';
6
- import { GuestRequest, GuestResponse, Id, ProjectStatus, SandboxStatus, SessionStatus } from './schema.js';
7
- import { assertTestWritable } from './test-guard.js';
8
- /** Anything bigger than this from the other side is ignored (a compromised sandbox must not exhaust the host). */
9
- export const MAX_MESSAGE_BYTES = 8 * 1024 * 1024;
10
- /** Ids become file names, so only a strict alphabet is allowed (no separators, no dots). */
11
- export const safeId = (id) => Id.parse(id);
12
- export const runPaths = (dataDir) => {
13
- const run = path.join(dataDir, 'run');
14
- const file = (dir) => (id) => path.join(run, dir, safeId(id) + '.json');
15
- return {
16
- run,
17
- sandbox: path.join(run, 'sandbox.json'),
18
- requests: path.join(run, 'requests'),
19
- responses: path.join(run, 'responses'),
20
- sessions: path.join(run, 'sessions'),
21
- projects: path.join(run, 'projects'),
22
- /** audit.processes: programs the sandbox started, in small .jsonl files the host takes in and deletes. */
23
- audit: path.join(run, 'audit'),
24
- request: file('requests'),
25
- response: file('responses'),
26
- session: file('sessions'),
27
- project: file('projects'),
28
- };
29
- };
30
- export const readJsonFile = (file) => {
31
- try {
32
- if (fs.statSync(file).size > MAX_MESSAGE_BYTES)
33
- return null;
34
- return JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
35
- }
36
- catch {
37
- return null;
38
- }
39
- };
40
- /** Reads and validates; a missing, oversized or malformed file is simply absent. */
41
- export const readValid = (schema, file) => {
42
- const parsed = schema.safeParse(readJsonFile(file));
43
- return parsed.success ? parsed.data : null;
44
- };
45
- const pause = (ms) => { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); };
46
- /**
47
- * Write to a uniquely named temp file and rename, so a reader on the other side of the mapped folder never sees half a
48
- * file. The rename is retried briefly: antivirus or the other side's reader can hold the target for a moment.
49
- */
50
- export const writeJsonAtomic = (file, value) => writeFileAtomic(file, JSON.stringify(value, null, 2) + '\n');
51
- /** Same for any text file (two commands at once, or a watcher and a command, never leave a half-written file). */
52
- export const writeFileAtomic = (file, text) => {
53
- assertTestWritable(file);
54
- fs.mkdirSync(path.dirname(file), { recursive: true });
55
- const temp = file + '.' + process.pid + '-' + Math.random().toString(36).slice(2) + '.tmp';
56
- fs.writeFileSync(temp, text, { encoding: 'utf8', flag: 'wx' });
57
- for (let attempt = 1;; attempt++) {
58
- try {
59
- fs.renameSync(temp, file);
60
- return;
61
- }
62
- catch (e) {
63
- const code = e.code;
64
- if (attempt >= 8 || (code !== 'EPERM' && code !== 'EBUSY' && code !== 'EACCES')) {
65
- fs.rmSync(temp, { force: true });
66
- throw e;
67
- }
68
- pause(50 * attempt);
69
- }
70
- }
71
- };
72
- /** Message files in a folder (strict names only), validated; invalid ones are reported separately for deletion. */
73
- const scan = (schema, dir) => {
74
- if (!fs.existsSync(dir))
75
- return { valid: [], invalid: [] };
76
- const valid = [];
77
- const invalid = [];
78
- for (const name of fs.readdirSync(dir)) {
79
- if (name.endsWith('.tmp'))
80
- continue;
81
- const message = /^[A-Za-z0-9_-]{1,64}\.json$/.test(name) ? readValid(schema, path.join(dir, name)) : null;
82
- if (message)
83
- valid.push(message);
84
- else
85
- invalid.push(path.join(dir, name));
86
- }
87
- return { valid, invalid };
88
- };
89
- export const readSandboxStatus = (dataDir) => readValid(SandboxStatus, runPaths(dataDir).sandbox);
90
- export const readSession = (dataDir, id) => readValid(SessionStatus, runPaths(dataDir).session(id));
91
- export const readResponse = (dataDir, id) => readValid(GuestResponse, runPaths(dataDir).response(id));
92
- export const listSessions = (dataDir) => scan(SessionStatus, runPaths(dataDir).sessions).valid.sort((a, b) => a.startedAt.localeCompare(b.startedAt));
93
- export const readProjectStatus = (dataDir, name) => readValid(ProjectStatus, runPaths(dataDir).project(name));
94
- export const listProjectStatus = (dataDir) => scan(ProjectStatus, runPaths(dataDir).projects).valid.slice(0, 64);
95
- export const scanRequests = (dataDir) => scan(GuestRequest, runPaths(dataDir).requests);
96
- export const now = () => new Date().toISOString();