@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,76 @@
1
+ import type { ModelMessage, ToolDefinition, CompletionResult, StreamInferenceOptions } from '../inference.js';
2
+ import type { InferenceHint } from '../contract/wire.js';
3
+ /**
4
+ * Side questions (`/btw`): a person asks the agent of a chat something about
5
+ * what it is doing, without stopping or steering its turn.
6
+ *
7
+ * Every model call of a chat turn records what it sent (`recordChatRequest`):
8
+ * the messages as they went out, the tools, and how the call was routed. A side
9
+ * question is answered on top of the last of those (`answerSideQuestion`): the
10
+ * same system prompt, tools and messages, one user message more, so the
11
+ * provider's prompt cache is hit, and `toolChoice: 'none'` so the answer is
12
+ * text in one go. Nothing of it goes back into the turn.
13
+ *
14
+ * Kept in memory per agent and chat, for a while after the turn ended. A chat
15
+ * this process holds nothing for answers `SIDE_QUESTION_NO_CONTEXT`, and the
16
+ * studio answers from the transcript instead.
17
+ */
18
+ /** How long a finished turn's context stays usable for a side question. */
19
+ export declare const SIDE_CONTEXT_TTL_MS: number;
20
+ /** Chats kept at most per process; the oldest goes first. */
21
+ export declare const SIDE_CONTEXT_MAX = 32;
22
+ export interface SideContext {
23
+ /** The request as it went out: a copy of the array, so the loop's later
24
+ * pushes do not change it and the prefix stays the one the provider cached. */
25
+ messages: ModelMessage[];
26
+ tools: ToolDefinition[];
27
+ queueUid?: string;
28
+ inference?: InferenceHint;
29
+ /** What the model answered to that request, once it did. */
30
+ latest?: {
31
+ text: string | null;
32
+ toolCalls: {
33
+ name: string;
34
+ arguments: Record<string, unknown>;
35
+ }[];
36
+ };
37
+ /** The turn is over (its loop returned). */
38
+ done: boolean;
39
+ updatedAt: number;
40
+ }
41
+ /** A chat turn sends a model call: remember it as the base for side questions. */
42
+ export declare function recordChatRequest(agentSlug: string, conversationId: string, req: {
43
+ messages: ModelMessage[];
44
+ tools: ToolDefinition[];
45
+ queueUid?: string;
46
+ inference?: InferenceHint;
47
+ }, now?: number): void;
48
+ /** The model answered the recorded call. */
49
+ export declare function recordChatReply(agentSlug: string, conversationId: string, result: Pick<CompletionResult, 'message' | 'toolCalls'>, now?: number): void;
50
+ /** The chat's turn ended: its context stays for `SIDE_CONTEXT_TTL_MS`. */
51
+ export declare function markChatTurnDone(agentSlug: string, conversationId: string, now?: number): void;
52
+ export declare function getSideContext(agentSlug: string, conversationId: string, now?: number): SideContext | null;
53
+ /** Forget every chat (tests). */
54
+ export declare function clearSideContexts(): void;
55
+ /**
56
+ * Where the turn stands since the recorded request, which the request itself
57
+ * does not hold: what the model answered to it (still running its tools, or
58
+ * the reply that ended the turn). Null when there is nothing to add.
59
+ */
60
+ export declare function describeTurnState(ctx: SideContext): string | null;
61
+ /** The messages of a side question: the recorded request, then one user
62
+ * message with where the turn stands and the studio's rendered prompt. */
63
+ export declare function buildSideQuestionMessages(ctx: SideContext, prompt: string): ModelMessage[];
64
+ export type SideQuestionOutcome = {
65
+ ok: true;
66
+ answer: string;
67
+ } | {
68
+ ok: false;
69
+ error: string;
70
+ };
71
+ export type SideQuestionInference = (opts: Pick<StreamInferenceOptions, 'messages' | 'tools' | 'toolChoice' | 'queueUid' | 'inference' | 'conversationId' | 'signal'>) => Promise<CompletionResult>;
72
+ /**
73
+ * Answer a side question about `conversationId` from what this process holds
74
+ * of its turn: one call, tools listed (the cached prefix) but none allowed.
75
+ */
76
+ export declare function answerSideQuestion(agentSlug: string, conversationId: string, prompt: string, infer: SideQuestionInference): Promise<SideQuestionOutcome>;
@@ -0,0 +1,155 @@
1
+ import { SIDE_QUESTION_NO_CONTEXT } from '../contract/wire.js';
2
+ /**
3
+ * Side questions (`/btw`): a person asks the agent of a chat something about
4
+ * what it is doing, without stopping or steering its turn.
5
+ *
6
+ * Every model call of a chat turn records what it sent (`recordChatRequest`):
7
+ * the messages as they went out, the tools, and how the call was routed. A side
8
+ * question is answered on top of the last of those (`answerSideQuestion`): the
9
+ * same system prompt, tools and messages, one user message more, so the
10
+ * provider's prompt cache is hit, and `toolChoice: 'none'` so the answer is
11
+ * text in one go. Nothing of it goes back into the turn.
12
+ *
13
+ * Kept in memory per agent and chat, for a while after the turn ended. A chat
14
+ * this process holds nothing for answers `SIDE_QUESTION_NO_CONTEXT`, and the
15
+ * studio answers from the transcript instead.
16
+ */
17
+ /** How long a finished turn's context stays usable for a side question. */
18
+ export const SIDE_CONTEXT_TTL_MS = 30 * 60 * 1000;
19
+ /** Chats kept at most per process; the oldest goes first. */
20
+ export const SIDE_CONTEXT_MAX = 32;
21
+ /** Longest piece of the turn's latest reply quoted into the side question. */
22
+ const LATEST_REPLY_MAX = 4000;
23
+ /** Longest argument summary of a running tool call quoted in. */
24
+ const TOOL_ARGS_MAX = 300;
25
+ const contexts = new Map();
26
+ function keyOf(agentSlug, conversationId) {
27
+ return `${agentSlug}\u0000${conversationId}`;
28
+ }
29
+ function prune(now) {
30
+ for (const [key, ctx] of contexts) {
31
+ if (now - ctx.updatedAt > SIDE_CONTEXT_TTL_MS)
32
+ contexts.delete(key);
33
+ }
34
+ while (contexts.size > SIDE_CONTEXT_MAX) {
35
+ const oldest = contexts.keys().next().value;
36
+ if (oldest === undefined)
37
+ break;
38
+ contexts.delete(oldest);
39
+ }
40
+ }
41
+ /** A chat turn sends a model call: remember it as the base for side questions. */
42
+ export function recordChatRequest(agentSlug, conversationId, req, now = Date.now()) {
43
+ const key = keyOf(agentSlug, conversationId);
44
+ contexts.delete(key);
45
+ contexts.set(key, {
46
+ messages: [...req.messages],
47
+ tools: req.tools,
48
+ ...(req.queueUid ? { queueUid: req.queueUid } : {}),
49
+ ...(req.inference ? { inference: req.inference } : {}),
50
+ done: false,
51
+ updatedAt: now,
52
+ });
53
+ prune(now);
54
+ }
55
+ /** The model answered the recorded call. */
56
+ export function recordChatReply(agentSlug, conversationId, result, now = Date.now()) {
57
+ const ctx = contexts.get(keyOf(agentSlug, conversationId));
58
+ if (!ctx)
59
+ return;
60
+ ctx.latest = {
61
+ text: result.message,
62
+ toolCalls: result.toolCalls.map(c => ({ name: c.name, arguments: c.arguments })),
63
+ };
64
+ ctx.updatedAt = now;
65
+ }
66
+ /** The chat's turn ended: its context stays for `SIDE_CONTEXT_TTL_MS`. */
67
+ export function markChatTurnDone(agentSlug, conversationId, now = Date.now()) {
68
+ const ctx = contexts.get(keyOf(agentSlug, conversationId));
69
+ if (!ctx)
70
+ return;
71
+ ctx.done = true;
72
+ ctx.updatedAt = now;
73
+ }
74
+ export function getSideContext(agentSlug, conversationId, now = Date.now()) {
75
+ prune(now);
76
+ return contexts.get(keyOf(agentSlug, conversationId)) ?? null;
77
+ }
78
+ /** Forget every chat (tests). */
79
+ export function clearSideContexts() {
80
+ contexts.clear();
81
+ }
82
+ function clip(text, max) {
83
+ return text.length > max ? `${text.slice(0, max)}...` : text;
84
+ }
85
+ /**
86
+ * Where the turn stands since the recorded request, which the request itself
87
+ * does not hold: what the model answered to it (still running its tools, or
88
+ * the reply that ended the turn). Null when there is nothing to add.
89
+ */
90
+ export function describeTurnState(ctx) {
91
+ const latest = ctx.latest;
92
+ if (!latest) {
93
+ return ctx.done
94
+ ? null
95
+ : 'Where your turn is now: you are working on the request above and have not answered it yet.';
96
+ }
97
+ const lines = [];
98
+ if (latest.toolCalls.length > 0) {
99
+ lines.push(ctx.done
100
+ ? 'Where your turn is now: it ended after this step.'
101
+ : 'Where your turn is now: still running. Your latest step called these tools, their results are not in yet:');
102
+ for (const call of latest.toolCalls) {
103
+ lines.push(`- ${call.name} ${clip(JSON.stringify(call.arguments ?? {}), TOOL_ARGS_MAX)}`);
104
+ }
105
+ if (latest.text?.trim())
106
+ lines.push(`With it you wrote: ${clip(latest.text.trim(), LATEST_REPLY_MAX)}`);
107
+ }
108
+ else if (latest.text?.trim()) {
109
+ lines.push(ctx.done
110
+ ? `Where your turn is now: it ended, and your reply in the chat was:\n${clip(latest.text.trim(), LATEST_REPLY_MAX)}`
111
+ : `Where your turn is now: still running. Your latest text was:\n${clip(latest.text.trim(), LATEST_REPLY_MAX)}`);
112
+ }
113
+ return lines.length ? lines.join('\n') : null;
114
+ }
115
+ /** The messages of a side question: the recorded request, then one user
116
+ * message with where the turn stands and the studio's rendered prompt. */
117
+ export function buildSideQuestionMessages(ctx, prompt) {
118
+ const state = describeTurnState(ctx);
119
+ const text = state ? `<system-reminder>\n${state}\n</system-reminder>\n\n${prompt}` : prompt;
120
+ return [...ctx.messages, { role: 'user', content: text }];
121
+ }
122
+ /** How long one side question may take on the runner; the studio waits a little longer. */
123
+ const SIDE_QUESTION_TIMEOUT_MS = 80_000;
124
+ /**
125
+ * Answer a side question about `conversationId` from what this process holds
126
+ * of its turn: one call, tools listed (the cached prefix) but none allowed.
127
+ */
128
+ export async function answerSideQuestion(agentSlug, conversationId, prompt, infer) {
129
+ const ctx = getSideContext(agentSlug, conversationId);
130
+ if (!ctx)
131
+ return { ok: false, error: SIDE_QUESTION_NO_CONTEXT };
132
+ const signal = AbortSignal.timeout(SIDE_QUESTION_TIMEOUT_MS);
133
+ try {
134
+ const result = await infer({
135
+ messages: buildSideQuestionMessages(ctx, prompt),
136
+ tools: ctx.tools,
137
+ toolChoice: 'none',
138
+ ...(ctx.queueUid ? { queueUid: ctx.queueUid } : {}),
139
+ ...(ctx.inference ? { inference: ctx.inference } : {}),
140
+ conversationId,
141
+ signal,
142
+ });
143
+ const answer = result.message?.trim() ?? '';
144
+ if (!answer) {
145
+ const tried = result.toolCalls.map(c => c.name).join(', ');
146
+ return { ok: false, error: tried ? `The model tried to call ${tried} instead of answering.` : 'The model gave no answer.' };
147
+ }
148
+ return { ok: true, answer };
149
+ }
150
+ catch (err) {
151
+ if (signal.aborted)
152
+ return { ok: false, error: 'The side question took too long.' };
153
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
154
+ }
155
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Helpers for handling `studio_update_task` schema-validation outcomes inside
3
+ * the task runner loop.
4
+ *
5
+ * KEEP IN SYNC WITH packages/os/os-shared/utils/task-validation.ts - that file
6
+ * is the canonical source. The runner copy is vendored because the runner can't import
7
+ * across the repo boundary. Differences kept intentional:
8
+ *
9
+ * - `extractFirstJsonObject` is imported from `./extract-json.js` (the runner has
10
+ * it as a separate module since the chat path also needs it). The OS-side
11
+ * file inlines the same function body verbatim.
12
+ * - Local type names match the OS export names (`TaskResultValidation`,
13
+ * `TaskResultValidationError`) so a future shared package can drop this
14
+ * file in unchanged.
15
+ *
16
+ * The studio's `PUT /api/mcp/tasks/[uid]` handler computes
17
+ * `task.resultJson.validation` whenever a task with `expectedResultJson`
18
+ * receives a structured result. The runner parses that outcome and, when
19
+ * invalid, feeds the field-level errors back to the model as a corrective
20
+ * user message so the next attempt can patch only the broken fields.
21
+ */
22
+ export interface TaskResultValidationError {
23
+ /** Dot-notation path: "author.email", "sections[0].heading" */
24
+ path: string;
25
+ message: string;
26
+ }
27
+ export interface TaskResultValidation {
28
+ valid: boolean;
29
+ errors: TaskResultValidationError[];
30
+ }
31
+ /**
32
+ * Pull the validation outcome out of the `studio_update_task` tool result.
33
+ * Returns `null` when the result contains no parseable JSON or when the
34
+ * server returned no `validation` block (i.e. the task has no result schema
35
+ * or the agent didn't submit `structured`).
36
+ */
37
+ export declare function extractValidationFromUpdateTaskOutput(rawOutput: string): TaskResultValidation | null;
38
+ /**
39
+ * Build a corrective user message listing exactly which fields failed
40
+ * schema validation, so the agent can patch only those fields on the next
41
+ * attempt instead of redoing the whole submission.
42
+ */
43
+ export declare function formatValidationFeedback(errors: TaskResultValidationError[], retriesLeft: number): string;
@@ -0,0 +1,37 @@
1
+ // MIRROR: studio packages/os/os-shared/utils/task-validation.ts
2
+ import { extractFirstJsonObject } from './extract-json.js';
3
+ /**
4
+ * Pull the validation outcome out of the `studio_update_task` tool result.
5
+ * Returns `null` when the result contains no parseable JSON or when the
6
+ * server returned no `validation` block (i.e. the task has no result schema
7
+ * or the agent didn't submit `structured`).
8
+ */
9
+ export function extractValidationFromUpdateTaskOutput(rawOutput) {
10
+ const slice = extractFirstJsonObject(rawOutput);
11
+ if (!slice)
12
+ return null;
13
+ try {
14
+ const parsed = JSON.parse(slice);
15
+ const validation = parsed?.task?.resultJson?.validation;
16
+ if (!validation || typeof validation.valid !== 'boolean')
17
+ return null;
18
+ return validation;
19
+ }
20
+ catch {
21
+ // Best-effort extractor: unparseable output is a graceful null, not an
22
+ // error. Callers with agent context surface it as a runtime note.
23
+ return null;
24
+ }
25
+ }
26
+ /**
27
+ * Build a corrective user message listing exactly which fields failed
28
+ * schema validation, so the agent can patch only those fields on the next
29
+ * attempt instead of redoing the whole submission.
30
+ */
31
+ export function formatValidationFeedback(errors, retriesLeft) {
32
+ const errorList = errors.map(e => `- ${e.path}: ${e.message}`).join('\n');
33
+ const retryHint = retriesLeft > 0
34
+ ? `You have ${retriesLeft} more correction attempt${retriesLeft === 1 ? '' : 's'}.`
35
+ : 'This is your final attempt.';
36
+ return `The structured result you just submitted failed schema validation:\n\n${errorList}\n\nFix ONLY these specific fields and call studio_update_task again with the corrected resultJson. Keep all other fields unchanged. ${retryHint}`;
37
+ }
@@ -0,0 +1,49 @@
1
+ import type { ToolDefPayload, ToolGroupPayload } from '../contract/wire.js';
2
+ /**
3
+ * Tools the RUNTIME executes itself, with neither an `mcpPath` nor an entry in
4
+ * a frontend's local-tool provider.
5
+ *
6
+ * `studio_pin` is intercepted inside the loop (it mutates the pinned-notes
7
+ * block re-injected every round); `studio_unload_toolset` is intercepted in the
8
+ * dispatch handlers (it mutates the per-dispatch registry). Neither can be a
9
+ * `LocalTool`, because both act on state the tool provider cannot see.
10
+ *
11
+ * Exported because the startup grant-drift check (`warnOnToolMismatch` in the
12
+ * CLI) compares the studio's `mcpPath: null` grants against the provider's
13
+ * executor names and would otherwise report these two as missing forever. A
14
+ * warning with a known false positive in it is a warning people stop reading,
15
+ * which is how the genuinely missing `studio_unload_toolset` stayed invisible.
16
+ */
17
+ export declare const RUNTIME_HANDLED_TOOLS: ReadonlySet<string>;
18
+ /**
19
+ * Tools `studio_unload_toolset` refuses to drop.
20
+ *
21
+ * Unloading the loader, the pin store or the delegation tools would leave the
22
+ * agent unable to recover capabilities or coordinate: it could no longer reach
23
+ * `studio_load_toolset` to bring anything back. Kept explicit rather than
24
+ * derived from `bootstrap: true`, so a future bootstrap tool that is genuinely
25
+ * drop-safe can be left out of this set without touching the mechanism.
26
+ *
27
+ * Byte-identical to `UNLOAD_PROTECTED` in the studio's
28
+ * `server/utils/internal-runtime/adapters.ts`. Change one side and change the
29
+ * other in the same change, or the same call strips different tools depending
30
+ * on where the agent happens to run.
31
+ */
32
+ export declare const UNLOAD_PROTECTED: ReadonlySet<string>;
33
+ /**
34
+ * Drop tool schemas from this dispatch's registry so the next inference round
35
+ * ships fewer of them.
36
+ *
37
+ * The mirror of `executeUnloadToolset` on the studio side: same argument shape,
38
+ * same protection set, same wording back to the model. Pure and synchronous -
39
+ * there is no endpoint behind this, only the registry the loop re-reads at the
40
+ * top of every round. The caller owns the `chat:tool-use` / `task:tool-use`
41
+ * framing, exactly as it does for every other tool.
42
+ *
43
+ * `groupForToolName` is built from the dispatch frame's `toolGroups`, i.e. from
44
+ * what this agent was actually granted, so a group key can never reach past it.
45
+ */
46
+ export declare function applyUnloadToolset(args: Record<string, unknown> | undefined, registry: Map<string, ToolDefPayload>, groupForToolName: Map<string, ToolGroupPayload>): {
47
+ result: string;
48
+ isError: boolean;
49
+ };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Tools the RUNTIME executes itself, with neither an `mcpPath` nor an entry in
3
+ * a frontend's local-tool provider.
4
+ *
5
+ * `studio_pin` is intercepted inside the loop (it mutates the pinned-notes
6
+ * block re-injected every round); `studio_unload_toolset` is intercepted in the
7
+ * dispatch handlers (it mutates the per-dispatch registry). Neither can be a
8
+ * `LocalTool`, because both act on state the tool provider cannot see.
9
+ *
10
+ * Exported because the startup grant-drift check (`warnOnToolMismatch` in the
11
+ * CLI) compares the studio's `mcpPath: null` grants against the provider's
12
+ * executor names and would otherwise report these two as missing forever. A
13
+ * warning with a known false positive in it is a warning people stop reading,
14
+ * which is how the genuinely missing `studio_unload_toolset` stayed invisible.
15
+ */
16
+ export const RUNTIME_HANDLED_TOOLS = new Set([
17
+ 'studio_pin',
18
+ 'studio_unload_toolset',
19
+ ]);
20
+ /**
21
+ * Tools `studio_unload_toolset` refuses to drop.
22
+ *
23
+ * Unloading the loader, the pin store or the delegation tools would leave the
24
+ * agent unable to recover capabilities or coordinate: it could no longer reach
25
+ * `studio_load_toolset` to bring anything back. Kept explicit rather than
26
+ * derived from `bootstrap: true`, so a future bootstrap tool that is genuinely
27
+ * drop-safe can be left out of this set without touching the mechanism.
28
+ *
29
+ * Byte-identical to `UNLOAD_PROTECTED` in the studio's
30
+ * `server/utils/internal-runtime/adapters.ts`. Change one side and change the
31
+ * other in the same change, or the same call strips different tools depending
32
+ * on where the agent happens to run.
33
+ */
34
+ export const UNLOAD_PROTECTED = new Set([
35
+ 'studio_load_toolset',
36
+ 'studio_unload_toolset',
37
+ 'studio_get_tool_instructions',
38
+ 'studio_set_activity',
39
+ 'studio_compact',
40
+ 'studio_pin',
41
+ 'studio_call_agent',
42
+ 'studio_ping_agent',
43
+ ]);
44
+ /**
45
+ * Drop tool schemas from this dispatch's registry so the next inference round
46
+ * ships fewer of them.
47
+ *
48
+ * The mirror of `executeUnloadToolset` on the studio side: same argument shape,
49
+ * same protection set, same wording back to the model. Pure and synchronous -
50
+ * there is no endpoint behind this, only the registry the loop re-reads at the
51
+ * top of every round. The caller owns the `chat:tool-use` / `task:tool-use`
52
+ * framing, exactly as it does for every other tool.
53
+ *
54
+ * `groupForToolName` is built from the dispatch frame's `toolGroups`, i.e. from
55
+ * what this agent was actually granted, so a group key can never reach past it.
56
+ */
57
+ export function applyUnloadToolset(args, registry, groupForToolName) {
58
+ const a = (args ?? {});
59
+ const requestedGroup = typeof a.group === 'string' ? a.group.trim() : '';
60
+ const requestedNames = Array.isArray(a.names)
61
+ ? a.names.filter((n) => typeof n === 'string')
62
+ : [];
63
+ if (!requestedGroup && requestedNames.length === 0) {
64
+ return {
65
+ result: 'Error: studio_unload_toolset requires either "group" or "names" (or both).',
66
+ isError: true,
67
+ };
68
+ }
69
+ const candidates = new Set(requestedNames);
70
+ if (requestedGroup) {
71
+ for (const [toolName, group] of groupForToolName) {
72
+ if (group.key === requestedGroup)
73
+ candidates.add(toolName);
74
+ }
75
+ }
76
+ const removed = [];
77
+ const skipped = [];
78
+ for (const name of candidates) {
79
+ if (UNLOAD_PROTECTED.has(name)) {
80
+ skipped.push(name);
81
+ continue;
82
+ }
83
+ if (registry.delete(name))
84
+ removed.push(name);
85
+ }
86
+ const requestLabel = [
87
+ requestedGroup ? `group "${requestedGroup}"` : null,
88
+ requestedNames.length > 0 ? `names ${requestedNames.map(n => `"${n}"`).join(', ')}` : null,
89
+ ]
90
+ .filter(Boolean)
91
+ .join(' + ') || '(no filter)';
92
+ const lines = [];
93
+ if (removed.length === 0) {
94
+ lines.push(`No tools unloaded for ${requestLabel} - either nothing matched or every match was already absent / protected.`);
95
+ }
96
+ else {
97
+ removed.sort();
98
+ lines.push(`Unloaded ${removed.length} tool${removed.length === 1 ? '' : 's'} from ${requestLabel}: ${removed.join(', ')}. Load them again via studio_load_toolset if you need them later.`);
99
+ }
100
+ if (skipped.length > 0) {
101
+ lines.push(`Protected (never unloaded): ${skipped.sort().join(', ')}.`);
102
+ }
103
+ return { result: lines.join('\n'), isError: false };
104
+ }
@@ -0,0 +1,16 @@
1
+ /** A session scope that is well-formed but names no folder in the root (renamed
2
+ * or deleted): the run keeps the relative scope and every write is refused. */
3
+ export interface MissingWriteScope {
4
+ missing: string;
5
+ }
6
+ /** Host seam: validate a dispatch's session scope (`ProjectRef.scope`, a
7
+ * relative POSIX folder) against the root the run works in (the checkout, or
8
+ * the run's own worktree) and return the absolute folder the run may change,
9
+ * a `{ missing }` marker when the folder does not exist (writes blocked), or
10
+ * null when the scope is malformed and ignored (the host logs why). */
11
+ export type ResolveWriteScope = (projectRoot: string, scope: string) => string | MissingWriteScope | null;
12
+ /** The ToolContext fields for a resolved session scope. */
13
+ export declare function writeScopeContext(scope: string | MissingWriteScope | null): {
14
+ writeScope?: string;
15
+ writeScopeMissing?: string;
16
+ };
@@ -0,0 +1,6 @@
1
+ /** The ToolContext fields for a resolved session scope. */
2
+ export function writeScopeContext(scope) {
3
+ if (!scope)
4
+ return {};
5
+ return typeof scope === 'string' ? { writeScope: scope } : { writeScopeMissing: scope.missing };
6
+ }
@@ -0,0 +1,86 @@
1
+ import { type CallOutcome } from '../contract/calls.js';
2
+ import type { ToolContext } from './index.js';
3
+ /** A call's outcome, plus the files of the checkout it changed (`delegate:result`). */
4
+ export type DelegateResultPayload = CallOutcome & {
5
+ ownFiles?: string[];
6
+ };
7
+ /**
8
+ * Correlates outbound `delegate:request` frames with inbound `delegate:result`
9
+ * frames. A minimal one-shot emitter (no `node:events`, so the core stays
10
+ * portable): the connect loop feeds results in via `emit(requestId, ...)`; the
11
+ * tool executor awaits them via `once(requestId, cb)`. Each id fires at most
12
+ * once and is dropped after firing or on timeout.
13
+ */
14
+ declare class OnceEmitter {
15
+ private readonly handlers;
16
+ once(id: string, cb: (payload: DelegateResultPayload) => void): void;
17
+ removeAllListeners(id: string): void;
18
+ emit(id: string, payload: DelegateResultPayload): boolean;
19
+ }
20
+ export declare const delegateEmitter: OnceEmitter;
21
+ /**
22
+ * `studio_call_agent`, runner side. Its face (arguments, limits, clock, result
23
+ * text) is the agent contract's (`contract/calls.ts`), the same code the
24
+ * studio's `executeCallAgent` runs for internal agents; only placing a call
25
+ * (a `delegate:request` frame) is the runner's own.
26
+ */
27
+ declare function executeCallAgent(params: Record<string, unknown>, context?: ToolContext): Promise<string>;
28
+ export declare const delegateTools: {
29
+ definition: {
30
+ name: string;
31
+ description: string;
32
+ parameters: {
33
+ type: string;
34
+ properties: {
35
+ agent: {
36
+ type: string;
37
+ description: string;
38
+ };
39
+ task: {
40
+ type: string;
41
+ description: string;
42
+ };
43
+ context: {
44
+ type: string;
45
+ description: string;
46
+ };
47
+ tier: {
48
+ type: string;
49
+ enum: "explore"[];
50
+ description: string;
51
+ };
52
+ background: {
53
+ type: string;
54
+ description: string;
55
+ };
56
+ batch: {
57
+ type: string;
58
+ maxItems: number;
59
+ description: string;
60
+ items: {
61
+ type: string;
62
+ properties: {
63
+ agent: {
64
+ type: string;
65
+ };
66
+ task: {
67
+ type: string;
68
+ };
69
+ context: {
70
+ type: string;
71
+ };
72
+ tier: {
73
+ type: string;
74
+ enum: "explore"[];
75
+ };
76
+ };
77
+ required: string[];
78
+ };
79
+ };
80
+ };
81
+ required: never[];
82
+ };
83
+ };
84
+ execute: typeof executeCallAgent;
85
+ }[];
86
+ export {};