@nordhavnhq/runner 0.0.0-stage → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/bin/cliclick +0 -0
  2. package/dist/brand.d.ts +5 -0
  3. package/dist/brand.js +18 -0
  4. package/dist/cli/agent.d.ts +9 -0
  5. package/dist/cli/agent.js +80 -0
  6. package/dist/cli/folder.d.ts +2 -0
  7. package/dist/cli/folder.js +103 -0
  8. package/dist/cli/init.d.ts +2 -0
  9. package/dist/cli/init.js +67 -0
  10. package/dist/cli/lifecycle.d.ts +3 -0
  11. package/dist/cli/lifecycle.js +149 -0
  12. package/dist/cli/link.d.ts +42 -0
  13. package/dist/cli/link.js +314 -0
  14. package/dist/cli/logs.d.ts +2 -0
  15. package/dist/cli/logs.js +147 -0
  16. package/dist/cli/prompts.d.ts +7 -0
  17. package/dist/cli/prompts.js +13 -0
  18. package/dist/cli/ps.d.ts +2 -0
  19. package/dist/cli/ps.js +81 -0
  20. package/dist/cli/relay.d.ts +4 -0
  21. package/dist/cli/relay.js +29 -0
  22. package/dist/cli/update.d.ts +6 -0
  23. package/dist/cli/update.js +131 -0
  24. package/dist/config.d.ts +166 -0
  25. package/dist/config.js +383 -0
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.js +145 -0
  28. package/dist/legacy-env.d.ts +4 -0
  29. package/dist/legacy-env.js +32 -0
  30. package/dist/paths.d.ts +37 -0
  31. package/dist/paths.js +92 -0
  32. package/dist/runtime/daemon.d.ts +57 -0
  33. package/dist/runtime/daemon.js +159 -0
  34. package/dist/runtime/dev-start.d.ts +31 -0
  35. package/dist/runtime/dev-start.js +110 -0
  36. package/dist/runtime/file-claims.d.ts +58 -0
  37. package/dist/runtime/file-claims.js +174 -0
  38. package/dist/runtime/fs-browse.d.ts +18 -0
  39. package/dist/runtime/fs-browse.js +104 -0
  40. package/dist/runtime/fs-checkout.d.ts +154 -0
  41. package/dist/runtime/fs-checkout.js +1049 -0
  42. package/dist/runtime/fs-git-index.d.ts +22 -0
  43. package/dist/runtime/fs-git-index.js +133 -0
  44. package/dist/runtime/fs-git.d.ts +16 -0
  45. package/dist/runtime/fs-git.js +424 -0
  46. package/dist/runtime/git-relay.d.ts +46 -0
  47. package/dist/runtime/git-relay.js +259 -0
  48. package/dist/runtime/git-unpushed.d.ts +36 -0
  49. package/dist/runtime/git-unpushed.js +93 -0
  50. package/dist/runtime/node-version.d.ts +12 -0
  51. package/dist/runtime/node-version.js +39 -0
  52. package/dist/runtime/preview-tunnel.d.ts +16 -0
  53. package/dist/runtime/preview-tunnel.js +135 -0
  54. package/dist/runtime/processes.d.ts +61 -0
  55. package/dist/runtime/processes.js +408 -0
  56. package/dist/runtime/project-node-download.d.ts +17 -0
  57. package/dist/runtime/project-node-download.js +137 -0
  58. package/dist/runtime/project-node.d.ts +65 -0
  59. package/dist/runtime/project-node.js +223 -0
  60. package/dist/runtime/reap-scratch.d.ts +22 -0
  61. package/dist/runtime/reap-scratch.js +112 -0
  62. package/dist/runtime/spill-tool-output.d.ts +14 -0
  63. package/dist/runtime/spill-tool-output.js +84 -0
  64. package/dist/runtime/up.d.ts +6 -0
  65. package/dist/runtime/up.js +1325 -0
  66. package/dist/tools/_coerce.d.ts +2 -0
  67. package/dist/tools/_coerce.js +26 -0
  68. package/dist/tools/_commit-scope.d.ts +14 -0
  69. package/dist/tools/_commit-scope.js +70 -0
  70. package/dist/tools/_jail.d.ts +68 -0
  71. package/dist/tools/_jail.js +209 -0
  72. package/dist/tools/_output.d.ts +24 -0
  73. package/dist/tools/_output.js +48 -0
  74. package/dist/tools/_ripgrep.d.ts +46 -0
  75. package/dist/tools/_ripgrep.js +148 -0
  76. package/dist/tools/_run-worktree.d.ts +10 -0
  77. package/dist/tools/_run-worktree.js +27 -0
  78. package/dist/tools/_shell-words.d.ts +15 -0
  79. package/dist/tools/_shell-words.js +43 -0
  80. package/dist/tools/_sonar/astro.d.ts +6 -0
  81. package/dist/tools/_sonar/astro.js +45 -0
  82. package/dist/tools/_sonar/blade.d.ts +3 -0
  83. package/dist/tools/_sonar/blade.js +53 -0
  84. package/dist/tools/_sonar/build.d.ts +44 -0
  85. package/dist/tools/_sonar/build.js +147 -0
  86. package/dist/tools/_sonar/changed.d.ts +21 -0
  87. package/dist/tools/_sonar/changed.js +230 -0
  88. package/dist/tools/_sonar/diagnose/delta.d.ts +27 -0
  89. package/dist/tools/_sonar/diagnose/delta.js +64 -0
  90. package/dist/tools/_sonar/diagnose/detect.d.ts +39 -0
  91. package/dist/tools/_sonar/diagnose/detect.js +117 -0
  92. package/dist/tools/_sonar/diagnose/index.d.ts +13 -0
  93. package/dist/tools/_sonar/diagnose/index.js +217 -0
  94. package/dist/tools/_sonar/diagnose/lint-worker.d.ts +1 -0
  95. package/dist/tools/_sonar/diagnose/lint-worker.js +48 -0
  96. package/dist/tools/_sonar/diagnose/pool.d.ts +22 -0
  97. package/dist/tools/_sonar/diagnose/pool.js +149 -0
  98. package/dist/tools/_sonar/diagnose/rules.d.ts +23 -0
  99. package/dist/tools/_sonar/diagnose/rules.js +131 -0
  100. package/dist/tools/_sonar/diagnose/types-worker.d.ts +1 -0
  101. package/dist/tools/_sonar/diagnose/types-worker.js +183 -0
  102. package/dist/tools/_sonar/files.d.ts +14 -0
  103. package/dist/tools/_sonar/files.js +121 -0
  104. package/dist/tools/_sonar/graph.d.ts +34 -0
  105. package/dist/tools/_sonar/graph.js +164 -0
  106. package/dist/tools/_sonar/hints.d.ts +116 -0
  107. package/dist/tools/_sonar/hints.js +545 -0
  108. package/dist/tools/_sonar/imports.d.ts +38 -0
  109. package/dist/tools/_sonar/imports.js +275 -0
  110. package/dist/tools/_sonar/index.d.ts +79 -0
  111. package/dist/tools/_sonar/index.js +462 -0
  112. package/dist/tools/_sonar/keys.d.ts +5 -0
  113. package/dist/tools/_sonar/keys.js +248 -0
  114. package/dist/tools/_sonar/laravel-routes.d.ts +15 -0
  115. package/dist/tools/_sonar/laravel-routes.js +263 -0
  116. package/dist/tools/_sonar/laravel.d.ts +64 -0
  117. package/dist/tools/_sonar/laravel.js +326 -0
  118. package/dist/tools/_sonar/location.d.ts +33 -0
  119. package/dist/tools/_sonar/location.js +137 -0
  120. package/dist/tools/_sonar/map.d.ts +43 -0
  121. package/dist/tools/_sonar/map.js +212 -0
  122. package/dist/tools/_sonar/parse.d.ts +3 -0
  123. package/dist/tools/_sonar/parse.js +76 -0
  124. package/dist/tools/_sonar/prewarm.d.ts +9 -0
  125. package/dist/tools/_sonar/prewarm.js +96 -0
  126. package/dist/tools/_sonar/prisma.d.ts +9 -0
  127. package/dist/tools/_sonar/prisma.js +51 -0
  128. package/dist/tools/_sonar/refs.d.ts +7 -0
  129. package/dist/tools/_sonar/refs.js +273 -0
  130. package/dist/tools/_sonar/render.d.ts +66 -0
  131. package/dist/tools/_sonar/render.js +498 -0
  132. package/dist/tools/_sonar/resolve.d.ts +63 -0
  133. package/dist/tools/_sonar/resolve.js +402 -0
  134. package/dist/tools/_sonar/roots.d.ts +4 -0
  135. package/dist/tools/_sonar/roots.js +42 -0
  136. package/dist/tools/_sonar/routes.d.ts +5 -0
  137. package/dist/tools/_sonar/routes.js +247 -0
  138. package/dist/tools/_sonar/serve.d.ts +12 -0
  139. package/dist/tools/_sonar/serve.js +104 -0
  140. package/dist/tools/_sonar/suggest.d.ts +23 -0
  141. package/dist/tools/_sonar/suggest.js +114 -0
  142. package/dist/tools/_sonar/tests.d.ts +21 -0
  143. package/dist/tools/_sonar/tests.js +134 -0
  144. package/dist/tools/_sonar/tsconfig.d.ts +34 -0
  145. package/dist/tools/_sonar/tsconfig.js +188 -0
  146. package/dist/tools/_sonar/types.d.ts +81 -0
  147. package/dist/tools/_sonar/types.js +6 -0
  148. package/dist/tools/_symbols.d.ts +27 -0
  149. package/dist/tools/_symbols.js +461 -0
  150. package/dist/tools/_test-report.d.ts +47 -0
  151. package/dist/tools/_test-report.js +203 -0
  152. package/dist/tools/_touched.d.ts +44 -0
  153. package/dist/tools/_touched.js +195 -0
  154. package/dist/tools/_upload.d.ts +26 -0
  155. package/dist/tools/_upload.js +132 -0
  156. package/dist/tools/_worktree-setup.d.ts +29 -0
  157. package/dist/tools/_worktree-setup.js +204 -0
  158. package/dist/tools/browser.d.ts +2 -0
  159. package/dist/tools/browser.js +8 -0
  160. package/dist/tools/commit-guard.d.ts +44 -0
  161. package/dist/tools/commit-guard.js +165 -0
  162. package/dist/tools/computer.d.ts +13 -0
  163. package/dist/tools/computer.js +952 -0
  164. package/dist/tools/console.d.ts +44 -0
  165. package/dist/tools/console.js +739 -0
  166. package/dist/tools/database.d.ts +28 -0
  167. package/dist/tools/database.js +152 -0
  168. package/dist/tools/filesystem.d.ts +36 -0
  169. package/dist/tools/filesystem.js +506 -0
  170. package/dist/tools/git-tag.d.ts +10 -0
  171. package/dist/tools/git-tag.js +164 -0
  172. package/dist/tools/git.d.ts +52 -0
  173. package/dist/tools/git.js +1272 -0
  174. package/dist/tools/http.d.ts +12 -0
  175. package/dist/tools/http.js +119 -0
  176. package/dist/tools/image.d.ts +8 -0
  177. package/dist/tools/image.js +551 -0
  178. package/dist/tools/index.d.ts +13 -0
  179. package/dist/tools/index.js +58 -0
  180. package/dist/tools/outline.d.ts +20 -0
  181. package/dist/tools/outline.js +98 -0
  182. package/dist/tools/search.d.ts +17 -0
  183. package/dist/tools/search.js +391 -0
  184. package/dist/tools/sonar.d.ts +17 -0
  185. package/dist/tools/sonar.js +231 -0
  186. package/dist/tools/testing.d.ts +36 -0
  187. package/dist/tools/testing.js +273 -0
  188. package/dist/tools/upload.d.ts +8 -0
  189. package/dist/tools/upload.js +106 -0
  190. package/dist/tools/webcam.d.ts +28 -0
  191. package/dist/tools/webcam.js +967 -0
  192. package/dist/update/install-kind.d.ts +35 -0
  193. package/dist/update/install-kind.js +109 -0
  194. package/dist/update/install.d.ts +32 -0
  195. package/dist/update/install.js +187 -0
  196. package/dist/update/manifest.d.ts +18 -0
  197. package/dist/update/manifest.js +73 -0
  198. package/dist/update/peers.d.ts +18 -0
  199. package/dist/update/peers.js +43 -0
  200. package/dist/update/policy.d.ts +20 -0
  201. package/dist/update/policy.js +49 -0
  202. package/dist/update/supervisor.d.ts +25 -0
  203. package/dist/update/supervisor.js +83 -0
  204. package/dist/update/updater.d.ts +44 -0
  205. package/dist/update/updater.js +116 -0
  206. package/dist/utils/format.d.ts +50 -0
  207. package/dist/utils/format.js +190 -0
  208. package/dist/version.d.ts +17 -0
  209. package/dist/version.js +63 -0
  210. package/dist/version.json +5 -0
  211. package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.d.ts +15 -0
  212. package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.js +541 -0
  213. package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.d.ts +25 -0
  214. package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.js +137 -0
  215. package/node_modules/@nordhavnhq/runner-browser/dist/guard.d.ts +21 -0
  216. package/node_modules/@nordhavnhq/runner-browser/dist/guard.js +104 -0
  217. package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.d.ts +47 -0
  218. package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.js +41 -0
  219. package/node_modules/@nordhavnhq/runner-browser/dist/host.d.ts +18 -0
  220. package/node_modules/@nordhavnhq/runner-browser/dist/host.js +15 -0
  221. package/node_modules/@nordhavnhq/runner-browser/dist/index.d.ts +13 -0
  222. package/node_modules/@nordhavnhq/runner-browser/dist/index.js +28 -0
  223. package/node_modules/@nordhavnhq/runner-browser/dist/live-input.d.ts +74 -0
  224. package/node_modules/@nordhavnhq/runner-browser/dist/live-input.js +93 -0
  225. package/node_modules/@nordhavnhq/runner-browser/dist/live-open.d.ts +4 -0
  226. package/node_modules/@nordhavnhq/runner-browser/dist/live-open.js +57 -0
  227. package/node_modules/@nordhavnhq/runner-browser/dist/live.d.ts +148 -0
  228. package/node_modules/@nordhavnhq/runner-browser/dist/live.js +179 -0
  229. package/node_modules/@nordhavnhq/runner-browser/dist/local-live.d.ts +31 -0
  230. package/node_modules/@nordhavnhq/runner-browser/dist/local-live.js +262 -0
  231. package/node_modules/@nordhavnhq/runner-browser/dist/marks.d.ts +36 -0
  232. package/node_modules/@nordhavnhq/runner-browser/dist/marks.js +173 -0
  233. package/node_modules/@nordhavnhq/runner-browser/dist/page-events.d.ts +27 -0
  234. package/node_modules/@nordhavnhq/runner-browser/dist/page-events.js +82 -0
  235. package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.d.ts +13 -0
  236. package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.js +526 -0
  237. package/node_modules/@nordhavnhq/runner-browser/dist/params.d.ts +12 -0
  238. package/node_modules/@nordhavnhq/runner-browser/dist/params.js +32 -0
  239. package/node_modules/@nordhavnhq/runner-browser/dist/pick.d.ts +24 -0
  240. package/node_modules/@nordhavnhq/runner-browser/dist/pick.js +76 -0
  241. package/node_modules/@nordhavnhq/runner-browser/dist/session.d.ts +225 -0
  242. package/node_modules/@nordhavnhq/runner-browser/dist/session.js +507 -0
  243. package/node_modules/@nordhavnhq/runner-browser/dist/shots.d.ts +11 -0
  244. package/node_modules/@nordhavnhq/runner-browser/dist/shots.js +103 -0
  245. package/node_modules/@nordhavnhq/runner-browser/dist/show.d.ts +10 -0
  246. package/node_modules/@nordhavnhq/runner-browser/dist/show.js +190 -0
  247. package/node_modules/@nordhavnhq/runner-browser/dist/target.d.ts +37 -0
  248. package/node_modules/@nordhavnhq/runner-browser/dist/target.js +82 -0
  249. package/node_modules/@nordhavnhq/runner-browser/dist/tour.d.ts +19 -0
  250. package/node_modules/@nordhavnhq/runner-browser/dist/tour.js +178 -0
  251. package/node_modules/@nordhavnhq/runner-browser/package.json +18 -0
  252. package/node_modules/@nordhavnhq/runner-runtime/dist/config.d.ts +96 -0
  253. package/node_modules/@nordhavnhq/runner-runtime/dist/config.js +25 -0
  254. package/node_modules/@nordhavnhq/runner-runtime/dist/connection.d.ts +276 -0
  255. package/node_modules/@nordhavnhq/runner-runtime/dist/connection.js +507 -0
  256. package/node_modules/@nordhavnhq/runner-runtime/dist/constants.d.ts +48 -0
  257. package/node_modules/@nordhavnhq/runner-runtime/dist/constants.js +95 -0
  258. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.d.ts +94 -0
  259. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.js +219 -0
  260. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.d.ts +136 -0
  261. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.js +214 -0
  262. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.d.ts +735 -0
  263. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.js +40 -0
  264. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.d.ts +362 -0
  265. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.js +703 -0
  266. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.d.ts +105 -0
  267. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.js +202 -0
  268. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.d.ts +204 -0
  269. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.js +497 -0
  270. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.d.ts +45 -0
  271. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.js +176 -0
  272. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.d.ts +74 -0
  273. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.js +72 -0
  274. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.d.ts +59 -0
  275. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.js +117 -0
  276. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.d.ts +62 -0
  277. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.js +84 -0
  278. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.d.ts +27 -0
  279. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.js +80 -0
  280. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.d.ts +22 -0
  281. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.js +22 -0
  282. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.d.ts +595 -0
  283. package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.js +85 -0
  284. package/node_modules/@nordhavnhq/runner-runtime/dist/index.d.ts +43 -0
  285. package/node_modules/@nordhavnhq/runner-runtime/dist/index.js +50 -0
  286. package/node_modules/@nordhavnhq/runner-runtime/dist/inference.d.ts +135 -0
  287. package/node_modules/@nordhavnhq/runner-runtime/dist/inference.js +945 -0
  288. package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.d.ts +67 -0
  289. package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.js +47 -0
  290. package/node_modules/@nordhavnhq/runner-runtime/dist/platform.d.ts +21 -0
  291. package/node_modules/@nordhavnhq/runner-runtime/dist/platform.js +25 -0
  292. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.d.ts +39 -0
  293. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.js +67 -0
  294. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.d.ts +61 -0
  295. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.js +58 -0
  296. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.d.ts +23 -0
  297. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.js +42 -0
  298. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.d.ts +6 -0
  299. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.js +12 -0
  300. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.d.ts +150 -0
  301. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.js +36 -0
  302. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.d.ts +14 -0
  303. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.js +49 -0
  304. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.d.ts +109 -0
  305. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.js +894 -0
  306. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.d.ts +73 -0
  307. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.js +765 -0
  308. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.d.ts +246 -0
  309. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.js +621 -0
  310. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.d.ts +88 -0
  311. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.js +188 -0
  312. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.d.ts +15 -0
  313. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.js +10 -0
  314. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.d.ts +16 -0
  315. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.js +97 -0
  316. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.d.ts +22 -0
  317. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.js +47 -0
  318. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.d.ts +26 -0
  319. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.js +48 -0
  320. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.d.ts +8 -0
  321. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.js +19 -0
  322. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.d.ts +76 -0
  323. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.js +155 -0
  324. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.d.ts +43 -0
  325. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.js +37 -0
  326. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.d.ts +49 -0
  327. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.js +104 -0
  328. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.d.ts +16 -0
  329. package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.js +6 -0
  330. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.d.ts +86 -0
  331. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.js +141 -0
  332. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.d.ts +179 -0
  333. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.js +35 -0
  334. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.d.ts +21 -0
  335. package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.js +179 -0
  336. package/node_modules/@nordhavnhq/runner-runtime/package.json +18 -0
  337. package/package.json +33 -4
  338. package/README.md +0 -3
