@draht/coding-agent 2026.7.30 → 2026.9.5-1

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 (459) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/README.md +46 -2
  3. package/agents/debugger.md +12 -1
  4. package/agents/git-committer.md +1 -0
  5. package/agents/implementer.md +20 -0
  6. package/agents/investigator.md +75 -0
  7. package/agents/reviewer.md +7 -0
  8. package/agents/spec-reviewer.md +66 -0
  9. package/agents/verifier.md +4 -3
  10. package/bin/draht-tools.cjs +472 -41
  11. package/dist/agents/debugger.md +12 -1
  12. package/dist/agents/git-committer.md +1 -0
  13. package/dist/agents/implementer.md +20 -0
  14. package/dist/agents/investigator.md +75 -0
  15. package/dist/agents/reviewer.md +7 -0
  16. package/dist/agents/spec-reviewer.md +66 -0
  17. package/dist/agents/verifier.md +4 -3
  18. package/dist/cli/args.d.ts +10 -0
  19. package/dist/cli/args.d.ts.map +1 -1
  20. package/dist/cli/args.js +69 -2
  21. package/dist/cli/args.js.map +1 -1
  22. package/dist/cli/attach-mode.d.ts +61 -0
  23. package/dist/cli/attach-mode.d.ts.map +1 -1
  24. package/dist/cli/attach-mode.js +243 -5
  25. package/dist/cli/attach-mode.js.map +1 -1
  26. package/dist/cli/credential-print.d.ts +1 -1
  27. package/dist/cli/credential-print.d.ts.map +1 -1
  28. package/dist/cli/credential-print.js +5 -4
  29. package/dist/cli/credential-print.js.map +1 -1
  30. package/dist/config.d.ts +9 -0
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +31 -4
  33. package/dist/config.js.map +1 -1
  34. package/dist/core/agent-session-runtime.d.ts +17 -1
  35. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  36. package/dist/core/agent-session-runtime.js +87 -30
  37. package/dist/core/agent-session-runtime.js.map +1 -1
  38. package/dist/core/agent-session-services.d.ts +1 -1
  39. package/dist/core/agent-session-services.d.ts.map +1 -1
  40. package/dist/core/agent-session-services.js +1 -0
  41. package/dist/core/agent-session-services.js.map +1 -1
  42. package/dist/core/agent-session.d.ts +35 -16
  43. package/dist/core/agent-session.d.ts.map +1 -1
  44. package/dist/core/agent-session.js +149 -64
  45. package/dist/core/agent-session.js.map +1 -1
  46. package/dist/core/auth-storage.d.ts +5 -1
  47. package/dist/core/auth-storage.d.ts.map +1 -1
  48. package/dist/core/auth-storage.js +72 -15
  49. package/dist/core/auth-storage.js.map +1 -1
  50. package/dist/core/builtins/checkpoints.d.ts +20 -0
  51. package/dist/core/builtins/checkpoints.d.ts.map +1 -0
  52. package/dist/core/builtins/checkpoints.js +161 -0
  53. package/dist/core/builtins/checkpoints.js.map +1 -0
  54. package/dist/core/builtins/duet.d.ts +26 -0
  55. package/dist/core/builtins/duet.d.ts.map +1 -0
  56. package/dist/core/builtins/duet.js +660 -0
  57. package/dist/core/builtins/duet.js.map +1 -0
  58. package/dist/core/builtins/index.d.ts.map +1 -1
  59. package/dist/core/builtins/index.js +7 -1
  60. package/dist/core/builtins/index.js.map +1 -1
  61. package/dist/core/builtins/subagent.d.ts +24 -4
  62. package/dist/core/builtins/subagent.d.ts.map +1 -1
  63. package/dist/core/builtins/subagent.js +278 -35
  64. package/dist/core/builtins/subagent.js.map +1 -1
  65. package/dist/core/checkpoints/checkpoint-cli.d.ts +17 -0
  66. package/dist/core/checkpoints/checkpoint-cli.d.ts.map +1 -0
  67. package/dist/core/checkpoints/checkpoint-cli.js +78 -0
  68. package/dist/core/checkpoints/checkpoint-cli.js.map +1 -0
  69. package/dist/core/checkpoints/checkpoint-manager.d.ts +294 -0
  70. package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -0
  71. package/dist/core/checkpoints/checkpoint-manager.js +865 -0
  72. package/dist/core/checkpoints/checkpoint-manager.js.map +1 -0
  73. package/dist/core/checkpoints/rewind.d.ts +141 -0
  74. package/dist/core/checkpoints/rewind.d.ts.map +1 -0
  75. package/dist/core/checkpoints/rewind.js +246 -0
  76. package/dist/core/checkpoints/rewind.js.map +1 -0
  77. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  78. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  79. package/dist/core/compaction/branch-summarization.js +9 -4
  80. package/dist/core/compaction/branch-summarization.js.map +1 -1
  81. package/dist/core/compaction/compaction.d.ts +5 -0
  82. package/dist/core/compaction/compaction.d.ts.map +1 -1
  83. package/dist/core/compaction/compaction.js +25 -4
  84. package/dist/core/compaction/compaction.js.map +1 -1
  85. package/dist/core/extensions/index.d.ts +1 -1
  86. package/dist/core/extensions/index.d.ts.map +1 -1
  87. package/dist/core/extensions/index.js.map +1 -1
  88. package/dist/core/extensions/loader.d.ts.map +1 -1
  89. package/dist/core/extensions/loader.js +83 -20
  90. package/dist/core/extensions/loader.js.map +1 -1
  91. package/dist/core/extensions/runner.d.ts +13 -2
  92. package/dist/core/extensions/runner.d.ts.map +1 -1
  93. package/dist/core/extensions/runner.js +37 -2
  94. package/dist/core/extensions/runner.js.map +1 -1
  95. package/dist/core/extensions/types.d.ts +189 -6
  96. package/dist/core/extensions/types.d.ts.map +1 -1
  97. package/dist/core/extensions/types.js.map +1 -1
  98. package/dist/core/http-dispatcher.d.ts.map +1 -1
  99. package/dist/core/http-dispatcher.js +7 -0
  100. package/dist/core/http-dispatcher.js.map +1 -1
  101. package/dist/core/index.d.ts +1 -1
  102. package/dist/core/index.d.ts.map +1 -1
  103. package/dist/core/index.js.map +1 -1
  104. package/dist/core/keybindings.d.ts +5 -0
  105. package/dist/core/keybindings.d.ts.map +1 -1
  106. package/dist/core/keybindings.js +1 -0
  107. package/dist/core/keybindings.js.map +1 -1
  108. package/dist/core/model-registry.d.ts +3 -2
  109. package/dist/core/model-registry.d.ts.map +1 -1
  110. package/dist/core/model-registry.js +8 -8
  111. package/dist/core/model-registry.js.map +1 -1
  112. package/dist/core/model-resolver.d.ts.map +1 -1
  113. package/dist/core/model-resolver.js +34 -7
  114. package/dist/core/model-resolver.js.map +1 -1
  115. package/dist/core/model-runtime.d.ts +7 -1
  116. package/dist/core/model-runtime.d.ts.map +1 -1
  117. package/dist/core/model-runtime.js +30 -10
  118. package/dist/core/model-runtime.js.map +1 -1
  119. package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
  120. package/dist/core/multi-agent/permission-gate.js +4 -3
  121. package/dist/core/multi-agent/permission-gate.js.map +1 -1
  122. package/dist/core/multi-agent/worktree.d.ts +2 -0
  123. package/dist/core/multi-agent/worktree.d.ts.map +1 -1
  124. package/dist/core/multi-agent/worktree.js +2 -2
  125. package/dist/core/multi-agent/worktree.js.map +1 -1
  126. package/dist/core/package-manager.d.ts +7 -1
  127. package/dist/core/package-manager.d.ts.map +1 -1
  128. package/dist/core/package-manager.js +21 -44
  129. package/dist/core/package-manager.js.map +1 -1
  130. package/dist/core/permission-relay/index.d.ts +19 -0
  131. package/dist/core/permission-relay/index.d.ts.map +1 -0
  132. package/dist/core/permission-relay/index.js +49 -0
  133. package/dist/core/permission-relay/index.js.map +1 -0
  134. package/dist/core/permission-relay/relay-ui-context.d.ts +39 -0
  135. package/dist/core/permission-relay/relay-ui-context.d.ts.map +1 -0
  136. package/dist/core/permission-relay/relay-ui-context.js +788 -0
  137. package/dist/core/permission-relay/relay-ui-context.js.map +1 -0
  138. package/dist/core/permission-relay/types.d.ts +222 -0
  139. package/dist/core/permission-relay/types.d.ts.map +1 -0
  140. package/dist/core/permission-relay/types.js +15 -0
  141. package/dist/core/permission-relay/types.js.map +1 -0
  142. package/dist/core/pi-manifest.d.ts +14 -0
  143. package/dist/core/pi-manifest.d.ts.map +1 -0
  144. package/dist/core/pi-manifest.js +35 -0
  145. package/dist/core/pi-manifest.js.map +1 -0
  146. package/dist/core/project-trust.js +2 -2
  147. package/dist/core/project-trust.js.map +1 -1
  148. package/dist/core/resource-loader.d.ts +21 -0
  149. package/dist/core/resource-loader.d.ts.map +1 -1
  150. package/dist/core/resource-loader.js +101 -24
  151. package/dist/core/resource-loader.js.map +1 -1
  152. package/dist/core/sandbox/bash-operations.d.ts +149 -0
  153. package/dist/core/sandbox/bash-operations.d.ts.map +1 -0
  154. package/dist/core/sandbox/bash-operations.js +163 -0
  155. package/dist/core/sandbox/bash-operations.js.map +1 -0
  156. package/dist/core/sandbox/env.d.ts +83 -0
  157. package/dist/core/sandbox/env.d.ts.map +1 -0
  158. package/dist/core/sandbox/env.js +123 -0
  159. package/dist/core/sandbox/env.js.map +1 -0
  160. package/dist/core/sandbox/executor.d.ts +104 -0
  161. package/dist/core/sandbox/executor.d.ts.map +1 -0
  162. package/dist/core/sandbox/executor.js +92 -0
  163. package/dist/core/sandbox/executor.js.map +1 -0
  164. package/dist/core/sandbox/index.d.ts +36 -0
  165. package/dist/core/sandbox/index.d.ts.map +1 -0
  166. package/dist/core/sandbox/index.js +36 -0
  167. package/dist/core/sandbox/index.js.map +1 -0
  168. package/dist/core/sandbox/linux.d.ts +121 -0
  169. package/dist/core/sandbox/linux.d.ts.map +1 -0
  170. package/dist/core/sandbox/linux.js +260 -0
  171. package/dist/core/sandbox/linux.js.map +1 -0
  172. package/dist/core/sandbox/policy.d.ts +142 -0
  173. package/dist/core/sandbox/policy.d.ts.map +1 -0
  174. package/dist/core/sandbox/policy.js +297 -0
  175. package/dist/core/sandbox/policy.js.map +1 -0
  176. package/dist/core/sandbox/real-path.d.ts +112 -0
  177. package/dist/core/sandbox/real-path.d.ts.map +1 -0
  178. package/dist/core/sandbox/real-path.js +158 -0
  179. package/dist/core/sandbox/real-path.js.map +1 -0
  180. package/dist/core/sandbox/seatbelt-profile.d.ts +95 -0
  181. package/dist/core/sandbox/seatbelt-profile.d.ts.map +1 -0
  182. package/dist/core/sandbox/seatbelt-profile.js +239 -0
  183. package/dist/core/sandbox/seatbelt-profile.js.map +1 -0
  184. package/dist/core/sandbox/seatbelt.d.ts +95 -0
  185. package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
  186. package/dist/core/sandbox/seatbelt.js +154 -0
  187. package/dist/core/sandbox/seatbelt.js.map +1 -0
  188. package/dist/core/sandbox/self-test.d.ts +109 -0
  189. package/dist/core/sandbox/self-test.d.ts.map +1 -0
  190. package/dist/core/sandbox/self-test.js +369 -0
  191. package/dist/core/sandbox/self-test.js.map +1 -0
  192. package/dist/core/sandbox/spawn.d.ts +33 -0
  193. package/dist/core/sandbox/spawn.d.ts.map +1 -0
  194. package/dist/core/sandbox/spawn.js +87 -0
  195. package/dist/core/sandbox/spawn.js.map +1 -0
  196. package/dist/core/sdk.d.ts.map +1 -1
  197. package/dist/core/sdk.js +3 -1
  198. package/dist/core/sdk.js.map +1 -1
  199. package/dist/core/session-manager.d.ts +60 -1
  200. package/dist/core/session-manager.d.ts.map +1 -1
  201. package/dist/core/session-manager.js +53 -6
  202. package/dist/core/session-manager.js.map +1 -1
  203. package/dist/core/settings-manager.d.ts +21 -0
  204. package/dist/core/settings-manager.d.ts.map +1 -1
  205. package/dist/core/settings-manager.js +36 -16
  206. package/dist/core/settings-manager.js.map +1 -1
  207. package/dist/core/skills.d.ts +3 -1
  208. package/dist/core/skills.d.ts.map +1 -1
  209. package/dist/core/skills.js +19 -6
  210. package/dist/core/skills.js.map +1 -1
  211. package/dist/core/slash-commands.d.ts.map +1 -1
  212. package/dist/core/slash-commands.js +1 -0
  213. package/dist/core/slash-commands.js.map +1 -1
  214. package/dist/core/soak/soak-log.d.ts +298 -0
  215. package/dist/core/soak/soak-log.d.ts.map +1 -0
  216. package/dist/core/soak/soak-log.js +660 -0
  217. package/dist/core/soak/soak-log.js.map +1 -0
  218. package/dist/core/soak/soak-reader.d.ts +60 -0
  219. package/dist/core/soak/soak-reader.d.ts.map +1 -0
  220. package/dist/core/soak/soak-reader.js +106 -0
  221. package/dist/core/soak/soak-reader.js.map +1 -0
  222. package/dist/core/socket-server/discovery.d.ts +78 -1
  223. package/dist/core/socket-server/discovery.d.ts.map +1 -1
  224. package/dist/core/socket-server/discovery.js +356 -37
  225. package/dist/core/socket-server/discovery.js.map +1 -1
  226. package/dist/core/socket-server/index.d.ts +10 -4
  227. package/dist/core/socket-server/index.d.ts.map +1 -1
  228. package/dist/core/socket-server/index.js +6 -3
  229. package/dist/core/socket-server/index.js.map +1 -1
  230. package/dist/core/socket-server/permission-delivery.d.ts +125 -0
  231. package/dist/core/socket-server/permission-delivery.d.ts.map +1 -0
  232. package/dist/core/socket-server/permission-delivery.js +152 -0
  233. package/dist/core/socket-server/permission-delivery.js.map +1 -0
  234. package/dist/core/socket-server/permission-registry.d.ts +301 -0
  235. package/dist/core/socket-server/permission-registry.d.ts.map +1 -0
  236. package/dist/core/socket-server/permission-registry.js +410 -0
  237. package/dist/core/socket-server/permission-registry.js.map +1 -0
  238. package/dist/core/socket-server/permission-relay.d.ts +81 -0
  239. package/dist/core/socket-server/permission-relay.d.ts.map +1 -0
  240. package/dist/core/socket-server/permission-relay.js +528 -0
  241. package/dist/core/socket-server/permission-relay.js.map +1 -0
  242. package/dist/core/socket-server/safe-text.d.ts +83 -0
  243. package/dist/core/socket-server/safe-text.d.ts.map +1 -0
  244. package/dist/core/socket-server/safe-text.js +277 -0
  245. package/dist/core/socket-server/safe-text.js.map +1 -0
  246. package/dist/core/socket-server/session-integration.d.ts +65 -2
  247. package/dist/core/socket-server/session-integration.d.ts.map +1 -1
  248. package/dist/core/socket-server/session-integration.js +434 -32
  249. package/dist/core/socket-server/session-integration.js.map +1 -1
  250. package/dist/core/socket-server/socket-client.d.ts +21 -2
  251. package/dist/core/socket-server/socket-client.d.ts.map +1 -1
  252. package/dist/core/socket-server/socket-client.js +52 -1
  253. package/dist/core/socket-server/socket-client.js.map +1 -1
  254. package/dist/core/socket-server/socket-server.d.ts +152 -1
  255. package/dist/core/socket-server/socket-server.d.ts.map +1 -1
  256. package/dist/core/socket-server/socket-server.js +775 -26
  257. package/dist/core/socket-server/socket-server.js.map +1 -1
  258. package/dist/core/socket-server/types.d.ts +106 -2
  259. package/dist/core/socket-server/types.d.ts.map +1 -1
  260. package/dist/core/socket-server/types.js +13 -1
  261. package/dist/core/socket-server/types.js.map +1 -1
  262. package/dist/core/system-prompt.d.ts.map +1 -1
  263. package/dist/core/system-prompt.js +8 -9
  264. package/dist/core/system-prompt.js.map +1 -1
  265. package/dist/core/tools/bash.d.ts +1 -1
  266. package/dist/core/tools/bash.d.ts.map +1 -1
  267. package/dist/core/tools/bash.js +5 -2
  268. package/dist/core/tools/bash.js.map +1 -1
  269. package/dist/core/tools/edit.d.ts.map +1 -1
  270. package/dist/core/tools/edit.js +17 -2
  271. package/dist/core/tools/edit.js.map +1 -1
  272. package/dist/core/tools/find.d.ts +3 -0
  273. package/dist/core/tools/find.d.ts.map +1 -1
  274. package/dist/core/tools/find.js +11 -18
  275. package/dist/core/tools/find.js.map +1 -1
  276. package/dist/core/trust-manager.d.ts +6 -4
  277. package/dist/core/trust-manager.d.ts.map +1 -1
  278. package/dist/core/trust-manager.js +55 -21
  279. package/dist/core/trust-manager.js.map +1 -1
  280. package/dist/extensions/index.d.ts.map +1 -1
  281. package/dist/extensions/index.js +5 -1
  282. package/dist/extensions/index.js.map +1 -1
  283. package/dist/extensions/llama/provider.d.ts.map +1 -1
  284. package/dist/extensions/llama/provider.js +5 -1
  285. package/dist/extensions/llama/provider.js.map +1 -1
  286. package/dist/extensions/stub-provider/index.d.ts +9 -0
  287. package/dist/extensions/stub-provider/index.d.ts.map +1 -0
  288. package/dist/extensions/stub-provider/index.js +13 -0
  289. package/dist/extensions/stub-provider/index.js.map +1 -0
  290. package/dist/extensions/stub-provider/provider.d.ts +77 -0
  291. package/dist/extensions/stub-provider/provider.d.ts.map +1 -0
  292. package/dist/extensions/stub-provider/provider.js +193 -0
  293. package/dist/extensions/stub-provider/provider.js.map +1 -0
  294. package/dist/hooks/gsd/draht-quality-gate.js +3 -3
  295. package/dist/index.d.ts +1 -1
  296. package/dist/index.d.ts.map +1 -1
  297. package/dist/index.js.map +1 -1
  298. package/dist/main.d.ts.map +1 -1
  299. package/dist/main.js +242 -45
  300. package/dist/main.js.map +1 -1
  301. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  302. package/dist/modes/interactive/components/config-selector.js +3 -2
  303. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  304. package/dist/modes/interactive/components/extension-selector.d.ts +49 -0
  305. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  306. package/dist/modes/interactive/components/extension-selector.js +202 -5
  307. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  308. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  309. package/dist/modes/interactive/components/session-selector.js +10 -2
  310. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  311. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  312. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  313. package/dist/modes/interactive/components/settings-selector.js +10 -0
  314. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  315. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  316. package/dist/modes/interactive/components/tool-execution.js +10 -1
  317. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  318. package/dist/modes/interactive/components/tree-selector.d.ts +20 -2
  319. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  320. package/dist/modes/interactive/components/tree-selector.js +21 -5
  321. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  322. package/dist/modes/interactive/interactive-mode.d.ts +97 -3
  323. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  324. package/dist/modes/interactive/interactive-mode.js +394 -24
  325. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  326. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  327. package/dist/modes/rpc/rpc-mode.js +165 -7
  328. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  329. package/dist/modes/rpc/rpc-types.d.ts +68 -1
  330. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  331. package/dist/modes/rpc/rpc-types.js.map +1 -1
  332. package/dist/prompts/commands/atomic-commit.md +1 -12
  333. package/dist/prompts/commands/brainstorm.md +12 -15
  334. package/dist/prompts/commands/create-verification-skill.md +108 -0
  335. package/dist/prompts/commands/discuss-phase.md +3 -14
  336. package/dist/prompts/commands/execute-phase.md +3 -11
  337. package/dist/prompts/commands/fix.md +41 -18
  338. package/dist/prompts/commands/grill.md +66 -0
  339. package/dist/prompts/commands/init-project.md +5 -15
  340. package/dist/prompts/commands/map-codebase.md +1 -13
  341. package/dist/prompts/commands/new-project.md +5 -15
  342. package/dist/prompts/commands/next-milestone.md +1 -13
  343. package/dist/prompts/commands/orchestrate.md +1 -1
  344. package/dist/prompts/commands/pause-work.md +1 -13
  345. package/dist/prompts/commands/plan-phase.md +2 -11
  346. package/dist/prompts/commands/progress.md +0 -13
  347. package/dist/prompts/commands/quick.md +3 -11
  348. package/dist/prompts/commands/resolve-conflicts.md +71 -0
  349. package/dist/prompts/commands/resume-work.md +0 -13
  350. package/dist/prompts/commands/review.md +4 -13
  351. package/dist/prompts/commands/triage.md +159 -0
  352. package/dist/prompts/commands/verify-work.md +4 -14
  353. package/dist/prompts/commands/why.md +135 -0
  354. package/dist/skills/atomic-reasoning/SKILL.md +115 -0
  355. package/dist/skills/blast-radius/SKILL.md +55 -0
  356. package/dist/skills/epistemics/SKILL.md +99 -0
  357. package/dist/skills/hexagon-animation/SKILL.md +49 -0
  358. package/dist/skills/hexagon-animation/generate.mjs +81 -0
  359. package/dist/skills/hexagon-animation/template.html +361 -0
  360. package/dist/skills/typescript-discipline/SKILL.md +50 -0
  361. package/dist/skills/typescript-discipline/references/patterns.md +294 -0
  362. package/dist/skills/unslop/SKILL.md +101 -0
  363. package/dist/utils/canonical-path.d.ts +28 -0
  364. package/dist/utils/canonical-path.d.ts.map +1 -0
  365. package/dist/utils/canonical-path.js +90 -0
  366. package/dist/utils/canonical-path.js.map +1 -0
  367. package/dist/utils/child-process.d.ts +12 -1
  368. package/dist/utils/child-process.d.ts.map +1 -1
  369. package/dist/utils/child-process.js +25 -8
  370. package/dist/utils/child-process.js.map +1 -1
  371. package/dist/utils/clipboard.d.ts +1 -1
  372. package/dist/utils/clipboard.d.ts.map +1 -1
  373. package/dist/utils/clipboard.js +22 -2
  374. package/dist/utils/clipboard.js.map +1 -1
  375. package/dist/utils/exif-orientation.d.ts.map +1 -1
  376. package/dist/utils/exif-orientation.js +2 -3
  377. package/dist/utils/exif-orientation.js.map +1 -1
  378. package/dist/utils/paths.d.ts +2 -7
  379. package/dist/utils/paths.d.ts.map +1 -1
  380. package/dist/utils/paths.js +13 -15
  381. package/dist/utils/paths.js.map +1 -1
  382. package/dist/utils/shell.d.ts.map +1 -1
  383. package/dist/utils/shell.js +6 -4
  384. package/dist/utils/shell.js.map +1 -1
  385. package/dist/utils/tools-manager.d.ts.map +1 -1
  386. package/dist/utils/tools-manager.js +3 -5
  387. package/dist/utils/tools-manager.js.map +1 -1
  388. package/docs/attachable-sessions.md +79 -0
  389. package/docs/compaction.md +21 -21
  390. package/docs/containerization.md +23 -23
  391. package/docs/custom-provider.md +16 -16
  392. package/docs/development.md +9 -9
  393. package/docs/docs.json +6 -2
  394. package/docs/duet.md +42 -0
  395. package/docs/extensions.md +58 -58
  396. package/docs/index.md +10 -10
  397. package/docs/json.md +7 -7
  398. package/docs/keybindings.md +6 -5
  399. package/docs/llama-cpp.md +6 -6
  400. package/docs/models.md +6 -6
  401. package/docs/packages.md +43 -43
  402. package/docs/prompt-templates.md +4 -4
  403. package/docs/providers.md +12 -12
  404. package/docs/quickstart.md +32 -32
  405. package/docs/rpc.md +83 -12
  406. package/docs/sdk.md +15 -15
  407. package/docs/security.md +18 -18
  408. package/docs/session-format.md +35 -13
  409. package/docs/sessions.md +17 -14
  410. package/docs/settings.md +25 -18
  411. package/docs/shell-aliases.md +2 -2
  412. package/docs/skills.md +12 -11
  413. package/docs/terminal-setup.md +12 -12
  414. package/docs/termux.md +6 -6
  415. package/docs/themes.md +11 -11
  416. package/docs/tmux.md +4 -4
  417. package/docs/tui.md +5 -5
  418. package/docs/usage.md +50 -50
  419. package/docs/windows.md +2 -2
  420. package/examples/extensions/overlay-qa-tests.ts +3 -3
  421. package/hooks/gsd/draht-quality-gate.js +3 -3
  422. package/package.json +11 -10
  423. package/prompts/commands/atomic-commit.md +1 -12
  424. package/prompts/commands/brainstorm.md +12 -15
  425. package/prompts/commands/create-verification-skill.md +108 -0
  426. package/prompts/commands/discuss-phase.md +3 -14
  427. package/prompts/commands/execute-phase.md +3 -11
  428. package/prompts/commands/fix.md +41 -18
  429. package/prompts/commands/grill.md +66 -0
  430. package/prompts/commands/init-project.md +5 -15
  431. package/prompts/commands/map-codebase.md +1 -13
  432. package/prompts/commands/new-project.md +5 -15
  433. package/prompts/commands/next-milestone.md +1 -13
  434. package/prompts/commands/orchestrate.md +1 -1
  435. package/prompts/commands/pause-work.md +1 -13
  436. package/prompts/commands/plan-phase.md +2 -11
  437. package/prompts/commands/progress.md +0 -13
  438. package/prompts/commands/quick.md +3 -11
  439. package/prompts/commands/resolve-conflicts.md +71 -0
  440. package/prompts/commands/resume-work.md +0 -13
  441. package/prompts/commands/review.md +4 -13
  442. package/prompts/commands/triage.md +159 -0
  443. package/prompts/commands/verify-work.md +4 -14
  444. package/prompts/commands/why.md +135 -0
  445. package/skills/atomic-reasoning/SKILL.md +115 -0
  446. package/skills/blast-radius/SKILL.md +55 -0
  447. package/skills/epistemics/SKILL.md +99 -0
  448. package/skills/hexagon-animation/SKILL.md +49 -0
  449. package/skills/hexagon-animation/generate.mjs +81 -0
  450. package/skills/hexagon-animation/template.html +361 -0
  451. package/skills/typescript-discipline/SKILL.md +50 -0
  452. package/skills/typescript-discipline/references/patterns.md +294 -0
  453. package/skills/unslop/SKILL.md +101 -0
  454. package/dist/prompts/agents/build.md +0 -86
  455. package/dist/prompts/agents/plan.md +0 -79
  456. package/dist/prompts/agents/verify.md +0 -69
  457. package/prompts/agents/build.md +0 -86
  458. package/prompts/agents/plan.md +0 -79
  459. package/prompts/agents/verify.md +0 -69
