@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,137 @@
1
+ import { errorLine } from './params.js';
2
+ import { activePage } from './session.js';
3
+ const hubs = new Map();
4
+ /** A frame counts as on time with 10% slack, so jitter does not halve the rate. */
5
+ const THROTTLE_SLACK = 0.9;
6
+ function wantedParams(hub) {
7
+ if (hub.subs.size === 0 || hub.session.pages.length === 0)
8
+ return null;
9
+ let fps = 0;
10
+ let quality = 0;
11
+ let maxWidth = 0;
12
+ for (const sub of hub.subs) {
13
+ fps = Math.max(fps, sub.opts.fps);
14
+ quality = Math.max(quality, sub.opts.quality);
15
+ maxWidth = Math.max(maxWidth, sub.opts.maxWidth);
16
+ }
17
+ const { width, height } = hub.session.viewport;
18
+ const scale = Math.min(1, maxWidth / width);
19
+ return {
20
+ page: activePage(hub.session),
21
+ fps,
22
+ quality,
23
+ width: Math.round(width * scale),
24
+ height: Math.round(height * scale),
25
+ };
26
+ }
27
+ function sameParams(a, b) {
28
+ if (!a || !b)
29
+ return a === b;
30
+ return a.page === b.page && a.fps === b.fps && a.quality === b.quality && a.width === b.width && a.height === b.height;
31
+ }
32
+ function deliver(hub, frame) {
33
+ for (const sub of hub.subs) {
34
+ const interval = 1000 / sub.opts.fps;
35
+ if (sub.lastTs !== null && frame.ts - sub.lastTs < interval * THROTTLE_SLACK)
36
+ continue;
37
+ sub.lastTs = frame.ts;
38
+ try {
39
+ sub.onFrame(frame);
40
+ }
41
+ catch { }
42
+ }
43
+ }
44
+ async function stopParams(params) {
45
+ try {
46
+ await params.page.screencast.hideActions();
47
+ }
48
+ catch { }
49
+ try {
50
+ await params.page.screencast.stop();
51
+ }
52
+ catch { }
53
+ }
54
+ async function startParams(hub, params) {
55
+ try {
56
+ await params.page.screencast.start({
57
+ fps: params.fps,
58
+ quality: params.quality,
59
+ size: { width: params.width, height: params.height },
60
+ onFrame: ({ data, viewportWidth, viewportHeight, timestamp }) => {
61
+ if (hub.running?.page !== params.page)
62
+ return;
63
+ deliver(hub, { data, width: viewportWidth, height: viewportHeight, ts: timestamp });
64
+ },
65
+ });
66
+ hub.running = params;
67
+ hub.failed = null;
68
+ // Show where the agent clicks and what it types, for the person watching.
69
+ await params.page.screencast.showActions({ duration: 600 }).catch(() => { });
70
+ }
71
+ catch (err) {
72
+ hub.failed = params;
73
+ const message = `Screencast failed: ${errorLine(err)}`;
74
+ for (const sub of hub.subs) {
75
+ try {
76
+ sub.onError(message);
77
+ }
78
+ catch { }
79
+ }
80
+ }
81
+ }
82
+ async function reconcileStep(hub) {
83
+ const want = wantedParams(hub);
84
+ if (want && !hub.running && sameParams(hub.failed, want))
85
+ return;
86
+ if (sameParams(hub.running, want)) {
87
+ if (!want && hubs.get(hub.session.id) === hub)
88
+ hubs.delete(hub.session.id);
89
+ return;
90
+ }
91
+ if (hub.running) {
92
+ const running = hub.running;
93
+ hub.running = null;
94
+ await stopParams(running);
95
+ }
96
+ if (want)
97
+ await startParams(hub, want);
98
+ else if (hub.subs.size === 0 && hubs.get(hub.session.id) === hub)
99
+ hubs.delete(hub.session.id);
100
+ }
101
+ function reconcile(hub) {
102
+ hub.chain = hub.chain.then(() => reconcileStep(hub));
103
+ return hub.chain;
104
+ }
105
+ /**
106
+ * Receive the frames of a session's active tab. The first subscriber starts
107
+ * the screencast; the returned function unsubscribes and resolves once the
108
+ * cast has adapted (stopped after the last one).
109
+ */
110
+ export function subscribeCast(session, opts, onFrame, onError) {
111
+ let hub = hubs.get(session.id);
112
+ if (!hub) {
113
+ hub = { session, subs: new Set(), running: null, failed: null, chain: Promise.resolve() };
114
+ hubs.set(session.id, hub);
115
+ }
116
+ hub.session = session;
117
+ hub.failed = null;
118
+ const sub = { opts, onFrame, onError, lastTs: null };
119
+ hub.subs.add(sub);
120
+ void reconcile(hub);
121
+ const owner = hub;
122
+ return () => {
123
+ owner.subs.delete(sub);
124
+ return reconcile(owner);
125
+ };
126
+ }
127
+ /**
128
+ * Follow a change of the session: another active tab, a new viewport. Call it
129
+ * on every session event; it resolves once the cast matches the session again.
130
+ */
131
+ export function refreshCast(session) {
132
+ const hub = hubs.get(session.id);
133
+ if (!hub)
134
+ return Promise.resolve();
135
+ hub.session = session;
136
+ return reconcile(hub);
137
+ }
@@ -0,0 +1,21 @@
1
+ import type { ToolContext } from '@nordhavnhq/runner-runtime';
2
+ /** True when the URL is on a host where submits can spend money. */
3
+ export declare function isGuardedUrl(url: string): boolean;
4
+ export interface GuardInput {
5
+ url: string;
6
+ /** Visible label of the target (text, aria-label, value, title). */
7
+ label: string;
8
+ /** The target submits a form (type=submit, Enter in a form field). */
9
+ submits?: boolean;
10
+ }
11
+ /** Why the action is gated, or null when it is free to run. */
12
+ export declare function gateReason(input: GuardInput): string | null;
13
+ /** Why a runner_browser_eval script is gated, or null when it may run. */
14
+ export declare function scriptGateReason(url: string, expression: string): string | null;
15
+ /**
16
+ * Null when the action may run; otherwise the refusal the tool returns.
17
+ * `confirmed` is the tool's `confirmed` param.
18
+ */
19
+ export declare function checkGate(input: GuardInput, confirmed: unknown, context: ToolContext | undefined): string | null;
20
+ /** The confirm-first gate for runner_browser_eval. */
21
+ export declare function checkScriptGate(url: string, expression: string, confirmed: unknown, context: ToolContext | undefined): string | null;
@@ -0,0 +1,104 @@
1
+ // ─── Confirm-first gate for actions that spend money or go public ───────────
2
+ //
3
+ // A browser agent may prepare anything (a campaign draft, a basket, a post),
4
+ // but the click that publishes it, pays for it or turns it on is the person's.
5
+ // The gate looks at the page's host and the label of the element the action
6
+ // targets:
7
+ // - a label that commits money or publishes (pay, place order, publish, ...)
8
+ // is gated on every site;
9
+ // - on ad, billing and payment hosts a confirm/submit/enable label is gated too,
10
+ // because there "Save" or "Confirm" can start spending.
11
+ // In a task run (nobody to ask) a gated action is refused. In a chat it runs
12
+ // only with `confirmed: true`, which the agent may pass only after the person
13
+ // said yes to THIS action in the chat; otherwise it hands over with
14
+ // runner_browser_handoff.
15
+ const COMMIT_LABEL = new RegExp([
16
+ 'publish', 'publiceer', 'publiceren', 'go live', 'live zetten', 'launch', 'lanceer', 'lanceren',
17
+ 'pay', 'pay now', 'betaal', 'betalen', 'afrekenen',
18
+ 'place order', 'bestelling plaatsen', 'plaats bestelling', 'bestellen', 'buy', 'buy now', 'kopen', 'nu kopen', 'purchase', 'aankopen',
19
+ 'subscribe', 'abonneren', 'upgrade', 'start (?:the )?campaign', 'campagne (?:starten|activeren|publiceren)',
20
+ 'activate campaign', 'boost', 'promote', 'add funds', 'add payment', 'tegoed toevoegen',
21
+ 'delete account', 'account verwijderen', 'transfer domain', 'domein overdragen',
22
+ ].map(w => `\\b${w}\\b`).join('|'), 'i');
23
+ const SUBMIT_LABEL = /\b(confirm|bevestig|bevestigen|submit|indienen|verzenden|send|enable|inschakelen|turn on|activate|activeer|activeren|save and publish|review and publish|done|klaar|continue to payment)\b/i;
24
+ const GUARDED_HOSTS = [
25
+ 'ads.google.com',
26
+ 'adwords.google.com',
27
+ 'pay.google.com',
28
+ 'payments.google.com',
29
+ 'business.google.com',
30
+ 'adsmanager.facebook.com',
31
+ 'business.facebook.com',
32
+ 'www.facebook.com/adsmanager',
33
+ 'www.facebook.com/ads',
34
+ 'ads.tiktok.com',
35
+ 'ads.linkedin.com',
36
+ 'www.linkedin.com/campaignmanager',
37
+ 'ads.microsoft.com',
38
+ 'ui.ads.microsoft.com',
39
+ 'checkout.stripe.com',
40
+ 'dashboard.stripe.com',
41
+ 'www.paypal.com',
42
+ 'my.mollie.com',
43
+ 'www.mollie.com/checkout',
44
+ ];
45
+ /** True when the URL is on a host where submits can spend money. */
46
+ export function isGuardedUrl(url) {
47
+ let u;
48
+ try {
49
+ u = new URL(url);
50
+ }
51
+ catch {
52
+ return false;
53
+ }
54
+ const hostPath = `${u.hostname}${u.pathname}`.toLowerCase();
55
+ return GUARDED_HOSTS.some(h => hostPath === h || hostPath.startsWith(h.endsWith('/') ? h : `${h}/`) || u.hostname.toLowerCase() === h);
56
+ }
57
+ /** Why the action is gated, or null when it is free to run. */
58
+ export function gateReason(input) {
59
+ const label = input.label.replace(/\s+/g, ' ').trim().slice(0, 120);
60
+ if (label && COMMIT_LABEL.test(label))
61
+ return `"${label}" looks like it publishes, pays or commits`;
62
+ if (isGuardedUrl(input.url)) {
63
+ if (label && SUBMIT_LABEL.test(label))
64
+ return `"${label}" on ${new URL(input.url).hostname} can start spending`;
65
+ if (input.submits)
66
+ return `a form submit on ${new URL(input.url).hostname} can start spending`;
67
+ }
68
+ return null;
69
+ }
70
+ /** A script that clicks or submits something itself. Not watertight (an
71
+ * event dispatch slips through), but it closes the obvious side door. */
72
+ const SCRIPT_ACTS = /\.\s*(click|submit|requestSubmit)\s*\(/;
73
+ /** Why a runner_browser_eval script is gated, or null when it may run. */
74
+ export function scriptGateReason(url, expression) {
75
+ if (isGuardedUrl(url))
76
+ return `a script on ${new URL(url).hostname} can start spending`;
77
+ if (SCRIPT_ACTS.test(expression))
78
+ return 'a script that clicks or submits skips the label check (use runner_browser_click or runner_browser_type instead)';
79
+ return null;
80
+ }
81
+ /**
82
+ * Null when the action may run; otherwise the refusal the tool returns.
83
+ * `confirmed` is the tool's `confirmed` param.
84
+ */
85
+ export function checkGate(input, confirmed, context) {
86
+ return refusal(gateReason(input), confirmed, context);
87
+ }
88
+ /** The confirm-first gate for runner_browser_eval. */
89
+ export function checkScriptGate(url, expression, confirmed, context) {
90
+ return refusal(scriptGateReason(url, expression), confirmed, context);
91
+ }
92
+ function refusal(reason, confirmed, context) {
93
+ if (!reason)
94
+ return null;
95
+ if (context?.userPresent !== true) {
96
+ return `Blocked: ${reason}. In a task run nobody can confirm it, so agents never do this themselves. ` +
97
+ 'Leave everything prepared up to this step, call runner_browser_handoff with what is ready, and report it in the task result.';
98
+ }
99
+ if (confirmed === true)
100
+ return null;
101
+ return `Blocked: ${reason}. Ask the person in this chat whether to do exactly this (what, where, what it costs). ` +
102
+ 'Only after an explicit yes for this action call the tool again with confirmed: true. ' +
103
+ 'Or call runner_browser_handoff so they click it themselves in the live view.';
104
+ }
@@ -0,0 +1,47 @@
1
+ import type { ToolContext } from '@nordhavnhq/runner-runtime';
2
+ /** The agent a frame is about. The studio says who; the host never decides it. */
3
+ export interface HostAgent {
4
+ id: number;
5
+ slug: string;
6
+ organisationSlug: string;
7
+ }
8
+ /** What a tool call runs with on the host: the dispatch's facts, no file system of the agent's. */
9
+ export interface HostCallContext {
10
+ conversationId?: string | null;
11
+ queueUid?: string | null;
12
+ taskUid?: string | null;
13
+ projectSlug?: string | null;
14
+ /** A person is on the other end and can say yes to a gated action (a chat). */
15
+ userPresent?: boolean;
16
+ }
17
+ export type StudioToHostFrame = {
18
+ type: 'host:call';
19
+ callId: string;
20
+ agent: HostAgent;
21
+ tool: string;
22
+ params: Record<string, unknown>;
23
+ context: HostCallContext;
24
+ };
25
+ export interface HostImage {
26
+ /** Base64. */
27
+ data: string;
28
+ mediaType: string;
29
+ }
30
+ export type HostToStudioFrame = {
31
+ type: 'host:result';
32
+ callId: string;
33
+ text: string;
34
+ images: HostImage[];
35
+ };
36
+ /** The names the host answers to (`runner_browser_*`): the studio maps its own names onto them. */
37
+ export declare function hostToolNames(): string[];
38
+ /**
39
+ * Run one browser tool for an agent and collect what it hands back: the text
40
+ * and any inline images (screenshots). Never throws: an unknown tool or a
41
+ * crash is an error line, like a tool result on a runner.
42
+ */
43
+ export declare function runHostCall(frame: Extract<StudioToHostFrame, {
44
+ type: 'host:call';
45
+ }>, base: Pick<ToolContext, 'agentHome' | 'studioUrl'>): Promise<Extract<HostToStudioFrame, {
46
+ type: 'host:result';
47
+ }>>;
@@ -0,0 +1,41 @@
1
+ import { actTools } from './act-tools.js';
2
+ import { pageTools } from './page-tools.js';
3
+ import { errorLine } from './params.js';
4
+ import { showTools } from './show.js';
5
+ import { tourTools } from './tour.js';
6
+ const tools = new Map([...pageTools, ...actTools, ...showTools, ...tourTools].map(t => [t.definition.name, t]));
7
+ /** The names the host answers to (`runner_browser_*`): the studio maps its own names onto them. */
8
+ export function hostToolNames() {
9
+ return [...tools.keys()];
10
+ }
11
+ /**
12
+ * Run one browser tool for an agent and collect what it hands back: the text
13
+ * and any inline images (screenshots). Never throws: an unknown tool or a
14
+ * crash is an error line, like a tool result on a runner.
15
+ */
16
+ export async function runHostCall(frame, base) {
17
+ const reply = (text, images = []) => ({ type: 'host:result', callId: frame.callId, text, images });
18
+ const tool = tools.get(frame.tool);
19
+ if (!tool)
20
+ return reply(`Error: Unknown browser tool "${frame.tool}".`);
21
+ const pendingToolImages = [];
22
+ const context = {
23
+ ...base,
24
+ agentSlug: frame.agent.slug,
25
+ organisationSlug: frame.agent.organisationSlug,
26
+ conversationId: frame.context.conversationId ?? undefined,
27
+ queueUid: frame.context.queueUid ?? undefined,
28
+ taskUid: frame.context.taskUid ?? undefined,
29
+ projectSlug: frame.context.projectSlug ?? undefined,
30
+ userPresent: frame.context.userPresent === true,
31
+ pendingToolImages,
32
+ };
33
+ let text;
34
+ try {
35
+ text = await tool.execute(frame.params ?? {}, context);
36
+ }
37
+ catch (err) {
38
+ text = `Error: ${errorLine(err)}`;
39
+ }
40
+ return reply(text, pendingToolImages.map(i => ({ data: i.data.toString('base64'), mediaType: i.mediaType })));
41
+ }
@@ -0,0 +1,18 @@
1
+ import type { ToolContext } from '@nordhavnhq/runner-runtime';
2
+ /**
3
+ * What the browser needs from the process it runs in, and cannot know itself:
4
+ * where a path an agent names is on disk, and how an image reaches the studio.
5
+ * The runner plugs in its jail and its agent-token upload; the studio server
6
+ * (internal agents) plugs in nothing. Unset, both refuse, so a
7
+ * missing hook is an error the agent reads, never a silent wrong path.
8
+ */
9
+ export interface BrowserHost {
10
+ /** A path the agent named, made absolute and checked (runner: `resolveForRead` of its jail). Throws when it may not be read. */
11
+ resolveForRead: (path: string, context: ToolContext | undefined) => string;
12
+ /** Store an image in the studio's file manager; returns the line the tool result carries. */
13
+ uploadImage: (data: Buffer, filename: string, folder: string, context: ToolContext, projectFolder?: string) => Promise<string>;
14
+ }
15
+ /** Plug in the process's hooks, once at start-up. */
16
+ export declare function setBrowserHost(next: BrowserHost): void;
17
+ export declare function resolveForRead(path: string, context: ToolContext | undefined): string;
18
+ export declare function uploadImage(data: Buffer, filename: string, folder: string, context: ToolContext, projectFolder?: string): Promise<string>;
@@ -0,0 +1,15 @@
1
+ const refuse = {
2
+ resolveForRead: () => { throw new Error('Files on disk are not available to this browser.'); },
3
+ uploadImage: async () => { throw new Error('Saving files is not available to this browser.'); },
4
+ };
5
+ let host = refuse;
6
+ /** Plug in the process's hooks, once at start-up. */
7
+ export function setBrowserHost(next) {
8
+ host = next;
9
+ }
10
+ export function resolveForRead(path, context) {
11
+ return host.resolveForRead(path, context);
12
+ }
13
+ export function uploadImage(data, filename, folder, context, projectFolder) {
14
+ return host.uploadImage(data, filename, folder, context, projectFolder);
15
+ }
@@ -0,0 +1,13 @@
1
+ export declare const browserTools: {
2
+ definition: import("@nordhavnhq/runner-runtime").ToolDefinition;
3
+ execute: (params: Record<string, unknown>, context?: import("@nordhavnhq/runner-runtime").ToolContext) => Promise<string>;
4
+ }[];
5
+ export { setBrowserHost, type BrowserHost } from './host.js';
6
+ export { onSessionEvent, listSessions, sessionById, describeSession, closeSession, closeAllSessions, reapIdle, findChromeBinary, type BrowserSession, type SessionOwner, } from './session.js';
7
+ export { createLiveController, summarise, type BrowserSessionSummary, type LiveController, type LiveInFrame, type LiveOptions, type LiveOutFrame, type LiveScope, type OpenPersonSession, } from './live.js';
8
+ export { subscribeCast, refreshCast, type CastFrame, type CastOptions } from './cast-hub.js';
9
+ export { startLocalLiveServer, defaultLocalLiveDir, LOCAL_LIVE_PROTOCOL, type LocalLiveAgent, type LocalLiveDeps, type LocalLiveServer, } from './local-live.js';
10
+ export { hostToolNames, runHostCall, type HostAgent, type HostCallContext, type HostImage, type HostToStudioFrame, type StudioToHostFrame, } from './host-protocol.js';
11
+ export { personSessionOpener } from './live-open.js';
12
+ export { checkGate, gateReason, isGuardedUrl } from './guard.js';
13
+ export { liveUrlOf } from './show.js';
@@ -0,0 +1,28 @@
1
+ import { pageTools } from './page-tools.js';
2
+ import { actTools } from './act-tools.js';
3
+ import { showTools } from './show.js';
4
+ import { tourTools } from './tour.js';
5
+ // ─── The agent browser (@nordhavnhq/runner-browser) ─────────────────────────────────
6
+ //
7
+ // Playwright browser automation for agents. Unlike `runner_capture_webpage`
8
+ // (one screenshot of a public URL), these tools drive a persistent browser
9
+ // across calls: open pages (local dev servers too), read them as an
10
+ // accessibility snapshot with element refs, act on those refs, read console
11
+ // and network failures, keep logins in named profiles, hand the wheel to a
12
+ // person in the live view, or show them something there (show.ts). See
13
+ // session.ts for the lifecycle and guard.ts for the confirm-first gate on
14
+ // actions that publish or pay.
15
+ //
16
+ // Two processes run it: the runner (an agent's own machine) and the studio
17
+ // server (utils/browser-host, for agents without a runner). The runner plugs
18
+ // in what only it knows with `setBrowserHost` (host.ts).
19
+ export const browserTools = [...pageTools, ...actTools, ...showTools, ...tourTools];
20
+ export { setBrowserHost } from './host.js';
21
+ export { onSessionEvent, listSessions, sessionById, describeSession, closeSession, closeAllSessions, reapIdle, findChromeBinary, } from './session.js';
22
+ export { createLiveController, summarise, } from './live.js';
23
+ export { subscribeCast, refreshCast } from './cast-hub.js';
24
+ export { startLocalLiveServer, defaultLocalLiveDir, LOCAL_LIVE_PROTOCOL, } from './local-live.js';
25
+ export { hostToolNames, runHostCall, } from './host-protocol.js';
26
+ export { personSessionOpener } from './live-open.js';
27
+ export { checkGate, gateReason, isGuardedUrl } from './guard.js';
28
+ export { liveUrlOf } from './show.js';
@@ -0,0 +1,74 @@
1
+ import { type BrowserSession } from './session.js';
2
+ export type BrowserInput = {
3
+ kind: 'click';
4
+ x: number;
5
+ y: number;
6
+ button?: 'left' | 'right' | 'middle';
7
+ double?: boolean;
8
+ } | {
9
+ kind: 'move';
10
+ x: number;
11
+ y: number;
12
+ } | {
13
+ kind: 'wheel';
14
+ x: number;
15
+ y: number;
16
+ deltaX?: number;
17
+ deltaY: number;
18
+ } | {
19
+ kind: 'key';
20
+ key: string;
21
+ } | {
22
+ kind: 'text';
23
+ text: string;
24
+ } | {
25
+ kind: 'navigate';
26
+ url: string;
27
+ } | {
28
+ kind: 'history';
29
+ action: 'back' | 'forward' | 'reload';
30
+ } | {
31
+ kind: 'tab';
32
+ index: number;
33
+ } | {
34
+ kind: 'tab-new';
35
+ url?: string;
36
+ } | {
37
+ kind: 'tab-close';
38
+ index: number;
39
+ } | {
40
+ kind: 'takeover';
41
+ } | {
42
+ kind: 'release';
43
+ } | {
44
+ kind: 'close';
45
+ }
46
+ /** Go to a stop of the agent's tour (0-based). */
47
+ | {
48
+ kind: 'tour-step';
49
+ index: number;
50
+ } | {
51
+ kind: 'tour-end';
52
+ }
53
+ /** Point at the element under (x, y): answered with `browser:picked` (live.ts), not applied here. */
54
+ | {
55
+ kind: 'pick';
56
+ x: number;
57
+ y: number;
58
+ pickId: string;
59
+ }
60
+ /** Drop the ring of the person's pick. */
61
+ | {
62
+ kind: 'pick-clear';
63
+ };
64
+ /** What a person types in the address bar, as a URL: a local dev server gets http. */
65
+ export declare function withScheme(url: string): string;
66
+ /** Viewers send coordinates as fractions of the frame, so frame scaling never matters. */
67
+ export declare function toPixels(scope: {
68
+ session: BrowserSession;
69
+ }, input: {
70
+ x: number;
71
+ y: number;
72
+ }): [number, number];
73
+ /** Apply one input to the session; an unknown kind does nothing. */
74
+ export declare function applyInput(session: BrowserSession, input: BrowserInput, closeSession: (key: string) => Promise<void>): Promise<void>;
@@ -0,0 +1,93 @@
1
+ import { clearMarks } from './marks.js';
2
+ import { activePage, emit, trackPage } from './session.js';
3
+ import { endTour, goToStop } from './tour.js';
4
+ /** What a person types in the address bar, as a URL: a local dev server gets http. */
5
+ export function withScheme(url) {
6
+ if (/^[a-z]+:/i.test(url) && !/^(localhost|127\.0\.0\.1|\[::1\]):\d/i.test(url))
7
+ return url;
8
+ return /^(localhost|127\.0\.0\.1|\[::1\])([:/]|$)/i.test(url) ? `http://${url}` : `https://${url}`;
9
+ }
10
+ /** Viewers send coordinates as fractions of the frame, so frame scaling never matters. */
11
+ export function toPixels(scope, input) {
12
+ const px = (f, size) => Math.round(Math.min(Math.max(f, 0), 1) * size);
13
+ return [px(input.x, scope.session.viewport.width), px(input.y, scope.session.viewport.height)];
14
+ }
15
+ const handlers = {
16
+ async click(input, scope) {
17
+ const [x, y] = toPixels(scope, input);
18
+ await scope.page.mouse.click(x, y, { button: input.button ?? 'left', clickCount: input.double ? 2 : 1 });
19
+ },
20
+ async move(input, scope) {
21
+ await scope.page.mouse.move(...toPixels(scope, input));
22
+ },
23
+ async wheel(input, scope) {
24
+ await scope.page.mouse.move(...toPixels(scope, input));
25
+ await scope.page.mouse.wheel(input.deltaX ?? 0, input.deltaY);
26
+ },
27
+ async key(input, scope) {
28
+ await scope.page.keyboard.press(input.key);
29
+ },
30
+ async text(input, scope) {
31
+ await scope.page.keyboard.insertText(input.text.slice(0, 5_000));
32
+ },
33
+ async navigate(input, scope) {
34
+ await scope.page.goto(withScheme(input.url), { waitUntil: 'domcontentloaded' });
35
+ },
36
+ async history(input, scope) {
37
+ if (input.action === 'back')
38
+ await scope.page.goBack();
39
+ else if (input.action === 'forward')
40
+ await scope.page.goForward();
41
+ else
42
+ await scope.page.reload();
43
+ },
44
+ async tab(input, { session }) {
45
+ if (!(input.index >= 0 && input.index < session.pages.length))
46
+ return;
47
+ session.active = input.index;
48
+ emit({ type: 'changed', session });
49
+ },
50
+ async 'tab-new'(input, { session }) {
51
+ const page = await session.context.newPage();
52
+ trackPage(session, page);
53
+ session.active = session.pages.indexOf(page);
54
+ emit({ type: 'changed', session });
55
+ if (input.url)
56
+ await page.goto(withScheme(input.url), { waitUntil: 'domcontentloaded' });
57
+ },
58
+ async 'tab-close'(input, { session }) {
59
+ // The last tab stays: closing it is closing the session, which has its own button.
60
+ if (session.pages.length < 2)
61
+ return;
62
+ const page = session.pages[input.index];
63
+ if (page)
64
+ await page.close();
65
+ },
66
+ async takeover(_input, { session }) {
67
+ session.handoff = session.handoff ?? { reason: 'Taken over by a person', at: Date.now() };
68
+ emit({ type: 'changed', session });
69
+ },
70
+ async release(_input, { session }) {
71
+ session.handoff = null;
72
+ emit({ type: 'changed', session });
73
+ },
74
+ async close(_input, { session, closeSession }) {
75
+ await closeSession(session.key);
76
+ },
77
+ async 'tour-step'(input, { session }) {
78
+ await goToStop(session, input.index);
79
+ },
80
+ async 'tour-end'(_input, { session }) {
81
+ await endTour(session);
82
+ },
83
+ async 'pick-clear'(_input, { page }) {
84
+ await clearMarks(page, 'pick');
85
+ },
86
+ };
87
+ /** Apply one input to the session; an unknown kind does nothing. */
88
+ export async function applyInput(session, input, closeSession) {
89
+ if (input.kind === 'pick' || !Object.hasOwn(handlers, input.kind))
90
+ return;
91
+ const handler = handlers[input.kind];
92
+ await handler(input, { session, page: activePage(session), closeSession });
93
+ }
@@ -0,0 +1,4 @@
1
+ import type { ToolContext } from '@nordhavnhq/runner-runtime';
2
+ import type { OpenPersonSession } from './live.js';
3
+ /** The opener for this agent's live view: `context` names the agent and its home. */
4
+ export declare function personSessionOpener(context: () => ToolContext): OpenPersonSession;
@@ -0,0 +1,57 @@
1
+ import { withScheme } from './live-input.js';
2
+ import { activePage, emit, ensureSession, normaliseProfile, resolveDevice, resolveViewport } from './session.js';
3
+ // A browser window a person opens from the Browser app, without an agent run.
4
+ // It runs on this agent's runner (profiles in the agent's home), under a key of
5
+ // its own: no dispatch ever shares it, and the person drives it from the start.
6
+ const OPEN_SCHEMES = new Set(['http:', 'https:', 'about:']);
7
+ function readOptions(frame) {
8
+ const profile = normaliseProfile(frame.profile);
9
+ if (profile && typeof profile === 'object')
10
+ return { error: profile.error };
11
+ let viewport;
12
+ if (frame.viewport !== undefined) {
13
+ const vp = resolveViewport(frame.viewport);
14
+ if ('error' in vp)
15
+ return { error: vp.error };
16
+ viewport = vp;
17
+ }
18
+ return {
19
+ profile,
20
+ headed: frame.headed === true,
21
+ viewport,
22
+ device: frame.viewport === undefined ? undefined : resolveDevice(frame.viewport),
23
+ };
24
+ }
25
+ function startUrl(raw) {
26
+ if (!raw?.trim())
27
+ return null;
28
+ const url = withScheme(raw.trim());
29
+ try {
30
+ if (!OPEN_SCHEMES.has(new URL(url).protocol))
31
+ return { error: `Unsupported URL scheme in "${raw}".` };
32
+ }
33
+ catch {
34
+ return { error: `Invalid URL "${raw}".` };
35
+ }
36
+ return url;
37
+ }
38
+ /** The opener for this agent's live view: `context` names the agent and its home. */
39
+ export function personSessionOpener(context) {
40
+ return async (frame) => {
41
+ const options = readOptions(frame);
42
+ if ('error' in options)
43
+ return options;
44
+ const url = startUrl(frame.url);
45
+ if (url && typeof url === 'object')
46
+ return url;
47
+ const opened = await ensureSession(context(), options, { userId: frame.byUserId, name: frame.by });
48
+ if ('error' in opened)
49
+ return opened;
50
+ if (url) {
51
+ // A page that does not load is still an open window the person can retry in.
52
+ await activePage(opened.session).goto(url, { waitUntil: 'domcontentloaded' }).catch(() => { });
53
+ emit({ type: 'changed', session: opened.session });
54
+ }
55
+ return { session: opened.session };
56
+ };
57
+ }