@@ -0,0 +1,110 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync, readFileSync, statSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { createServer } from 'node:net';
5
+ import { commandEnv, isBlocked, isLongRunningCommand } from '../tools/console.js';
6
+ import { checkout, inside } from './fs-checkout.js';
7
+ import { resolveProjectNode } from './project-node.js';
8
+ import { trackProcess } from './processes.js';
9
+ /**
10
+ * A dev server a person starts from the studio (`proc:start`: the Dev
11
+ * environment of a surface in the code app). It runs like one an agent starts
12
+ * with `runner_run_command` (the same sandboxed environment, the project's
13
+ * pinned Node, tracked and previewed by processes.ts), under the agent whose
14
+ * socket carried the frame, with `startedBy` naming the person.
15
+ *
16
+ * What may run is narrow: the checkout must lie inside the runner's folder
17
+ * roots, the folder inside the checkout, and the command one the code app
18
+ * proposes (`devCommandFor` in packages/os/os-shared/utils/surface-dev.ts): a
19
+ * script of the folder's package.json run by its package manager (`npm run
20
+ * dev`, `pnpm dev`, `npm start`), a composer.json script (`composer run dev`)
21
+ * or `php artisan serve` beside an `artisan` file. The whole line must be that,
22
+ * no shell metacharacters, a dev server (`isLongRunningCommand`) and none the
23
+ * shell tool blocks; anything else is refused. The runner hands it
24
+ * a free port in `PORT`; a dev server that ignores it (Vite, Astro) picks its
25
+ * own, and the port is read from its output either way.
26
+ */
27
+ /** A port nothing listens on right now, from the OS. Exported for tests. */
28
+ export function freePort() {
29
+ return new Promise((resolve, reject) => {
30
+ const server = createServer();
31
+ server.unref();
32
+ server.once('error', reject);
33
+ server.listen(0, '127.0.0.1', () => {
34
+ const address = server.address();
35
+ const port = typeof address === 'object' && address ? address.port : 0;
36
+ server.close(() => port ? resolve(port) : reject(new Error('No free port')));
37
+ });
38
+ });
39
+ }
40
+ /** A script name as package.json and composer.json use them (`dev`, `dev:web`). */
41
+ const SCRIPT = String.raw `([\w:.][\w:.-]*)`;
42
+ /** `npm run dev`, `pnpm dev`, `yarn run start`, `bun run dev`: the package manager and the script. */
43
+ const PACKAGE_SCRIPT = new RegExp(String.raw `^(npm|pnpm|yarn|bun)\s+(?:run\s+)?${SCRIPT}$`);
44
+ const COMPOSER_SCRIPT = new RegExp(String.raw `^composer\s+run\s+${SCRIPT}$`);
45
+ const ARTISAN_SERVE = /^php\s+artisan\s+serve$/;
46
+ /** The script names of the JSON manifest `file` in `cwd` (`scripts` of package.json or composer.json). */
47
+ function manifestScripts(cwd, file) {
48
+ try {
49
+ const parsed = JSON.parse(readFileSync(join(cwd, file), 'utf8'));
50
+ const scripts = parsed.scripts;
51
+ return scripts && typeof scripts === 'object' && !Array.isArray(scripts) ? new Set(Object.keys(scripts)) : new Set();
52
+ }
53
+ catch {
54
+ return new Set();
55
+ }
56
+ }
57
+ /** Why the exact shape of `line` may not run in `cwd`, or null when it is one of the accepted ones. */
58
+ function shapeRefusal(line, cwd) {
59
+ const pkg = PACKAGE_SCRIPT.exec(line);
60
+ if (pkg) {
61
+ const [, manager, script] = pkg;
62
+ // `npm <script>` is no script run; only `npm start` is (npm's own alias).
63
+ if (manager === 'npm' && !/^npm\s+run\s/.test(line) && script !== 'start')
64
+ return `Use "npm run ${script}"`;
65
+ return manifestScripts(cwd, 'package.json').has(script) ? null : `No script "${script}" in the package.json of this folder`;
66
+ }
67
+ const composer = COMPOSER_SCRIPT.exec(line);
68
+ if (composer) {
69
+ const script = composer[1];
70
+ return manifestScripts(cwd, 'composer.json').has(script) ? null : `No script "${script}" in the composer.json of this folder`;
71
+ }
72
+ if (ARTISAN_SERVE.test(line))
73
+ return existsSync(join(cwd, 'artisan')) ? null : 'No artisan file in this folder';
74
+ return `Not a dev command the studio starts (a package.json or composer.json script, or php artisan serve): ${line}`;
75
+ }
76
+ /** Why `command` may not be started from the studio in `cwd`, or null when it may. Exported for tests. */
77
+ export function devCommandRefusal(command, cwd) {
78
+ const line = command.trim();
79
+ if (!line)
80
+ return 'No command to start';
81
+ if (/[\n\r]/.test(line))
82
+ return 'A dev command is one line';
83
+ // One command, nothing chained, piped, redirected, quoted or substituted beside it.
84
+ if (/[;&|`$<>()\\'"]/.test(line))
85
+ return 'A dev command is a single command, without ; & | ` $ < > ( ) \\ or quotes';
86
+ const blocked = isBlocked(line);
87
+ if (blocked)
88
+ return blocked;
89
+ if (!isLongRunningCommand(line))
90
+ return `Not a dev server command: ${line}`;
91
+ return shapeRefusal(line, cwd);
92
+ }
93
+ /** Start the dev server `frame` asks for; throws with the reason it may not. */
94
+ export async function startDevServer(config, frame, agent) {
95
+ const root = checkout(config, frame.root);
96
+ const cwd = frame.cwd ? inside(root, frame.cwd) : root;
97
+ if (!existsSync(cwd) || !statSync(cwd).isDirectory())
98
+ throw new Error('The folder does not exist on this runner');
99
+ const refusal = devCommandRefusal(frame.command, cwd);
100
+ if (refusal)
101
+ throw new Error(refusal);
102
+ const context = { agentSlug: agent.slug, organisationSlug: agent.organisationSlug, agentHome: agent.agentHome, projectRoot: root };
103
+ const node = await resolveProjectNode(cwd, root);
104
+ const port = await freePort();
105
+ const env = { ...commandEnv(context, root, process.env, node?.binDir), PORT: String(port) };
106
+ const child = spawn('sh', ['-c', frame.command], { cwd, env, stdio: ['pipe', 'pipe', 'pipe'], detached: true });
107
+ child.stdin?.end();
108
+ child.on('error', () => { });
109
+ trackProcess(child, { command: frame.command, cwd, kind: 'server', context, id: frame.processId, startedBy: frame.startedBy });
110
+ }
@@ -0,0 +1,58 @@
1
+ /** Who a run works for: the conversation of a chat, the task of a task run, or
2
+ * (for a call) whoever placed it. Several dispatches can share one owner. */
3
+ export interface RunOwner {
4
+ /** The studio uid the claim is keyed on (conversation uid, task uid, or a
5
+ * call's queue uid when its caller is not running here). */
6
+ owner: string;
7
+ /** How a refusal names the owner, e.g. `chat CNJ94536`. */
8
+ label: string;
9
+ }
10
+ /**
11
+ * Mark a dispatch as running for `who`. Returns the function that marks it
12
+ * ended (idempotent). When an owner's last dispatch ends, its claims go: a
13
+ * claim only ever blocks while its owner is live.
14
+ */
15
+ export declare function beginClaimRun(queueUid: string | undefined, who: RunOwner): () => void;
16
+ /** The owner of a chat turn: its conversation, over every turn. */
17
+ export declare function chatRunOwner(conversationUid: string): RunOwner;
18
+ /**
19
+ * The owner of a task dispatch: its task, or for a call (no task uid) the run
20
+ * that placed it when that runs here too (a call works on its caller's
21
+ * files, as `ownFiles` already says), else the call itself.
22
+ */
23
+ export declare function taskRunOwner(queueUid: string, input: unknown): RunOwner;
24
+ /** The fields of a tool context that say which run is calling. */
25
+ export interface ClaimContext {
26
+ queueUid?: string;
27
+ taskUid?: string;
28
+ conversationId?: string;
29
+ }
30
+ /** The owner of the run behind a tool call: the registered dispatch, else
31
+ * the task, else the chat. Null when the call names no run at all. */
32
+ export declare function ownerOfContext(ctx: ClaimContext | undefined): RunOwner | null;
33
+ /**
34
+ * The refusal for a write to `absPath` by the run behind `ctx`, or null when
35
+ * the write may go ahead. A claim of an ended owner, or on a file that is
36
+ * clean again, is dropped here so the writer can take it over.
37
+ */
38
+ export declare function refuseClaimedWrite(absPath: string, displayPath: string, ctx: ClaimContext | undefined): string | null;
39
+ /**
40
+ * The other live run that claims `absPath`, or null: no claim, the claiming
41
+ * run has ended, or it is the run behind `ctx` itself. Changes nothing (a shell
42
+ * command uses it to leave another run's files out of what it touched).
43
+ */
44
+ export declare function claimedByOtherRun(absPath: string, ctx: ClaimContext | undefined): RunOwner | null;
45
+ /**
46
+ * The line on top of a read of `absPath` while another live run has it
47
+ * changed and uncommitted, or null. Changes nothing: a stale claim is dropped
48
+ * by the next write (refuseClaimedWrite). Git is only asked when there is a
49
+ * live claim of another run, so an ordinary read costs a map lookup.
50
+ */
51
+ export declare function claimedReadNote(absPath: string, displayPath: string, ctx: ClaimContext | undefined): string | null;
52
+ /** The owner whose live run claims `absPath`, or null. Changes nothing. */
53
+ export declare function liveClaimOwner(absPath: string): string | null;
54
+ /** Record that the run behind `ctx` wrote `absPath`. Keeps the first write's
55
+ * time while the same owner holds the claim. */
56
+ export declare function claimFile(absPath: string, ctx: ClaimContext | undefined): void;
57
+ /** Forget every claim and live run. Tests only. */
58
+ export declare function resetFileClaims(): void;
@@ -0,0 +1,174 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { basename, dirname } from 'node:path';
3
+ /** The owner of each live dispatch, by its queue uid. */
4
+ const ownerByQueue = new Map();
5
+ /** Live dispatches per owner (a chat whose next turn supersedes the last one
6
+ * counts twice for a moment). */
7
+ const liveCount = new Map();
8
+ const liveLabels = new Map();
9
+ /** Claims by canonical absolute path. */
10
+ const claims = new Map();
11
+ /** True while a dispatch of `owner` is running on this runner. */
12
+ function isRunLive(owner) {
13
+ return (liveCount.get(owner) ?? 0) > 0;
14
+ }
15
+ /**
16
+ * Mark a dispatch as running for `who`. Returns the function that marks it
17
+ * ended (idempotent). When an owner's last dispatch ends, its claims go: a
18
+ * claim only ever blocks while its owner is live.
19
+ */
20
+ export function beginClaimRun(queueUid, who) {
21
+ if (queueUid)
22
+ ownerByQueue.set(queueUid, who);
23
+ liveCount.set(who.owner, (liveCount.get(who.owner) ?? 0) + 1);
24
+ liveLabels.set(who.owner, who.label);
25
+ let ended = false;
26
+ return () => {
27
+ if (ended)
28
+ return;
29
+ ended = true;
30
+ if (queueUid && ownerByQueue.get(queueUid) === who)
31
+ ownerByQueue.delete(queueUid);
32
+ const left = (liveCount.get(who.owner) ?? 1) - 1;
33
+ if (left > 0) {
34
+ liveCount.set(who.owner, left);
35
+ return;
36
+ }
37
+ liveCount.delete(who.owner);
38
+ liveLabels.delete(who.owner);
39
+ for (const [path, claim] of claims) {
40
+ if (claim.owner === who.owner)
41
+ claims.delete(path);
42
+ }
43
+ };
44
+ }
45
+ /** The owner of a chat turn: its conversation, over every turn. */
46
+ export function chatRunOwner(conversationUid) {
47
+ return { owner: conversationUid, label: `chat ${conversationUid}` };
48
+ }
49
+ /**
50
+ * The owner of a task dispatch: its task, or for a call (no task uid) the run
51
+ * that placed it when that runs here too (a call works on its caller's
52
+ * files, as `ownFiles` already says), else the call itself.
53
+ */
54
+ export function taskRunOwner(queueUid, input) {
55
+ const i = (input && typeof input === 'object' ? input : {});
56
+ if (typeof i.taskUid === 'string' && i.taskUid)
57
+ return { owner: i.taskUid, label: `task ${i.taskUid}` };
58
+ const key = typeof i.caller?.scratchKey === 'string' ? i.caller.scratchKey : null;
59
+ if (key) {
60
+ const viaQueue = ownerByQueue.get(key);
61
+ if (viaQueue)
62
+ return viaQueue;
63
+ const label = liveLabels.get(key);
64
+ if (label)
65
+ return { owner: key, label };
66
+ }
67
+ return { owner: queueUid, label: `call ${queueUid}` };
68
+ }
69
+ /** The owner of the run behind a tool call: the registered dispatch, else
70
+ * the task, else the chat. Null when the call names no run at all. */
71
+ export function ownerOfContext(ctx) {
72
+ const registered = ctx?.queueUid ? ownerByQueue.get(ctx.queueUid) : undefined;
73
+ if (registered)
74
+ return registered;
75
+ if (ctx?.taskUid)
76
+ return { owner: ctx.taskUid, label: `task ${ctx.taskUid}` };
77
+ if (ctx?.conversationId)
78
+ return chatRunOwner(ctx.conversationId);
79
+ return null;
80
+ }
81
+ /**
82
+ * Whether the file differs from HEAD in its repo (an untracked file counts).
83
+ * Null when it is not in a git repo or git fails: the caller then goes by
84
+ * liveness alone.
85
+ */
86
+ function isFileChanged(absPath) {
87
+ try {
88
+ const out = execFileSync('git', ['status', '--porcelain', '--untracked-files=all', '--', basename(absPath)], {
89
+ cwd: dirname(absPath),
90
+ encoding: 'utf-8',
91
+ stdio: ['ignore', 'pipe', 'ignore'],
92
+ timeout: 5000,
93
+ });
94
+ return out.trim() !== '';
95
+ }
96
+ catch {
97
+ return null;
98
+ }
99
+ }
100
+ function clock(ms) {
101
+ return new Date(ms).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' });
102
+ }
103
+ /**
104
+ * The refusal for a write to `absPath` by the run behind `ctx`, or null when
105
+ * the write may go ahead. A claim of an ended owner, or on a file that is
106
+ * clean again, is dropped here so the writer can take it over.
107
+ */
108
+ export function refuseClaimedWrite(absPath, displayPath, ctx) {
109
+ const claim = claims.get(absPath);
110
+ if (!claim)
111
+ return null;
112
+ const me = ownerOfContext(ctx);
113
+ if (me && claim.owner === me.owner)
114
+ return null;
115
+ if (!isRunLive(claim.owner) || isFileChanged(absPath) === false) {
116
+ claims.delete(absPath);
117
+ return null;
118
+ }
119
+ return `Error: ${displayPath} has uncommitted changes from another run (${claim.label}, since ${clock(claim.since)}). Do not edit it: say so to the person, or wait until that run commits.`;
120
+ }
121
+ /**
122
+ * The other live run that claims `absPath`, or null: no claim, the claiming
123
+ * run has ended, or it is the run behind `ctx` itself. Changes nothing (a shell
124
+ * command uses it to leave another run's files out of what it touched).
125
+ */
126
+ export function claimedByOtherRun(absPath, ctx) {
127
+ const claim = claims.get(absPath);
128
+ if (!claim || !isRunLive(claim.owner))
129
+ return null;
130
+ const me = ownerOfContext(ctx);
131
+ if (me && claim.owner === me.owner)
132
+ return null;
133
+ return { owner: claim.owner, label: claim.label };
134
+ }
135
+ /**
136
+ * The line on top of a read of `absPath` while another live run has it
137
+ * changed and uncommitted, or null. Changes nothing: a stale claim is dropped
138
+ * by the next write (refuseClaimedWrite). Git is only asked when there is a
139
+ * live claim of another run, so an ordinary read costs a map lookup.
140
+ */
141
+ export function claimedReadNote(absPath, displayPath, ctx) {
142
+ const claim = claims.get(absPath);
143
+ if (!claim || !isRunLive(claim.owner))
144
+ return null;
145
+ const me = ownerOfContext(ctx);
146
+ if (me && claim.owner === me.owner)
147
+ return null;
148
+ if (isFileChanged(absPath) === false)
149
+ return null;
150
+ return `note: ${displayPath} has uncommitted changes from another run (${claim.label}, since ${clock(claim.since)}). It can change under you, and an edit is refused until that run commits or ends.`;
151
+ }
152
+ /** The owner whose live run claims `absPath`, or null. Changes nothing. */
153
+ export function liveClaimOwner(absPath) {
154
+ const claim = claims.get(absPath);
155
+ return claim && isRunLive(claim.owner) ? claim.owner : null;
156
+ }
157
+ /** Record that the run behind `ctx` wrote `absPath`. Keeps the first write's
158
+ * time while the same owner holds the claim. */
159
+ export function claimFile(absPath, ctx) {
160
+ const me = ownerOfContext(ctx);
161
+ if (!me)
162
+ return;
163
+ const current = claims.get(absPath);
164
+ if (current?.owner === me.owner)
165
+ return;
166
+ claims.set(absPath, { ...me, since: Date.now() });
167
+ }
168
+ /** Forget every claim and live run. Tests only. */
169
+ export function resetFileClaims() {
170
+ ownerByQueue.clear();
171
+ liveCount.clear();
172
+ liveLabels.clear();
173
+ claims.clear();
174
+ }
@@ -0,0 +1,18 @@
1
+ import type { FolderEntry } from '@nordhavnhq/runner-runtime';
2
+ import type { Config } from '../config.js';
3
+ /**
4
+ * List folders for the picker. `path === null` returns the runner's folder
5
+ * ROOTS (its access scope, from `nordhavn folder add`) as the top level, so
6
+ * the operator can drill into any of them and create a new folder directly
7
+ * inside a root. A concrete `path` returns that folder's immediate sub-folders,
8
+ * after checking it is inside a root. Throws (surfaced as an `fs:result` error)
9
+ * when the path escapes the runner's scope.
10
+ */
11
+ export declare function browseFolders(config: Config, path: string | null): FolderEntry[];
12
+ /**
13
+ * Create `name` inside `parent` and return the new folder as a `FolderEntry`.
14
+ * `parent` must be inside a root; `name` must be a single safe path segment
15
+ * (no separators, no `..`). Idempotent: an existing folder of that name is
16
+ * returned as-is rather than erroring.
17
+ */
18
+ export declare function makeFolder(config: Config, parent: string, name: string): FolderEntry;
@@ -0,0 +1,104 @@
1
+ import { existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
2
+ import { basename, join, resolve, sep } from 'node:path';
3
+ import { isInsideRoot } from '../tools/_jail.js';
4
+ // ─── Folder browsing for the studio picker ─────────────────────────
5
+ //
6
+ // The studio UI drives a lazy treeview: it asks the runner to list the
7
+ // immediate sub-folders of a path so the operator can drill down and couple
8
+ // the right checkout to a project (or create a fresh folder for one). Every
9
+ // path the studio hands us is validated to sit inside one of the runner's
10
+ // configured folder roots (`config.projectsRoots`) - its access scope - before
11
+ // we touch the disk. There is no way to browse or create outside those roots.
12
+ /** Skipped everywhere: dot-dirs and heavy build/vcs dirs never hold a project
13
+ * checkout worth coupling, and scanning them is slow. */
14
+ function isIgnored(name) {
15
+ return name.startsWith('.') || name === 'node_modules';
16
+ }
17
+ /** True when `dir` has at least one non-ignored sub-directory - lets the UI
18
+ * render an expand affordance without a second round-trip. Unreadable dirs
19
+ * (permissions) report false rather than throwing. */
20
+ function hasChildFolders(dir) {
21
+ try {
22
+ for (const d of readdirSync(dir, { withFileTypes: true })) {
23
+ if (d.isDirectory() && !isIgnored(d.name))
24
+ return true;
25
+ }
26
+ }
27
+ catch { /* unreadable - treat as leaf */ }
28
+ return false;
29
+ }
30
+ /** The runner's folder roots, resolved. */
31
+ function roots(config) {
32
+ return (config.projectsRoots ?? []).map(r => resolve(r));
33
+ }
34
+ /** True when `path` is one of the roots or lives inside one. */
35
+ function inScope(config, path) {
36
+ const resolved = resolve(path);
37
+ return roots(config).some(root => isInsideRoot(resolved, root));
38
+ }
39
+ function listChildFolders(dir) {
40
+ const out = [];
41
+ try {
42
+ for (const d of readdirSync(dir, { withFileTypes: true })) {
43
+ if (!d.isDirectory() || isIgnored(d.name))
44
+ continue;
45
+ const path = join(dir, d.name);
46
+ out.push({ name: d.name, path, hasChildren: hasChildFolders(path) });
47
+ }
48
+ }
49
+ catch { /* unreadable - return whatever we gathered */ }
50
+ return out.sort((a, b) => a.name.localeCompare(b.name));
51
+ }
52
+ /**
53
+ * List folders for the picker. `path === null` returns the runner's folder
54
+ * ROOTS (its access scope, from `nordhavn folder add`) as the top level, so
55
+ * the operator can drill into any of them and create a new folder directly
56
+ * inside a root. A concrete `path` returns that folder's immediate sub-folders,
57
+ * after checking it is inside a root. Throws (surfaced as an `fs:result` error)
58
+ * when the path escapes the runner's scope.
59
+ */
60
+ export function browseFolders(config, path) {
61
+ if (path == null) {
62
+ const seen = new Set();
63
+ const out = [];
64
+ for (const root of roots(config)) {
65
+ if (seen.has(root) || !existsSync(root))
66
+ continue;
67
+ seen.add(root);
68
+ // Roots are always expandable: even an empty one must be openable so the
69
+ // operator can create the first folder inside it.
70
+ out.push({ name: basename(root) || root, path: root, hasChildren: true });
71
+ }
72
+ return out.sort((a, b) => a.name.localeCompare(b.name));
73
+ }
74
+ if (!inScope(config, path)) {
75
+ throw new Error('Folder is outside the runner\'s allowed roots');
76
+ }
77
+ const resolved = resolve(path);
78
+ if (!existsSync(resolved) || !statSync(resolved).isDirectory()) {
79
+ throw new Error('Folder does not exist');
80
+ }
81
+ return listChildFolders(resolved);
82
+ }
83
+ /**
84
+ * Create `name` inside `parent` and return the new folder as a `FolderEntry`.
85
+ * `parent` must be inside a root; `name` must be a single safe path segment
86
+ * (no separators, no `..`). Idempotent: an existing folder of that name is
87
+ * returned as-is rather than erroring.
88
+ */
89
+ export function makeFolder(config, parent, name) {
90
+ const clean = name.trim();
91
+ if (!clean || clean.includes('/') || clean.includes('\\') || clean.includes(sep) || clean === '.' || clean === '..') {
92
+ throw new Error('Invalid folder name');
93
+ }
94
+ if (!inScope(config, parent)) {
95
+ throw new Error('Parent folder is outside the runner\'s allowed roots');
96
+ }
97
+ const parentResolved = resolve(parent);
98
+ if (!existsSync(parentResolved) || !statSync(parentResolved).isDirectory()) {
99
+ throw new Error('Parent folder does not exist');
100
+ }
101
+ const path = join(parentResolved, clean);
102
+ mkdirSync(path, { recursive: true });
103
+ return { name: clean, path, hasChildren: hasChildFolders(path) };
104
+ }
@@ -0,0 +1,154 @@
1
+ import { type FsEntryAction, type FsFileBytes, type FsFileContent, type FsFileEntry, type FsGitBlame, type FsGitBranch, type FsGitChange, type FsGitCommit, type FsGitRepo, type FsGitCommitDetail, type FsGitFileChange, type FsGitRemote, type FsGitRepoState, type FsGitTag } from '@nordhavnhq/runner-runtime';
2
+ import type { Config } from '../config.js';
3
+ /** `root` resolved, once it lies inside the runner's folder roots and exists. Exported for `proc:start`. */
4
+ export declare function checkout(config: Config, root: string): string;
5
+ /** `path` inside the checkout, or an error when it leaves it, by its name or
6
+ * through a symlink (an existing path is compared by its real location). */
7
+ export declare function inside(base: string, path: string): string;
8
+ /** One folder of the checkout: folders first, then files, what git ignores
9
+ * marked `ignored` (outside a repo: dependencies, builds and caches), the way
10
+ * an editor greys it out. */
11
+ export declare function listCheckout(config: Config, root: string, path: string): FsFileEntry[];
12
+ /**
13
+ * Every file of the checkout by its path, as the tree has them: in a repo
14
+ * what git tracks and what it does not ignore (paths relative to the
15
+ * checkout, which may be a folder inside the repo), plus an ignored secret
16
+ * in a folder git keeps; outside one a walk that leaves out dependencies,
17
+ * builds and caches. At most `FS_PATHS_LIMIT`, sorted.
18
+ */
19
+ export declare function checkoutPaths(config: Config, root: string): {
20
+ paths: string[];
21
+ truncated: boolean;
22
+ };
23
+ /** One file of the checkout as text, unless it is binary or too large; a
24
+ * sensitive one marked so. */
25
+ export declare function readCheckoutFile(config: Config, root: string, path: string): FsFileContent;
26
+ /** A slice of one file of the checkout as bytes, read off disk on its own
27
+ * (a video is never read whole); a sensitive one marked so. */
28
+ export declare function readCheckoutBytes(config: Config, root: string, path: string, offset: number, length: number): FsFileBytes;
29
+ /** The file on disk is not the version the editor started from. */
30
+ export declare class CheckoutConflictError extends Error {
31
+ constructor();
32
+ }
33
+ /**
34
+ * Save one existing file of the checkout as UTF-8, unless it is inside
35
+ * `.git` or too large (a sensitive one too: a person edits its secrets). With `baseHash`, only while the file on disk is
36
+ * still that version (else `CheckoutConflictError`): an agent may have written
37
+ * it meanwhile, and its work must not vanish under somebody's save. Written
38
+ * in place, so the file keeps its mode. Returns the file as saved.
39
+ */
40
+ export declare function writeCheckoutFile(config: Config, root: string, path: string, content: string, baseHash: string | null): FsFileContent;
41
+ /**
42
+ * Make a file (empty) or a folder in the checkout, rename one, or delete
43
+ * several, from the code app's tree. Every path is checked before anything
44
+ * changes: inside the checkout, not `.git`, a new one free (nothing is
45
+ * overwritten), its missing folders made with it. A delete is for good, a
46
+ * folder with all it holds. An upload comes in pieces: the first makes the
47
+ * file (never over one), each next one appends only when the file is exactly
48
+ * as long as its `offset` says, so a piece twice or out of order is refused.
49
+ * Returns the new path of a create, a rename or an upload.
50
+ */
51
+ export declare function checkoutEntry(config: Config, root: string, action: FsEntryAction): {
52
+ created?: string;
53
+ };
54
+ /**
55
+ * What git says changed in the checkout, staged or not, untracked files one
56
+ * by one: paths relative to the checkout, which may be a folder inside the
57
+ * repo (git answers relative to the repo's root, so its prefix is cut off and
58
+ * what lies outside the checkout is left out). Throws when it is no repo.
59
+ */
60
+ export declare function checkoutGitStatus(config: Config, root: string): FsGitChange[];
61
+ export interface GitRun {
62
+ ok: boolean;
63
+ stdout: string;
64
+ stderr: string;
65
+ }
66
+ /** git in the checkout, without blocking the runner. It never prompts: a
67
+ * remote that wants a password nobody stored fails instead of hanging. */
68
+ export declare function git(base: string, args: string[], opts?: {
69
+ timeout?: number;
70
+ env?: Record<string, string>;
71
+ }): Promise<GitRun>;
72
+ /** What git said when it failed, for the person who asked. */
73
+ export declare const failure: (run: GitRun, fallback: string) => string;
74
+ export declare const said: (run: GitRun) => string;
75
+ /** The checkout, failing like `checkoutGitStatus` when it is no repo. */
76
+ export declare function repo(config: Config, root: string): Promise<string>;
77
+ /**
78
+ * The folders below `base` that hold a `.git` (a folder, or a file for a
79
+ * submodule or a worktree), relative to it with `/`, sorted: level by level,
80
+ * at most `depth` deep, into a repository too (one can hold another). Hidden
81
+ * folders and `REPO_SKIP` are passed over, a symlink is never followed.
82
+ */
83
+ export declare function findRepos(base: string, depth?: number, limit?: number): string[];
84
+ /**
85
+ * The git repositories in the checkout, for the code app's Git view to pick
86
+ * one: the checkout itself first when it is (or lies in) one, then every
87
+ * folder below it that holds one (`findRepos`), each with its branch and
88
+ * how many paths changed in it. None when there is no repository at all.
89
+ */
90
+ export declare function checkoutRepos(config: Config, root: string): Promise<FsGitRepo[]>;
91
+ /** A remote's url without a user or password in it (a token often is one);
92
+ * `git@host:path` keeps its `git`, which is no secret. */
93
+ export declare function publicRemoteUrl(url: string): string;
94
+ export declare function remotesOf(base: string): Promise<FsGitRemote[]>;
95
+ /**
96
+ * The checkout's branches, the one checked out first, then the other local
97
+ * ones, then the remote ones, each group the most recently committed first:
98
+ * with its last commit and how far it is from the branch it follows. And its
99
+ * remotes. Throws when it is no repo.
100
+ */
101
+ export declare function checkoutBranches(config: Config, root: string): Promise<{
102
+ branches: FsGitBranch[];
103
+ remotes: FsGitRemote[];
104
+ repo: FsGitRepoState;
105
+ tags: FsGitTag[];
106
+ }>;
107
+ /** The merge, rebase, cherry-pick or revert the checkout is in the middle of. */
108
+ export declare function operationOf(base: string): Promise<FsGitRepoState['operation']>;
109
+ /** The files with a conflict, relative to the checkout. */
110
+ export declare function conflictsOf(base: string): Promise<string[]>;
111
+ /** Whether a remote branch holds the commit: then it is not undone. */
112
+ export declare function isPushed(base: string, rev: string): Promise<boolean>;
113
+ export declare const exists: (base: string, rev: string) => Promise<boolean>;
114
+ /**
115
+ * The latest commits of the checkout, newest first and each before its
116
+ * parents (what a graph needs), at most `FS_LOG_LIMIT`: on `ref` (a full ref
117
+ * of a local or remote branch), on what is checked out when it is null, or
118
+ * with `all` on every branch, remote branch and tag. Only the commits that
119
+ * touch the checkout, which may be a folder inside the repo, their parents
120
+ * the nearest that do. A repo without commits has none. Throws when it is no
121
+ * repo or `ref` is no branch.
122
+ */
123
+ export declare function checkoutLog(config: Config, root: string, ref: string | null, all?: boolean, opts?: LogOptions): Promise<FsGitCommit[]>;
124
+ /** What narrows `checkoutLog`: paging, a search, one path (`FsLogFrame`). */
125
+ export interface LogOptions {
126
+ skip?: number;
127
+ search?: string;
128
+ path?: string;
129
+ }
130
+ /** `fs:log` with `unpushed`: the commits on HEAD no remote branch holds, each
131
+ * with its body and stat: what a tag of the unpushed work covers (the whole
132
+ * repo, not just the checkout's folder, as the tag is). Throws when it is no repo. */
133
+ export declare function checkoutUnpushedLog(config: Config, root: string): Promise<FsGitCommit[]>;
134
+ /** The commit `sha` names, in full, or an error when it is no commit here. */
135
+ export declare function commitOf(base: string, sha: string): Promise<string>;
136
+ /**
137
+ * One commit with its whole message and what it changed against its first
138
+ * parent (a merge: what it brought in), file by file, only inside the
139
+ * checkout, paths relative to it.
140
+ */
141
+ export declare function checkoutShow(config: Config, root: string, sha: string, against?: string): Promise<FsGitCommitDetail>;
142
+ /**
143
+ * Who last changed each line of one file of the checkout, as it is on disk:
144
+ * per line the commit, null for a line not committed yet, and per commit who,
145
+ * when and why. Throws when git does not track the file.
146
+ */
147
+ export declare function checkoutBlame(config: Config, root: string, path: string): Promise<FsGitBlame>;
148
+ /**
149
+ * What changed in the checkout against what is committed, staged or not,
150
+ * file by file with its patch (`path`: that one file): tracked files as git
151
+ * diffs them, untracked ones as added. Only inside the checkout, paths
152
+ * relative to it. A repo without commits has every file added.
153
+ */
154
+ export declare function checkoutDiff(config: Config, root: string, path: string | null, side?: 'staged' | 'unstaged'): Promise<FsGitFileChange[]>;