@nordhavnhq/runner 0.0.0-stage → 0.96.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.
- package/bin/cliclick +0 -0
- package/dist/brand.d.ts +5 -0
- package/dist/brand.js +18 -0
- package/dist/cli/agent.d.ts +9 -0
- package/dist/cli/agent.js +39 -0
- package/dist/cli/folder.d.ts +2 -0
- package/dist/cli/folder.js +103 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +67 -0
- package/dist/cli/lifecycle.d.ts +3 -0
- package/dist/cli/lifecycle.js +149 -0
- package/dist/cli/link.d.ts +20 -0
- package/dist/cli/link.js +312 -0
- package/dist/cli/logs.d.ts +2 -0
- package/dist/cli/logs.js +144 -0
- package/dist/cli/prompts.d.ts +7 -0
- package/dist/cli/prompts.js +13 -0
- package/dist/cli/ps.d.ts +2 -0
- package/dist/cli/ps.js +80 -0
- package/dist/cli/relay.d.ts +4 -0
- package/dist/cli/relay.js +29 -0
- package/dist/cli/update.d.ts +6 -0
- package/dist/cli/update.js +131 -0
- package/dist/config.d.ts +166 -0
- package/dist/config.js +383 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +135 -0
- package/dist/legacy-env.d.ts +4 -0
- package/dist/legacy-env.js +32 -0
- package/dist/paths.d.ts +37 -0
- package/dist/paths.js +92 -0
- package/dist/runtime/daemon.d.ts +57 -0
- package/dist/runtime/daemon.js +159 -0
- package/dist/runtime/dev-start.d.ts +31 -0
- package/dist/runtime/dev-start.js +110 -0
- package/dist/runtime/file-claims.d.ts +58 -0
- package/dist/runtime/file-claims.js +174 -0
- package/dist/runtime/fs-browse.d.ts +18 -0
- package/dist/runtime/fs-browse.js +104 -0
- package/dist/runtime/fs-checkout.d.ts +154 -0
- package/dist/runtime/fs-checkout.js +1049 -0
- package/dist/runtime/fs-git-index.d.ts +22 -0
- package/dist/runtime/fs-git-index.js +133 -0
- package/dist/runtime/fs-git.d.ts +16 -0
- package/dist/runtime/fs-git.js +424 -0
- package/dist/runtime/git-relay.d.ts +46 -0
- package/dist/runtime/git-relay.js +259 -0
- package/dist/runtime/git-unpushed.d.ts +36 -0
- package/dist/runtime/git-unpushed.js +93 -0
- package/dist/runtime/node-version.d.ts +12 -0
- package/dist/runtime/node-version.js +39 -0
- package/dist/runtime/preview-tunnel.d.ts +16 -0
- package/dist/runtime/preview-tunnel.js +135 -0
- package/dist/runtime/processes.d.ts +61 -0
- package/dist/runtime/processes.js +408 -0
- package/dist/runtime/project-node-download.d.ts +17 -0
- package/dist/runtime/project-node-download.js +137 -0
- package/dist/runtime/project-node.d.ts +65 -0
- package/dist/runtime/project-node.js +223 -0
- package/dist/runtime/reap-scratch.d.ts +22 -0
- package/dist/runtime/reap-scratch.js +112 -0
- package/dist/runtime/spill-tool-output.d.ts +14 -0
- package/dist/runtime/spill-tool-output.js +84 -0
- package/dist/runtime/up.d.ts +6 -0
- package/dist/runtime/up.js +1324 -0
- package/dist/tools/_coerce.d.ts +2 -0
- package/dist/tools/_coerce.js +26 -0
- package/dist/tools/_commit-scope.d.ts +14 -0
- package/dist/tools/_commit-scope.js +70 -0
- package/dist/tools/_jail.d.ts +68 -0
- package/dist/tools/_jail.js +209 -0
- package/dist/tools/_output.d.ts +24 -0
- package/dist/tools/_output.js +48 -0
- package/dist/tools/_ripgrep.d.ts +46 -0
- package/dist/tools/_ripgrep.js +148 -0
- package/dist/tools/_run-worktree.d.ts +10 -0
- package/dist/tools/_run-worktree.js +27 -0
- package/dist/tools/_shell-words.d.ts +15 -0
- package/dist/tools/_shell-words.js +43 -0
- package/dist/tools/_sonar/astro.d.ts +6 -0
- package/dist/tools/_sonar/astro.js +45 -0
- package/dist/tools/_sonar/blade.d.ts +3 -0
- package/dist/tools/_sonar/blade.js +53 -0
- package/dist/tools/_sonar/build.d.ts +44 -0
- package/dist/tools/_sonar/build.js +147 -0
- package/dist/tools/_sonar/changed.d.ts +21 -0
- package/dist/tools/_sonar/changed.js +230 -0
- package/dist/tools/_sonar/diagnose/delta.d.ts +27 -0
- package/dist/tools/_sonar/diagnose/delta.js +64 -0
- package/dist/tools/_sonar/diagnose/detect.d.ts +39 -0
- package/dist/tools/_sonar/diagnose/detect.js +117 -0
- package/dist/tools/_sonar/diagnose/index.d.ts +13 -0
- package/dist/tools/_sonar/diagnose/index.js +217 -0
- package/dist/tools/_sonar/diagnose/lint-worker.d.ts +1 -0
- package/dist/tools/_sonar/diagnose/lint-worker.js +48 -0
- package/dist/tools/_sonar/diagnose/pool.d.ts +22 -0
- package/dist/tools/_sonar/diagnose/pool.js +149 -0
- package/dist/tools/_sonar/diagnose/rules.d.ts +23 -0
- package/dist/tools/_sonar/diagnose/rules.js +131 -0
- package/dist/tools/_sonar/diagnose/types-worker.d.ts +1 -0
- package/dist/tools/_sonar/diagnose/types-worker.js +183 -0
- package/dist/tools/_sonar/files.d.ts +14 -0
- package/dist/tools/_sonar/files.js +121 -0
- package/dist/tools/_sonar/graph.d.ts +34 -0
- package/dist/tools/_sonar/graph.js +164 -0
- package/dist/tools/_sonar/hints.d.ts +116 -0
- package/dist/tools/_sonar/hints.js +545 -0
- package/dist/tools/_sonar/imports.d.ts +38 -0
- package/dist/tools/_sonar/imports.js +275 -0
- package/dist/tools/_sonar/index.d.ts +79 -0
- package/dist/tools/_sonar/index.js +462 -0
- package/dist/tools/_sonar/keys.d.ts +5 -0
- package/dist/tools/_sonar/keys.js +248 -0
- package/dist/tools/_sonar/laravel-routes.d.ts +15 -0
- package/dist/tools/_sonar/laravel-routes.js +263 -0
- package/dist/tools/_sonar/laravel.d.ts +64 -0
- package/dist/tools/_sonar/laravel.js +326 -0
- package/dist/tools/_sonar/location.d.ts +33 -0
- package/dist/tools/_sonar/location.js +137 -0
- package/dist/tools/_sonar/map.d.ts +43 -0
- package/dist/tools/_sonar/map.js +212 -0
- package/dist/tools/_sonar/parse.d.ts +3 -0
- package/dist/tools/_sonar/parse.js +76 -0
- package/dist/tools/_sonar/prewarm.d.ts +9 -0
- package/dist/tools/_sonar/prewarm.js +96 -0
- package/dist/tools/_sonar/prisma.d.ts +9 -0
- package/dist/tools/_sonar/prisma.js +51 -0
- package/dist/tools/_sonar/refs.d.ts +7 -0
- package/dist/tools/_sonar/refs.js +273 -0
- package/dist/tools/_sonar/render.d.ts +66 -0
- package/dist/tools/_sonar/render.js +498 -0
- package/dist/tools/_sonar/resolve.d.ts +63 -0
- package/dist/tools/_sonar/resolve.js +402 -0
- package/dist/tools/_sonar/roots.d.ts +4 -0
- package/dist/tools/_sonar/roots.js +42 -0
- package/dist/tools/_sonar/routes.d.ts +5 -0
- package/dist/tools/_sonar/routes.js +247 -0
- package/dist/tools/_sonar/serve.d.ts +12 -0
- package/dist/tools/_sonar/serve.js +104 -0
- package/dist/tools/_sonar/suggest.d.ts +23 -0
- package/dist/tools/_sonar/suggest.js +114 -0
- package/dist/tools/_sonar/tests.d.ts +21 -0
- package/dist/tools/_sonar/tests.js +134 -0
- package/dist/tools/_sonar/tsconfig.d.ts +34 -0
- package/dist/tools/_sonar/tsconfig.js +188 -0
- package/dist/tools/_sonar/types.d.ts +81 -0
- package/dist/tools/_sonar/types.js +6 -0
- package/dist/tools/_symbols.d.ts +27 -0
- package/dist/tools/_symbols.js +461 -0
- package/dist/tools/_test-report.d.ts +47 -0
- package/dist/tools/_test-report.js +203 -0
- package/dist/tools/_touched.d.ts +44 -0
- package/dist/tools/_touched.js +195 -0
- package/dist/tools/_upload.d.ts +26 -0
- package/dist/tools/_upload.js +132 -0
- package/dist/tools/_worktree-setup.d.ts +29 -0
- package/dist/tools/_worktree-setup.js +204 -0
- package/dist/tools/browser.d.ts +2 -0
- package/dist/tools/browser.js +8 -0
- package/dist/tools/commit-guard.d.ts +44 -0
- package/dist/tools/commit-guard.js +165 -0
- package/dist/tools/computer.d.ts +13 -0
- package/dist/tools/computer.js +952 -0
- package/dist/tools/console.d.ts +44 -0
- package/dist/tools/console.js +739 -0
- package/dist/tools/database.d.ts +28 -0
- package/dist/tools/database.js +152 -0
- package/dist/tools/filesystem.d.ts +36 -0
- package/dist/tools/filesystem.js +506 -0
- package/dist/tools/git-tag.d.ts +10 -0
- package/dist/tools/git-tag.js +164 -0
- package/dist/tools/git.d.ts +52 -0
- package/dist/tools/git.js +1272 -0
- package/dist/tools/http.d.ts +12 -0
- package/dist/tools/http.js +119 -0
- package/dist/tools/image.d.ts +8 -0
- package/dist/tools/image.js +551 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +58 -0
- package/dist/tools/outline.d.ts +20 -0
- package/dist/tools/outline.js +98 -0
- package/dist/tools/search.d.ts +17 -0
- package/dist/tools/search.js +391 -0
- package/dist/tools/sonar.d.ts +17 -0
- package/dist/tools/sonar.js +231 -0
- package/dist/tools/testing.d.ts +36 -0
- package/dist/tools/testing.js +273 -0
- package/dist/tools/upload.d.ts +8 -0
- package/dist/tools/upload.js +106 -0
- package/dist/tools/webcam.d.ts +28 -0
- package/dist/tools/webcam.js +967 -0
- package/dist/update/install-kind.d.ts +35 -0
- package/dist/update/install-kind.js +109 -0
- package/dist/update/install.d.ts +32 -0
- package/dist/update/install.js +187 -0
- package/dist/update/manifest.d.ts +18 -0
- package/dist/update/manifest.js +73 -0
- package/dist/update/peers.d.ts +18 -0
- package/dist/update/peers.js +43 -0
- package/dist/update/policy.d.ts +20 -0
- package/dist/update/policy.js +49 -0
- package/dist/update/supervisor.d.ts +25 -0
- package/dist/update/supervisor.js +83 -0
- package/dist/update/updater.d.ts +44 -0
- package/dist/update/updater.js +116 -0
- package/dist/utils/format.d.ts +50 -0
- package/dist/utils/format.js +190 -0
- package/dist/version.d.ts +17 -0
- package/dist/version.js +63 -0
- package/dist/version.json +5 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.d.ts +15 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/act-tools.js +541 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.d.ts +25 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/cast-hub.js +137 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/guard.d.ts +21 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/guard.js +104 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.d.ts +47 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host-protocol.js +41 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host.d.ts +18 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/host.js +15 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/index.d.ts +13 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/index.js +28 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-input.d.ts +74 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-input.js +93 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-open.d.ts +4 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live-open.js +57 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live.d.ts +148 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/live.js +179 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/local-live.d.ts +31 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/local-live.js +262 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/marks.d.ts +36 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/marks.js +173 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-events.d.ts +27 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-events.js +82 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.d.ts +13 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/page-tools.js +526 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/params.d.ts +12 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/params.js +32 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/pick.d.ts +24 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/pick.js +76 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/session.d.ts +225 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/session.js +507 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/shots.d.ts +11 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/shots.js +103 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/show.d.ts +10 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/show.js +190 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/target.d.ts +37 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/target.js +82 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/tour.d.ts +19 -0
- package/node_modules/@nordhavnhq/runner-browser/dist/tour.js +178 -0
- package/node_modules/@nordhavnhq/runner-browser/package.json +18 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/config.d.ts +96 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/config.js +25 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/connection.d.ts +276 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/connection.js +507 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/constants.d.ts +48 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/constants.js +95 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.d.ts +94 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.js +219 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.d.ts +136 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.js +214 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.d.ts +735 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/fs.js +40 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.d.ts +362 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.js +703 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.d.ts +105 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/own-files.js +202 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.d.ts +204 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.js +497 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.d.ts +45 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.js +176 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.d.ts +74 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/processes.js +72 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.d.ts +59 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/release-tag.js +117 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.d.ts +62 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/replay.js +84 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.d.ts +27 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.js +80 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.d.ts +22 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.js +22 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.d.ts +595 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.js +85 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/index.d.ts +43 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/index.js +50 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/inference.d.ts +135 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/inference.js +945 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.d.ts +67 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/mcp.js +47 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/platform.d.ts +21 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/platform.js +25 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.d.ts +39 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.js +67 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.d.ts +61 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/background-commands.js +58 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.d.ts +23 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/chat-run-ends.js +42 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.d.ts +6 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/duration.js +12 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.d.ts +150 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/events.js +36 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.d.ts +14 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.js +49 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.d.ts +109 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.js +894 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.d.ts +73 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.js +765 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.d.ts +246 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.js +621 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.d.ts +88 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/messages.js +188 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.d.ts +15 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/pending-steers.js +10 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.d.ts +16 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.js +97 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.d.ts +22 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/project-instructions.js +47 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.d.ts +26 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.js +48 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.d.ts +8 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.js +19 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.d.ts +76 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/side-question.js +155 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.d.ts +43 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.js +37 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.d.ts +49 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.js +104 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.d.ts +16 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/write-scope.js +6 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.d.ts +86 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.js +141 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.d.ts +179 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.js +35 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.d.ts +21 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.js +179 -0
- package/node_modules/@nordhavnhq/runner-runtime/package.json +18 -0
- package/package.json +33 -4
- package/README.md +0 -3
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CALL_TIERS, DEFAULT_CALL_TIMEOUT_MS, MAX_OPEN_CALLS_PER_RUN, callTimeoutMs, planCalls, renderCallOutcomes } from '../contract/calls.js';
|
|
2
|
+
import { sendWsDelegateCancel, sendWsDelegateRequest } from '../connection.js';
|
|
3
|
+
import { randomId } from '../platform.js';
|
|
4
|
+
/** The studio owns a call's clock and answers when it runs out. This backstop
|
|
5
|
+
* only fires when that answer can never come (the studio restarted mid-call),
|
|
6
|
+
* so it sits just past the studio's own deadline. */
|
|
7
|
+
const BACKSTOP_GRACE_MS = 60_000;
|
|
8
|
+
/**
|
|
9
|
+
* Correlates outbound `delegate:request` frames with inbound `delegate:result`
|
|
10
|
+
* frames. A minimal one-shot emitter (no `node:events`, so the core stays
|
|
11
|
+
* portable): the connect loop feeds results in via `emit(requestId, ...)`; the
|
|
12
|
+
* tool executor awaits them via `once(requestId, cb)`. Each id fires at most
|
|
13
|
+
* once and is dropped after firing or on timeout.
|
|
14
|
+
*/
|
|
15
|
+
class OnceEmitter {
|
|
16
|
+
handlers = new Map();
|
|
17
|
+
once(id, cb) {
|
|
18
|
+
this.handlers.set(id, cb);
|
|
19
|
+
}
|
|
20
|
+
removeAllListeners(id) {
|
|
21
|
+
this.handlers.delete(id);
|
|
22
|
+
}
|
|
23
|
+
emit(id, payload) {
|
|
24
|
+
const cb = this.handlers.get(id);
|
|
25
|
+
if (!cb)
|
|
26
|
+
return false;
|
|
27
|
+
this.handlers.delete(id);
|
|
28
|
+
cb(payload);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const delegateEmitter = new OnceEmitter();
|
|
33
|
+
/** Place one call and wait for it. Aborting the caller asks the studio to stop
|
|
34
|
+
* the target too, instead of leaving it working for nobody. A background call
|
|
35
|
+
* waits only for the studio's word that it is out (`delegate:result` at once),
|
|
36
|
+
* and is not cancelled when this caller stops: it outlives the run. */
|
|
37
|
+
function placeCall(args, context, timeoutMs, background) {
|
|
38
|
+
const socket = context.socket;
|
|
39
|
+
const requestId = randomId();
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
let settled = false;
|
|
42
|
+
const settle = (result) => {
|
|
43
|
+
if (settled)
|
|
44
|
+
return;
|
|
45
|
+
settled = true;
|
|
46
|
+
clearTimeout(backstop);
|
|
47
|
+
delegateEmitter.removeAllListeners(requestId);
|
|
48
|
+
context.signal?.removeEventListener('abort', onAbort);
|
|
49
|
+
// What the call changed in the checkout is this run's own from now on.
|
|
50
|
+
if (context.ownFiles) {
|
|
51
|
+
for (const file of result.ownFiles ?? []) {
|
|
52
|
+
context.ownFiles.delete(file);
|
|
53
|
+
context.ownFiles.add(file);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
resolve(result);
|
|
57
|
+
};
|
|
58
|
+
const onAbort = () => {
|
|
59
|
+
if (!background)
|
|
60
|
+
sendWsDelegateCancel(socket, requestId, 'The caller was stopped');
|
|
61
|
+
settle({ error: 'Cancelled' });
|
|
62
|
+
};
|
|
63
|
+
const backstop = setTimeout(() => {
|
|
64
|
+
settle({ error: `No answer from ${args.agent}: the studio did not report back. The call may have been lost in a restart; try again.` });
|
|
65
|
+
}, (background ? 0 : (timeoutMs ?? DEFAULT_CALL_TIMEOUT_MS)) + BACKSTOP_GRACE_MS);
|
|
66
|
+
if (context.signal?.aborted)
|
|
67
|
+
return settle({ error: 'Cancelled' });
|
|
68
|
+
context.signal?.addEventListener('abort', onAbort, { once: true });
|
|
69
|
+
delegateEmitter.once(requestId, settle);
|
|
70
|
+
sendWsDelegateRequest(socket, {
|
|
71
|
+
requestId,
|
|
72
|
+
targetAgent: args.agent,
|
|
73
|
+
task: args.task,
|
|
74
|
+
...(args.context ? { context: args.context } : {}),
|
|
75
|
+
...(context.queueUid ? { callerQueueUid: context.queueUid } : {}),
|
|
76
|
+
...(timeoutMs != null ? { timeoutMs } : {}),
|
|
77
|
+
...(background ? { background: true } : {}),
|
|
78
|
+
...(args.tier ? { tier: args.tier } : {}),
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `studio_call_agent`, runner side. Its face (arguments, limits, clock, result
|
|
84
|
+
* text) is the agent contract's (`contract/calls.ts`), the same code the
|
|
85
|
+
* studio's `executeCallAgent` runs for internal agents; only placing a call
|
|
86
|
+
* (a `delegate:request` frame) is the runner's own.
|
|
87
|
+
*/
|
|
88
|
+
async function executeCallAgent(params, context) {
|
|
89
|
+
if (!context?.socket)
|
|
90
|
+
return 'Error: delegation requires an active WebSocket connection';
|
|
91
|
+
const plan = planCalls(params);
|
|
92
|
+
if ('refusal' in plan)
|
|
93
|
+
return plan.refusal;
|
|
94
|
+
// A background call is not held to this run's clock: the studio gives it
|
|
95
|
+
// its own. Only a call we wait for gets our timeout.
|
|
96
|
+
const timeoutMs = plan.background ? undefined : callTimeoutMs(context.delegateTimeoutMs, context.runDeadlineAt, Date.now());
|
|
97
|
+
const outcomes = await Promise.all(plan.calls.map(args => placeCall(args, context, timeoutMs, plan.background)));
|
|
98
|
+
return renderCallOutcomes(outcomes, plan.isBatch).text;
|
|
99
|
+
}
|
|
100
|
+
export const delegateTools = [
|
|
101
|
+
{
|
|
102
|
+
definition: {
|
|
103
|
+
name: 'studio_call_agent',
|
|
104
|
+
description: 'Place a call to another agent (or a working copy of yourself) and wait for the answer, like phoning a colleague. '
|
|
105
|
+
+ 'Pass `{ batch: [...] }` to put several calls out at once, `background: true` to carry on without waiting, '
|
|
106
|
+
+ 'and `tier: "explore"` with your own slug to send a cheap read-only copy to search and summarise.',
|
|
107
|
+
parameters: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
agent: { type: 'string', description: 'Target agent slug. Your own slug starts a working copy of yourself.' },
|
|
111
|
+
task: { type: 'string', description: 'Clear, focused question or instruction. One deliverable per call.' },
|
|
112
|
+
context: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
description: 'What you already know that they need: facts, paths, uids, decisions. Saves them rediscovering it.',
|
|
115
|
+
},
|
|
116
|
+
tier: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
enum: [...CALL_TIERS],
|
|
119
|
+
description: '`explore`: a read-only working copy of yourself (your own slug as `agent`) that searches, reads and summarises on your explore model and answers in about 2,000 tokens at most.',
|
|
120
|
+
},
|
|
121
|
+
background: {
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
description: 'Do not wait: the answer arrives later in this chat (or running task) and you get a turn to act on it.',
|
|
124
|
+
},
|
|
125
|
+
batch: {
|
|
126
|
+
type: 'array',
|
|
127
|
+
maxItems: MAX_OPEN_CALLS_PER_RUN,
|
|
128
|
+
description: 'Several calls at once, run in parallel. Use instead of agent/task/context at the top level.',
|
|
129
|
+
items: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: { agent: { type: 'string' }, task: { type: 'string' }, context: { type: 'string' }, tier: { type: 'string', enum: [...CALL_TIERS] } },
|
|
132
|
+
required: ['agent', 'task'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
required: [],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
execute: executeCallAgent,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../inference.js';
|
|
2
|
+
import type { AgentSocket } from '../connection.js';
|
|
3
|
+
import type { ChatGitRelay, ToolDefPayload } from '../contract/wire.js';
|
|
4
|
+
/**
|
|
5
|
+
* Per-call execution context handed to tool implementations.
|
|
6
|
+
*
|
|
7
|
+
* The core threads this through opaquely: it constructs the context, drains
|
|
8
|
+
* `pendingToolImages` after each local-tool call, and hands the rest to the
|
|
9
|
+
* frontend's `ToolProvider`. Frontend-specific fields (`lastScreenCapture`,
|
|
10
|
+
* `fsUnrestricted`) are set/read only by that frontend's tools; the core never
|
|
11
|
+
* inspects them.
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolContext {
|
|
14
|
+
agentSlug: string;
|
|
15
|
+
/** The agent's display name, from the studio's `connected` frame: the git
|
|
16
|
+
* tools commit as `<name> <slug>@justmade.be` when the repo has no
|
|
17
|
+
* identity. Absent before the first connect. */
|
|
18
|
+
agentName?: string;
|
|
19
|
+
/** The organisation the agent works for: with `agentSlug` it names the
|
|
20
|
+
* agent on a runner paired with several (a slug is unique only within one). */
|
|
21
|
+
organisationSlug?: string | null;
|
|
22
|
+
/** Resolved absolute path of the **project root** for this dispatch - the repo
|
|
23
|
+
* the agent is helping with (host frontends only). Relative tool paths
|
|
24
|
+
* resolve against it, like a shell `cwd`. Falls back to the agent's home when
|
|
25
|
+
* the dispatch's project isn't linked on this machine. */
|
|
26
|
+
projectRoot?: string;
|
|
27
|
+
/** Resolved absolute paths of the project's unmuted **workspace folders**: extra
|
|
28
|
+
* folders a person added beside the checkout in the Code app. Inside the jail
|
|
29
|
+
* by absolute path; relative paths still resolve against `projectRoot`, and
|
|
30
|
+
* the session's write scope does not apply to them. Host frontends only. */
|
|
31
|
+
workspaceRoots?: string[];
|
|
32
|
+
/** Resolved absolute path of the agent's private **home** (`<home>/agent_<slug>`).
|
|
33
|
+
* Always inside the jail alongside `projectRoot` so the agent can build things
|
|
34
|
+
* for itself regardless of which project it is working on. */
|
|
35
|
+
agentHome?: string;
|
|
36
|
+
/** Resolved absolute path of this dispatch's throwaway **scratch** dir
|
|
37
|
+
* (`<home>/tmp/<slug>/<dispatchId>`). Inside the jail like `agentHome`, but
|
|
38
|
+
* auto-deleted by the runner's reaper once older than the scratch TTL (24h).
|
|
39
|
+
* The agent is steered here (prompt + `$NORDHAVN_SCRATCH`) for temp /
|
|
40
|
+
* intermediate files so it never litters the project checkout. Host
|
|
41
|
+
* frontends only. */
|
|
42
|
+
scratchRoot?: string;
|
|
43
|
+
/** Absolute dirs this dispatch may READ but never write: a call's caller's
|
|
44
|
+
* scratch dir, so a copy can open the files its caller handed it there.
|
|
45
|
+
* Host frontends only. */
|
|
46
|
+
readOnlyRoots?: string[];
|
|
47
|
+
/** Absolute, canonical folder inside `projectRoot` this dispatch may CHANGE
|
|
48
|
+
* (a Code session's scope, `ProjectRef.scope`, validated by the host):
|
|
49
|
+
* writes, deletes, moves, the shell's cwd and commits must stay inside it,
|
|
50
|
+
* reads stay on the whole checkout and searches default to it. The agent
|
|
51
|
+
* home and scratch stay writable. Absent = the whole checkout. Host
|
|
52
|
+
* frontends only. */
|
|
53
|
+
writeScope?: string;
|
|
54
|
+
/** The session's scope (relative POSIX) when it is well-formed but the folder
|
|
55
|
+
* does not exist in the checkout (renamed or deleted): every change in the
|
|
56
|
+
* checkout is refused, reads stay on the whole checkout and searches and the
|
|
57
|
+
* shell default to the checkout root. Set instead of `writeScope`. */
|
|
58
|
+
writeScopeMissing?: string;
|
|
59
|
+
/** Slug of the Nordhavn OS **project** this dispatch is bound to (the studio
|
|
60
|
+
* passes it on the dispatch; agents are cross-project so it varies per
|
|
61
|
+
* dispatch). Distinct from `projectRoot` (the local FS path this project maps
|
|
62
|
+
* to on the runner). When set, file uploads forward this slug to the studio so
|
|
63
|
+
* the resulting File row lands in the project's file manager instead of being
|
|
64
|
+
* org-scoped only. */
|
|
65
|
+
projectSlug?: string;
|
|
66
|
+
/** UID of the conversation this tool call belongs to. */
|
|
67
|
+
conversationId?: string;
|
|
68
|
+
/** UID of the agent queue entry for this dispatch (task OR chat). Injected
|
|
69
|
+
* into MCP tool-call payloads so the studio can resolve the invocation
|
|
70
|
+
* project, which gates project-scoped secret resolution. */
|
|
71
|
+
queueUid?: string;
|
|
72
|
+
/** UID of the Task this dispatch is bound to. Populated for task dispatches
|
|
73
|
+
* so MCP tool calls against `/api/mcp/tasks/{taskUid}/…` can omit the arg
|
|
74
|
+
* in their payload - the executor backfills it from here before path
|
|
75
|
+
* interpolation, matching the studio prompt's promise that taskUid is
|
|
76
|
+
* auto-filled. Absent for chat dispatches. */
|
|
77
|
+
taskUid?: string;
|
|
78
|
+
/** A person is on the other end of this dispatch and can approve an action
|
|
79
|
+
* (set by the chat handler, never by the task handler). Confirm-first tools
|
|
80
|
+
* such as `runner_git_push` gate on this. It is explicit on purpose: a chat
|
|
81
|
+
* carries a `queueUid` too, so "no queueUid" does not mean "a user is here". */
|
|
82
|
+
userPresent?: boolean;
|
|
83
|
+
/** The person who started this chat connected a git relay (the chat frame's
|
|
84
|
+
* `gitRelay`): `runner_git_commit` commits in their name with the agent as
|
|
85
|
+
* co-author, and `runner_git_push` goes through their machine unless the
|
|
86
|
+
* relay is on this runner. Absent for a task, or a person without one. */
|
|
87
|
+
gitRelay?: ChatGitRelay;
|
|
88
|
+
/** The files of the checkout this chat or task changed itself and has not
|
|
89
|
+
* committed since (`contract/own-files.ts`), the last changed last: seeded
|
|
90
|
+
* from the frame's `project.ownFiles`, kept up to date by every local tool
|
|
91
|
+
* call (`createToolProvider`) and by a call's answer. `runner_git_status`
|
|
92
|
+
* names them `yours`, `runner_git_commit` with `mine` commits them. */
|
|
93
|
+
ownFiles?: Set<string>;
|
|
94
|
+
/** Where a local tool leaves the files of the checkout it changed beyond
|
|
95
|
+
* its own `path` argument (`runner_run_command`: what git status says the
|
|
96
|
+
* command touched), keyed by the params object of the call, since calls of
|
|
97
|
+
* one round can run side by side. Set by the dispatch handler when it keeps
|
|
98
|
+
* `ownFiles`; read by `createToolProvider` (own files) and by the handler
|
|
99
|
+
* (the `touched` of the tool-use frame). */
|
|
100
|
+
touchedFiles?: WeakMap<Record<string, unknown>, readonly string[]>;
|
|
101
|
+
/** Abort signal - tools should bail when it fires. */
|
|
102
|
+
signal?: AbortSignal;
|
|
103
|
+
/** The agent's own cap on a `studio_call_agent` (agentConfig). */
|
|
104
|
+
delegateTimeoutMs?: number;
|
|
105
|
+
/** When this dispatch's wall-clock budget ends (epoch ms). A call placed
|
|
106
|
+
* from it is never given longer. Absent for a task with no budget. */
|
|
107
|
+
runDeadlineAt?: number;
|
|
108
|
+
/** Studio base URL - needed by the generic MCP executor for tools
|
|
109
|
+
* whose `mcpPath` resolves to a studio HTTP endpoint. */
|
|
110
|
+
studioUrl?: string;
|
|
111
|
+
/** Agent connection token used as `Authorization: Bearer` for MCP calls. */
|
|
112
|
+
agentToken?: string;
|
|
113
|
+
/** Active WebSocket socket - needed by delegation tool to send WS frames. */
|
|
114
|
+
socket?: AgentSocket;
|
|
115
|
+
/** Accumulator for attachments produced by tools (e.g. webcam captures).
|
|
116
|
+
* Populated by uploadImage() in host tools; surfaced via sendWsChatDone(). */
|
|
117
|
+
attachments?: {
|
|
118
|
+
url: string;
|
|
119
|
+
name: string;
|
|
120
|
+
type: string;
|
|
121
|
+
size: number;
|
|
122
|
+
}[];
|
|
123
|
+
/** Per-call sink for image bytes a tool wants the LLM to see inline,
|
|
124
|
+
* without an S3 upload. Cleared by the core loop before each local-tool
|
|
125
|
+
* call and drained immediately after - the next tool-result message inlines
|
|
126
|
+
* them via the v6 `output.type='content'` variant. */
|
|
127
|
+
pendingToolImages?: {
|
|
128
|
+
data: Buffer;
|
|
129
|
+
mediaType: string;
|
|
130
|
+
}[];
|
|
131
|
+
/** Last screen/window capture metadata - used by host `mouse_control` tools
|
|
132
|
+
* to translate pixel coords to logical screen coords. Opaque to the core;
|
|
133
|
+
* host tools cast it to their own `ScreenMeta`. */
|
|
134
|
+
lastScreenCapture?: unknown;
|
|
135
|
+
/** Sink for `studio_load_toolset` results. When the model calls it, the MCP
|
|
136
|
+
* executor parses the studio response and invokes this callback so the core
|
|
137
|
+
* loop merges the new tool defs into its per-dispatch registry - the next
|
|
138
|
+
* inference round registers them with the LLM. */
|
|
139
|
+
loadTools?: (defs: ToolDefPayload[]) => void;
|
|
140
|
+
/** True when the agent holds the tool `name` in this dispatch: in its
|
|
141
|
+
* registry, granted at dispatch or loaded since with `studio_load_toolset`.
|
|
142
|
+
* Lets a tool point the agent at another one only when it can call it
|
|
143
|
+
* (the runner's sonar hints). Absent outside a dispatch: read as "no". */
|
|
144
|
+
hasTool?: (name: string) => boolean;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A single tool the frontend can execute locally. Frontends assemble their own
|
|
148
|
+
* set (host tools for the CLI, editor tools for VS Code, page tools for the
|
|
149
|
+
* browser) and expose them to the core through a {@link ToolProvider}.
|
|
150
|
+
*/
|
|
151
|
+
export interface LocalTool {
|
|
152
|
+
definition: ToolDefinition;
|
|
153
|
+
execute: (params: Record<string, unknown>, context?: ToolContext) => Promise<string>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The seam between the environment-agnostic core and a concrete frontend's
|
|
157
|
+
* local tools. The core never imports host/editor/browser tools directly - it
|
|
158
|
+
* receives one of these in its dispatch-handler deps and routes every
|
|
159
|
+
* non-MCP tool call through it. Build one with {@link createToolProvider}.
|
|
160
|
+
*/
|
|
161
|
+
export interface ToolProvider {
|
|
162
|
+
/** True when this frontend has a local executor for `name`. */
|
|
163
|
+
isLocalTool(name: string): boolean;
|
|
164
|
+
/** Names of every locally-executable tool, sorted. Used at startup to warn
|
|
165
|
+
* about grant drift (studio granted a tool this frontend can't run). */
|
|
166
|
+
listExecutorNames(): string[];
|
|
167
|
+
/** Definition for a local tool, or undefined if not registered here. */
|
|
168
|
+
getLocalToolDefinition(name: string): ToolDefinition | undefined;
|
|
169
|
+
/** Execute a local tool by name. Returns a string the model can read;
|
|
170
|
+
* missing required params return a clear error string (never throws). */
|
|
171
|
+
executeLocalTool(name: string, params: Record<string, unknown>, context?: ToolContext): Promise<string>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Build a {@link ToolProvider} from a flat list of {@link LocalTool}s. This is
|
|
175
|
+
* pure (no host imports), so every frontend uses it to wrap its own tool set:
|
|
176
|
+
* `createToolProvider([...filesystemTools, ...consoleTools])` on the CLI,
|
|
177
|
+
* `createToolProvider([...editorTools])` in VS Code.
|
|
178
|
+
*/
|
|
179
|
+
export declare function createToolProvider(tools: LocalTool[]): ToolProvider;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { applyOwnFileStep } from '../contract/own-files.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build a {@link ToolProvider} from a flat list of {@link LocalTool}s. This is
|
|
4
|
+
* pure (no host imports), so every frontend uses it to wrap its own tool set:
|
|
5
|
+
* `createToolProvider([...filesystemTools, ...consoleTools])` on the CLI,
|
|
6
|
+
* `createToolProvider([...editorTools])` in VS Code.
|
|
7
|
+
*/
|
|
8
|
+
export function createToolProvider(tools) {
|
|
9
|
+
const byName = new Map(tools.map(t => [t.definition.name, t]));
|
|
10
|
+
return {
|
|
11
|
+
isLocalTool: (name) => byName.has(name),
|
|
12
|
+
listExecutorNames: () => [...byName.keys()].sort(),
|
|
13
|
+
getLocalToolDefinition: (name) => byName.get(name)?.definition,
|
|
14
|
+
async executeLocalTool(name, params, context) {
|
|
15
|
+
const tool = byName.get(name);
|
|
16
|
+
if (!tool)
|
|
17
|
+
return `Error: Unknown tool "${name}"`;
|
|
18
|
+
const required = tool.definition.parameters?.required;
|
|
19
|
+
if (required && required.length > 0) {
|
|
20
|
+
const missing = required.filter(p => params[p] === undefined || params[p] === null || params[p] === '');
|
|
21
|
+
if (missing.length > 0) {
|
|
22
|
+
return `Error: Missing required parameter(s): ${missing.join(', ')}.`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const result = await tool.execute(params, context);
|
|
26
|
+
// A write, an edit, a command's touched files or a commit that worked
|
|
27
|
+
// moves the run's own files.
|
|
28
|
+
if (context?.ownFiles) {
|
|
29
|
+
const touched = context.touchedFiles?.get(params) ?? null;
|
|
30
|
+
applyOwnFileStep(context.ownFiles, { tool: name, args: params, result, touched });
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ToolDefPayload } from '../contract/wire.js';
|
|
2
|
+
import type { ToolContext } from './index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Execute an MCP tool by making an HTTP call to the studio's MCP API.
|
|
5
|
+
*
|
|
6
|
+
* - `{param}` placeholders in `mcpPath` are interpolated from `args` and
|
|
7
|
+
* the interpolated values are removed from the request body/query.
|
|
8
|
+
* - When `mcpQuery` is true, remaining args are sent as URL query parameters.
|
|
9
|
+
* - When `mcpQuery` is false (default), remaining args are sent as JSON body.
|
|
10
|
+
*
|
|
11
|
+
* Batch dispatch: any studio_* tool can be called with `{ batch: [args, ...] }`
|
|
12
|
+
* and fans out into N parallel single-call invocations, returning a
|
|
13
|
+
* stringified `{ results: [{ ok: true, data } | { ok: false, error, statusCode? }, ...] }`.
|
|
14
|
+
* The envelope is the agent contract's `runBatch`, the same code the studio's
|
|
15
|
+
* `invokeMcpTool` runs for internal agents.
|
|
16
|
+
*
|
|
17
|
+
* The agent's connection token is forwarded via `Authorization: Bearer` so
|
|
18
|
+
* the MCP-auth middleware accepts the call with the same identity used for
|
|
19
|
+
* the inference proxy.
|
|
20
|
+
*/
|
|
21
|
+
export declare function executeMcpTool(toolDef: ToolDefPayload, args: Record<string, unknown>, ctx: ToolContext): Promise<string>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { runBatch } from '../contract/batch.js';
|
|
2
|
+
import { RUN_STOPPED_PREFIX, RUN_STOPPED_STATUSES } from '../contract/loop.js';
|
|
3
|
+
import { networkErrorMessage } from '../inference.js';
|
|
4
|
+
/**
|
|
5
|
+
* Execute an MCP tool by making an HTTP call to the studio's MCP API.
|
|
6
|
+
*
|
|
7
|
+
* - `{param}` placeholders in `mcpPath` are interpolated from `args` and
|
|
8
|
+
* the interpolated values are removed from the request body/query.
|
|
9
|
+
* - When `mcpQuery` is true, remaining args are sent as URL query parameters.
|
|
10
|
+
* - When `mcpQuery` is false (default), remaining args are sent as JSON body.
|
|
11
|
+
*
|
|
12
|
+
* Batch dispatch: any studio_* tool can be called with `{ batch: [args, ...] }`
|
|
13
|
+
* and fans out into N parallel single-call invocations, returning a
|
|
14
|
+
* stringified `{ results: [{ ok: true, data } | { ok: false, error, statusCode? }, ...] }`.
|
|
15
|
+
* The envelope is the agent contract's `runBatch`, the same code the studio's
|
|
16
|
+
* `invokeMcpTool` runs for internal agents.
|
|
17
|
+
*
|
|
18
|
+
* The agent's connection token is forwarded via `Authorization: Bearer` so
|
|
19
|
+
* the MCP-auth middleware accepts the call with the same identity used for
|
|
20
|
+
* the inference proxy.
|
|
21
|
+
*/
|
|
22
|
+
export async function executeMcpTool(toolDef, args, ctx) {
|
|
23
|
+
const { mcpPath, mcpMethod = 'POST', mcpQuery = false } = toolDef;
|
|
24
|
+
if (!mcpPath)
|
|
25
|
+
return 'Error: Tool has no MCP path configured.';
|
|
26
|
+
if (!ctx.studioUrl)
|
|
27
|
+
return 'Error: No studio URL in tool context.';
|
|
28
|
+
if (!ctx.agentToken)
|
|
29
|
+
return 'Error: No agent token in tool context.';
|
|
30
|
+
// Batch dispatch: detect `{ batch: [...] }` BEFORE path interpolation so each
|
|
31
|
+
// item can supply its own URL params. Each item recurses into a single call.
|
|
32
|
+
let envelope;
|
|
33
|
+
try {
|
|
34
|
+
envelope = await runBatch(toolDef.name, args, async (itemArgs) => {
|
|
35
|
+
// A single call answers "Error: <detail>" or a JSON-stringified body.
|
|
36
|
+
const text = await executeMcpTool(toolDef, itemArgs, ctx);
|
|
37
|
+
if (text.startsWith('Error: '))
|
|
38
|
+
return { ok: false, error: text.slice(7) };
|
|
39
|
+
try {
|
|
40
|
+
return { ok: true, data: JSON.parse(text) };
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return { ok: true, data: text };
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
// Malformed `batch`, too many items, or a tool that never fans out: a plain
|
|
49
|
+
// error string, this function's contract, instead of an uncaught throw.
|
|
50
|
+
return `Error: ${e instanceof Error ? e.message : String(e)}`;
|
|
51
|
+
}
|
|
52
|
+
if (envelope)
|
|
53
|
+
return JSON.stringify(envelope);
|
|
54
|
+
// Backfill `taskUid` from the dispatch context before interpolation runs.
|
|
55
|
+
// The studio prompt promises that taskUid auto-fills for tools targeting the
|
|
56
|
+
// current task (e.g. studio_update_task, studio_get_task) - without this, an
|
|
57
|
+
// omitted arg leaves `{taskUid}` empty and the URL collapses to
|
|
58
|
+
// `/api/mcp/tasks/`, which 404s.
|
|
59
|
+
if (ctx.taskUid && args.taskUid === undefined) {
|
|
60
|
+
args = { ...args, taskUid: ctx.taskUid };
|
|
61
|
+
}
|
|
62
|
+
// Interpolate {param} placeholders.
|
|
63
|
+
const usedParams = new Set();
|
|
64
|
+
const interpolated = mcpPath.replace(/\{(\w+)\}/g, (_, key) => {
|
|
65
|
+
usedParams.add(key);
|
|
66
|
+
const val = args[key];
|
|
67
|
+
return val !== undefined && val !== null ? encodeURIComponent(String(val)) : '';
|
|
68
|
+
});
|
|
69
|
+
// Remaining args (not consumed by path interpolation).
|
|
70
|
+
const remaining = {};
|
|
71
|
+
for (const [k, v] of Object.entries(args)) {
|
|
72
|
+
if (!usedParams.has(k))
|
|
73
|
+
remaining[k] = v;
|
|
74
|
+
}
|
|
75
|
+
// Inject execution context so the endpoint knows which conversation/queue
|
|
76
|
+
// this call is scoped to. The conversation only when the caller names none.
|
|
77
|
+
if (ctx.conversationId && remaining.conversationId === undefined) {
|
|
78
|
+
remaining.conversationId = ctx.conversationId;
|
|
79
|
+
}
|
|
80
|
+
// The queue uid always comes from the dispatch, never from the model: the
|
|
81
|
+
// studio's run gates (portal and guest fences, explore and plan-mode locks,
|
|
82
|
+
// the 410 on a finished run) all hang off it, and an empty or foreign value
|
|
83
|
+
// from the model's arguments would skip them.
|
|
84
|
+
if (ctx.queueUid) {
|
|
85
|
+
remaining.queueUid = ctx.queueUid;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
delete remaining.queueUid;
|
|
89
|
+
}
|
|
90
|
+
let url = ctx.studioUrl + interpolated;
|
|
91
|
+
const method = (mcpMethod ?? 'POST').toUpperCase();
|
|
92
|
+
const headers = {
|
|
93
|
+
Authorization: `Bearer ${ctx.agentToken}`,
|
|
94
|
+
};
|
|
95
|
+
let body;
|
|
96
|
+
if (mcpQuery || method === 'GET' || method === 'DELETE') {
|
|
97
|
+
const qs = new URLSearchParams();
|
|
98
|
+
for (const [k, v] of Object.entries(remaining)) {
|
|
99
|
+
if (v !== undefined && v !== null)
|
|
100
|
+
qs.set(k, String(v));
|
|
101
|
+
}
|
|
102
|
+
const qsStr = qs.toString();
|
|
103
|
+
if (qsStr)
|
|
104
|
+
url += (url.includes('?') ? '&' : '?') + qsStr;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
headers['Content-Type'] = 'application/json';
|
|
108
|
+
body = JSON.stringify(remaining);
|
|
109
|
+
}
|
|
110
|
+
let res;
|
|
111
|
+
try {
|
|
112
|
+
res = await fetch(url, { method, headers, body });
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
return `Error: Network error calling ${method} ${interpolated}: ${networkErrorMessage(err)}`;
|
|
116
|
+
}
|
|
117
|
+
const text = await res.text().catch(() => '');
|
|
118
|
+
// 410: the studio says this run has no reason any more (its task or mission
|
|
119
|
+
// was stopped). 402: the task's budget is spent. Either way the run STOPS -
|
|
120
|
+
// the loop reads this marker and ends the turn, rather than leaving it to
|
|
121
|
+
// the model, which may retry. The studio's `invokeMcpTool` alike.
|
|
122
|
+
if (RUN_STOPPED_STATUSES.has(res.status)) {
|
|
123
|
+
return `${RUN_STOPPED_PREFIX}${text.slice(0, 500)}`;
|
|
124
|
+
}
|
|
125
|
+
if (!res.ok) {
|
|
126
|
+
return `Error: ${method} ${interpolated} returned ${res.status}: ${text.slice(0, 500)}`;
|
|
127
|
+
}
|
|
128
|
+
// studio_load_toolset is the one MCP call whose response the runner consumes itself:
|
|
129
|
+
// the studio returns `{ toolDefs[], warnings? }` and the runner merges the defs into
|
|
130
|
+
// its per-dispatch tool registry so subsequent inference rounds can invoke
|
|
131
|
+
// them. The model only ever sees a short human-readable summary.
|
|
132
|
+
if (toolDef.name === 'studio_load_toolset') {
|
|
133
|
+
return handleLoadToolsetResponse(text, args, ctx);
|
|
134
|
+
}
|
|
135
|
+
// If the response is JSON, return the serialized form; otherwise raw text.
|
|
136
|
+
try {
|
|
137
|
+
const json = JSON.parse(text);
|
|
138
|
+
return typeof json === 'string' ? json : JSON.stringify(json);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return text || 'ok';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function handleLoadToolsetResponse(text, args, ctx) {
|
|
145
|
+
let body;
|
|
146
|
+
try {
|
|
147
|
+
body = JSON.parse(text);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return `Error: studio returned a non-JSON response from /api/mcp/tools/load: ${text.slice(0, 200)}`;
|
|
151
|
+
}
|
|
152
|
+
const defs = Array.isArray(body.toolDefs) ? body.toolDefs : [];
|
|
153
|
+
const warnings = Array.isArray(body.warnings) ? body.warnings : [];
|
|
154
|
+
if (defs.length > 0 && ctx.loadTools) {
|
|
155
|
+
ctx.loadTools(defs);
|
|
156
|
+
}
|
|
157
|
+
const requestedGroup = typeof args.group === 'string' ? args.group.trim() : '';
|
|
158
|
+
const requestedNames = Array.isArray(args.names)
|
|
159
|
+
? args.names.filter((n) => typeof n === 'string')
|
|
160
|
+
: [];
|
|
161
|
+
const requestLabel = [
|
|
162
|
+
requestedGroup ? `group "${requestedGroup}"` : null,
|
|
163
|
+
requestedNames.length > 0 ? `names ${requestedNames.map(n => `"${n}"`).join(', ')}` : null,
|
|
164
|
+
].filter(Boolean).join(' + ') || '(no filter)';
|
|
165
|
+
const lines = [];
|
|
166
|
+
if (defs.length === 0) {
|
|
167
|
+
lines.push(`No new tools registered for ${requestLabel} - either the request matched nothing new or every match was already loaded.`);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const names = defs.map(d => d.name).sort();
|
|
171
|
+
lines.push(`Registered ${defs.length} tool${defs.length === 1 ? '' : 's'} from ${requestLabel}: ${names.join(', ')}. You can invoke them on your next step.`);
|
|
172
|
+
}
|
|
173
|
+
if (warnings.length > 0) {
|
|
174
|
+
lines.push('Warnings:');
|
|
175
|
+
for (const w of warnings)
|
|
176
|
+
lines.push(`- ${w}`);
|
|
177
|
+
}
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nordhavnhq/runner-runtime",
|
|
3
|
+
"version": "0.96.0",
|
|
4
|
+
"description": "Nordhavn OS agent-runtime core: studio connection, dispatch wire, MCP client, inference, agent loop",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
]
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordhavnhq/runner",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.96.0",
|
|
4
|
+
"description": "Nordhavn OS runner CLI: runs agents headless on a host and supplies the host tools",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=22"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"nordhavn": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"bin"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"ai": "^6.0.315",
|
|
22
|
+
"playwright-core": "^1.64.1",
|
|
23
|
+
"sharp": "^0.35.5",
|
|
24
|
+
"ws": "^8.22.0",
|
|
25
|
+
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
26
|
+
"@vscode/ripgrep": "^1.18.0",
|
|
27
|
+
"mysql2": "^3.24.6",
|
|
28
|
+
"@nordhavnhq/runner-runtime": "0.96.0",
|
|
29
|
+
"@nordhavnhq/runner-browser": "0.96.0"
|
|
30
|
+
},
|
|
31
|
+
"bundleDependencies": [
|
|
32
|
+
"@nordhavnhq/runner-runtime",
|
|
33
|
+
"@nordhavnhq/runner-browser"
|
|
34
|
+
]
|
|
35
|
+
}
|
package/README.md
DELETED