@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,507 @@
1
+ import { WebSocket } from 'ws';
2
+ import { recogniseDispatch, } from './contract/wire.js';
3
+ import { emitEvent } from './runtime/events.js';
4
+ import { clipToolResult } from './contract/batch.js';
5
+ import { scheduleMacrotask } from './platform.js';
6
+ const MAX_OUTBOUND_QUEUE = 500;
7
+ /** Frames worth nothing late: never queued while the socket is down. A reply's
8
+ * deltas are in its `chat:done` too, a process's output in its log. */
9
+ const LIVE_ONLY_FRAMES = new Set([
10
+ 'chat:stream', 'proc:output', 'ping', 'health:pong', 'loop:probe:ack',
11
+ // The live view of the agent browser: the studio asks again (`browser:list`) after a reconnect.
12
+ 'browser:sessions', 'browser:session', 'browser:closed', 'browser:frame', 'browser:error', 'browser:opened', 'browser:picked',
13
+ ]);
14
+ const PONG_TIMEOUT_MS = 45_000;
15
+ /** How long a socket may sit in CONNECTING before it's force-recycled. */
16
+ const CONNECT_TIMEOUT_MS = 20_000;
17
+ export function connectWebSocket(config, agent,
18
+ /** The pairing this agent connects under - the one whose organisation matches
19
+ * the agent's. Passed in rather than looked up here because the machine can
20
+ * hold several, and picking the wrong one is exactly what the studio's
21
+ * cross-org handshake check rejects. */
22
+ host, agentHome, callbacks, opts = {}) {
23
+ // Home paths are reported here so the studio can render the local-paths line
24
+ // of the system prompt - the runner owns where its files live, the studio
25
+ // owns prompt assembly. The per-dispatch project is sent separately on each
26
+ // frame (agents are cross-project). The `hostToken` proves this machine is a
27
+ // paired runner; the studio refuses connects without it.
28
+ //
29
+ // Param names `project`/`agentProject` mirror what the studio's `_ws/agents`
30
+ // handler reads - keep them in sync with that route.
31
+ if (!host?.token) {
32
+ throw new Error('Runner is not paired - run `nordhavn link <code>` first');
33
+ }
34
+ const params = new URLSearchParams({
35
+ token: agent.token,
36
+ hostToken: host.token,
37
+ project: config.home,
38
+ agentProject: agentHome,
39
+ });
40
+ if (opts.running?.length)
41
+ params.set('running', opts.running.join(','));
42
+ // Project folders are no longer reported at connect: the studio picker browses
43
+ // the runner live (via `fs:browse`), so folders created after connect show up
44
+ // without a reconnect.
45
+ const wsUrl = config.studioUrl.replace(/^http/, 'ws') + `/_ws/agents?${params.toString()}`;
46
+ const socket = opts.reuse ?? {
47
+ ws: null,
48
+ agent,
49
+ connected: false,
50
+ lastPongAt: Date.now(),
51
+ ready: false,
52
+ outboundQueue: [],
53
+ };
54
+ socket.connected = false;
55
+ socket.ready = false;
56
+ const previous = opts.reuse?.ws;
57
+ const ws = new WebSocket(wsUrl);
58
+ socket.ws = ws;
59
+ if (previous && previous.readyState !== WebSocket.CLOSED) {
60
+ try {
61
+ previous.terminate();
62
+ }
63
+ catch { }
64
+ }
65
+ // A reused socket's earlier connection may still say something: only the
66
+ // current one speaks for the agent.
67
+ const current = () => socket.ws === ws;
68
+ // A dev server mid-restart can accept the TCP connection but stall the HTTP
69
+ // upgrade indefinitely - no 'open', 'error' or 'close' ever fires. Force the
70
+ // socket down after a timeout so the caller's onClose schedules a fresh try.
71
+ let connectTimer = setTimeout(() => {
72
+ connectTimer = null;
73
+ if (ws.readyState === WebSocket.CONNECTING) {
74
+ try {
75
+ ws.terminate();
76
+ }
77
+ catch { }
78
+ }
79
+ }, CONNECT_TIMEOUT_MS);
80
+ const clearConnectTimer = () => {
81
+ if (connectTimer) {
82
+ clearTimeout(connectTimer);
83
+ connectTimer = null;
84
+ }
85
+ };
86
+ ws.on('open', () => {
87
+ clearConnectTimer();
88
+ if (!current())
89
+ return;
90
+ socket.connected = true;
91
+ socket.lastPongAt = Date.now();
92
+ });
93
+ ws.on('message', (raw) => {
94
+ if (!current())
95
+ return;
96
+ let parsed;
97
+ try {
98
+ parsed = JSON.parse(raw.toString());
99
+ }
100
+ catch {
101
+ emitEvent({
102
+ kind: 'note',
103
+ agentSlug: agent.slug,
104
+ level: 'warn',
105
+ message: 'unparseable frame from studio: not JSON',
106
+ });
107
+ return;
108
+ }
109
+ const frame = recogniseDispatch(parsed);
110
+ if (!frame) {
111
+ const t = parsed?.type;
112
+ emitEvent({
113
+ kind: 'note',
114
+ agentSlug: agent.slug,
115
+ level: 'warn',
116
+ message: `unknown frame from studio: type=${typeof t === 'string' ? t : 'missing'}`,
117
+ });
118
+ return;
119
+ }
120
+ switch (frame.type) {
121
+ case 'connected':
122
+ callbacks.onConnected(frame);
123
+ return;
124
+ case 'task':
125
+ callbacks.onTask(frame);
126
+ return;
127
+ case 'task:cancel':
128
+ callbacks.onTaskCancel?.(frame);
129
+ return;
130
+ case 'task:steer':
131
+ callbacks.onTaskSteer?.(frame);
132
+ return;
133
+ case 'chat':
134
+ callbacks.onChat(frame);
135
+ return;
136
+ case 'chat:cancel':
137
+ callbacks.onCancel?.(frame);
138
+ return;
139
+ case 'chat:steer':
140
+ callbacks.onChatSteer?.(frame);
141
+ return;
142
+ case 'chat:side-question':
143
+ callbacks.onSideQuestion?.(frame);
144
+ return;
145
+ case 'chat:generate-title':
146
+ callbacks.onGenerateTitle(frame);
147
+ return;
148
+ case 'delegate:result':
149
+ callbacks.onDelegateResult?.(frame);
150
+ return;
151
+ case 'agent:renamed':
152
+ callbacks.onAgentRenamed?.(frame);
153
+ return;
154
+ case 'fs:browse':
155
+ callbacks.onFsBrowse?.(frame);
156
+ return;
157
+ case 'fs:mkdir':
158
+ callbacks.onFsMkdir?.(frame);
159
+ return;
160
+ case 'fs:list':
161
+ callbacks.onFsList?.(frame);
162
+ return;
163
+ case 'fs:read':
164
+ callbacks.onFsRead?.(frame);
165
+ return;
166
+ case 'fs:bytes':
167
+ callbacks.onFsBytes?.(frame);
168
+ return;
169
+ case 'fs:write':
170
+ callbacks.onFsWrite?.(frame);
171
+ return;
172
+ case 'fs:entry':
173
+ callbacks.onFsEntry?.(frame);
174
+ return;
175
+ case 'fs:status':
176
+ callbacks.onFsStatus?.(frame);
177
+ return;
178
+ case 'fs:paths':
179
+ callbacks.onFsPaths?.(frame);
180
+ return;
181
+ case 'fs:sonar':
182
+ callbacks.onFsSonar?.(frame);
183
+ return;
184
+ case 'fs:repos':
185
+ callbacks.onFsRepos?.(frame);
186
+ return;
187
+ case 'fs:branches':
188
+ callbacks.onFsBranches?.(frame);
189
+ return;
190
+ case 'fs:log':
191
+ callbacks.onFsLog?.(frame);
192
+ return;
193
+ case 'fs:show':
194
+ callbacks.onFsShow?.(frame);
195
+ return;
196
+ case 'fs:blame':
197
+ callbacks.onFsBlame?.(frame);
198
+ return;
199
+ case 'fs:diff':
200
+ callbacks.onFsDiff?.(frame);
201
+ return;
202
+ case 'fs:git':
203
+ callbacks.onFsGit?.(frame);
204
+ return;
205
+ case 'relay:status':
206
+ callbacks.onRelayStatus?.(frame);
207
+ return;
208
+ case 'relay:connect':
209
+ callbacks.onRelayConnect?.(frame);
210
+ return;
211
+ case 'relay:disconnect':
212
+ callbacks.onRelayDisconnect?.(frame);
213
+ return;
214
+ case 'relay:push':
215
+ callbacks.onRelayPush?.(frame);
216
+ return;
217
+ case 'proc:stop':
218
+ callbacks.onProcStop?.(frame);
219
+ return;
220
+ case 'proc:start':
221
+ callbacks.onProcStart?.(frame);
222
+ return;
223
+ case 'preview:open':
224
+ callbacks.onPreviewOpen?.(frame);
225
+ return;
226
+ case 'preview:close':
227
+ callbacks.onPreviewClose?.(frame);
228
+ return;
229
+ case 'preview:refused':
230
+ callbacks.onPreviewRefused?.(frame);
231
+ return;
232
+ case 'browser:list':
233
+ case 'browser:watch':
234
+ case 'browser:unwatch':
235
+ case 'browser:input':
236
+ case 'browser:open':
237
+ callbacks.onBrowser?.(frame);
238
+ return;
239
+ case 'restart':
240
+ callbacks.onRestart?.();
241
+ return;
242
+ case 'pong':
243
+ socket.lastPongAt = Date.now();
244
+ return;
245
+ case 'error':
246
+ callbacks.onError(`server: ${frame.message}`);
247
+ return;
248
+ // Diagnostic echo replies - never reach the agent loop or LLM. The
249
+ // `health:pong` answer is sent inline so RTT measures pure socket
250
+ // round-trip; `loop:probe:ack` is bounced through `setImmediate` so
251
+ // a missing ack means the runtime event loop is stuck rather than
252
+ // the socket being dead.
253
+ case 'health:ping':
254
+ sendWsHealthPong(socket, frame.nonce);
255
+ return;
256
+ case 'loop:probe':
257
+ sendWsLoopProbeAck(socket, frame.nonce);
258
+ return;
259
+ case 'chat:ack':
260
+ case 'result:ack':
261
+ case 'progress:ack':
262
+ case 'presence:user-online':
263
+ case 'presence:user-offline':
264
+ return;
265
+ default: {
266
+ // A frame recogniseDispatch accepts but this switch does not route:
267
+ // `never` fails the typecheck, the note covers a wire/runtime mismatch.
268
+ const unhandled = frame;
269
+ emitEvent({
270
+ kind: 'note',
271
+ agentSlug: agent.slug,
272
+ level: 'warn',
273
+ message: `unhandled frame from studio: type=${String(unhandled.type)}`,
274
+ });
275
+ return;
276
+ }
277
+ }
278
+ });
279
+ ws.on('error', (err) => {
280
+ if (current())
281
+ callbacks.onError(err.message);
282
+ });
283
+ ws.on('close', (code, reason) => {
284
+ clearConnectTimer();
285
+ if (!current())
286
+ return;
287
+ socket.connected = false;
288
+ socket.ready = false;
289
+ callbacks.onClose(code, reason?.toString() ?? '');
290
+ });
291
+ return socket;
292
+ }
293
+ /**
294
+ * The studio said `connected`: send what waited, then everything as it comes.
295
+ * `keep` leaves out the frames of a run the studio did not keep, which would
296
+ * otherwise settle a row it already settled or started over.
297
+ */
298
+ export function releaseQueuedFrames(socket, keep = () => true) {
299
+ socket.ready = true;
300
+ for (const payload of socket.outboundQueue.splice(0)) {
301
+ const frame = JSON.parse(payload);
302
+ if (!keep(frame))
303
+ continue;
304
+ try {
305
+ socket.ws.send(payload);
306
+ }
307
+ catch {
308
+ emitEvent({ kind: 'ws.send.failed', agentSlug: socket.agent.slug, frameType: frame.type ?? 'unknown', reason: 'dropped' });
309
+ }
310
+ }
311
+ }
312
+ function wsSend(socket, payload) {
313
+ const serialised = JSON.stringify(payload);
314
+ const frameType = typeof payload.type === 'string' ? payload.type : 'unknown';
315
+ if (socket.ws?.readyState === WebSocket.OPEN && socket.ready) {
316
+ try {
317
+ socket.ws.send(serialised);
318
+ return;
319
+ }
320
+ catch {
321
+ emitEvent({ kind: 'ws.send.failed', agentSlug: socket.agent.slug, frameType, reason: 'queued' });
322
+ }
323
+ }
324
+ if (LIVE_ONLY_FRAMES.has(frameType))
325
+ return;
326
+ if (socket.outboundQueue.length >= MAX_OUTBOUND_QUEUE) {
327
+ const dropped = socket.outboundQueue.shift();
328
+ const droppedType = dropped ? JSON.parse(dropped).type ?? 'unknown' : 'unknown';
329
+ emitEvent({ kind: 'ws.send.failed', agentSlug: socket.agent.slug, frameType: droppedType, reason: 'dropped' });
330
+ }
331
+ socket.outboundQueue.push(serialised);
332
+ emitEvent({ kind: 'ws.send.failed', agentSlug: socket.agent.slug, frameType, reason: 'queued' });
333
+ }
334
+ /**
335
+ * Lifecycle bucket for a socket - lets the heartbeat tell an in-progress
336
+ * handshake apart from a live or dead connection.
337
+ */
338
+ export function wsLifecycle(socket) {
339
+ switch (socket.ws?.readyState) {
340
+ case WebSocket.CONNECTING: return 'connecting';
341
+ case WebSocket.OPEN: return 'open';
342
+ default: return 'closed';
343
+ }
344
+ }
345
+ /**
346
+ * True if an OPEN socket is still healthy. A stale socket (no pong within
347
+ * PONG_TIMEOUT_MS) is terminated as a side effect. Only meaningful for
348
+ * sockets in the 'open' lifecycle state - callers should check first.
349
+ */
350
+ export function checkWsAlive(socket) {
351
+ if (socket.ws?.readyState !== WebSocket.OPEN || !socket.connected)
352
+ return false;
353
+ const stale = Date.now() - socket.lastPongAt > PONG_TIMEOUT_MS;
354
+ if (stale) {
355
+ try {
356
+ socket.ws.terminate();
357
+ }
358
+ catch { }
359
+ return false;
360
+ }
361
+ return true;
362
+ }
363
+ export function sendWsPing(socket) {
364
+ wsSend(socket, { type: 'ping' });
365
+ }
366
+ /** Post-connect `config` frame. The studio's `connected` ack expects it; today
367
+ * it carries the runner's version + platform so the studio can record which
368
+ * runner build an agent is on and tell the agent when it's outdated, and the
369
+ * `features` it handles beyond its version (`SIDE_QUESTION_FEATURE`). */
370
+ export function sendWsConfig(socket, info) {
371
+ wsSend(socket, { type: 'config', version: info.version, platform: info.platform, ...(info.features?.length ? { features: info.features } : {}) });
372
+ }
373
+ export function sendWsHealthPong(socket, nonce) {
374
+ wsSend(socket, { type: 'health:pong', nonce });
375
+ }
376
+ export function sendWsLoopProbeAck(socket, nonce) {
377
+ // Bounce through the event loop so the ack only fires once the runtime
378
+ // can service a queued task. If the loop is wedged, the studio will see
379
+ // the missing ack and know it's the runtime, not the socket.
380
+ scheduleMacrotask(() => wsSend(socket, { type: 'loop:probe:ack', nonce }));
381
+ }
382
+ export function sendWsChatStream(socket, conversationId, delta, thinking) {
383
+ wsSend(socket, { type: 'chat:stream', conversationId, delta, ...(thinking ? { thinking: true } : {}) });
384
+ }
385
+ export function sendWsChatDone(socket, conversationId, content, usage, attachments, thoughts,
386
+ /** What the agent last SAID, when that is not what `content` persists - a room
387
+ * whose final aside was already sent as `chat:narration`. The studio routes
388
+ * the follow-up on this; absent everywhere else, where the two are the same. */
389
+ spokenContent) {
390
+ wsSend(socket, { type: 'chat:done', conversationId, content, usage, attachments, ...(thoughts ? { thoughts } : {}), ...(spokenContent ? { spokenContent } : {}) });
391
+ }
392
+ /**
393
+ * What the agent says to a ROOM while it works, sent the moment the round's text
394
+ * is final instead of at the end of the turn.
395
+ *
396
+ * Meetings only, and the caller decides that from `inMeeting` on the dispatch
397
+ * frame - the studio verifies it again before writing anything. In a one-to-one
398
+ * chat the live bubble is never cleared, so there is nothing to repair and this
399
+ * would only add rows.
400
+ *
401
+ * Sent BEFORE the round's first `chat:tool-use`, which is the whole point: that
402
+ * frame clears the room's live bubble (it must, or the sentence before the call
403
+ * glues onto the one after it) and the tool then runs for seconds or minutes.
404
+ * Mirrors `createMeetingNarrator` in the studio's `run-chat.ts`, which reaches
405
+ * the same writer in-process for an internal agent.
406
+ */
407
+ export function sendWsChatNarration(socket, conversationId, content, round, steerReply) {
408
+ wsSend(socket, { type: 'chat:narration', conversationId, content, round, ...(steerReply ? { steerReply: true } : {}) });
409
+ }
410
+ /** The turn read these steers (`chat:steer` with a `steerId`): the studio moves
411
+ * them from the stack above the input into the transcript, here. */
412
+ export function sendWsChatSteerApplied(socket, conversationId, steerIds) {
413
+ if (steerIds.length === 0)
414
+ return;
415
+ wsSend(socket, { type: 'chat:steer-applied', conversationId, steerIds });
416
+ }
417
+ /** The same for a task run (`task:steer` with a `steerId`). */
418
+ export function sendWsTaskSteerApplied(socket, queueId, steerIds) {
419
+ if (steerIds.length === 0)
420
+ return;
421
+ wsSend(socket, { type: 'task:steer-applied', queueId, steerIds });
422
+ }
423
+ export function sendWsChatError(socket, conversationId, error) {
424
+ wsSend(socket, { type: 'chat:error', conversationId, error });
425
+ }
426
+ export function sendWsChatTitle(socket, conversationId, title) {
427
+ wsSend(socket, { type: 'chat:title', conversationId, title });
428
+ }
429
+ export function sendWsDelegateRequest(socket, payload) {
430
+ wsSend(socket, { type: 'delegate:request', ...payload });
431
+ }
432
+ /** The caller stopped waiting: ask the studio to stop the call on the
433
+ * target's side too. */
434
+ export function sendWsDelegateCancel(socket, requestId, reason) {
435
+ wsSend(socket, { type: 'delegate:cancel', requestId, ...(reason ? { reason } : {}) });
436
+ }
437
+ /** Reply to an `fs:*` request, correlated by `requestId`. On success carries
438
+ * the browsed `entries` and/or the `created` folder path (`fs:browse`,
439
+ * `fs:mkdir`), a checkout folder's `files` (`fs:list`), one `file`
440
+ * (`fs:read`, and as saved by `fs:write`), the path `fs:entry` made or
441
+ * renamed to (`created`), a slice of its bytes
442
+ * (`fs:bytes`), what git says changed
443
+ * (`fs:status`), every file's path (`fs:paths`, `truncated` past the
444
+ * limit), the repositories in it (`fs:repos`), the branches, remotes and
445
+ * state (`fs:branches`), the commits
446
+ * (`fs:log`), one commit with its diff (`fs:show`), the working tree's
447
+ * (`fs:diff`), a file's blame (`fs:blame`), or what `fs:git` did (git's
448
+ * `output`, the `sha` it committed). A save refused
449
+ * because the file moved on is `conflict`, a commit refused because it would
450
+ * leave an import behind `missing`. */
451
+ export function sendWsFsResult(socket, result) {
452
+ wsSend(socket, { type: 'fs:result', ...result });
453
+ }
454
+ /** A process the runner keeps running started, changed (its port found) or
455
+ * ended (the agent contract's processes.ts). */
456
+ export function sendWsProcState(socket, process) {
457
+ wsSend(socket, { type: 'proc:state', process });
458
+ }
459
+ /** What a process printed since the last frame (at most
460
+ * `PROCESS_OUTPUT_FRAME_MAX_CHARS`). */
461
+ export function sendWsProcOutput(socket, processId, data) {
462
+ wsSend(socket, { type: 'proc:output', processId, data });
463
+ }
464
+ /** Every process of this agent, each with the end of its output: on every
465
+ * (re)connect, so the studio holds what runs now. */
466
+ export function sendWsProcSync(socket, processes) {
467
+ wsSend(socket, { type: 'proc:sync', processes });
468
+ }
469
+ /** Ask a preview for a process (`name`: the address it had before).
470
+ * Answered with `preview:open` or `preview:refused`. */
471
+ export function sendWsPreviewRequest(socket, requestId, processId, name) {
472
+ wsSend(socket, { type: 'preview:request', requestId, processId, ...(name ? { name } : {}) });
473
+ }
474
+ /** A frame of the live view of the agent browser (@nordhavnhq/runner-browser, src/live.ts):
475
+ * browser:sessions|session|closed|frame|error. Never queued while the socket is down. */
476
+ export function sendWsBrowser(socket, frame) {
477
+ wsSend(socket, frame);
478
+ }
479
+ function buildToolUse(name, status, args, result, durationMs, touched) {
480
+ return {
481
+ name,
482
+ status,
483
+ arguments: args ?? undefined,
484
+ // Clipped per item for a batch envelope, so it stays JSON the studio can read.
485
+ result: result ? clipToolResult(result) : undefined,
486
+ durationMs: durationMs ?? undefined,
487
+ ...(touched?.length ? { touched: [...touched] } : {}),
488
+ };
489
+ }
490
+ export function sendWsToolUse(socket, conversationId, toolName, status, args, result, durationMs, touched) {
491
+ wsSend(socket, { type: 'chat:tool-use', conversationId, tool: buildToolUse(toolName, status, args, result, durationMs, touched) });
492
+ }
493
+ export function sendWsTaskDone(socket, queueId, output, usage, error,
494
+ /** Notes for the next run of a task that ended without delivering, or that
495
+ * stopped on a blocking question. */
496
+ handoff,
497
+ /** Why the loop ended: the studio holds the task for a decision on
498
+ * `awaiting-user` (a blocking question) and `loop` (it opens a blocker). */
499
+ stopReason) {
500
+ wsSend(socket, { type: 'task:done', queueId, output, usage, error, ...(handoff ? { handoff } : {}), ...(stopReason ? { stopReason } : {}) });
501
+ }
502
+ export function sendWsTaskToolUse(socket, queueId, toolName, status, args, result, durationMs, touched) {
503
+ wsSend(socket, { type: 'task:tool-use', queueId, tool: buildToolUse(toolName, status, args, result, durationMs, touched) });
504
+ }
505
+ export function sendWsTaskMessage(socket, queueId, content, thoughts, round) {
506
+ wsSend(socket, { type: 'task:message', queueId, content, thoughts, round });
507
+ }
@@ -0,0 +1,48 @@
1
+ export declare const MAX_TOOL_ROUNDS = 200;
2
+ export declare const MAX_TASK_TOOL_ROUNDS = 200;
3
+ /** Wall-clock cap on a single chat turn (ms). Task runs use their own
4
+ * (effectively unlimited) budget - see handle-task.ts. 20 min gives a chat/
5
+ * companion turn room to do real multi-step work before the safety net trips.
6
+ * Fallback only: the studio sends `agentConfig.maxLoopMs` (60 min for a
7
+ * non-room chat turn, see server/utils/agent/queue/loop-budget.ts), so this
8
+ * still applies to meeting/channel turns and to an older studio. */
9
+ export declare const MAX_LOOP_MS: number;
10
+ export declare const RECONNECT_BASE_DELAY_MS = 1000;
11
+ export declare const RECONNECT_MAX_DELAY_MS = 30000;
12
+ /** The studio closes every socket with 1012 (Service Restart) when it shuts
13
+ * down gracefully, which in production means a deploy whose successor is
14
+ * already up. After that close the runner retries on a tight schedule
15
+ * (250ms doubling to 2s) for RESTART_FAST_ATTEMPTS tries, about 25s, before it
16
+ * falls back to the normal backoff: a deploy should not cost every runner
17
+ * 10-30s offline. */
18
+ export declare const CLOSE_SERVICE_RESTART = 1012;
19
+ export declare const RESTART_RECONNECT_BASE_DELAY_MS = 250;
20
+ export declare const RESTART_RECONNECT_MAX_DELAY_MS = 2000;
21
+ export declare const RESTART_FAST_ATTEMPTS = 15;
22
+ /** Authentication or pairing is wrong: missing/invalid agent or host token, or
23
+ * an agent and host belonging to different organisations. Reconnecting cannot
24
+ * fix any of these without a human re-pairing. */
25
+ export declare const CLOSE_AUTH_FAILED = 4001;
26
+ /** The studio asked for a fresh connection. Reconnecting is exactly right. */
27
+ export declare const CLOSE_STALE_CONNECTION = 4002;
28
+ /** A newer connection for this agent won the registration race. Transient - the
29
+ * loser reconnects and either wins or is superseded again. */
30
+ export declare const CLOSE_SUPERSEDED = 4003;
31
+ /** The runner already hosts another agent that is connected right now. A runner
32
+ * hosts one agent; a second one needs its own profile and pairing. */
33
+ export declare const CLOSE_RUNNER_TAKEN = 4009;
34
+ /** The runner host was revoked or deleted studio-side (`disconnectRunner`). The
35
+ * stored host token is dead; the machine has to be paired again. */
36
+ export declare const CLOSE_HOST_REVOKED = 4010;
37
+ /** The Agent row was deleted studio-side (`disconnectAgent`). Nothing to
38
+ * reconnect to. */
39
+ export declare const CLOSE_AGENT_DELETED = 4011;
40
+ /**
41
+ * Close codes no amount of retrying will resolve. Everything else - network
42
+ * drops, studio restarts (1012), timeouts, 4002, 4003 - keeps the normal
43
+ * backoff-and-retry behaviour.
44
+ */
45
+ export declare const FATAL_CLOSE_CODES: ReadonlySet<number>;
46
+ /** Operator-facing explanation for a fatal close, including what to do next. */
47
+ export declare function fatalCloseHint(code: number, reason: string): string;
48
+ export declare const STATUS_STALE_MS = 90000;
@@ -0,0 +1,95 @@
1
+ // MIRROR: studio apps/server/server/routes/_ws/agents.ts, apps/server/server/utils/agent/sockets.ts
2
+ // ─── Runtime Constants ───────────────────────
3
+ //
4
+ // Tunables for the chat loop, reconnection, and CLI behaviour.
5
+ // Centralised here so they can be tuned without hunting through index.ts.
6
+ // Chat/task loop - defaults; can be overridden per agent via the `maxToolRounds`
7
+ // column. History: 25 was far too low (a build + CMS data-entry turn hit the cap
8
+ // mid-task in ~20 rounds), bumped to 50, but 50 still made runner agents "give
9
+ // up" long before a VS-Code-style coding agent would - short turns that a couple
10
+ // dozen extra rounds would have finished. Raised to 200 to MATCH the studio
11
+ // internal runtime, so both transports run equally long on a single turn. The
12
+ // real longevity levers are (a) this cap, (b) token-budget compaction in loop.ts
13
+ // which compacts-and-continues when the context window fills instead of stopping,
14
+ // and (c) the wall-clock cap below. A turn that still hits a cap ends with an
15
+ // actionable "reply continue" message (see emptyChatFallback in handle-chat.ts).
16
+ export const MAX_TOOL_ROUNDS = 200;
17
+ export const MAX_TASK_TOOL_ROUNDS = 200;
18
+ /** Wall-clock cap on a single chat turn (ms). Task runs use their own
19
+ * (effectively unlimited) budget - see handle-task.ts. 20 min gives a chat/
20
+ * companion turn room to do real multi-step work before the safety net trips.
21
+ * Fallback only: the studio sends `agentConfig.maxLoopMs` (60 min for a
22
+ * non-room chat turn, see server/utils/agent/queue/loop-budget.ts), so this
23
+ * still applies to meeting/channel turns and to an older studio. */
24
+ export const MAX_LOOP_MS = 20 * 60_000;
25
+ // WebSocket reconnect
26
+ export const RECONNECT_BASE_DELAY_MS = 1_000;
27
+ export const RECONNECT_MAX_DELAY_MS = 30_000;
28
+ /** The studio closes every socket with 1012 (Service Restart) when it shuts
29
+ * down gracefully, which in production means a deploy whose successor is
30
+ * already up. After that close the runner retries on a tight schedule
31
+ * (250ms doubling to 2s) for RESTART_FAST_ATTEMPTS tries, about 25s, before it
32
+ * falls back to the normal backoff: a deploy should not cost every runner
33
+ * 10-30s offline. */
34
+ export const CLOSE_SERVICE_RESTART = 1012;
35
+ export const RESTART_RECONNECT_BASE_DELAY_MS = 250;
36
+ export const RESTART_RECONNECT_MAX_DELAY_MS = 2_000;
37
+ export const RESTART_FAST_ATTEMPTS = 15;
38
+ // ─── Studio close codes ──────────────────────
39
+ //
40
+ // The studio's `_ws/agents` handler closes with a 4xxx code saying WHY. The
41
+ // runner needs the distinction because its reconnect loop has no attempt
42
+ // ceiling: retrying a transient drop forever is correct, retrying a rejected
43
+ // token forever is a silent infinite loop that never surfaces the real problem.
44
+ // Keep in sync with `apps/server/server/routes/_ws/agents.ts` +
45
+ // `apps/server/server/utils/agent/sockets.ts`.
46
+ /** Authentication or pairing is wrong: missing/invalid agent or host token, or
47
+ * an agent and host belonging to different organisations. Reconnecting cannot
48
+ * fix any of these without a human re-pairing. */
49
+ export const CLOSE_AUTH_FAILED = 4001;
50
+ /** The studio asked for a fresh connection. Reconnecting is exactly right. */
51
+ export const CLOSE_STALE_CONNECTION = 4002;
52
+ /** A newer connection for this agent won the registration race. Transient - the
53
+ * loser reconnects and either wins or is superseded again. */
54
+ export const CLOSE_SUPERSEDED = 4003;
55
+ /** The runner already hosts another agent that is connected right now. A runner
56
+ * hosts one agent; a second one needs its own profile and pairing. */
57
+ export const CLOSE_RUNNER_TAKEN = 4009;
58
+ /** The runner host was revoked or deleted studio-side (`disconnectRunner`). The
59
+ * stored host token is dead; the machine has to be paired again. */
60
+ export const CLOSE_HOST_REVOKED = 4010;
61
+ /** The Agent row was deleted studio-side (`disconnectAgent`). Nothing to
62
+ * reconnect to. */
63
+ export const CLOSE_AGENT_DELETED = 4011;
64
+ /**
65
+ * Close codes no amount of retrying will resolve. Everything else - network
66
+ * drops, studio restarts (1012), timeouts, 4002, 4003 - keeps the normal
67
+ * backoff-and-retry behaviour.
68
+ */
69
+ export const FATAL_CLOSE_CODES = new Set([
70
+ CLOSE_AUTH_FAILED,
71
+ CLOSE_RUNNER_TAKEN,
72
+ CLOSE_HOST_REVOKED,
73
+ CLOSE_AGENT_DELETED,
74
+ ]);
75
+ /** Operator-facing explanation for a fatal close, including what to do next. */
76
+ export function fatalCloseHint(code, reason) {
77
+ switch (code) {
78
+ case CLOSE_AUTH_FAILED:
79
+ // The studio sends a precise reason ("Cross-org pairing", "Invalid agent
80
+ // token", ...) in an `error` frame just before closing; echo it rather
81
+ // than guessing which of the five cases this was.
82
+ return `${reason || 'authentication failed'} - re-link with \`nordhavn link <code>\``;
83
+ case CLOSE_RUNNER_TAKEN:
84
+ return `${reason || 'this runner already hosts another agent'} - a runner hosts one agent: run this one in its own profile (\`NORDHAVN_PROFILE=<name> nordhavn init\`, then \`nordhavn link <code>\`)`;
85
+ case CLOSE_HOST_REVOKED:
86
+ return `this runner was revoked in the studio - pair again with \`nordhavn link <code>\``;
87
+ case CLOSE_AGENT_DELETED:
88
+ return `this agent no longer exists in the studio - remove it with \`nordhavn agent remove\``;
89
+ default:
90
+ return reason || `closed with code ${code}`;
91
+ }
92
+ }
93
+ // Runtime status - an agent whose status file hasn't been refreshed within
94
+ // this window (the heartbeat runs every 30s) is shown as "stale" by `nordhavn ps`.
95
+ export const STATUS_STALE_MS = 90_000;