@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,314 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { mkdirSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { loadConfig, saveConfig, addAgent, agentHomeDir, agentRef, canClaimFlatHome, hostedAgent, removePairing, NAMELESS_ORG_LABEL, } from '../config.js';
5
+ import { readAllStatuses, isStatusAlive } from '../runtime/daemon.js';
6
+ import { dim, green, red, bold, showHelp, helpOpt } from '../utils/format.js';
7
+ import { ask, wantsHelp } from './prompts.js';
8
+ /**
9
+ * Proof that this machine already owns a host row, so a re-pair rotates that
10
+ * row (keeping its uuid and its project<->folder mapping) instead of leaving a
11
+ * dead row behind with a token that stays valid forever.
12
+ *
13
+ * Every NAMED pairing is offered, because the code carries no organisation:
14
+ * only the studio can tell which of them is in scope, and it picks the match
15
+ * itself. Hashes rather than the tokens, since `Runner.tokenHash` is what it
16
+ * compares against - the plaintext of unrelated organisations has no business
17
+ * in a request authenticated by one code.
18
+ *
19
+ * A pairing from before organisations were recorded (`organisationSlug: null`)
20
+ * is deliberately withheld. Rotating it would kill the only token its agents
21
+ * have: they carry a null organisation too, `hostForAgent` matches them to that
22
+ * nameless entry, and this command replaces pairings by organisation - so it
23
+ * would add a second entry and leave those agents pointing at the one the
24
+ * studio just invalidated. Healing that shape means re-keying the agents (home
25
+ * dir, status file, log file all derive from the organisation), which is a
26
+ * migration, not a side effect of `link`. The rule this keeps: never ask the
27
+ * studio to rotate a row we are not also replacing locally.
28
+ */
29
+ function pairingProofs(config) {
30
+ return config.hosts
31
+ .filter(h => h.organisationSlug !== null && h.organisationSlug !== undefined)
32
+ .map(h => h.token)
33
+ .filter((t) => typeof t === 'string' && t.length > 0)
34
+ .slice(0, 50)
35
+ .map(t => createHash('sha256').update(t).digest('hex'));
36
+ }
37
+ /**
38
+ * Refs of this organisation's agents that have a live process right now.
39
+ *
40
+ * Matched on the ref the status file was written under, with a fallback on
41
+ * slug + organisation for a file written before a rename or by an older runner
42
+ * - the same two-way match `unlink` makes for the same reason.
43
+ */
44
+ function runningAgentsFor(config, organisationSlug) {
45
+ const live = readAllStatuses().filter(s => isStatusAlive(s));
46
+ return config.agents
47
+ .filter(a => a.organisationSlug === organisationSlug)
48
+ .map(a => ({ ref: agentRef(config, a), agent: a }))
49
+ .filter(({ ref, agent }) => live.some(s => s.ref === ref || (s.slug === agent.slug && s.organisationSlug === agent.organisationSlug)))
50
+ .map(({ ref }) => ref);
51
+ }
52
+ async function redeemCode(studioUrl, code, previousTokenHashes, nameOverride) {
53
+ const res = await fetch(`${studioUrl}/api/runners/pair`, {
54
+ method: 'POST',
55
+ headers: { 'Content-Type': 'application/json' },
56
+ body: JSON.stringify({
57
+ code: code.trim().toUpperCase(),
58
+ name: nameOverride,
59
+ previousTokenHashes,
60
+ }),
61
+ });
62
+ if (!res.ok) {
63
+ const err = await res.json().catch(() => ({}));
64
+ throw new Error(err.message || `Pair failed: ${res.status}`);
65
+ }
66
+ return res.json();
67
+ }
68
+ function readHosted(config) {
69
+ const agent = hostedAgent(config);
70
+ if (!agent)
71
+ return null;
72
+ return {
73
+ agent,
74
+ ref: agentRef(config, agent),
75
+ running: runningAgentsFor(config, agent.organisationSlug).length > 0,
76
+ };
77
+ }
78
+ /**
79
+ * Whether the code is for the agent this runner already hosts. An agent from
80
+ * before organisations were recorded counts as the same one when its slug
81
+ * matches: its pairing was made against exactly one organisation.
82
+ */
83
+ function isSameAgent(hosted, entry) {
84
+ return hosted.slug === entry.slug
85
+ && (hosted.organisationSlug === entry.organisationSlug || hosted.organisationSlug === null);
86
+ }
87
+ /** Write the pairing and the agent from one response into `config`. */
88
+ function applyLink(config, data, hosted) {
89
+ const org = data.organisation.slug;
90
+ const entry = { slug: data.agent.slug, token: data.agent.token, enabled: true, organisationSlug: org };
91
+ // A legacy agent re-linked as itself names its organisation and keeps the
92
+ // flat home directory it already has.
93
+ if (hosted?.organisationSlug === null && isSameAgent(hosted, entry) && config.flatHomeOrg === null) {
94
+ config.flatHomeOrg = org;
95
+ }
96
+ const dropped = config.hosts.filter(h => h.organisationSlug !== org);
97
+ config.hosts = config.hosts.filter(h => h.organisationSlug === org);
98
+ config.agents = [];
99
+ const replaced = config.hosts.length > 0;
100
+ // The first organisation on a fresh install keeps the flat home layout
101
+ // (`<home>/agent_<slug>`); every later one nests under its own directory.
102
+ // Asked with the old pairing and agent gone but before the new pairing is
103
+ // stored; the home directories of a replaced agent stay on disk, so they
104
+ // still block the flat layer for another organisation. A re-pair changes
105
+ // nothing about who holds it.
106
+ const claimsFlatHome = !replaced && canClaimFlatHome(config);
107
+ config.hosts = [{ uuid: data.host.uuid, token: data.token, name: data.host.name, organisationSlug: org }];
108
+ if (claimsFlatHome)
109
+ config.flatHomeOrg = org;
110
+ addAgent(config, entry);
111
+ return { entry, replaced, dropped };
112
+ }
113
+ /** The lines about what `link` replaced or left behind. */
114
+ function printReplacements(data, applied, hosted, same) {
115
+ if (hosted && !same) {
116
+ const oldOrg = hosted.agent.organisationSlug ?? NAMELESS_ORG_LABEL;
117
+ const where = oldOrg === data.organisation.slug ? '' : ` of "${oldOrg}"`;
118
+ console.log(dim(` Replaced agent "${hosted.ref}"${where}: a runner hosts one agent. Its home directory stays on disk.`));
119
+ }
120
+ // Only the studio knows whether the row was reused: the pairing we just
121
+ // overwrote locally may point at a row that was revoked there. Say so rather
122
+ // than let the operator assume the previous machine entry is gone.
123
+ if (applied.replaced && data.replaced !== true) {
124
+ console.log(dim(' The studio did not recognise the previous pairing, so this machine got a'));
125
+ console.log(dim(' new entry. If the old one is still in Settings → Runners, revoke it there;'));
126
+ console.log(dim(' its project folders are not carried over.'));
127
+ }
128
+ if (applied.dropped.length > 0) {
129
+ const names = applied.dropped.map(h => h.organisationSlug ?? NAMELESS_ORG_LABEL).join(', ');
130
+ console.log(dim(` Dropped the pairing with ${names}: a runner holds one. Revoke it in that studio's Settings → Runners.`));
131
+ }
132
+ }
133
+ /**
134
+ * The next step. A running agent keeps the token (or the identity) it started
135
+ * with: its open socket survives, but `link` cannot restart anything itself,
136
+ * so it names the restart.
137
+ */
138
+ function printNextStep(hosted, same) {
139
+ console.log('');
140
+ if (hosted?.running) {
141
+ console.log(dim(` "${hosted.ref}" is still running with the previous ${same ? 'token' : 'agent'}. Restart it:`));
142
+ console.log(dim(' nordhavn down, then nordhavn up\n'));
143
+ return;
144
+ }
145
+ console.log(dim(' Next: `nordhavn up` (or `nordhavn up -d` to run in the background).\n'));
146
+ }
147
+ /**
148
+ * Redeem a code from an agent's page in the studio and make this machine that
149
+ * agent's runner: one command pairs the machine AND connects its agent.
150
+ *
151
+ * A runner hosts one agent, with one pairing: the one of its agent's
152
+ * organisation. The code names the agent, so `link` simply makes this runner
153
+ * that agent - whatever agent or organisation it hosted before is replaced,
154
+ * and says so. A code for the agent already hosted here rotates both its host
155
+ * token and its agent token ("re-link").
156
+ *
157
+ * The studio rotates this machine's existing host row when it can (see
158
+ * `pairingProofs`), so its project<->folder mapping survives and no dead row is
159
+ * left behind holding a token that still works. A previous row that was
160
+ * revoked meanwhile still yields a new row - which the output then says out
161
+ * loud. What is shared across re-links is deliberate - `home` and
162
+ * `projectsRoots` describe this machine, not an organisation.
163
+ */
164
+ export async function link(ctx) {
165
+ if (wantsHelp(ctx)) {
166
+ showHelp('nordhavn link <code> [name]', 'Pair this machine and connect its agent, with a one-time code', [
167
+ helpOpt(dim('<code>'), 'Code from the agent\'s page in the studio'),
168
+ helpOpt(dim('[name]'), 'Optional runner name override; falls back to the studio suggestion'),
169
+ ], ['nordhavn link AB7F2QXR', 'nordhavn link AB7F2QXR "Studio Mac"']);
170
+ return;
171
+ }
172
+ console.log('');
173
+ console.log(bold(' Link runner\n'));
174
+ const config = await loadConfig();
175
+ if (!config) {
176
+ console.log(red(' Not configured. Run `nordhavn init` first.\n'));
177
+ process.exit(1);
178
+ }
179
+ const code = ctx.subarg || await ask(' Code: ');
180
+ if (!code.trim()) {
181
+ console.log(red(' Code is required.\n'));
182
+ process.exit(1);
183
+ }
184
+ // Second positional is an optional name override.
185
+ const nameOverride = ctx.cmdArgs[1] && !ctx.cmdArgs[1].startsWith('-') ? ctx.cmdArgs[1] : undefined;
186
+ console.log(dim(' Redeeming code...'));
187
+ try {
188
+ // Collected before the response, since the pairing and agent this call
189
+ // replaces are about to be overwritten in memory.
190
+ const proofs = pairingProofs(config);
191
+ const hosted = readHosted(config);
192
+ const data = await redeemCode(config.studioUrl, code, proofs, nameOverride);
193
+ if (!data.agent?.token) {
194
+ throw new Error(`the studio named no agent for this code. Update the studio, then link with a new code (revoke "${data.host.name}" in Settings → Runners).`);
195
+ }
196
+ const applied = applyLink(config, data, hosted?.agent ?? null);
197
+ const home = agentHomeDir(config, applied.entry);
198
+ mkdirSync(home, { recursive: true });
199
+ await saveConfig(config);
200
+ const same = hosted !== null && isSameAgent(hosted.agent, applied.entry);
201
+ console.log('');
202
+ console.log(green(` ✓ Agent "${data.agent.name}" (${agentRef(config, applied.entry)}) ${same ? 'relinked' : 'connected'}.`));
203
+ console.log(dim(` Runner: "${data.host.name}"${applied.replaced ? ' (re-paired)' : ''}`));
204
+ console.log(dim(` Organisation: ${data.organisation.slug}`));
205
+ console.log(dim(` Home: ${home}`));
206
+ printReplacements(data, applied, hosted, same);
207
+ printNextStep(hosted, same);
208
+ }
209
+ catch (e) {
210
+ console.log(red(` Link failed: ${e.message}\n`));
211
+ process.exit(1);
212
+ }
213
+ }
214
+ /**
215
+ * Remove a pairing and every agent that belongs to it - the inverse of `link`,
216
+ * for a client whose work is finished or a studio this machine should no longer
217
+ * answer to.
218
+ *
219
+ * Refuses while any of the organisation's agents are still running. Their host
220
+ * token disappears with the pairing, so the process would keep spinning on a
221
+ * connection it can no longer make instead of failing where the operator can
222
+ * see it. Stopping them from here is tempting but wrong: a foreground session
223
+ * can drive agents from several organisations at once, and killing it would
224
+ * take the others down too - which is exactly why `down` refuses that case as
225
+ * well.
226
+ *
227
+ * The studio-side `Runner` row is left alone: there is no local endpoint to
228
+ * revoke it, and unlike a re-pair there is no code being redeemed that could
229
+ * carry the proof of ownership along (see `pairingProofs`), so this says
230
+ * so rather than pretending the machine is gone from the organisation.
231
+ *
232
+ * Agent home directories are left on disk, matching `agent remove`. That is why
233
+ * `flatHomeOrg` is not cleared here - see `removePairing` and
234
+ * `canClaimFlatHome` for how the flat layout is protected afterwards.
235
+ */
236
+ export async function unlink(ctx) {
237
+ if (wantsHelp(ctx)) {
238
+ showHelp('nordhavn unlink <organisation>', 'Remove a pairing and its agents from this machine', [helpOpt(dim('<organisation>'), 'Organisation to unlink, as named by `agent ls` / `ps`')], ['nordhavn unlink klant-x']);
239
+ return;
240
+ }
241
+ console.log('');
242
+ const config = await loadConfig();
243
+ if (!config) {
244
+ console.log(red(' Not configured. Run `nordhavn init` first.\n'));
245
+ process.exit(1);
246
+ return;
247
+ }
248
+ const org = ctx.subarg;
249
+ if (!org) {
250
+ console.log(red(' Usage: nordhavn unlink <organisation>\n'));
251
+ console.log(dim(' `nordhavn ps` names the organisations this machine is paired with.\n'));
252
+ process.exit(1);
253
+ return;
254
+ }
255
+ // Refuse before mutating anything: a running agent means the operator has a
256
+ // process to deal with first, and a half-applied unlink would leave it
257
+ // holding a token no host backs any more.
258
+ const target = config.hosts.find(h => h.organisationSlug === org)
259
+ ?? (org === NAMELESS_ORG_LABEL ? config.hosts.find(h => h.organisationSlug === null) : undefined);
260
+ if (target) {
261
+ const live = readAllStatuses().filter(s => isStatusAlive(s));
262
+ const running = config.agents
263
+ .filter(a => a.organisationSlug === target.organisationSlug)
264
+ .map(a => ({ ref: agentRef(config, a), agent: a }))
265
+ // Match on the ref the status file was written under, and on the
266
+ // organisation it recorded - a status file written before a rename or by
267
+ // an older runner can carry the other one.
268
+ .map(({ ref, agent }) => ({
269
+ ref,
270
+ status: live.find(s => s.ref === ref)
271
+ ?? live.find(s => s.slug === agent.slug && s.organisationSlug === agent.organisationSlug),
272
+ }))
273
+ .filter((r) => r.status !== undefined);
274
+ if (running.length > 0) {
275
+ const shared = running.some(r => r.status.mode === 'foreground');
276
+ console.log(red(` ${running.length} agent(s) from "${org}" are still running:`));
277
+ for (const r of running)
278
+ console.log(red(` ${r.ref} ${dim(`(${r.status.mode}, pid ${r.status.pid})`)}`));
279
+ console.log('');
280
+ console.log(dim(' Stop them first, then unlink again:'));
281
+ console.log(dim(` nordhavn down ${running[0].ref}${running.length > 1 ? ' (repeat per agent)' : ''}`));
282
+ if (shared) {
283
+ console.log(dim(' A foreground session can drive other organisations\' agents too - `down` will'));
284
+ console.log(dim(' refuse it and tell you to Ctrl+C that session instead.'));
285
+ }
286
+ console.log('');
287
+ process.exit(1);
288
+ return;
289
+ }
290
+ }
291
+ const result = removePairing(config, org);
292
+ if ('missing' in result) {
293
+ const paired = config.hosts.map(h => h.organisationSlug ?? NAMELESS_ORG_LABEL).join(', ');
294
+ console.log(red(` Not paired with "${org}".`));
295
+ console.log(dim(` This machine is paired with: ${paired || 'nothing'}.\n`));
296
+ process.exit(1);
297
+ return;
298
+ }
299
+ await saveConfig(config);
300
+ const name = result.host.organisationSlug ?? NAMELESS_ORG_LABEL;
301
+ console.log(green(` ✓ Unlinked "${name}" (${result.host.name}).`));
302
+ if (result.removedAgents.length > 0) {
303
+ console.log(dim(` Removed ${result.removedAgents.length} agent(s): ${result.removedAgents.map(a => a.slug).join(', ')}.`));
304
+ console.log(dim(' Their home directories are left on disk, as `agent remove` leaves them.'));
305
+ }
306
+ // Only worth explaining when the flat layer is actually still occupied -
307
+ // otherwise the next `link` simply reclaims it and there is nothing to know.
308
+ if (result.heldFlatHome && !canClaimFlatHome(config)) {
309
+ console.log(dim(` "${name}" held the flat home layout (${join(config.home, 'agent_*')}), and those`));
310
+ console.log(dim(' directories are still there, so a future organisation paired here will nest'));
311
+ console.log(dim(' under its own directory rather than inherit them. Delete them by hand to free it.'));
312
+ }
313
+ console.log(dim(' The Runner row still exists in the studio - revoke it from Settings → Runners if needed.\n'));
314
+ }
@@ -0,0 +1,2 @@
1
+ import { type CliCtx } from './prompts.js';
2
+ export declare function logs(ctx: CliCtx): Promise<void>;
@@ -0,0 +1,147 @@
1
+ import { existsSync, readdirSync, statSync, openSync, readSync, closeSync, watchFile } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { logPath, logsDir } from '../runtime/daemon.js';
4
+ import { loadConfig, agentRef, resolveAgentRef } from '../config.js';
5
+ import { dim, red, showHelp, helpOpt, printAmbiguous } from '../utils/format.js';
6
+ import { wantsHelp } from './prompts.js';
7
+ /** How much of the tail of a log file to read for the initial dump. */
8
+ const TAIL_BYTES = 64 * 1024;
9
+ function tailLines(file, max) {
10
+ let size;
11
+ try {
12
+ size = statSync(file).size;
13
+ }
14
+ catch {
15
+ return [];
16
+ }
17
+ if (size === 0)
18
+ return [];
19
+ const readBytes = Math.min(size, TAIL_BYTES);
20
+ const buf = Buffer.alloc(readBytes);
21
+ const fd = openSync(file, 'r');
22
+ try {
23
+ readSync(fd, buf, 0, readBytes, size - readBytes);
24
+ }
25
+ finally {
26
+ closeSync(fd);
27
+ }
28
+ const lines = buf.toString('utf-8').split('\n');
29
+ // Drop the partial first line when we didn't read from the start of the file.
30
+ if (size > readBytes)
31
+ lines.shift();
32
+ while (lines.length > 0 && lines[lines.length - 1] === '')
33
+ lines.pop();
34
+ return lines.slice(-max);
35
+ }
36
+ function formatLine(line, ref, multi) {
37
+ return multi ? `${dim(ref.padEnd(14))}${dim('│')} ${line}` : line;
38
+ }
39
+ /**
40
+ * Map a user-typed agent argument onto the ref its log file is named after.
41
+ * Returns null when the input is ambiguous (already reported to the operator).
42
+ *
43
+ * Falls back to the raw input when the config can't be read or the agent is
44
+ * unknown: a log file outlives the config row it came from, so `logs` must
45
+ * still be able to open one for an agent that was since removed.
46
+ */
47
+ async function resolveLogRef(input) {
48
+ const config = await loadConfig();
49
+ if (!config)
50
+ return input;
51
+ const found = resolveAgentRef(config, input);
52
+ if ('agent' in found)
53
+ return agentRef(config, found.agent);
54
+ if ('ambiguous' in found) {
55
+ printAmbiguous(config, input, found.ambiguous);
56
+ return null;
57
+ }
58
+ return input;
59
+ }
60
+ /** Stream new lines appended to a log file, prefixing each in multi-agent mode. */
61
+ function follow(target, multi) {
62
+ let offset;
63
+ try {
64
+ offset = statSync(target.file).size;
65
+ }
66
+ catch {
67
+ offset = 0;
68
+ }
69
+ let carry = '';
70
+ watchFile(target.file, { interval: 400 }, (curr) => {
71
+ if (curr.size < offset) {
72
+ offset = 0;
73
+ carry = '';
74
+ } // file was truncated or rotated
75
+ if (curr.size <= offset)
76
+ return;
77
+ const len = curr.size - offset;
78
+ const buf = Buffer.alloc(len);
79
+ const fd = openSync(target.file, 'r');
80
+ try {
81
+ readSync(fd, buf, 0, len, offset);
82
+ }
83
+ finally {
84
+ closeSync(fd);
85
+ }
86
+ offset = curr.size;
87
+ carry += buf.toString('utf-8');
88
+ const parts = carry.split('\n');
89
+ carry = parts.pop() ?? '';
90
+ for (const line of parts)
91
+ console.log(formatLine(line, target.ref, multi));
92
+ });
93
+ }
94
+ export async function logs(ctx) {
95
+ if (wantsHelp(ctx)) {
96
+ showHelp('nordhavn logs [agent] [--once]', 'Tail logs for background agents', [
97
+ helpOpt(dim('[agent]'), 'Agent to show; every agent with logs if omitted. Use slug@organisation when a slug exists in more than one'),
98
+ helpOpt(dim('--once'), 'Print the recent lines and exit instead of following'),
99
+ ], ['nordhavn logs', 'nordhavn logs atlas', 'nordhavn logs atlas@klant-x', 'nordhavn logs --once']);
100
+ return;
101
+ }
102
+ // Follow live by default; --once is the one-shot dump (for piping/scrollback).
103
+ const once = ctx.cmdArgs.includes('--once');
104
+ console.log('');
105
+ let targets;
106
+ if (ctx.subarg) {
107
+ // Resolve through the config the same way `up` / `down` / `restart` do, so
108
+ // a bare slug that is unique still finds its log file even when the agent
109
+ // lives in a nested organisation (its file is named `slug@org.log`).
110
+ const ref = await resolveLogRef(ctx.subarg);
111
+ if (ref === null)
112
+ return;
113
+ const file = logPath(ref);
114
+ if (!existsSync(file)) {
115
+ console.log(red(` No logs for "${ref}". Background runs log to ~/.nordhavn-os/logs/.\n`));
116
+ return;
117
+ }
118
+ targets = [{ ref, file }];
119
+ }
120
+ else {
121
+ let files = [];
122
+ try {
123
+ files = readdirSync(logsDir());
124
+ }
125
+ catch { /* no logs dir yet */ }
126
+ targets = files
127
+ .filter(f => f.endsWith('.log'))
128
+ .map(f => ({ ref: f.slice(0, -4), file: join(logsDir(), f) }));
129
+ if (targets.length === 0) {
130
+ console.log(dim(' No agent logs yet. Start an agent with `nordhavn up -d`.\n'));
131
+ return;
132
+ }
133
+ }
134
+ const multi = targets.length > 1;
135
+ for (const target of targets) {
136
+ for (const line of tailLines(target.file, multi ? 12 : 80)) {
137
+ console.log(formatLine(line, target.ref, multi));
138
+ }
139
+ }
140
+ if (once) {
141
+ console.log('');
142
+ return;
143
+ }
144
+ console.log(dim(`\n ─── following ${targets.length} log file(s) · Ctrl+C to stop ───\n`));
145
+ for (const target of targets)
146
+ follow(target, multi);
147
+ }
@@ -0,0 +1,7 @@
1
+ export interface CliCtx {
2
+ subarg?: string;
3
+ cmdArgs: string[];
4
+ resolvedCommand: string;
5
+ }
6
+ export declare function wantsHelp(ctx: CliCtx): boolean;
7
+ export declare function ask(question: string): Promise<string>;
@@ -0,0 +1,13 @@
1
+ import { createInterface } from 'node:readline';
2
+ export function wantsHelp(ctx) {
3
+ return ctx.cmdArgs.includes('-h') || ctx.cmdArgs.includes('--help') || ctx.subarg === '-h' || ctx.subarg === '--help';
4
+ }
5
+ export function ask(question) {
6
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
7
+ return new Promise((resolve) => {
8
+ rl.question(question, (answer) => {
9
+ rl.close();
10
+ resolve(answer.trim());
11
+ });
12
+ });
13
+ }
@@ -0,0 +1,2 @@
1
+ import { type CliCtx } from './prompts.js';
2
+ export declare function ps(ctx: CliCtx): Promise<void>;
package/dist/cli/ps.js ADDED
@@ -0,0 +1,81 @@
1
+ import { STATUS_STALE_MS } from '@nordhavnhq/runner-runtime';
2
+ import { loadConfig, agentRef, NAMELESS_ORG_LABEL } from '../config.js';
3
+ import { readAllStatuses, isStatusAlive, clearStatus } from '../runtime/daemon.js';
4
+ import { dim, bold, green, yellow, red, showHelp, stripAnsi } from '../utils/format.js';
5
+ import { wantsHelp } from './prompts.js';
6
+ function uptimeOf(iso) {
7
+ const ms = Date.now() - new Date(iso).getTime();
8
+ if (!Number.isFinite(ms) || ms < 0)
9
+ return '-';
10
+ const secs = Math.floor(ms / 1000);
11
+ const h = Math.floor(secs / 3600);
12
+ const m = Math.floor((secs % 3600) / 60);
13
+ if (h > 0)
14
+ return `${h}h${m}m`;
15
+ if (m > 0)
16
+ return `${m}m`;
17
+ return `${secs}s`;
18
+ }
19
+ /** Pad to a column width, ignoring ANSI escapes in the width calculation. */
20
+ function pad(s, width) {
21
+ return s + ' '.repeat(Math.max(0, width - stripAnsi(s).length));
22
+ }
23
+ function cellFor(status) {
24
+ if (!status)
25
+ return { dot: dim('○'), label: dim('stopped') };
26
+ const stale = Date.now() - new Date(status.lastSeen).getTime() > STATUS_STALE_MS;
27
+ if (stale)
28
+ return { dot: yellow('◐'), label: yellow('stale') };
29
+ if (status.status === 'connected')
30
+ return { dot: green('●'), label: green('connected') };
31
+ return { dot: yellow('◐'), label: yellow(status.status) };
32
+ }
33
+ export async function ps(ctx) {
34
+ if (wantsHelp(ctx)) {
35
+ showHelp('nordhavn ps', 'Show the runtime status of every agent', [], ['nordhavn ps']);
36
+ return;
37
+ }
38
+ console.log('');
39
+ const config = await loadConfig();
40
+ if (!config) {
41
+ console.log(red(' Not configured. Run `nordhavn init` first.\n'));
42
+ process.exit(1);
43
+ return;
44
+ }
45
+ // Prune status files whose process has died, then index the survivors.
46
+ for (const s of readAllStatuses()) {
47
+ if (!isStatusAlive(s))
48
+ clearStatus(s.ref);
49
+ }
50
+ // Keyed by agent ref, so two organisations sharing a slug get a row each
51
+ // instead of silently collapsing into one.
52
+ const live = new Map(readAllStatuses().map(s => [s.ref, s]));
53
+ const orgByRef = new Map(config.agents.map(a => [agentRef(config, a), a.organisationSlug]));
54
+ const refs = [...new Set([...orgByRef.keys(), ...live.keys()])].sort();
55
+ if (refs.length === 0) {
56
+ console.log(dim(' No agent configured. Run `nordhavn link <code>` with a code from the agent\'s page in the studio.\n'));
57
+ return;
58
+ }
59
+ // Organisation is noise while there is only one pairing, and essential once
60
+ // there are several - so the column only appears when it can actually differ.
61
+ const showOrg = config.hosts.length > 1;
62
+ const refWidth = Math.max(16, ...refs.map(r => r.length + 2));
63
+ console.log(bold(' Runtime\n'));
64
+ for (const ref of refs) {
65
+ const status = live.get(ref);
66
+ const { dot, label } = cellFor(status);
67
+ const uptime = status ? uptimeOf(status.startedAt) : '-';
68
+ const mode = status ? status.mode : '-';
69
+ const pid = status ? `pid ${status.pid}` : '-';
70
+ const org = showOrg
71
+ ? pad(dim(orgByRef.get(ref) ?? status?.organisationSlug ?? NAMELESS_ORG_LABEL), 18)
72
+ : '';
73
+ console.log(` ${dot} ${pad(bold(ref), refWidth)}${org}${pad(label, 16)}${pad(dim(uptime), 10)}${pad(dim(mode), 13)}${dim(pid)}`);
74
+ }
75
+ console.log('');
76
+ console.log(dim(` ${refs.length} agent(s) · ${live.size} running`));
77
+ if (live.size > 0) {
78
+ console.log(dim(' `nordhavn logs` to follow output · `nordhavn down <agent>` to stop'));
79
+ }
80
+ console.log('');
81
+ }
@@ -0,0 +1,4 @@
1
+ import { type CliCtx } from './prompts.js';
2
+ /** `nordhavn relay [off]`: how the git relay of this machine stands, or turn
3
+ * it off. Connecting happens from the code app (the runner asks here). */
4
+ export declare function relay(ctx: CliCtx): Promise<void>;
@@ -0,0 +1,29 @@
1
+ import { dim, green, red, showHelp, helpOpt } from '../utils/format.js';
2
+ import { wantsHelp } from './prompts.js';
3
+ import { relayDisconnect, relayStatus } from '../runtime/git-relay.js';
4
+ /** `nordhavn relay [off]`: how the git relay of this machine stands, or turn
5
+ * it off. Connecting happens from the code app (the runner asks here). */
6
+ export async function relay(ctx) {
7
+ if (wantsHelp(ctx)) {
8
+ showHelp('nordhavn relay [off]', 'The git relay: agents elsewhere push in your name through this machine, after your click', [
9
+ helpOpt(dim('(none)'), 'Show whether it is connected, and as whom'),
10
+ helpOpt('off', 'Disconnect it; nothing is pushed through this machine until you connect again from the code app'),
11
+ ], ['nordhavn relay', 'nordhavn relay off']);
12
+ return;
13
+ }
14
+ if (ctx.subarg && ctx.subarg !== 'off') {
15
+ console.log(red(` Unknown: relay ${ctx.subarg}`));
16
+ return;
17
+ }
18
+ const status = ctx.subarg === 'off' ? relayDisconnect() : relayStatus();
19
+ if (status.enabled) {
20
+ console.log(` ${green('connected')} as @${status.githubLogin}, commits by ${status.gitName} <${status.gitEmail}>`);
21
+ console.log(dim(` since ${status.connectedAt}. Turn it off: nordhavn relay off`));
22
+ }
23
+ else {
24
+ console.log(` ${red('not connected')}${ctx.subarg === 'off' ? ' (turned off)' : ''}`);
25
+ console.log(dim(' Connect it from the status bar of the code app.'));
26
+ }
27
+ if (!status.dialog)
28
+ console.log(dim(' This machine cannot show the confirmation dialog: every push is refused.'));
29
+ }
@@ -0,0 +1,6 @@
1
+ import { type CliCtx } from './prompts.js';
2
+ /**
3
+ * `nordhavn update [--check] [--force]`: install the latest release into the
4
+ * prefix this runner lives in, then move the running runtimes onto it.
5
+ */
6
+ export declare function update(ctx: CliCtx): Promise<void>;