@@ -0,0 +1,36 @@
1
+ /**
2
+ * OS-level sandbox for the bash tool (Phase 44, R44-SBX.1 .. R44-SBX.3).
3
+ *
4
+ * - `policy.ts` -- `SandboxPolicy` v1: the declarative write allowlist, read
5
+ * mode, network toggle and privilege-escalation invariant.
6
+ * - `real-path.ts` -- real-path resolution applied to every policy path before
7
+ * any profile is generated, so no symlink or `..` hop can widen the allowlist.
8
+ * - `executor.ts` -- the `SandboxExecutor` seam, backend registry and the
9
+ * `unavailable` posture.
10
+ * - `seatbelt-profile.ts` / `seatbelt.ts` -- the macOS backend. The profile is
11
+ * an allow-list (`(deny default)` plus enumerated capabilities) handed to
12
+ * `sandbox-exec` inline, so it never exists as a file the sandbox could edit.
13
+ * Exercised for real against `/usr/bin/sandbox-exec` by
14
+ * `test/sandbox-backend.test.ts`, including the escape vectors it closes.
15
+ * - `linux.ts` -- the Linux backend (Landlock helper / bwrap / unshare).
16
+ * **Source-only evidence: never executed.** See its module doc.
17
+ * - `self-test.ts` -- R44-SBX.4. The only thing that may report `available`.
18
+ * - `env.ts` -- R44-SBX.5. The child's environment is constructed, not inherited.
19
+ * - `spawn.ts` -- the shared wrapped-child process plumbing.
20
+ *
21
+ * The `BashOperations` wrapper (R44-SBX.6) lives in `bash-operations.ts` and is
22
+ * deliberately **not** re-exported here: it is the one file in this directory
23
+ * that imports from `../tools/`, and keeping it out of the barrel lets anything
24
+ * that only wants the policy model import this without dragging the tool layer
25
+ * along -- and keeps a future `tools/bash.ts` -> sandbox import cycle-free.
26
+ * Import it directly: `from "../sandbox/bash-operations.ts"`.
27
+ */
28
+ export { type BuildSandboxEnvOptions, buildSandboxEnv, SANDBOX_ENV_ALLOWLIST, SANDBOX_ENV_MARKER, } from "./env.ts";
29
+ export { BUILTIN_SANDBOX_BACKENDS, type CreateSandboxExecutorOptions, createSandboxExecutor, createUnavailableSandboxExecutor, type SandboxBackendFactory, type SandboxExecOptions, type SandboxExecResult, type SandboxExecutor, type SandboxStatus, SandboxUnavailableError, SUPPORTED_SANDBOX_PLATFORMS, } from "./executor.ts";
30
+ export { buildLinuxSandboxCommand, createLinuxSandboxExecutor, detectLinuxSandboxMechanism, type LinuxSandboxMechanism, type LinuxSandboxOptions, MIN_LANDLOCK_KERNEL, supportsLandlock, } from "./linux.ts";
31
+ export { excludedWriteRootReason, isPathWritable, type RejectedWritePath, resolveSandboxPolicy, SANDBOX_POLICY_VERSION, type SandboxNetworkMode, type SandboxPolicy, SandboxPolicyError, type SandboxPolicyInput, type SandboxPolicyResolution, } from "./policy.ts";
32
+ export { isContainedIn, type RealPathResolution, type ResolveRealPathOptions, resolveRealPath } from "./real-path.ts";
33
+ export { buildSandboxExecArgs, createSeatbeltSandboxExecutor, DEFAULT_SANDBOX_EXEC_BIN, MAX_INLINE_PROFILE_BYTES, type SeatbeltSandboxOptions, } from "./seatbelt.ts";
34
+ export { buildSeatbeltProfile, quoteSbplString, SandboxProfileError } from "./seatbelt-profile.ts";
35
+ export { runSandboxSelfTest, type SandboxSelfTestOptions, type SandboxSelfTestRunner } from "./self-test.ts";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACN,KAAK,sBAAsB,EAC3B,eAAe,EACf,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,qBAAqB,EACrB,gCAAgC,EAChC,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,uBAAuB,EACvB,2BAA2B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,uBAAuB,EACvB,cAAc,EACd,KAAK,iBAAiB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtH,OAAO,EACN,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,sBAAsB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,KAAK,sBAAsB,EAAE,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * OS-level sandbox for the bash tool (Phase 44, R44-SBX.1 .. R44-SBX.3).
3
+ *
4
+ * - `policy.ts` -- `SandboxPolicy` v1: the declarative write allowlist, read
5
+ * mode, network toggle and privilege-escalation invariant.
6
+ * - `real-path.ts` -- real-path resolution applied to every policy path before
7
+ * any profile is generated, so no symlink or `..` hop can widen the allowlist.
8
+ * - `executor.ts` -- the `SandboxExecutor` seam, backend registry and the
9
+ * `unavailable` posture.
10
+ * - `seatbelt-profile.ts` / `seatbelt.ts` -- the macOS backend. The profile is
11
+ * an allow-list (`(deny default)` plus enumerated capabilities) handed to
12
+ * `sandbox-exec` inline, so it never exists as a file the sandbox could edit.
13
+ * Exercised for real against `/usr/bin/sandbox-exec` by
14
+ * `test/sandbox-backend.test.ts`, including the escape vectors it closes.
15
+ * - `linux.ts` -- the Linux backend (Landlock helper / bwrap / unshare).
16
+ * **Source-only evidence: never executed.** See its module doc.
17
+ * - `self-test.ts` -- R44-SBX.4. The only thing that may report `available`.
18
+ * - `env.ts` -- R44-SBX.5. The child's environment is constructed, not inherited.
19
+ * - `spawn.ts` -- the shared wrapped-child process plumbing.
20
+ *
21
+ * The `BashOperations` wrapper (R44-SBX.6) lives in `bash-operations.ts` and is
22
+ * deliberately **not** re-exported here: it is the one file in this directory
23
+ * that imports from `../tools/`, and keeping it out of the barrel lets anything
24
+ * that only wants the policy model import this without dragging the tool layer
25
+ * along -- and keeps a future `tools/bash.ts` -> sandbox import cycle-free.
26
+ * Import it directly: `from "../sandbox/bash-operations.ts"`.
27
+ */
28
+ export { buildSandboxEnv, SANDBOX_ENV_ALLOWLIST, SANDBOX_ENV_MARKER, } from "./env.js";
29
+ export { BUILTIN_SANDBOX_BACKENDS, createSandboxExecutor, createUnavailableSandboxExecutor, SandboxUnavailableError, SUPPORTED_SANDBOX_PLATFORMS, } from "./executor.js";
30
+ export { buildLinuxSandboxCommand, createLinuxSandboxExecutor, detectLinuxSandboxMechanism, MIN_LANDLOCK_KERNEL, supportsLandlock, } from "./linux.js";
31
+ export { excludedWriteRootReason, isPathWritable, resolveSandboxPolicy, SANDBOX_POLICY_VERSION, SandboxPolicyError, } from "./policy.js";
32
+ export { isContainedIn, resolveRealPath } from "./real-path.js";
33
+ export { buildSandboxExecArgs, createSeatbeltSandboxExecutor, DEFAULT_SANDBOX_EXEC_BIN, MAX_INLINE_PROFILE_BYTES, } from "./seatbelt.js";
34
+ export { buildSeatbeltProfile, quoteSbplString, SandboxProfileError } from "./seatbelt-profile.js";
35
+ export { runSandboxSelfTest } from "./self-test.js";
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAEN,eAAe,EACf,qBAAqB,EACrB,kBAAkB,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,wBAAwB,EAExB,qBAAqB,EACrB,gCAAgC,EAMhC,uBAAuB,EACvB,2BAA2B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAG3B,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,uBAAuB,EACvB,cAAc,EAEd,oBAAoB,EACpB,sBAAsB,EAGtB,kBAAkB,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAwD,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtH,OAAO,EACN,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,GAExB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAA2D,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * OS-level sandbox for the bash tool (Phase 44, R44-SBX.1 .. R44-SBX.3).\n *\n * - `policy.ts` -- `SandboxPolicy` v1: the declarative write allowlist, read\n * mode, network toggle and privilege-escalation invariant.\n * - `real-path.ts` -- real-path resolution applied to every policy path before\n * any profile is generated, so no symlink or `..` hop can widen the allowlist.\n * - `executor.ts` -- the `SandboxExecutor` seam, backend registry and the\n * `unavailable` posture.\n * - `seatbelt-profile.ts` / `seatbelt.ts` -- the macOS backend. The profile is\n * an allow-list (`(deny default)` plus enumerated capabilities) handed to\n * `sandbox-exec` inline, so it never exists as a file the sandbox could edit.\n * Exercised for real against `/usr/bin/sandbox-exec` by\n * `test/sandbox-backend.test.ts`, including the escape vectors it closes.\n * - `linux.ts` -- the Linux backend (Landlock helper / bwrap / unshare).\n * **Source-only evidence: never executed.** See its module doc.\n * - `self-test.ts` -- R44-SBX.4. The only thing that may report `available`.\n * - `env.ts` -- R44-SBX.5. The child's environment is constructed, not inherited.\n * - `spawn.ts` -- the shared wrapped-child process plumbing.\n *\n * The `BashOperations` wrapper (R44-SBX.6) lives in `bash-operations.ts` and is\n * deliberately **not** re-exported here: it is the one file in this directory\n * that imports from `../tools/`, and keeping it out of the barrel lets anything\n * that only wants the policy model import this without dragging the tool layer\n * along -- and keeps a future `tools/bash.ts` -> sandbox import cycle-free.\n * Import it directly: `from \"../sandbox/bash-operations.ts\"`.\n */\n\nexport {\n\ttype BuildSandboxEnvOptions,\n\tbuildSandboxEnv,\n\tSANDBOX_ENV_ALLOWLIST,\n\tSANDBOX_ENV_MARKER,\n} from \"./env.ts\";\nexport {\n\tBUILTIN_SANDBOX_BACKENDS,\n\ttype CreateSandboxExecutorOptions,\n\tcreateSandboxExecutor,\n\tcreateUnavailableSandboxExecutor,\n\ttype SandboxBackendFactory,\n\ttype SandboxExecOptions,\n\ttype SandboxExecResult,\n\ttype SandboxExecutor,\n\ttype SandboxStatus,\n\tSandboxUnavailableError,\n\tSUPPORTED_SANDBOX_PLATFORMS,\n} from \"./executor.ts\";\nexport {\n\tbuildLinuxSandboxCommand,\n\tcreateLinuxSandboxExecutor,\n\tdetectLinuxSandboxMechanism,\n\ttype LinuxSandboxMechanism,\n\ttype LinuxSandboxOptions,\n\tMIN_LANDLOCK_KERNEL,\n\tsupportsLandlock,\n} from \"./linux.ts\";\nexport {\n\texcludedWriteRootReason,\n\tisPathWritable,\n\ttype RejectedWritePath,\n\tresolveSandboxPolicy,\n\tSANDBOX_POLICY_VERSION,\n\ttype SandboxNetworkMode,\n\ttype SandboxPolicy,\n\tSandboxPolicyError,\n\ttype SandboxPolicyInput,\n\ttype SandboxPolicyResolution,\n} from \"./policy.ts\";\nexport { isContainedIn, type RealPathResolution, type ResolveRealPathOptions, resolveRealPath } from \"./real-path.ts\";\nexport {\n\tbuildSandboxExecArgs,\n\tcreateSeatbeltSandboxExecutor,\n\tDEFAULT_SANDBOX_EXEC_BIN,\n\tMAX_INLINE_PROFILE_BYTES,\n\ttype SeatbeltSandboxOptions,\n} from \"./seatbelt.ts\";\nexport { buildSeatbeltProfile, quoteSbplString, SandboxProfileError } from \"./seatbelt-profile.ts\";\nexport { runSandboxSelfTest, type SandboxSelfTestOptions, type SandboxSelfTestRunner } from \"./self-test.ts\";\n"]}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Linux backend (R44-SBX.1) -- Landlock helper, bubblewrap, or `unshare`.
3
+ *
4
+ * ## Evidence class: SOURCE-ONLY. Nothing here has been executed.
5
+ *
6
+ * This module was written and reviewed on macOS (darwin). No line of it has ever
7
+ * run on Linux, and the tests that accompany it assert on *constructed argument
8
+ * vectors*, never on confinement -- constructing the right argv is not evidence
9
+ * that the argv confines anything. Treat every claim below as a design intent
10
+ * awaiting the Linux CI matrix that R46-SBH.2 owns, which exists precisely
11
+ * because Phase 28 shipped an unverified Linux path from this same machine.
12
+ *
13
+ * The reason that posture is *safe* rather than merely honest: this backend is
14
+ * gated by the same R44-SBX.4 self-test as the macOS one, and the self-test
15
+ * confirms confinement from outside the sandbox. If any mechanism below fails to
16
+ * confine on a real kernel, `status()` answers `unavailable` and no command runs
17
+ * through it. Unverified code cannot promote itself to `available`; only a
18
+ * passing probe on the actual host can.
19
+ *
20
+ * ## Landlock, and why it is a seam rather than an implementation
21
+ *
22
+ * R44-SBX.1 names Landlock (kernel >= 5.13) as the preferred mechanism, and it
23
+ * is the right one: per-process filesystem restriction, no root, no setuid
24
+ * helper, no namespaces. But applying it means calling `landlock_create_ruleset(2)`,
25
+ * `landlock_add_rule(2)` and `prctl(PR_SET_NO_NEW_PRIVS)` *between* fork and exec,
26
+ * and Node exposes none of those. Codex solves this with a native Rust helper it
27
+ * ships; Phase 44 builds no native artefact, and adding one is not something
28
+ * that can be validated from here.
29
+ *
30
+ * So Landlock is wired as an explicit, opt-in helper contract rather than
31
+ * guessed at against a third-party CLI whose flags cannot be checked from this
32
+ * machine:
33
+ *
34
+ * <helper> --ro <path> --rw <path> [--rw <path> ...] [--no-network] -- <argv...>
35
+ *
36
+ * configured via `landlockHelperBin` or `DRAHT_SANDBOX_LANDLOCK_HELPER`. If no
37
+ * helper is configured the mechanism is simply not selected. If one is
38
+ * configured but does not honour the contract, the self-test fails and the
39
+ * backend reports `unavailable` -- which is why shipping an unproven contract
40
+ * here is not a security risk.
41
+ *
42
+ * ## Namespace mechanisms (the fallback R44-SBX.1 asks for)
43
+ *
44
+ * - **bubblewrap** (`bwrap`), preferred: `--ro-bind / /` gives read allow-all,
45
+ * then one `--bind` per policy write path makes exactly those subtrees
46
+ * writable. That is the R44-SBX.2 policy shape expressed directly. bwrap sets
47
+ * `PR_SET_NO_NEW_PRIVS` by default, which is what makes `sudo` and every other
48
+ * setuid binary inert -- the privilege-escalation invariant. `--unshare-net`
49
+ * when the policy says network off.
50
+ * - **`unshare`**, fallback: `--user --map-root-user --mount` and then a mount
51
+ * preamble that makes `/` read-only and re-binds the write paths read-write.
52
+ * Coarser and more fragile than bwrap (it is a shell preamble, not a
53
+ * supervisor), and the one piece here most likely to need revision once it has
54
+ * actually run. `--net` for network off, as in Phase 28.
55
+ *
56
+ * Note the consequence of the R44-SBX.4 privilege-escalation probe: `unshare`
57
+ * sets neither `PR_SET_NO_NEW_PRIVS` nor anything that refuses `exec` of a
58
+ * setuid binary, so it can demonstrate neither half of the
59
+ * `allowPrivilegeEscalation: false` invariant and the self-test will report
60
+ * `unavailable` for it. That is the fail-closed reading and it is the intended
61
+ * one: this backend's entire safety argument is the self-test, so a mechanism
62
+ * that cannot show the invariant holds does not get to claim it.
63
+ *
64
+ * Ordering is Landlock helper, then bwrap, then unshare: most precise mechanism
65
+ * first, and the kernel-version check keeps the Landlock path from being chosen
66
+ * on a kernel that cannot support it even when a helper is configured.
67
+ */
68
+ import { type ShellConfig } from "../../utils/shell.ts";
69
+ import { type SandboxExecutor } from "./executor.ts";
70
+ import type { SandboxPolicy } from "./policy.ts";
71
+ /** Landlock filesystem restriction landed in Linux 5.13. Below that the helper cannot work. */
72
+ export declare const MIN_LANDLOCK_KERNEL: {
73
+ readonly major: 5;
74
+ readonly minor: 13;
75
+ };
76
+ export type LinuxSandboxMechanism = {
77
+ kind: "landlock";
78
+ bin: string;
79
+ } | {
80
+ kind: "bwrap";
81
+ bin: string;
82
+ } | {
83
+ kind: "unshare";
84
+ bin: string;
85
+ };
86
+ export interface LinuxSandboxOptions {
87
+ /** Path to a Landlock helper implementing the contract in the module doc. */
88
+ landlockHelperBin?: string;
89
+ /** Resolves a bare binary name; defaults to a `PATH` scan. Injection point for tests. */
90
+ lookupBin?: (name: string) => string | null;
91
+ /**
92
+ * Defaults to `os.release()`. Injection point for tests.
93
+ *
94
+ * The default is applied inside `detectLinuxSandboxMechanism` rather than only
95
+ * at the one call site in `createLinuxSandboxExecutor`, because it used to
96
+ * default to `""` there: every *exported* call therefore failed
97
+ * `supportsLandlock("")` and silently fell through to bwrap, even on a kernel
98
+ * that supports Landlock and with a helper configured.
99
+ */
100
+ kernelRelease?: string;
101
+ shellPath?: string;
102
+ extraAllowedEnvVars?: readonly string[];
103
+ selfTestTimeoutSeconds?: number;
104
+ }
105
+ /** True when `release` (an `os.release()` string) is at least 5.13. Unparseable releases answer `false`. */
106
+ export declare function supportsLandlock(release: string): boolean;
107
+ /** Picks the mechanism to use, most precise first. `null` means this host has none. */
108
+ export declare function detectLinuxSandboxMechanism(options?: LinuxSandboxOptions): LinuxSandboxMechanism | null;
109
+ /**
110
+ * Builds the wrapper invocation for `mechanism`.
111
+ *
112
+ * Exported so the argument vectors are reviewable and testable without a Linux
113
+ * host -- with the standing caveat that a correct-looking argv is not evidence
114
+ * of confinement.
115
+ */
116
+ export declare function buildLinuxSandboxCommand(mechanism: LinuxSandboxMechanism, policy: SandboxPolicy, command: string, shell: ShellConfig, cwd: string): {
117
+ command: string;
118
+ args: string[];
119
+ };
120
+ export declare function createLinuxSandboxExecutor(options?: LinuxSandboxOptions): SandboxExecutor;
121
+ //# sourceMappingURL=linux.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linux.d.ts","sourceRoot":"","sources":["../../../src/core/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AAS,EAAE,qBAAqB,EAChC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,MAAM,GACT;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAiDrC;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,mBAAwB,GAAG,eAAe,CAyE7F"}
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Linux backend (R44-SBX.1) -- Landlock helper, bubblewrap, or `unshare`.
3
+ *
4
+ * ## Evidence class: SOURCE-ONLY. Nothing here has been executed.
5
+ *
6
+ * This module was written and reviewed on macOS (darwin). No line of it has ever
7
+ * run on Linux, and the tests that accompany it assert on *constructed argument
8
+ * vectors*, never on confinement -- constructing the right argv is not evidence
9
+ * that the argv confines anything. Treat every claim below as a design intent
10
+ * awaiting the Linux CI matrix that R46-SBH.2 owns, which exists precisely
11
+ * because Phase 28 shipped an unverified Linux path from this same machine.
12
+ *
13
+ * The reason that posture is *safe* rather than merely honest: this backend is
14
+ * gated by the same R44-SBX.4 self-test as the macOS one, and the self-test
15
+ * confirms confinement from outside the sandbox. If any mechanism below fails to
16
+ * confine on a real kernel, `status()` answers `unavailable` and no command runs
17
+ * through it. Unverified code cannot promote itself to `available`; only a
18
+ * passing probe on the actual host can.
19
+ *
20
+ * ## Landlock, and why it is a seam rather than an implementation
21
+ *
22
+ * R44-SBX.1 names Landlock (kernel >= 5.13) as the preferred mechanism, and it
23
+ * is the right one: per-process filesystem restriction, no root, no setuid
24
+ * helper, no namespaces. But applying it means calling `landlock_create_ruleset(2)`,
25
+ * `landlock_add_rule(2)` and `prctl(PR_SET_NO_NEW_PRIVS)` *between* fork and exec,
26
+ * and Node exposes none of those. Codex solves this with a native Rust helper it
27
+ * ships; Phase 44 builds no native artefact, and adding one is not something
28
+ * that can be validated from here.
29
+ *
30
+ * So Landlock is wired as an explicit, opt-in helper contract rather than
31
+ * guessed at against a third-party CLI whose flags cannot be checked from this
32
+ * machine:
33
+ *
34
+ * <helper> --ro <path> --rw <path> [--rw <path> ...] [--no-network] -- <argv...>
35
+ *
36
+ * configured via `landlockHelperBin` or `DRAHT_SANDBOX_LANDLOCK_HELPER`. If no
37
+ * helper is configured the mechanism is simply not selected. If one is
38
+ * configured but does not honour the contract, the self-test fails and the
39
+ * backend reports `unavailable` -- which is why shipping an unproven contract
40
+ * here is not a security risk.
41
+ *
42
+ * ## Namespace mechanisms (the fallback R44-SBX.1 asks for)
43
+ *
44
+ * - **bubblewrap** (`bwrap`), preferred: `--ro-bind / /` gives read allow-all,
45
+ * then one `--bind` per policy write path makes exactly those subtrees
46
+ * writable. That is the R44-SBX.2 policy shape expressed directly. bwrap sets
47
+ * `PR_SET_NO_NEW_PRIVS` by default, which is what makes `sudo` and every other
48
+ * setuid binary inert -- the privilege-escalation invariant. `--unshare-net`
49
+ * when the policy says network off.
50
+ * - **`unshare`**, fallback: `--user --map-root-user --mount` and then a mount
51
+ * preamble that makes `/` read-only and re-binds the write paths read-write.
52
+ * Coarser and more fragile than bwrap (it is a shell preamble, not a
53
+ * supervisor), and the one piece here most likely to need revision once it has
54
+ * actually run. `--net` for network off, as in Phase 28.
55
+ *
56
+ * Note the consequence of the R44-SBX.4 privilege-escalation probe: `unshare`
57
+ * sets neither `PR_SET_NO_NEW_PRIVS` nor anything that refuses `exec` of a
58
+ * setuid binary, so it can demonstrate neither half of the
59
+ * `allowPrivilegeEscalation: false` invariant and the self-test will report
60
+ * `unavailable` for it. That is the fail-closed reading and it is the intended
61
+ * one: this backend's entire safety argument is the self-test, so a mechanism
62
+ * that cannot show the invariant holds does not get to claim it.
63
+ *
64
+ * Ordering is Landlock helper, then bwrap, then unshare: most precise mechanism
65
+ * first, and the kernel-version check keeps the Landlock path from being chosen
66
+ * on a kernel that cannot support it even when a helper is configured.
67
+ */
68
+ import { existsSync } from "node:fs";
69
+ import { release as osRelease } from "node:os";
70
+ import { delimiter, join } from "node:path";
71
+ import { getShellConfig } from "../../utils/shell.js";
72
+ import { buildSandboxEnv } from "./env.js";
73
+ import { SandboxUnavailableError, } from "./executor.js";
74
+ import { SandboxProfileError } from "./seatbelt-profile.js";
75
+ import { runSandboxSelfTest } from "./self-test.js";
76
+ import { spawnSandboxedProcess } from "./spawn.js";
77
+ /** Landlock filesystem restriction landed in Linux 5.13. Below that the helper cannot work. */
78
+ export const MIN_LANDLOCK_KERNEL = { major: 5, minor: 13 };
79
+ function lookupOnPath(name) {
80
+ for (const dir of (process.env.PATH ?? "").split(delimiter)) {
81
+ if (!dir)
82
+ continue;
83
+ const candidate = join(dir, name);
84
+ if (existsSync(candidate))
85
+ return candidate;
86
+ }
87
+ return null;
88
+ }
89
+ /** True when `release` (an `os.release()` string) is at least 5.13. Unparseable releases answer `false`. */
90
+ export function supportsLandlock(release) {
91
+ const match = /^(\d+)\.(\d+)/.exec(release);
92
+ if (!match)
93
+ return false;
94
+ const major = Number(match[1]);
95
+ const minor = Number(match[2]);
96
+ if (major > MIN_LANDLOCK_KERNEL.major)
97
+ return true;
98
+ return major === MIN_LANDLOCK_KERNEL.major && minor >= MIN_LANDLOCK_KERNEL.minor;
99
+ }
100
+ /** Picks the mechanism to use, most precise first. `null` means this host has none. */
101
+ export function detectLinuxSandboxMechanism(options = {}) {
102
+ const lookup = options.lookupBin ?? lookupOnPath;
103
+ const release = options.kernelRelease ?? osRelease();
104
+ const helper = options.landlockHelperBin ?? process.env.DRAHT_SANDBOX_LANDLOCK_HELPER;
105
+ if (helper && existsSync(helper) && supportsLandlock(release))
106
+ return { kind: "landlock", bin: helper };
107
+ const bwrap = lookup("bwrap");
108
+ if (bwrap)
109
+ return { kind: "bwrap", bin: bwrap };
110
+ const unshare = lookup("unshare");
111
+ if (unshare)
112
+ return { kind: "unshare", bin: unshare };
113
+ return null;
114
+ }
115
+ /** Single-quoted shell word for the `unshare` preamble. */
116
+ function shellQuote(value) {
117
+ return `'${value.replace(/'/g, `'\\''`)}'`;
118
+ }
119
+ /**
120
+ * The `unshare` mount preamble: make propagation private, remount `/` read-only,
121
+ * then bind each write path back read-write.
122
+ *
123
+ * `/dev` and `/proc` are remounted read-write best-effort (`|| true`): they carry
124
+ * no user data, and a shell that cannot write `/dev/null` is unusable. Failures
125
+ * are tolerated because the self-test, not this preamble, decides whether the
126
+ * result is good enough to call a sandbox.
127
+ */
128
+ function buildUnsharePreamble(policy) {
129
+ const steps = [
130
+ "mount --make-rprivate /",
131
+ "mount --bind / /",
132
+ "mount -o remount,bind,ro /",
133
+ "mount -o remount,bind,rw /dev 2>/dev/null || true",
134
+ "mount -o remount,bind,rw /proc 2>/dev/null || true",
135
+ ];
136
+ for (const path of policy.writePaths) {
137
+ const quoted = shellQuote(path);
138
+ steps.push(`mount --bind ${quoted} ${quoted}`, `mount -o remount,bind,rw ${quoted}`);
139
+ }
140
+ return steps.join(" && ");
141
+ }
142
+ /**
143
+ * Builds the wrapper invocation for `mechanism`.
144
+ *
145
+ * Exported so the argument vectors are reviewable and testable without a Linux
146
+ * host -- with the standing caveat that a correct-looking argv is not evidence
147
+ * of confinement.
148
+ */
149
+ export function buildLinuxSandboxCommand(mechanism, policy, command, shell, cwd) {
150
+ if (policy.writePaths.length === 0) {
151
+ throw new SandboxProfileError("cannot build a linux sandbox command: the write allowlist is empty");
152
+ }
153
+ if (policy.writePaths.includes("/")) {
154
+ throw new SandboxProfileError("cannot build a linux sandbox command: the write allowlist contains the filesystem root, which would confine nothing");
155
+ }
156
+ const shellInvocation = [shell.shell, ...shell.args, command];
157
+ if (mechanism.kind === "landlock") {
158
+ const args = ["--ro", "/"];
159
+ for (const path of policy.writePaths)
160
+ args.push("--rw", path);
161
+ if (policy.network === "off")
162
+ args.push("--no-network");
163
+ return { command: mechanism.bin, args: [...args, "--", ...shellInvocation] };
164
+ }
165
+ if (mechanism.kind === "bwrap") {
166
+ const args = [
167
+ "--die-with-parent",
168
+ // Read allow-all: the whole filesystem, read-only ...
169
+ "--ro-bind",
170
+ "/",
171
+ "/",
172
+ // ... with the kernel/device filesystems a shell needs ...
173
+ "--dev-bind",
174
+ "/dev",
175
+ "/dev",
176
+ "--proc",
177
+ "/proc",
178
+ ];
179
+ // ... and exactly the policy's paths writable again. Later binds win, so
180
+ // these must follow the read-only root bind.
181
+ for (const path of policy.writePaths)
182
+ args.push("--bind", path, path);
183
+ if (policy.network === "off")
184
+ args.push("--unshare-net");
185
+ args.push("--chdir", cwd, "--");
186
+ return { command: mechanism.bin, args: [...args, ...shellInvocation] };
187
+ }
188
+ // unshare: the namespace flags Phase 28 used, plus a preamble that turns a
189
+ // mount namespace into an actual write allowlist.
190
+ const args = ["--user", "--map-root-user", "--mount"];
191
+ if (policy.network === "off")
192
+ args.push("--net");
193
+ const preamble = buildUnsharePreamble(policy);
194
+ return {
195
+ command: mechanism.bin,
196
+ args: [...args, "--", shell.shell, ...shell.args, `${preamble} && cd ${shellQuote(cwd)} && ${command}`],
197
+ };
198
+ }
199
+ export function createLinuxSandboxExecutor(options = {}) {
200
+ const mechanism = detectLinuxSandboxMechanism(options);
201
+ const runConfined = async (command, cwd, policy, execOptions) => {
202
+ if (!mechanism) {
203
+ throw new SandboxUnavailableError("no linux sandbox mechanism is available on this host (looked for a Landlock helper, bwrap, then unshare) -- refusing to run the command unconfined");
204
+ }
205
+ const shell = getShellConfig(options.shellPath);
206
+ let built;
207
+ try {
208
+ built = buildLinuxSandboxCommand(mechanism, policy, command, shell, cwd);
209
+ }
210
+ catch (err) {
211
+ // Same reasoning as the Seatbelt backend: a policy that cannot be
212
+ // expressed is one that cannot be enforced, and nothing has spawned yet.
213
+ throw new SandboxUnavailableError(`cannot build a linux sandbox invocation for this policy: ${err instanceof Error ? err.message : String(err)}`);
214
+ }
215
+ return spawnSandboxedProcess(built.command, built.args, {
216
+ cwd,
217
+ env: buildSandboxEnv({ source: execOptions.env, extraAllowedNames: options.extraAllowedEnvVars }),
218
+ onData: execOptions.onData,
219
+ signal: execOptions.signal,
220
+ timeout: execOptions.timeout,
221
+ });
222
+ };
223
+ let statusPromise;
224
+ const status = () => {
225
+ statusPromise ??= (mechanism
226
+ ? runSandboxSelfTest({
227
+ backendName: `linux-${mechanism.kind}`,
228
+ timeoutSeconds: options.selfTestTimeoutSeconds,
229
+ run: async (command, cwd, policy, timeoutSeconds) => {
230
+ let output = "";
231
+ const result = await runConfined(command, cwd, policy, {
232
+ onData: (data) => {
233
+ output += data.toString();
234
+ },
235
+ timeout: timeoutSeconds,
236
+ });
237
+ return { exitCode: result.exitCode, output };
238
+ },
239
+ })
240
+ : Promise.resolve({
241
+ available: false,
242
+ reason: "no linux sandbox mechanism is available on this host: no Landlock helper is configured (DRAHT_SANDBOX_LANDLOCK_HELPER), and neither bwrap nor unshare was found on PATH",
243
+ })).catch((err) => ({
244
+ available: false,
245
+ reason: `linux sandbox self-test failed: ${err instanceof Error ? err.message : String(err)}`,
246
+ }));
247
+ return statusPromise;
248
+ };
249
+ return {
250
+ name: mechanism ? `linux-${mechanism.kind}` : "linux-unavailable",
251
+ status,
252
+ exec: async (command, cwd, policy, execOptions) => {
253
+ const current = await status();
254
+ if (!current.available)
255
+ throw new SandboxUnavailableError(current.reason);
256
+ return runConfined(command, cwd, policy, execOptions);
257
+ },
258
+ };
259
+ }
260
+ //# sourceMappingURL=linux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linux.js","sourceRoot":"","sources":["../../../src/core/sandbox/linux.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAoB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,eAAe,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* This module was written and reviewed on macOS (darwin). No line of it has ever\n * run on Linux, and the tests that accompany it assert on *constructed argument\n * vectors*, never on confinement -- constructing the right argv is not evidence\n * that the argv confines anything. Treat every claim below as a design intent\n * awaiting the Linux CI matrix that R46-SBH.2 owns, which exists precisely\n * because Phase 28 shipped an unverified Linux path from this same machine.\n *\n * The reason that posture is *safe* rather than merely honest: this backend is\n * gated by the same R44-SBX.4 self-test as the macOS one, and the self-test\n * confirms confinement from outside the sandbox. If any mechanism below fails to\n * confine on a real kernel, `status()` answers `unavailable` and no command runs\n * through it. Unverified code cannot promote itself to `available`; only a\n * passing probe on the actual host can.\n *\n * ## Landlock, and why it is a seam rather than an implementation\n *\n * R44-SBX.1 names Landlock (kernel >= 5.13) as the preferred mechanism, and it\n * is the right one: per-process filesystem restriction, no root, no setuid\n * helper, no namespaces. But applying it means calling `landlock_create_ruleset(2)`,\n * `landlock_add_rule(2)` and `prctl(PR_SET_NO_NEW_PRIVS)` *between* fork and exec,\n * and Node exposes none of those. Codex solves this with a native Rust helper it\n * ships; Phase 44 builds no native artefact, and adding one is not something\n * that can be validated from here.\n *\n * So Landlock is wired as an explicit, opt-in helper contract rather than\n * guessed at against a third-party CLI whose flags cannot be checked from this\n * machine:\n *\n * <helper> --ro <path> --rw <path> [--rw <path> ...] [--no-network] -- <argv...>\n *\n * configured via `landlockHelperBin` or `DRAHT_SANDBOX_LANDLOCK_HELPER`. If no\n * helper is configured the mechanism is simply not selected. If one is\n * configured but does not honour the contract, the self-test fails and the\n * backend reports `unavailable` -- which is why shipping an unproven contract\n * here is not a security risk.\n *\n * ## Namespace mechanisms (the fallback R44-SBX.1 asks for)\n *\n * - **bubblewrap** (`bwrap`), preferred: `--ro-bind / /` gives read allow-all,\n * then one `--bind` per policy write path makes exactly those subtrees\n * writable. That is the R44-SBX.2 policy shape expressed directly. bwrap sets\n * `PR_SET_NO_NEW_PRIVS` by default, which is what makes `sudo` and every other\n * setuid binary inert -- the privilege-escalation invariant. `--unshare-net`\n * when the policy says network off.\n * - **`unshare`**, fallback: `--user --map-root-user --mount` and then a mount\n * preamble that makes `/` read-only and re-binds the write paths read-write.\n * Coarser and more fragile than bwrap (it is a shell preamble, not a\n * supervisor), and the one piece here most likely to need revision once it has\n * actually run. `--net` for network off, as in Phase 28.\n *\n * Note the consequence of the R44-SBX.4 privilege-escalation probe: `unshare`\n * sets neither `PR_SET_NO_NEW_PRIVS` nor anything that refuses `exec` of a\n * setuid binary, so it can demonstrate neither half of the\n * `allowPrivilegeEscalation: false` invariant and the self-test will report\n * `unavailable` for it. That is the fail-closed reading and it is the intended\n * one: this backend's entire safety argument is the self-test, so a mechanism\n * that cannot show the invariant holds does not get to claim it.\n *\n * Ordering is Landlock helper, then bwrap, then unshare: most precise mechanism\n * first, and the kernel-version check keeps the Landlock path from being chosen\n * on a kernel that cannot support it even when a helper is configured.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { release as osRelease } from \"node:os\";\nimport { delimiter, join } from \"node:path\";\nimport { getShellConfig, type ShellConfig } from \"../../utils/shell.ts\";\nimport { buildSandboxEnv } from \"./env.ts\";\nimport {\n\ttype SandboxExecOptions,\n\ttype SandboxExecResult,\n\ttype SandboxExecutor,\n\ttype SandboxStatus,\n\tSandboxUnavailableError,\n} from \"./executor.ts\";\nimport type { SandboxPolicy } from \"./policy.ts\";\nimport { SandboxProfileError } from \"./seatbelt-profile.ts\";\nimport { runSandboxSelfTest } from \"./self-test.ts\";\nimport { spawnSandboxedProcess } from \"./spawn.ts\";\n\n/** Landlock filesystem restriction landed in Linux 5.13. Below that the helper cannot work. */\nexport const MIN_LANDLOCK_KERNEL = { major: 5, minor: 13 } as const;\n\nexport type LinuxSandboxMechanism =\n\t| { kind: \"landlock\"; bin: string }\n\t| { kind: \"bwrap\"; bin: string }\n\t| { kind: \"unshare\"; bin: string };\n\nexport interface LinuxSandboxOptions {\n\t/** Path to a Landlock helper implementing the contract in the module doc. */\n\tlandlockHelperBin?: string;\n\t/** Resolves a bare binary name; defaults to a `PATH` scan. Injection point for tests. */\n\tlookupBin?: (name: string) => string | null;\n\t/**\n\t * Defaults to `os.release()`. Injection point for tests.\n\t *\n\t * The default is applied inside `detectLinuxSandboxMechanism` rather than only\n\t * at the one call site in `createLinuxSandboxExecutor`, because it used to\n\t * default to `\"\"` there: every *exported* call therefore failed\n\t * `supportsLandlock(\"\")` and silently fell through to bwrap, even on a kernel\n\t * that supports Landlock and with a helper configured.\n\t */\n\tkernelRelease?: string;\n\tshellPath?: string;\n\textraAllowedEnvVars?: readonly string[];\n\tselfTestTimeoutSeconds?: number;\n}\n\nfunction lookupOnPath(name: string): string | null {\n\tfor (const dir of (process.env.PATH ?? \"\").split(delimiter)) {\n\t\tif (!dir) continue;\n\t\tconst candidate = join(dir, name);\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\treturn null;\n}\n\n/** True when `release` (an `os.release()` string) is at least 5.13. Unparseable releases answer `false`. */\nexport function supportsLandlock(release: string): boolean {\n\tconst match = /^(\\d+)\\.(\\d+)/.exec(release);\n\tif (!match) return false;\n\tconst major = Number(match[1]);\n\tconst minor = Number(match[2]);\n\tif (major > MIN_LANDLOCK_KERNEL.major) return true;\n\treturn major === MIN_LANDLOCK_KERNEL.major && minor >= MIN_LANDLOCK_KERNEL.minor;\n}\n\n/** Picks the mechanism to use, most precise first. `null` means this host has none. */\nexport function detectLinuxSandboxMechanism(options: LinuxSandboxOptions = {}): LinuxSandboxMechanism | null {\n\tconst lookup = options.lookupBin ?? lookupOnPath;\n\tconst release = options.kernelRelease ?? osRelease();\n\n\tconst helper = options.landlockHelperBin ?? process.env.DRAHT_SANDBOX_LANDLOCK_HELPER;\n\tif (helper && existsSync(helper) && supportsLandlock(release)) return { kind: \"landlock\", bin: helper };\n\n\tconst bwrap = lookup(\"bwrap\");\n\tif (bwrap) return { kind: \"bwrap\", bin: bwrap };\n\n\tconst unshare = lookup(\"unshare\");\n\tif (unshare) return { kind: \"unshare\", bin: unshare };\n\n\treturn null;\n}\n\n/** Single-quoted shell word for the `unshare` preamble. */\nfunction shellQuote(value: string): string {\n\treturn `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\n/**\n * The `unshare` mount preamble: make propagation private, remount `/` read-only,\n * then bind each write path back read-write.\n *\n * `/dev` and `/proc` are remounted read-write best-effort (`|| true`): they carry\n * no user data, and a shell that cannot write `/dev/null` is unusable. Failures\n * are tolerated because the self-test, not this preamble, decides whether the\n * result is good enough to call a sandbox.\n */\nfunction buildUnsharePreamble(policy: SandboxPolicy): string {\n\tconst steps = [\n\t\t\"mount --make-rprivate /\",\n\t\t\"mount --bind / /\",\n\t\t\"mount -o remount,bind,ro /\",\n\t\t\"mount -o remount,bind,rw /dev 2>/dev/null || true\",\n\t\t\"mount -o remount,bind,rw /proc 2>/dev/null || true\",\n\t];\n\tfor (const path of policy.writePaths) {\n\t\tconst quoted = shellQuote(path);\n\t\tsteps.push(`mount --bind ${quoted} ${quoted}`, `mount -o remount,bind,rw ${quoted}`);\n\t}\n\treturn steps.join(\" && \");\n}\n\n/**\n * Builds the wrapper invocation for `mechanism`.\n *\n * Exported so the argument vectors are reviewable and testable without a Linux\n * host -- with the standing caveat that a correct-looking argv is not evidence\n * of confinement.\n */\nexport function buildLinuxSandboxCommand(\n\tmechanism: LinuxSandboxMechanism,\n\tpolicy: SandboxPolicy,\n\tcommand: string,\n\tshell: ShellConfig,\n\tcwd: string,\n): { command: string; args: string[] } {\n\tif (policy.writePaths.length === 0) {\n\t\tthrow new SandboxProfileError(\"cannot build a linux sandbox command: the write allowlist is empty\");\n\t}\n\tif (policy.writePaths.includes(\"/\")) {\n\t\tthrow new SandboxProfileError(\n\t\t\t\"cannot build a linux sandbox command: the write allowlist contains the filesystem root, which would confine nothing\",\n\t\t);\n\t}\n\tconst shellInvocation = [shell.shell, ...shell.args, command];\n\n\tif (mechanism.kind === \"landlock\") {\n\t\tconst args = [\"--ro\", \"/\"];\n\t\tfor (const path of policy.writePaths) args.push(\"--rw\", path);\n\t\tif (policy.network === \"off\") args.push(\"--no-network\");\n\t\treturn { command: mechanism.bin, args: [...args, \"--\", ...shellInvocation] };\n\t}\n\n\tif (mechanism.kind === \"bwrap\") {\n\t\tconst args = [\n\t\t\t\"--die-with-parent\",\n\t\t\t// Read allow-all: the whole filesystem, read-only ...\n\t\t\t\"--ro-bind\",\n\t\t\t\"/\",\n\t\t\t\"/\",\n\t\t\t// ... with the kernel/device filesystems a shell needs ...\n\t\t\t\"--dev-bind\",\n\t\t\t\"/dev\",\n\t\t\t\"/dev\",\n\t\t\t\"--proc\",\n\t\t\t\"/proc\",\n\t\t];\n\t\t// ... and exactly the policy's paths writable again. Later binds win, so\n\t\t// these must follow the read-only root bind.\n\t\tfor (const path of policy.writePaths) args.push(\"--bind\", path, path);\n\t\tif (policy.network === \"off\") args.push(\"--unshare-net\");\n\t\targs.push(\"--chdir\", cwd, \"--\");\n\t\treturn { command: mechanism.bin, args: [...args, ...shellInvocation] };\n\t}\n\n\t// unshare: the namespace flags Phase 28 used, plus a preamble that turns a\n\t// mount namespace into an actual write allowlist.\n\tconst args = [\"--user\", \"--map-root-user\", \"--mount\"];\n\tif (policy.network === \"off\") args.push(\"--net\");\n\tconst preamble = buildUnsharePreamble(policy);\n\treturn {\n\t\tcommand: mechanism.bin,\n\t\targs: [...args, \"--\", shell.shell, ...shell.args, `${preamble} && cd ${shellQuote(cwd)} && ${command}`],\n\t};\n}\n\nexport function createLinuxSandboxExecutor(options: LinuxSandboxOptions = {}): SandboxExecutor {\n\tconst mechanism = detectLinuxSandboxMechanism(options);\n\n\tconst runConfined = async (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\tpolicy: SandboxPolicy,\n\t\texecOptions: SandboxExecOptions,\n\t): Promise<SandboxExecResult> => {\n\t\tif (!mechanism) {\n\t\t\tthrow new SandboxUnavailableError(\n\t\t\t\t\"no linux sandbox mechanism is available on this host (looked for a Landlock helper, bwrap, then unshare) -- refusing to run the command unconfined\",\n\t\t\t);\n\t\t}\n\t\tconst shell = getShellConfig(options.shellPath);\n\t\tlet built: { command: string; args: string[] };\n\t\ttry {\n\t\t\tbuilt = buildLinuxSandboxCommand(mechanism, policy, command, shell, cwd);\n\t\t} catch (err) {\n\t\t\t// Same reasoning as the Seatbelt backend: a policy that cannot be\n\t\t\t// expressed is one that cannot be enforced, and nothing has spawned yet.\n\t\t\tthrow new SandboxUnavailableError(\n\t\t\t\t`cannot build a linux sandbox invocation for this policy: ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t);\n\t\t}\n\t\treturn spawnSandboxedProcess(built.command, built.args, {\n\t\t\tcwd,\n\t\t\tenv: buildSandboxEnv({ source: execOptions.env, extraAllowedNames: options.extraAllowedEnvVars }),\n\t\t\tonData: execOptions.onData,\n\t\t\tsignal: execOptions.signal,\n\t\t\ttimeout: execOptions.timeout,\n\t\t});\n\t};\n\n\tlet statusPromise: Promise<SandboxStatus> | undefined;\n\tconst status = (): Promise<SandboxStatus> => {\n\t\tstatusPromise ??= (\n\t\t\tmechanism\n\t\t\t\t? runSandboxSelfTest({\n\t\t\t\t\t\tbackendName: `linux-${mechanism.kind}`,\n\t\t\t\t\t\ttimeoutSeconds: options.selfTestTimeoutSeconds,\n\t\t\t\t\t\trun: async (command, cwd, policy, timeoutSeconds) => {\n\t\t\t\t\t\t\tlet output = \"\";\n\t\t\t\t\t\t\tconst result = await runConfined(command, cwd, policy, {\n\t\t\t\t\t\t\t\tonData: (data) => {\n\t\t\t\t\t\t\t\t\toutput += data.toString();\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttimeout: timeoutSeconds,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn { exitCode: result.exitCode, output };\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t: Promise.resolve<SandboxStatus>({\n\t\t\t\t\t\tavailable: false,\n\t\t\t\t\t\treason:\n\t\t\t\t\t\t\t\"no linux sandbox mechanism is available on this host: no Landlock helper is configured (DRAHT_SANDBOX_LANDLOCK_HELPER), and neither bwrap nor unshare was found on PATH\",\n\t\t\t\t\t})\n\t\t).catch((err) => ({\n\t\t\tavailable: false as const,\n\t\t\treason: `linux sandbox self-test failed: ${err instanceof Error ? err.message : String(err)}`,\n\t\t}));\n\t\treturn statusPromise;\n\t};\n\n\treturn {\n\t\tname: mechanism ? `linux-${mechanism.kind}` : \"linux-unavailable\",\n\t\tstatus,\n\t\texec: async (command, cwd, policy, execOptions) => {\n\t\t\tconst current = await status();\n\t\t\tif (!current.available) throw new SandboxUnavailableError(current.reason);\n\t\t\treturn runConfined(command, cwd, policy, execOptions);\n\t\t},\n\t};\n}\n"]}