@nordhavnhq/runner 0.0.0-stage → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +80 -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 +42 -0
- package/dist/cli/link.js +314 -0
- package/dist/cli/logs.d.ts +2 -0
- package/dist/cli/logs.js +147 -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 +81 -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 +145 -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 +1325 -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,246 @@
|
|
|
1
|
+
import { type HandoffChoice, type LoopStopReason } from '../contract/loop.js';
|
|
2
|
+
import type { CompletionResult, ModelMessage, ToolCall, ToolDefinition } from '../inference.js';
|
|
3
|
+
import type { ToolDefPayload } from '../contract/wire.js';
|
|
4
|
+
import { byToolName } from './run-tools.js';
|
|
5
|
+
/**
|
|
6
|
+
* Agentic loop core. Owns: round counter, abort + time-budget checks, the
|
|
7
|
+
* inference call, the tool-execution-and-replay sequence, and the
|
|
8
|
+
* conversation message accumulator. Does not own: WS framing, local-vs-MCP
|
|
9
|
+
* tool routing, debug logging, schema validation. Those are caller
|
|
10
|
+
* responsibilities surfaced via the adapters below.
|
|
11
|
+
*
|
|
12
|
+
* A freshly-written sibling lives at
|
|
13
|
+
* apps/server/server/utils/internal-runtime/loop.ts - same agentic-loop
|
|
14
|
+
* shape, but built against InferenceMessage with its own message builders.
|
|
15
|
+
* They are not literally in sync; don't mirror edits across mechanically.
|
|
16
|
+
* What both must do alike (stop reasons, loop breakers, the texts fed back to
|
|
17
|
+
* the model, how the context stays bounded) is the agent contract's
|
|
18
|
+
* (`contract/loop.ts`), which both run.
|
|
19
|
+
*/
|
|
20
|
+
export interface AgenticUsage {
|
|
21
|
+
inputTokens: number;
|
|
22
|
+
outputTokens: number;
|
|
23
|
+
costMicros: number;
|
|
24
|
+
cacheCreationTokens?: number;
|
|
25
|
+
cacheReadTokens?: number;
|
|
26
|
+
/** Input-token count of the LAST inference call this dispatch, i.e. the real
|
|
27
|
+
* context-window occupancy at the end of the run. Unlike `inputTokens` (a
|
|
28
|
+
* sum over every round) this is a point-in-time reading, so the studio's
|
|
29
|
+
* context meter divides IT by the model window instead of the round-sum
|
|
30
|
+
* (which pins the meter at 100% on any multi-round run). Mirrors the
|
|
31
|
+
* internal runtime's `totalUsage.contextTokens` in
|
|
32
|
+
* server/utils/internal-runtime/loop.ts. */
|
|
33
|
+
contextTokens?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ToolOutcome {
|
|
36
|
+
/** Stringified result handed back to the model. For errors, the human-
|
|
37
|
+
* readable failure message (the loop wraps it in an `error-text` part). */
|
|
38
|
+
result: string;
|
|
39
|
+
isError: boolean;
|
|
40
|
+
durationMs: number;
|
|
41
|
+
/** Inline image bytes to embed in the tool result (capture tools with
|
|
42
|
+
* `keep:false`). Threaded into `buildToolResultMessage({ images })` so
|
|
43
|
+
* the model can see the bytes without a separate view round-trip. */
|
|
44
|
+
images?: {
|
|
45
|
+
data: Buffer;
|
|
46
|
+
mediaType: string;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
export interface InferenceRequest {
|
|
50
|
+
messages: ModelMessage[];
|
|
51
|
+
tools: ToolDefinition[];
|
|
52
|
+
toolChoice?: 'auto' | 'required' | 'none';
|
|
53
|
+
/** `handoff`: the closing call of a run that is stopping, which the studio
|
|
54
|
+
* lets through once past a spent budget (`HANDOFF_CALL_PURPOSE`). */
|
|
55
|
+
purpose?: 'handoff';
|
|
56
|
+
}
|
|
57
|
+
/** Bound to a concrete inference transport by the caller. The signal is the
|
|
58
|
+
* same `AbortSignal` the loop is driven by - propagate it into the
|
|
59
|
+
* underlying SDK so a cancel actually aborts the network call. */
|
|
60
|
+
export type CallInference = (req: InferenceRequest, signal: AbortSignal) => Promise<CompletionResult>;
|
|
61
|
+
/** Bound to a concrete tool transport by the caller. Called for every tool
|
|
62
|
+
* call the model makes, in order. The `toolDef` is `undefined` when the
|
|
63
|
+
* model hallucinated a name not in the registry - the caller decides how to
|
|
64
|
+
* surface that (typically by emitting an "unknown tool" error frame and
|
|
65
|
+
* returning a `ToolOutcome` with `isError: true`). */
|
|
66
|
+
export type ExecuteTool = (call: ToolCall, toolDef: ToolDefPayload | undefined) => Promise<ToolOutcome>;
|
|
67
|
+
/** Keep a tool's whole output somewhere the agent can read it in ranges, and
|
|
68
|
+
* return that place (a path), or null. See `AgenticLoopOpts.spillToolOutput`. */
|
|
69
|
+
export type SpillToolOutput = (callId: string, toolName: string, text: string) => Promise<string | null>;
|
|
70
|
+
export interface AgenticLoopHooks {
|
|
71
|
+
/** Fired just before the inference call. Used by `--debug` to log inputs. */
|
|
72
|
+
onInferenceInput?: (round: number, messages: ModelMessage[], tools: ToolDefinition[]) => void;
|
|
73
|
+
/** Fired right after the inference call returns. Used by `--debug` to log
|
|
74
|
+
* outputs, and by callers that want to accumulate per-round metrics
|
|
75
|
+
* beyond the usage already tracked by the loop. */
|
|
76
|
+
onInferenceOutput?: (round: number, result: CompletionResult) => void;
|
|
77
|
+
/** Fired when the model produced any tool calls - gives callers a chance
|
|
78
|
+
* to stream the assistant's narration text before the tools run (the
|
|
79
|
+
* task runner uses this for `task:message` frames so the activity log
|
|
80
|
+
* shows what the agent is "thinking" between tool rounds). */
|
|
81
|
+
onAssistantNarration?: (round: number, narration: string, thoughts: string | null) => void;
|
|
82
|
+
/** Fired at the top of every round, BEFORE the inference call. Return
|
|
83
|
+
* `{ injectUserMessage }` to push a user message into the conversation
|
|
84
|
+
* first (task steers use this). */
|
|
85
|
+
onRoundStart?: (round: number) => Promise<{
|
|
86
|
+
injectUserMessage?: string;
|
|
87
|
+
} | void> | {
|
|
88
|
+
injectUserMessage?: string;
|
|
89
|
+
} | void;
|
|
90
|
+
/** Whether a steer is waiting to be drained by `onRoundStart`. Asked before
|
|
91
|
+
* every tool call: once it says yes, the calls left in the round are not
|
|
92
|
+
* run (each gets `STEER_SKIPPED_RESULT`) and the next round starts, so a
|
|
93
|
+
* steer waits for one tool at most, not for a whole batched round. */
|
|
94
|
+
hasPendingSteer?: () => boolean;
|
|
95
|
+
/** Fired when the model returned a plain reply (no tool calls). Return
|
|
96
|
+
* `{ continueWithUserMessage }` to push the assistant's reply back into
|
|
97
|
+
* the conversation followed by a corrective user message and run another
|
|
98
|
+
* round (task uses this to nudge the agent into calling
|
|
99
|
+
* `studio_update_task` when a structured-result schema is required).
|
|
100
|
+
* Returning `void` ends the loop with `finalReply = result.message`. */
|
|
101
|
+
onEmptyToolCalls?: (round: number, finalReply: string) => Promise<{
|
|
102
|
+
continueWithUserMessage?: string;
|
|
103
|
+
} | void> | {
|
|
104
|
+
continueWithUserMessage?: string;
|
|
105
|
+
} | void;
|
|
106
|
+
/** Fired after all tool calls in a round have been executed and their
|
|
107
|
+
* results appended to the conversation. Return `{ stop: true }` to break
|
|
108
|
+
* out of the loop early (task uses this once a terminal `studio_update_task`
|
|
109
|
+
* call has been seen). `injectUserMessage` queues a user-role message
|
|
110
|
+
* onto the next round (task uses this to surface validation feedback).
|
|
111
|
+
* `overrideFinalReply` replaces the loop's `finalReply` when `stop` is
|
|
112
|
+
* set (task uses this to lift `resultJson.output` as the deliverable). */
|
|
113
|
+
onAfterRound?: (round: number) => {
|
|
114
|
+
stop?: boolean;
|
|
115
|
+
injectUserMessage?: string;
|
|
116
|
+
overrideFinalReply?: string;
|
|
117
|
+
} | void;
|
|
118
|
+
}
|
|
119
|
+
export interface AgenticLoopOpts {
|
|
120
|
+
/** The system prompt. Inserted as the first message; not duplicated into
|
|
121
|
+
* `initialMessages`. */
|
|
122
|
+
systemPrompt: string;
|
|
123
|
+
/** Conversation history *excluding* the system message. The loop does not
|
|
124
|
+
* truncate - callers that need pair-aware truncation (chat does) should
|
|
125
|
+
* trim these before passing them in. */
|
|
126
|
+
initialMessages: ModelMessage[];
|
|
127
|
+
/** Mutable per-dispatch tool registry. The loop re-reads it at the top of
|
|
128
|
+
* every round so mid-loop expansion via `studio_load_toolset` is picked up
|
|
129
|
+
* on the next inference call. */
|
|
130
|
+
registry: Map<string, ToolDefPayload>;
|
|
131
|
+
callInference: CallInference;
|
|
132
|
+
/** Optional separate transport for the fold into a summary, bound to the
|
|
133
|
+
* agent's configured compaction model. Omitted, the fold asks the agent's
|
|
134
|
+
* own model at the end of its own transcript, which is a cache read. */
|
|
135
|
+
callSummaryInference?: CallInference;
|
|
136
|
+
executeTool: ExecuteTool;
|
|
137
|
+
/** Host-provided, optional: keep the whole output of a tool result that is
|
|
138
|
+
* too long for the conversation, and return where it is (a path the agent
|
|
139
|
+
* can read in ranges), or null when it kept nothing. The loop cuts the
|
|
140
|
+
* result either way (`truncateToolResult`); with a path the note points
|
|
141
|
+
* there. Omitted by frontends without a real filesystem: the note then asks
|
|
142
|
+
* for a narrower call. */
|
|
143
|
+
spillToolOutput?: SpillToolOutput;
|
|
144
|
+
limits: {
|
|
145
|
+
/** Hard cap on round count. */
|
|
146
|
+
maxRounds: number;
|
|
147
|
+
/** Wall-clock cap (ms) for the whole loop. Checked at the top of each round. */
|
|
148
|
+
maxLoopMs: number;
|
|
149
|
+
/** Most one tool result with no saved copy may put into the
|
|
150
|
+
* conversation; also caps a spilled one (`toolResultCaps`). */
|
|
151
|
+
toolResultTruncateChars: number;
|
|
152
|
+
/** Circuit breaker on accumulated cost (micros). Checked at the top of
|
|
153
|
+
* each round once at least one round has run, so a tripped budget halts
|
|
154
|
+
* the next inference call rather than mid-round. Omit for no cap. */
|
|
155
|
+
maxCostMicros?: number;
|
|
156
|
+
/** The model's context-window size in tokens. A small window lowers the
|
|
157
|
+
* context size at which the run is folded into a summary
|
|
158
|
+
* (`compactionThresholdTokens`); a large one never raises it past the
|
|
159
|
+
* contract's ceiling. Omit to fall back to DEFAULT_CONTEXT_WINDOW_TOKENS. */
|
|
160
|
+
contextWindowTokens?: number;
|
|
161
|
+
/** Cut off a single inference call at whatever is left of `maxLoopMs`,
|
|
162
|
+
* instead of only checking the budget between rounds.
|
|
163
|
+
*
|
|
164
|
+
* The between-rounds check cannot interrupt a call already in flight, so
|
|
165
|
+
* one long generation runs to completion however far past the budget it
|
|
166
|
+
* goes: a five-minute limit became a nine-minute turn that way, and the
|
|
167
|
+
* whole room waited for it. This is the only thing that puts a ceiling on
|
|
168
|
+
* how long a turn can hold a room.
|
|
169
|
+
*
|
|
170
|
+
* Off by default, and set only for a meeting. In an ordinary chat nobody
|
|
171
|
+
* is blocked by a long generation, so aborting one would discard work to
|
|
172
|
+
* buy nothing: what is in flight is LOST, since the reply is only read off
|
|
173
|
+
* a call that returned. That cost is why the agent gets a clock first
|
|
174
|
+
* (`budgetNotice`) and this is the backstop for when it misses it.
|
|
175
|
+
* Keep in sync with the studio's loop. */
|
|
176
|
+
abortInferenceAtBudget?: boolean;
|
|
177
|
+
};
|
|
178
|
+
signal: AbortSignal;
|
|
179
|
+
/** Passed straight to `callInference`. Default is provider default (no
|
|
180
|
+
* field sent). */
|
|
181
|
+
toolChoice?: 'auto' | 'required' | 'none';
|
|
182
|
+
/** When true, an empty `registry` produces an *omitted* tools field on
|
|
183
|
+
* the inference request rather than `tools: []`. Matches task-side
|
|
184
|
+
* behaviour where providers reject an empty tools array. */
|
|
185
|
+
omitToolsWhenEmpty?: boolean;
|
|
186
|
+
/** Wall-clock start time used for the `maxLoopMs` budget. Defaults to
|
|
187
|
+
* `Date.now()` when omitted. Callers that want pre-loop work to count
|
|
188
|
+
* against the budget should pass in the timestamp taken before that
|
|
189
|
+
* work started. */
|
|
190
|
+
startedAtMs?: number;
|
|
191
|
+
/** Pinned notes restored from task memory at dispatch (label -> text), so the
|
|
192
|
+
* agent's `studio_pin` working set survives a task interruption / resume.
|
|
193
|
+
* Auto-pinned skills are NOT restored here - they are cheaply re-loaded. */
|
|
194
|
+
initialPinnedNotes?: Array<[string, string]>;
|
|
195
|
+
/** Fired whenever the agent's pinned notes change, so the caller can persist
|
|
196
|
+
* them (the task runner writes them to task-scoped memory). */
|
|
197
|
+
onPinnedNotesChanged?: (notes: Array<[string, string]>) => void;
|
|
198
|
+
/** Handle `studio_compact` IN-LOOP (a fold of the live in-memory
|
|
199
|
+
* transcript into a summary) instead of routing it to the MCP endpoint.
|
|
200
|
+
* Set by task runs, which have no persisted conversation to archive - their
|
|
201
|
+
* context is this message array, so the tool must fold it here. Chat runs
|
|
202
|
+
* leave this false and let the tool archive Conversation entries via MCP. */
|
|
203
|
+
compactInMemory?: boolean;
|
|
204
|
+
/** Ask the agent for handoff notes when the run ends without delivering
|
|
205
|
+
* (`HANDOFF_STOP_REASONS`): set by task runs, whose next run would
|
|
206
|
+
* otherwise start over from the brief. Comes back as `handoff`. A function
|
|
207
|
+
* decides per stop reason (a phase that hands over to the next writes none;
|
|
208
|
+
* a run that handed its work for review asks for the short `review` notes). */
|
|
209
|
+
writeHandoff?: HandoffChoice | ((stopReason: LoopStopReason) => HandoffChoice);
|
|
210
|
+
/** A run that goes in circles gets one closing round (finish, or open a
|
|
211
|
+
* blocker) before it stops (`loopClosingMessage`): set by task runs. */
|
|
212
|
+
closeOnLoop?: boolean;
|
|
213
|
+
/** Remind the run once to pin what it found after `PIN_NUDGE_AFTER_READS`
|
|
214
|
+
* reads without a pin: set by task runs. */
|
|
215
|
+
nudgePins?: boolean;
|
|
216
|
+
/** Remind the run (at most `MAX_TODO_NUDGES` times) to update its todo
|
|
217
|
+
* list when it has open items and `TODO_NUDGE_AFTER_CALLS` tool calls
|
|
218
|
+
* went by without `studio_manage_todos`. Off for delegations. */
|
|
219
|
+
nudgeTodos?: boolean;
|
|
220
|
+
hooks?: AgenticLoopHooks;
|
|
221
|
+
}
|
|
222
|
+
export interface AgenticLoopResult {
|
|
223
|
+
/** The reply to surface to the caller (chat: assistant's final message;
|
|
224
|
+
* task: derived from the final assistant message or
|
|
225
|
+
* `overrideFinalReply`). Empty string when the loop terminated without
|
|
226
|
+
* producing a clean assistant reply (e.g. abort mid-tool). */
|
|
227
|
+
finalReply: string;
|
|
228
|
+
/** Why the loop stopped - see LoopStopReason. */
|
|
229
|
+
stopReason: LoopStopReason;
|
|
230
|
+
/** Reasoning text the model emitted on the round that produced
|
|
231
|
+
* `finalReply`. Earlier rounds' thoughts (between tool calls) flow
|
|
232
|
+
* through `onAssistantNarration` and aren't accumulated here. */
|
|
233
|
+
finalThoughts: string | null;
|
|
234
|
+
/** Full message array including the system prompt and every round's
|
|
235
|
+
* assistant + tool messages. Useful for callers that want to persist
|
|
236
|
+
* the transcript or replay it. */
|
|
237
|
+
messages: ModelMessage[];
|
|
238
|
+
totalUsage: AgenticUsage;
|
|
239
|
+
finalModel: string;
|
|
240
|
+
rounds: number;
|
|
241
|
+
/** Notes for the next run of the task, when `writeHandoff` was set and the
|
|
242
|
+
* run ended without delivering. */
|
|
243
|
+
handoff?: string | null;
|
|
244
|
+
}
|
|
245
|
+
export { byToolName };
|
|
246
|
+
export declare function runAgenticLoop(opts: AgenticLoopOpts): Promise<AgenticLoopResult>;
|