@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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client over the studio-os MCP endpoints. The agent connection token
|
|
3
|
+
* authenticates every request via `Authorization: Bearer <token>`.
|
|
4
|
+
*/
|
|
5
|
+
export interface McpToolEntry {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
mcpMethod: string | null;
|
|
9
|
+
mcpPath: string | null;
|
|
10
|
+
mcpQuery: boolean;
|
|
11
|
+
requiresConsent: boolean;
|
|
12
|
+
alwaysAvailable: boolean;
|
|
13
|
+
activityLabel: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface McpMeResponse {
|
|
16
|
+
slug: string;
|
|
17
|
+
name: string;
|
|
18
|
+
role: string;
|
|
19
|
+
avatarUrl?: string | null;
|
|
20
|
+
provider?: string | null;
|
|
21
|
+
model?: string | null;
|
|
22
|
+
systemPrompt?: string | null;
|
|
23
|
+
personality?: string | null;
|
|
24
|
+
maxToolRounds?: number | null;
|
|
25
|
+
maxCostPerTurn?: number | null;
|
|
26
|
+
canManageHQ?: boolean;
|
|
27
|
+
cronTasks?: unknown;
|
|
28
|
+
department?: string | null;
|
|
29
|
+
tools: McpToolEntry[];
|
|
30
|
+
}
|
|
31
|
+
export declare function fetchMcpMe(studioUrl: string, token: string, signal?: AbortSignal): Promise<McpMeResponse>;
|
|
32
|
+
export interface CreateTaskOutput {
|
|
33
|
+
type: string;
|
|
34
|
+
config?: Record<string, unknown>;
|
|
35
|
+
payload?: Record<string, unknown>;
|
|
36
|
+
on_failure?: 'continue' | 'pause_remaining' | 'rollback_all';
|
|
37
|
+
}
|
|
38
|
+
export interface CreateTaskRequest {
|
|
39
|
+
title: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
assignedAgentSlug: string;
|
|
42
|
+
conversationId?: string;
|
|
43
|
+
outputs?: CreateTaskOutput[];
|
|
44
|
+
}
|
|
45
|
+
export interface CreateTaskResponse {
|
|
46
|
+
task: {
|
|
47
|
+
uid: string;
|
|
48
|
+
status: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface StudioLogPayload {
|
|
52
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
53
|
+
type?: string;
|
|
54
|
+
source?: string;
|
|
55
|
+
message: string;
|
|
56
|
+
data?: Record<string, unknown>;
|
|
57
|
+
conversationUid?: string;
|
|
58
|
+
queueUid?: string;
|
|
59
|
+
userUuid?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fire-and-forget: write a structured log entry to the OS log store.
|
|
63
|
+
* Called by the --debug runtime subscriber. Errors are silently swallowed
|
|
64
|
+
* so a failing studio connection can never crash the agent loop.
|
|
65
|
+
*/
|
|
66
|
+
export declare function postStudioLog(studioUrl: string, token: string, payload: StudioLogPayload): void;
|
|
67
|
+
export declare function createTask(studioUrl: string, token: string, body: CreateTaskRequest, signal?: AbortSignal): Promise<CreateTaskResponse>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client over the studio-os MCP endpoints. The agent connection token
|
|
3
|
+
* authenticates every request via `Authorization: Bearer <token>`.
|
|
4
|
+
*/
|
|
5
|
+
export async function fetchMcpMe(studioUrl, token, signal) {
|
|
6
|
+
const res = await fetch(`${studioUrl}/api/mcp/me`, {
|
|
7
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
8
|
+
signal,
|
|
9
|
+
});
|
|
10
|
+
if (!res.ok) {
|
|
11
|
+
throw new Error(`/api/mcp/me failed: ${res.status} ${res.statusText}`);
|
|
12
|
+
}
|
|
13
|
+
return res.json();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Fire-and-forget: write a structured log entry to the OS log store.
|
|
17
|
+
* Called by the --debug runtime subscriber. Errors are silently swallowed
|
|
18
|
+
* so a failing studio connection can never crash the agent loop.
|
|
19
|
+
*/
|
|
20
|
+
export function postStudioLog(studioUrl, token, payload) {
|
|
21
|
+
fetch(`${studioUrl}/api/mcp/logs`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${token}`,
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({ source: 'runner', ...payload }),
|
|
28
|
+
}).catch(() => {
|
|
29
|
+
// Silently swallow - debug logging must never break the runtime.
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export async function createTask(studioUrl, token, body, signal) {
|
|
33
|
+
const res = await fetch(`${studioUrl}/api/mcp/tasks`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${token}`,
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(body),
|
|
40
|
+
signal,
|
|
41
|
+
});
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
const text = await res.text().catch(() => '');
|
|
44
|
+
throw new Error(`/api/mcp/tasks failed: ${res.status} ${res.statusText}${text ? ` - ${text.slice(0, 200)}` : ''}`);
|
|
45
|
+
}
|
|
46
|
+
return res.json();
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny platform seam - the handful of primitives that would otherwise reach
|
|
3
|
+
* for a Node-only API from inside the environment-agnostic core. Each default
|
|
4
|
+
* works in both Node 22+ and the browser, so the core stays portable without
|
|
5
|
+
* an injection step.
|
|
6
|
+
*
|
|
7
|
+
* The one primitive NOT abstracted here is the WebSocket itself: it is still
|
|
8
|
+
* constructed in [connection.ts](connection.ts) via the `ws` package. That is
|
|
9
|
+
* the single remaining Node dependency of the core and the documented swap
|
|
10
|
+
* point for the future browser edition (browser has a native `WebSocket`, so
|
|
11
|
+
* connection.ts is the only file that edition needs to fork).
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Schedule a callback on a future macrotask. Node's `setImmediate` is the most
|
|
15
|
+
* precise fit but is Node-only; `setTimeout(cb, 0)` has equivalent "after the
|
|
16
|
+
* current turn, before long timers" semantics in both runtimes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function scheduleMacrotask(cb: () => void): void;
|
|
19
|
+
/** A unique id (used for delegation request ids). `crypto.randomUUID` is
|
|
20
|
+
* available on `globalThis` in Node 18+ and every modern browser. */
|
|
21
|
+
export declare function randomId(): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny platform seam - the handful of primitives that would otherwise reach
|
|
3
|
+
* for a Node-only API from inside the environment-agnostic core. Each default
|
|
4
|
+
* works in both Node 22+ and the browser, so the core stays portable without
|
|
5
|
+
* an injection step.
|
|
6
|
+
*
|
|
7
|
+
* The one primitive NOT abstracted here is the WebSocket itself: it is still
|
|
8
|
+
* constructed in [connection.ts](connection.ts) via the `ws` package. That is
|
|
9
|
+
* the single remaining Node dependency of the core and the documented swap
|
|
10
|
+
* point for the future browser edition (browser has a native `WebSocket`, so
|
|
11
|
+
* connection.ts is the only file that edition needs to fork).
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Schedule a callback on a future macrotask. Node's `setImmediate` is the most
|
|
15
|
+
* precise fit but is Node-only; `setTimeout(cb, 0)` has equivalent "after the
|
|
16
|
+
* current turn, before long timers" semantics in both runtimes.
|
|
17
|
+
*/
|
|
18
|
+
export function scheduleMacrotask(cb) {
|
|
19
|
+
setTimeout(cb, 0);
|
|
20
|
+
}
|
|
21
|
+
/** A unique id (used for delegation request ids). `crypto.randomUUID` is
|
|
22
|
+
* available on `globalThis` in Node 18+ and every modern browser. */
|
|
23
|
+
export function randomId() {
|
|
24
|
+
return globalThis.crypto.randomUUID();
|
|
25
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ToolDefPayload } from '../contract/wire.js';
|
|
2
|
+
import type { ToolContext } from '../tools/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* First-use auto-load (runner side).
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the studio-side `autoLoadToolDef` in
|
|
7
|
+
* `apps/server/server/utils/internal-runtime/adapters.ts`: when the model
|
|
8
|
+
* invokes a real, granted `studio_*` tool whose schema hasn't been loaded into
|
|
9
|
+
* this dispatch's registry yet, pull it in-band instead of bouncing the model
|
|
10
|
+
* with "call studio_load_toolset and retry" (a wasted round).
|
|
11
|
+
*
|
|
12
|
+
* The load goes through the exact same path an explicit `studio_load_toolset`
|
|
13
|
+
* call uses: `executeMcpTool` special-cases that tool name, hits
|
|
14
|
+
* `/api/mcp/tools/load` (which re-applies authorisation and persists to
|
|
15
|
+
* `Conversation.loadedToolNames`), and merges the returned defs into the
|
|
16
|
+
* registry via `ctx.loadTools`. We only invoke it for its side effect and
|
|
17
|
+
* discard the human-readable summary it returns.
|
|
18
|
+
*
|
|
19
|
+
* Returns the freshly registered def, or undefined when the load yielded
|
|
20
|
+
* nothing (not granted / unknown) so the caller can fall back to the normal
|
|
21
|
+
* unknown-tool error.
|
|
22
|
+
*/
|
|
23
|
+
export declare function autoLoadToolDef(toolName: string, registry: Map<string, ToolDefPayload>, ctx: ToolContext): Promise<ToolDefPayload | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Wrapper text prepended to a just-auto-loaded tool's instructions when its
|
|
26
|
+
* first call errored. Kept byte-identical to the studio side
|
|
27
|
+
* (`autoLoadInstructionsHint` in adapters.ts) so both runtimes feed the model
|
|
28
|
+
* the same correction guidance.
|
|
29
|
+
*/
|
|
30
|
+
export declare function autoLoadInstructionsHint(toolName: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Rich first-use fallback: append a freshly auto-loaded tool's full
|
|
33
|
+
* instructions to an error result. Unlike the studio side (which reads the
|
|
34
|
+
* registry in-process), the runner has no local instructions store, so it fetches
|
|
35
|
+
* them lazily from `/api/mcp/tools/{name}/instructions` - only on the error
|
|
36
|
+
* path of a first call, so the happy path pays nothing. Returns the original
|
|
37
|
+
* result unchanged when instructions can't be fetched.
|
|
38
|
+
*/
|
|
39
|
+
export declare function appendAutoLoadInstructions(toolName: string, result: string, ctx: ToolContext): Promise<string>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { executeMcpTool } from '../tools/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* First-use auto-load (runner side).
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the studio-side `autoLoadToolDef` in
|
|
6
|
+
* `apps/server/server/utils/internal-runtime/adapters.ts`: when the model
|
|
7
|
+
* invokes a real, granted `studio_*` tool whose schema hasn't been loaded into
|
|
8
|
+
* this dispatch's registry yet, pull it in-band instead of bouncing the model
|
|
9
|
+
* with "call studio_load_toolset and retry" (a wasted round).
|
|
10
|
+
*
|
|
11
|
+
* The load goes through the exact same path an explicit `studio_load_toolset`
|
|
12
|
+
* call uses: `executeMcpTool` special-cases that tool name, hits
|
|
13
|
+
* `/api/mcp/tools/load` (which re-applies authorisation and persists to
|
|
14
|
+
* `Conversation.loadedToolNames`), and merges the returned defs into the
|
|
15
|
+
* registry via `ctx.loadTools`. We only invoke it for its side effect and
|
|
16
|
+
* discard the human-readable summary it returns.
|
|
17
|
+
*
|
|
18
|
+
* Returns the freshly registered def, or undefined when the load yielded
|
|
19
|
+
* nothing (not granted / unknown) so the caller can fall back to the normal
|
|
20
|
+
* unknown-tool error.
|
|
21
|
+
*/
|
|
22
|
+
export async function autoLoadToolDef(toolName, registry, ctx) {
|
|
23
|
+
const loadDef = registry.get('studio_load_toolset');
|
|
24
|
+
if (!loadDef)
|
|
25
|
+
return undefined;
|
|
26
|
+
try {
|
|
27
|
+
await executeMcpTool(loadDef, { names: [toolName] }, ctx);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Load failed (network / authz) - fall through; the caller surfaces the
|
|
31
|
+
// standard unknown-tool error.
|
|
32
|
+
}
|
|
33
|
+
return registry.get(toolName);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Wrapper text prepended to a just-auto-loaded tool's instructions when its
|
|
37
|
+
* first call errored. Kept byte-identical to the studio side
|
|
38
|
+
* (`autoLoadInstructionsHint` in adapters.ts) so both runtimes feed the model
|
|
39
|
+
* the same correction guidance.
|
|
40
|
+
*/
|
|
41
|
+
export function autoLoadInstructionsHint(toolName) {
|
|
42
|
+
return `Note: "${toolName}" was auto-loaded the moment you first called it, so you invoked it without seeing its schema. It is registered now. Here are its full instructions - re-read them and retry with corrected arguments:`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Rich first-use fallback: append a freshly auto-loaded tool's full
|
|
46
|
+
* instructions to an error result. Unlike the studio side (which reads the
|
|
47
|
+
* registry in-process), the runner has no local instructions store, so it fetches
|
|
48
|
+
* them lazily from `/api/mcp/tools/{name}/instructions` - only on the error
|
|
49
|
+
* path of a first call, so the happy path pays nothing. Returns the original
|
|
50
|
+
* result unchanged when instructions can't be fetched.
|
|
51
|
+
*/
|
|
52
|
+
export async function appendAutoLoadInstructions(toolName, result, ctx) {
|
|
53
|
+
if (!ctx.studioUrl || !ctx.agentToken)
|
|
54
|
+
return result;
|
|
55
|
+
try {
|
|
56
|
+
const res = await fetch(`${ctx.studioUrl}/api/mcp/tools/${encodeURIComponent(toolName)}/instructions`, { headers: { Authorization: `Bearer ${ctx.agentToken}` } });
|
|
57
|
+
if (!res.ok)
|
|
58
|
+
return result;
|
|
59
|
+
const body = (await res.json());
|
|
60
|
+
if (!body.instructions)
|
|
61
|
+
return result;
|
|
62
|
+
return `${result}\n\n${autoLoadInstructionsHint(toolName)}\n${body.instructions}`;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background commands at the end of a task run.
|
|
3
|
+
*
|
|
4
|
+
* `runner_run_command` with `background: true` returns at once (a full test
|
|
5
|
+
* suite, a long build), so a run can end and report green while that command
|
|
6
|
+
* still runs, or after it failed. Before a task run sends its result, the
|
|
7
|
+
* handler waits for the background commands that dispatch started, up to
|
|
8
|
+
* {@link BACKGROUND_WAIT_MS}, and adds a short note to the result for each one
|
|
9
|
+
* that still runs or ended with a non-zero exit code. Nothing is stopped.
|
|
10
|
+
*
|
|
11
|
+
* The runtime keeps no processes: the frontend that starts them waits for
|
|
12
|
+
* them (`HandleTaskDeps.waitForBackgroundCommands`). This file holds the
|
|
13
|
+
* shapes of that seam and the pure parts (how long, what the note says).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The longest a task run waits for its background commands before it ends.
|
|
17
|
+
* Kept under the server's settled-run grace (`AGENT_SETTLED_RUN_GRACE_MINUTES`,
|
|
18
|
+
* 5 min in the stale watchdog), which counts from the run's last message: the
|
|
19
|
+
* wait announces itself with one, so a full wait must end before that grace
|
|
20
|
+
* does, or the watchdog closes the run and the note is lost.
|
|
21
|
+
*/
|
|
22
|
+
export declare const BACKGROUND_WAIT_MS: number;
|
|
23
|
+
/** One background command a run started, as it stood when the wait ended. */
|
|
24
|
+
export interface BackgroundCommandOutcome {
|
|
25
|
+
command: string;
|
|
26
|
+
status: 'running' | 'exited';
|
|
27
|
+
exitCode: number | null;
|
|
28
|
+
/** Where its output went, when the frontend keeps a log. */
|
|
29
|
+
log: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface BackgroundCommandsWait {
|
|
32
|
+
/** Every background command the run started, finished or not. */
|
|
33
|
+
commands: BackgroundCommandOutcome[];
|
|
34
|
+
/** How long the wait took (0 when nothing was running). */
|
|
35
|
+
waitedMs: number;
|
|
36
|
+
}
|
|
37
|
+
export interface WaitForBackgroundCommandsOptions {
|
|
38
|
+
/** The cap on the wait; 0 only collects what the run started. */
|
|
39
|
+
timeoutMs: number;
|
|
40
|
+
/** Ends the wait at once (the run was cancelled). */
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
/** Called once, before the wait, with the commands still running. Not called when nothing is. */
|
|
43
|
+
onWait?: (running: BackgroundCommandOutcome[]) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Wait for the background commands the dispatch `queueUid` started to end,
|
|
47
|
+
* within `timeoutMs`, and return how each one stands. Only commands of kind
|
|
48
|
+
* `background` count, never a dev server. Collecting forgets them: a second
|
|
49
|
+
* call for the same `queueUid` returns nothing.
|
|
50
|
+
*/
|
|
51
|
+
export type WaitForBackgroundCommands = (queueUid: string, opts: WaitForBackgroundCommandsOptions) => Promise<BackgroundCommandsWait>;
|
|
52
|
+
/** How long a run may wait: the cap, or less when its own clock ends sooner. */
|
|
53
|
+
export declare function backgroundWaitMs(now: number, runDeadlineAt?: number, capMs?: number): number;
|
|
54
|
+
/** The line that says the run waits, for the run's timeline. */
|
|
55
|
+
export declare function formatBackgroundWaitMessage(running: BackgroundCommandOutcome[], timeoutMs: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* The section added to a run's result for the background commands that did not
|
|
58
|
+
* end well: still running, or exited non-zero. Null when every one exited 0
|
|
59
|
+
* (or there were none), so a clean run reads as before.
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatBackgroundCommandsNote(wait: BackgroundCommandsWait): string | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { formatDuration } from './duration.js';
|
|
2
|
+
/**
|
|
3
|
+
* Background commands at the end of a task run.
|
|
4
|
+
*
|
|
5
|
+
* `runner_run_command` with `background: true` returns at once (a full test
|
|
6
|
+
* suite, a long build), so a run can end and report green while that command
|
|
7
|
+
* still runs, or after it failed. Before a task run sends its result, the
|
|
8
|
+
* handler waits for the background commands that dispatch started, up to
|
|
9
|
+
* {@link BACKGROUND_WAIT_MS}, and adds a short note to the result for each one
|
|
10
|
+
* that still runs or ended with a non-zero exit code. Nothing is stopped.
|
|
11
|
+
*
|
|
12
|
+
* The runtime keeps no processes: the frontend that starts them waits for
|
|
13
|
+
* them (`HandleTaskDeps.waitForBackgroundCommands`). This file holds the
|
|
14
|
+
* shapes of that seam and the pure parts (how long, what the note says).
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The longest a task run waits for its background commands before it ends.
|
|
18
|
+
* Kept under the server's settled-run grace (`AGENT_SETTLED_RUN_GRACE_MINUTES`,
|
|
19
|
+
* 5 min in the stale watchdog), which counts from the run's last message: the
|
|
20
|
+
* wait announces itself with one, so a full wait must end before that grace
|
|
21
|
+
* does, or the watchdog closes the run and the note is lost.
|
|
22
|
+
*/
|
|
23
|
+
export const BACKGROUND_WAIT_MS = 4.5 * 60_000;
|
|
24
|
+
/** How long a run may wait: the cap, or less when its own clock ends sooner. */
|
|
25
|
+
export function backgroundWaitMs(now, runDeadlineAt, capMs = BACKGROUND_WAIT_MS) {
|
|
26
|
+
if (runDeadlineAt === undefined)
|
|
27
|
+
return capMs;
|
|
28
|
+
return Math.max(0, Math.min(capMs, runDeadlineAt - now));
|
|
29
|
+
}
|
|
30
|
+
const COMMAND_MAX_CHARS = 120;
|
|
31
|
+
function shortCommand(command) {
|
|
32
|
+
const line = command.replace(/\s+/g, ' ').replace(/`/g, '\'').trim();
|
|
33
|
+
return line.length > COMMAND_MAX_CHARS ? `${line.slice(0, COMMAND_MAX_CHARS - 3)}...` : line;
|
|
34
|
+
}
|
|
35
|
+
/** The line that says the run waits, for the run's timeline. */
|
|
36
|
+
export function formatBackgroundWaitMessage(running, timeoutMs) {
|
|
37
|
+
const names = running.map(c => `\`${shortCommand(c.command)}\``).join(', ');
|
|
38
|
+
return `Waiting up to ${formatDuration(timeoutMs)} for ${running.length} background command(s) to finish: ${names}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The section added to a run's result for the background commands that did not
|
|
42
|
+
* end well: still running, or exited non-zero. Null when every one exited 0
|
|
43
|
+
* (or there were none), so a clean run reads as before.
|
|
44
|
+
*/
|
|
45
|
+
export function formatBackgroundCommandsNote(wait) {
|
|
46
|
+
const waited = wait.waitedMs >= 1000 ? ` (waited ${formatDuration(wait.waitedMs)})` : '';
|
|
47
|
+
const lines = wait.commands
|
|
48
|
+
.filter(c => c.status === 'running' || c.exitCode !== 0)
|
|
49
|
+
.map((c) => {
|
|
50
|
+
const state = c.status === 'running'
|
|
51
|
+
? `still running when the run ended${waited}`
|
|
52
|
+
: c.exitCode === null ? 'exited without an exit code' : `exited ${c.exitCode}`;
|
|
53
|
+
return `- \`${shortCommand(c.command)}\` ${state}${c.log ? ` (log ${c.log})` : ''}`;
|
|
54
|
+
});
|
|
55
|
+
if (lines.length === 0)
|
|
56
|
+
return null;
|
|
57
|
+
return `Background commands (not confirmed by this run):\n${lines.join('\n')}`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long a chat run that replaces another waits for the old one to wind
|
|
3
|
+
* down after its abort. The loop and its tools honour the abort signal, so
|
|
4
|
+
* this is normally milliseconds; the cap only keeps a tool that ignores the
|
|
5
|
+
* signal from blocking the conversation for good.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SUPERSEDED_RUN_WAIT_MS = 60000;
|
|
8
|
+
export interface ChatRunHandle {
|
|
9
|
+
/** The end of the run this one replaces, when one still runs. */
|
|
10
|
+
previous: Promise<void> | undefined;
|
|
11
|
+
/** Marks this run ended. Call it exactly once, in a `finally`. */
|
|
12
|
+
end: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The end of every chat run by conversation, so a run that replaces another
|
|
16
|
+
* one (same conversation, dispatched again) starts only once the old loop has
|
|
17
|
+
* stopped: never two loops in the same conversation and checkout.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createChatRunEnds(): {
|
|
20
|
+
begin(conversationId: string): ChatRunHandle;
|
|
21
|
+
};
|
|
22
|
+
/** Whether `run` ended within `maxMs`. */
|
|
23
|
+
export declare function endsWithin(run: Promise<void>, maxMs: number): Promise<boolean>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long a chat run that replaces another waits for the old one to wind
|
|
3
|
+
* down after its abort. The loop and its tools honour the abort signal, so
|
|
4
|
+
* this is normally milliseconds; the cap only keeps a tool that ignores the
|
|
5
|
+
* signal from blocking the conversation for good.
|
|
6
|
+
*/
|
|
7
|
+
export const SUPERSEDED_RUN_WAIT_MS = 60_000;
|
|
8
|
+
/**
|
|
9
|
+
* The end of every chat run by conversation, so a run that replaces another
|
|
10
|
+
* one (same conversation, dispatched again) starts only once the old loop has
|
|
11
|
+
* stopped: never two loops in the same conversation and checkout.
|
|
12
|
+
*/
|
|
13
|
+
export function createChatRunEnds() {
|
|
14
|
+
const ends = new Map();
|
|
15
|
+
return {
|
|
16
|
+
begin(conversationId) {
|
|
17
|
+
const previous = ends.get(conversationId);
|
|
18
|
+
let resolve;
|
|
19
|
+
const ended = new Promise((r) => { resolve = r; });
|
|
20
|
+
ends.set(conversationId, ended);
|
|
21
|
+
return {
|
|
22
|
+
previous,
|
|
23
|
+
end: () => {
|
|
24
|
+
resolve();
|
|
25
|
+
if (ends.get(conversationId) === ended)
|
|
26
|
+
ends.delete(conversationId);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Whether `run` ended within `maxMs`. */
|
|
33
|
+
export async function endsWithin(run, maxMs) {
|
|
34
|
+
let timer;
|
|
35
|
+
const timedOut = new Promise((resolve) => { timer = setTimeout(() => resolve(false), maxMs); });
|
|
36
|
+
try {
|
|
37
|
+
return await Promise.race([run.then(() => true), timedOut]);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A duration for a log line or a run message: `850ms`, `12.3s`, `5 min`.
|
|
3
|
+
* The one copy for the runtime and the runner (the runner depends on the
|
|
4
|
+
* runtime, never the other way round).
|
|
5
|
+
*/
|
|
6
|
+
export function formatDuration(ms) {
|
|
7
|
+
if (ms < 1000)
|
|
8
|
+
return `${Math.round(ms)}ms`;
|
|
9
|
+
if (ms < 60_000)
|
|
10
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
11
|
+
return `${Math.round(ms / 60_000)} min`;
|
|
12
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured event emitter used by the runtime for observability. Zero
|
|
3
|
+
* dependencies - a small in-process pub/sub. Default subscriber pretty-
|
|
4
|
+
* prints one-line summaries; the `--debug` flag switches to a verbose
|
|
5
|
+
* subscriber that dumps the full payload.
|
|
6
|
+
*
|
|
7
|
+
* Why a custom emitter and not Node's EventEmitter? We want a typed
|
|
8
|
+
* discriminated union over the `kind` field, automatic timestamping,
|
|
9
|
+
* and a single dispatch path that won't crash the runtime if a subscriber
|
|
10
|
+
* throws.
|
|
11
|
+
*/
|
|
12
|
+
interface BaseEvent {
|
|
13
|
+
/** ms epoch */
|
|
14
|
+
ts: number;
|
|
15
|
+
/** Slug of the agent the event belongs to. */
|
|
16
|
+
agentSlug: string;
|
|
17
|
+
}
|
|
18
|
+
export interface InferenceStartEvent extends BaseEvent {
|
|
19
|
+
kind: 'inference.start';
|
|
20
|
+
/** Queue uid when inference is happening for a specific chat/task. */
|
|
21
|
+
queueUid?: string;
|
|
22
|
+
conversationId?: string;
|
|
23
|
+
toolCount: number;
|
|
24
|
+
messageCount: number;
|
|
25
|
+
}
|
|
26
|
+
export interface InferenceEndEvent extends BaseEvent {
|
|
27
|
+
kind: 'inference.end';
|
|
28
|
+
queueUid?: string;
|
|
29
|
+
conversationId?: string;
|
|
30
|
+
durMs: number;
|
|
31
|
+
inputTokens: number;
|
|
32
|
+
outputTokens: number;
|
|
33
|
+
costMicros: number;
|
|
34
|
+
model: string;
|
|
35
|
+
/** How many tool calls the model returned in this round. */
|
|
36
|
+
toolCalls: number;
|
|
37
|
+
/** Set if the call completed with an error rather than a normal stop. */
|
|
38
|
+
error?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolStartEvent extends BaseEvent {
|
|
41
|
+
kind: 'tool.start';
|
|
42
|
+
tool: string;
|
|
43
|
+
queueUid?: string;
|
|
44
|
+
conversationId?: string;
|
|
45
|
+
argsBytes: number;
|
|
46
|
+
}
|
|
47
|
+
export interface ToolEndEvent extends BaseEvent {
|
|
48
|
+
kind: 'tool.end';
|
|
49
|
+
tool: string;
|
|
50
|
+
queueUid?: string;
|
|
51
|
+
conversationId?: string;
|
|
52
|
+
durMs: number;
|
|
53
|
+
/** When the tool returned an error string instead of throwing, the runner
|
|
54
|
+
* classifies that as a soft error - included here for visibility. */
|
|
55
|
+
error?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface WsReconnectEvent extends BaseEvent {
|
|
58
|
+
kind: 'ws.reconnect';
|
|
59
|
+
reason: string;
|
|
60
|
+
attempt: number;
|
|
61
|
+
delayMs: number;
|
|
62
|
+
}
|
|
63
|
+
export interface WsSendFailedEvent extends BaseEvent {
|
|
64
|
+
kind: 'ws.send.failed';
|
|
65
|
+
/** Frame `type` if known. */
|
|
66
|
+
frameType: string;
|
|
67
|
+
reason: 'queued' | 'dropped';
|
|
68
|
+
}
|
|
69
|
+
export interface AgentRenamedEvent extends BaseEvent {
|
|
70
|
+
kind: 'agent.renamed';
|
|
71
|
+
oldSlug: string;
|
|
72
|
+
newSlug: string;
|
|
73
|
+
/** Source of the rename: explicit `agent:renamed` push, or detected via
|
|
74
|
+
* `connected`-frame reconciliation on (re)connect. */
|
|
75
|
+
via: 'push' | 'reconnect';
|
|
76
|
+
/** When the rename was deferred until in-flight work drains (detached
|
|
77
|
+
* mode), this is the count of busy slots at the time the frame arrived. */
|
|
78
|
+
pendingSlots?: number;
|
|
79
|
+
}
|
|
80
|
+
/** A chat or task dispatch was received from the studio and is about to run.
|
|
81
|
+
* Emitted by the core so any frontend (CLI ANSI line, VSCode webview row) can
|
|
82
|
+
* show the inbound turn without the core knowing how it's rendered. */
|
|
83
|
+
export interface DispatchReceivedEvent extends BaseEvent {
|
|
84
|
+
kind: 'dispatch.received';
|
|
85
|
+
channel: 'chat' | 'task';
|
|
86
|
+
queueUid?: string;
|
|
87
|
+
conversationId?: string;
|
|
88
|
+
/** Display name of the user who sent it, when known. */
|
|
89
|
+
userName?: string;
|
|
90
|
+
/** Number of history messages carried in the dispatch. */
|
|
91
|
+
messageCount: number;
|
|
92
|
+
/** Short preview of the latest user content (already truncated by the core). */
|
|
93
|
+
preview?: string;
|
|
94
|
+
}
|
|
95
|
+
/** A dispatch finished cleanly. Carries the roll-up the CLI prints on the
|
|
96
|
+
* `->` summary line and the VSCode UI shows as the turn footer. */
|
|
97
|
+
export interface DispatchFinishedEvent extends BaseEvent {
|
|
98
|
+
kind: 'dispatch.finished';
|
|
99
|
+
channel: 'chat' | 'task';
|
|
100
|
+
queueUid?: string;
|
|
101
|
+
conversationId?: string;
|
|
102
|
+
durMs: number;
|
|
103
|
+
inputTokens: number;
|
|
104
|
+
outputTokens: number;
|
|
105
|
+
costMicros: number;
|
|
106
|
+
model: string;
|
|
107
|
+
}
|
|
108
|
+
/** A dispatch was cancelled (abort signal fired) before completing. */
|
|
109
|
+
export interface DispatchCancelledEvent extends BaseEvent {
|
|
110
|
+
kind: 'dispatch.cancelled';
|
|
111
|
+
channel: 'chat' | 'task';
|
|
112
|
+
queueUid?: string;
|
|
113
|
+
conversationId?: string;
|
|
114
|
+
}
|
|
115
|
+
/** A dispatch failed with an error the frontend should surface. */
|
|
116
|
+
export interface DispatchFailedEvent extends BaseEvent {
|
|
117
|
+
kind: 'dispatch.failed';
|
|
118
|
+
channel: 'chat' | 'task';
|
|
119
|
+
queueUid?: string;
|
|
120
|
+
conversationId?: string;
|
|
121
|
+
error: string;
|
|
122
|
+
}
|
|
123
|
+
/** A freeform diagnostic line the core wants to surface without minting a
|
|
124
|
+
* dedicated typed event (steer applied, validation retry, terminal status,
|
|
125
|
+
* ...). Frontends render it however they like; the CLI prints a `·` line. */
|
|
126
|
+
export interface RuntimeNoteEvent extends BaseEvent {
|
|
127
|
+
kind: 'note';
|
|
128
|
+
channel?: 'chat' | 'task';
|
|
129
|
+
queueUid?: string;
|
|
130
|
+
conversationId?: string;
|
|
131
|
+
level: 'info' | 'warn' | 'error';
|
|
132
|
+
message: string;
|
|
133
|
+
}
|
|
134
|
+
export type RuntimeEvent = InferenceStartEvent | InferenceEndEvent | ToolStartEvent | ToolEndEvent | WsReconnectEvent | WsSendFailedEvent | AgentRenamedEvent | DispatchReceivedEvent | DispatchFinishedEvent | DispatchCancelledEvent | DispatchFailedEvent | RuntimeNoteEvent;
|
|
135
|
+
type Listener = (event: RuntimeEvent) => void;
|
|
136
|
+
/**
|
|
137
|
+
* Distributive omit - preserves the discriminated union when `ts` is
|
|
138
|
+
* stripped from each variant. Plain `Omit<RuntimeEvent, 'ts'>` collapses
|
|
139
|
+
* the union to the intersection of common fields, which loses per-variant
|
|
140
|
+
* properties at the call-site.
|
|
141
|
+
*/
|
|
142
|
+
type EmittableEvent<E extends RuntimeEvent = RuntimeEvent> = E extends RuntimeEvent ? Omit<E, 'ts'> : never;
|
|
143
|
+
/**
|
|
144
|
+
* Emit a runtime event. `ts` is filled in automatically. Listeners that
|
|
145
|
+
* throw are isolated - one buggy subscriber can never bring down a task.
|
|
146
|
+
*/
|
|
147
|
+
export declare function emitEvent(event: EmittableEvent): void;
|
|
148
|
+
/** Subscribe to all events. Returns an unsubscribe handle. */
|
|
149
|
+
export declare function onEvent(listener: Listener): () => void;
|
|
150
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured event emitter used by the runtime for observability. Zero
|
|
3
|
+
* dependencies - a small in-process pub/sub. Default subscriber pretty-
|
|
4
|
+
* prints one-line summaries; the `--debug` flag switches to a verbose
|
|
5
|
+
* subscriber that dumps the full payload.
|
|
6
|
+
*
|
|
7
|
+
* Why a custom emitter and not Node's EventEmitter? We want a typed
|
|
8
|
+
* discriminated union over the `kind` field, automatic timestamping,
|
|
9
|
+
* and a single dispatch path that won't crash the runtime if a subscriber
|
|
10
|
+
* throws.
|
|
11
|
+
*/
|
|
12
|
+
const listeners = new Set();
|
|
13
|
+
/**
|
|
14
|
+
* Emit a runtime event. `ts` is filled in automatically. Listeners that
|
|
15
|
+
* throw are isolated - one buggy subscriber can never bring down a task.
|
|
16
|
+
*/
|
|
17
|
+
export function emitEvent(event) {
|
|
18
|
+
const stamped = { ...event, ts: Date.now() };
|
|
19
|
+
for (const listener of listeners) {
|
|
20
|
+
try {
|
|
21
|
+
listener(stamped);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
// Stay defensive: a broken subscriber must never break the runner. This is
|
|
25
|
+
// the one place in runtime/src allowed to touch the console - the emitter
|
|
26
|
+
// is the diagnostics floor and cannot route this failure through itself.
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error(`[events] listener threw on ${stamped.kind}:`, err);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Subscribe to all events. Returns an unsubscribe handle. */
|
|
33
|
+
export function onEvent(listener) {
|
|
34
|
+
listeners.add(listener);
|
|
35
|
+
return () => listeners.delete(listener);
|
|
36
|
+
}
|