@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,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message builders for the agent loop. The OS-side internal-runtime hosts
|
|
3
|
+
* a parallel set of builders (different tool surface, different deployment)
|
|
4
|
+
* in `server/utils/internal-runtime/run-chat.ts` (`buildUserMessage`) and
|
|
5
|
+
* `server/utils/internal-runtime/loop.ts` (`buildAssistantToolCallsMessage`,
|
|
6
|
+
* `buildToolResultMessage`).
|
|
7
|
+
*
|
|
8
|
+
* The hint string inside `buildUserMessage` is intentionally per-runtime
|
|
9
|
+
* (the runner names `runner_view_image`; OS has its own image-viewing tool with its
|
|
10
|
+
* own description). Everything else - attachment partition, file-ref
|
|
11
|
+
* formatting, multipart content layout, tool-call/result part shapes - must
|
|
12
|
+
* stay structurally identical to the OS side. Parity is enforced by
|
|
13
|
+
* snapshot tests on each side (`tests/messages.test.ts` here, the matching
|
|
14
|
+
* tests on the OS side).
|
|
15
|
+
*/
|
|
16
|
+
import type { ModelMessage, ReplayableAssistantPart, ToolCall } from '../inference.js';
|
|
17
|
+
import type { AttachmentRef, HistoryEntry } from '../contract/wire.js';
|
|
18
|
+
/**
|
|
19
|
+
* Attachments arriving on the dispatch frame. Identical to the wire-side
|
|
20
|
+
* `AttachmentRef` (same Zod object in `ws-agent-dispatch.ts` on the studio).
|
|
21
|
+
* Aliased here so call sites can keep using the local name while the type
|
|
22
|
+
* itself remains anchored to the wire contract.
|
|
23
|
+
*/
|
|
24
|
+
export type MessageAttachment = AttachmentRef;
|
|
25
|
+
interface BuildUserMessageOptions {
|
|
26
|
+
/** The user-facing text body (already prefixed with [Name]: if applicable). */
|
|
27
|
+
text: string;
|
|
28
|
+
/** Files attached to this message. */
|
|
29
|
+
attachments?: MessageAttachment[];
|
|
30
|
+
/** When true, images are inlined as image parts and a "do not call runner_view_image" hint is added. */
|
|
31
|
+
inlineImages?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Said in place of the text of a message that is only files: never an empty text block. */
|
|
34
|
+
export declare const FILES_ONLY_TEXT = "(no text, only the attached files)";
|
|
35
|
+
/**
|
|
36
|
+
* The text of a person's history entry, prefixed with their name. A message
|
|
37
|
+
* without text (a photo sent on its own) reads as FILES_ONLY_TEXT.
|
|
38
|
+
* Mirrors the studio's `userMessageText` in internal-runtime/chat-messages.ts.
|
|
39
|
+
*/
|
|
40
|
+
export declare function userMessageText(content: string | null | undefined, userName?: string | null): string;
|
|
41
|
+
/**
|
|
42
|
+
* Build a v6 `UserModelMessage`, handling text-only and multi-part
|
|
43
|
+
* (text + inline images) variants uniformly.
|
|
44
|
+
*
|
|
45
|
+
* Used by both the chat loop (per-history-entry) and the task loop (initial
|
|
46
|
+
* user message) so attachment handling is consistent.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildUserMessage(opts: BuildUserMessageOptions): ModelMessage;
|
|
49
|
+
/**
|
|
50
|
+
* Build a v6 `AssistantModelMessage` for replaying a tool-calling turn back
|
|
51
|
+
* to the model. The optional `text` lands as a leading `text` part; each
|
|
52
|
+
* runtime `ToolCall` becomes a `tool-call` part with the v6 `input` key.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildAssistantToolCallsMessage(text: string | null | undefined, calls: ToolCall[], content?: ReplayableAssistantPart[]): ModelMessage;
|
|
55
|
+
/**
|
|
56
|
+
* Build a v6 `ToolModelMessage` carrying a single tool result. v6 forbids
|
|
57
|
+
* string content for the tool role, hence the array wrapper, and replaces
|
|
58
|
+
* the legacy `result` / `isError` pair with a discriminated `output`.
|
|
59
|
+
*
|
|
60
|
+
* When `images` is provided (and there is no error), emit the `content`
|
|
61
|
+
* variant (text + base64 media parts) so the model can read the bytes
|
|
62
|
+
* inline without a separate view round-trip. Used by the runner capture tools
|
|
63
|
+
* when called with `keep:false` (the default).
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildToolResultMessage(callId: string, toolName: string, value: string, opts?: {
|
|
66
|
+
isError?: boolean;
|
|
67
|
+
images?: {
|
|
68
|
+
data: Buffer;
|
|
69
|
+
mediaType: string;
|
|
70
|
+
}[];
|
|
71
|
+
}): ModelMessage;
|
|
72
|
+
/**
|
|
73
|
+
* Expand one agent history entry into the v6 messages the model replays.
|
|
74
|
+
*
|
|
75
|
+
* An agent turn that ran tools becomes a proper tool-calling transcript:
|
|
76
|
+
* assistant [tool-call …] → tool [tool-result …] → assistant "narration"
|
|
77
|
+
* so the model sees its own tool usage as real tool_use/tool_result blocks
|
|
78
|
+
* instead of being left to assume it invented the outcome. The `toolCalls`
|
|
79
|
+
* payload is intentionally minimal (name + truncated args + ok + short result
|
|
80
|
+
* snippet); full tool outputs are never re-fed.
|
|
81
|
+
*
|
|
82
|
+
* Mirror of the studio-side `buildAgentHistoryMessages` in
|
|
83
|
+
* `apps/server/server/utils/internal-runtime/run-chat.ts`. The wire-visible
|
|
84
|
+
* structure must stay identical; parity is pinned by snapshot tests on each
|
|
85
|
+
* side.
|
|
86
|
+
*/
|
|
87
|
+
export declare function buildAgentHistoryMessages(entry: HistoryEntry, idPrefix: string): ModelMessage[];
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/** Said in place of the text of a message that is only files: never an empty text block. */
|
|
2
|
+
export const FILES_ONLY_TEXT = '(no text, only the attached files)';
|
|
3
|
+
/**
|
|
4
|
+
* The text of a person's history entry, prefixed with their name. A message
|
|
5
|
+
* without text (a photo sent on its own) reads as FILES_ONLY_TEXT.
|
|
6
|
+
* Mirrors the studio's `userMessageText` in internal-runtime/chat-messages.ts.
|
|
7
|
+
*/
|
|
8
|
+
export function userMessageText(content, userName) {
|
|
9
|
+
const said = content && content.trim().length > 0 ? content : FILES_ONLY_TEXT;
|
|
10
|
+
return userName ? `[${userName}]: ${said}` : said;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build a v6 `UserModelMessage`, handling text-only and multi-part
|
|
14
|
+
* (text + inline images) variants uniformly.
|
|
15
|
+
*
|
|
16
|
+
* Used by both the chat loop (per-history-entry) and the task loop (initial
|
|
17
|
+
* user message) so attachment handling is consistent.
|
|
18
|
+
*/
|
|
19
|
+
export function buildUserMessage(opts) {
|
|
20
|
+
const { text, attachments = [], inlineImages = true } = opts;
|
|
21
|
+
const images = attachments.filter(a => a.type?.startsWith('image/'));
|
|
22
|
+
const nonImages = attachments.filter(a => !a.type?.startsWith('image/'));
|
|
23
|
+
// Text-only path: no attachments, or images aren't being inlined.
|
|
24
|
+
if (!inlineImages || images.length === 0) {
|
|
25
|
+
let content = text;
|
|
26
|
+
if (attachments.length > 0) {
|
|
27
|
+
content += '\n\nAttached files: ' + attachments.map(formatFileRef).join(', ');
|
|
28
|
+
}
|
|
29
|
+
return { role: 'user', content };
|
|
30
|
+
}
|
|
31
|
+
// Multi-part path: text + inline images for vision models.
|
|
32
|
+
let textContent = text;
|
|
33
|
+
textContent += '\n\n[The images below are already provided inline - analyze them directly. Do NOT call runner_view_image or any file tool for these images.]';
|
|
34
|
+
textContent += '\nAttached images: ' + images.map(formatImageRef).join(', ');
|
|
35
|
+
if (nonImages.length > 0) {
|
|
36
|
+
textContent += '\nOther attached files: ' + nonImages.map(formatFileRef).join(', ');
|
|
37
|
+
}
|
|
38
|
+
const parts = [
|
|
39
|
+
{ type: 'text', text: textContent },
|
|
40
|
+
...images.map((a) => ({
|
|
41
|
+
type: 'image',
|
|
42
|
+
image: a.url,
|
|
43
|
+
...(a.type ? { mediaType: a.type } : {}),
|
|
44
|
+
})),
|
|
45
|
+
];
|
|
46
|
+
return { role: 'user', content: parts };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build a v6 `AssistantModelMessage` for replaying a tool-calling turn back
|
|
50
|
+
* to the model. The optional `text` lands as a leading `text` part; each
|
|
51
|
+
* runtime `ToolCall` becomes a `tool-call` part with the v6 `input` key.
|
|
52
|
+
*/
|
|
53
|
+
export function buildAssistantToolCallsMessage(text, calls, content) {
|
|
54
|
+
// A signed turn goes back exactly as it came: Opus 5.5 and Fable 5.1 answer
|
|
55
|
+
// a rebuilt one (thinking dropped or moved) with a 400. Only the tool inputs
|
|
56
|
+
// are normalised, the same way the rebuilt path does it. Mirrors the
|
|
57
|
+
// studio's `buildAssistantToolCallsMessage`.
|
|
58
|
+
if (content?.length) {
|
|
59
|
+
return {
|
|
60
|
+
role: 'assistant',
|
|
61
|
+
content: content.map(p => p.type === 'tool-call' ? { ...p, input: coerceToolInput(p.input) } : p),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const parts = [];
|
|
65
|
+
if (text && text.length > 0)
|
|
66
|
+
parts.push({ type: 'text', text });
|
|
67
|
+
for (const c of calls) {
|
|
68
|
+
parts.push({
|
|
69
|
+
type: 'tool-call',
|
|
70
|
+
toolCallId: c.id,
|
|
71
|
+
toolName: c.name,
|
|
72
|
+
input: coerceToolInput(c.arguments),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return { role: 'assistant', content: parts };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Anthropic (and other providers) reject `tool_use.input` if it is not a JSON
|
|
79
|
+
* object - "messages.N.content.M.tool_use.input: Input should be an object".
|
|
80
|
+
* Some models occasionally emit null/string/primitive args. Coerce so the next
|
|
81
|
+
* inference round does not blow up replaying our own history. Mirrored on the
|
|
82
|
+
* studio side in `server/utils/internal-runtime/loop.ts`.
|
|
83
|
+
*/
|
|
84
|
+
function coerceToolInput(args) {
|
|
85
|
+
if (args && typeof args === 'object' && !Array.isArray(args)) {
|
|
86
|
+
return args;
|
|
87
|
+
}
|
|
88
|
+
if (typeof args === 'string' && args.length > 0) {
|
|
89
|
+
try {
|
|
90
|
+
const parsed = JSON.parse(args);
|
|
91
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
92
|
+
return parsed;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch { /* fall through to empty object */ }
|
|
96
|
+
}
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Build a v6 `ToolModelMessage` carrying a single tool result. v6 forbids
|
|
101
|
+
* string content for the tool role, hence the array wrapper, and replaces
|
|
102
|
+
* the legacy `result` / `isError` pair with a discriminated `output`.
|
|
103
|
+
*
|
|
104
|
+
* When `images` is provided (and there is no error), emit the `content`
|
|
105
|
+
* variant (text + base64 media parts) so the model can read the bytes
|
|
106
|
+
* inline without a separate view round-trip. Used by the runner capture tools
|
|
107
|
+
* when called with `keep:false` (the default).
|
|
108
|
+
*/
|
|
109
|
+
export function buildToolResultMessage(callId, toolName, value, opts) {
|
|
110
|
+
let output;
|
|
111
|
+
if (opts?.isError) {
|
|
112
|
+
output = { type: 'error-text', value };
|
|
113
|
+
}
|
|
114
|
+
else if (opts?.images && opts.images.length > 0) {
|
|
115
|
+
output = {
|
|
116
|
+
type: 'content',
|
|
117
|
+
value: [
|
|
118
|
+
{ type: 'text', text: value },
|
|
119
|
+
...opts.images.map(img => ({
|
|
120
|
+
type: 'media',
|
|
121
|
+
data: img.data.toString('base64'),
|
|
122
|
+
mediaType: img.mediaType,
|
|
123
|
+
})),
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
output = { type: 'text', value };
|
|
129
|
+
}
|
|
130
|
+
const part = {
|
|
131
|
+
type: 'tool-result',
|
|
132
|
+
toolCallId: callId,
|
|
133
|
+
toolName,
|
|
134
|
+
output,
|
|
135
|
+
};
|
|
136
|
+
return { role: 'tool', content: [part] };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Expand one agent history entry into the v6 messages the model replays.
|
|
140
|
+
*
|
|
141
|
+
* An agent turn that ran tools becomes a proper tool-calling transcript:
|
|
142
|
+
* assistant [tool-call …] → tool [tool-result …] → assistant "narration"
|
|
143
|
+
* so the model sees its own tool usage as real tool_use/tool_result blocks
|
|
144
|
+
* instead of being left to assume it invented the outcome. The `toolCalls`
|
|
145
|
+
* payload is intentionally minimal (name + truncated args + ok + short result
|
|
146
|
+
* snippet); full tool outputs are never re-fed.
|
|
147
|
+
*
|
|
148
|
+
* Mirror of the studio-side `buildAgentHistoryMessages` in
|
|
149
|
+
* `apps/server/server/utils/internal-runtime/run-chat.ts`. The wire-visible
|
|
150
|
+
* structure must stay identical; parity is pinned by snapshot tests on each
|
|
151
|
+
* side.
|
|
152
|
+
*/
|
|
153
|
+
export function buildAgentHistoryMessages(entry, idPrefix) {
|
|
154
|
+
const out = [];
|
|
155
|
+
const calls = entry.toolCalls ?? [];
|
|
156
|
+
if (calls.length > 0) {
|
|
157
|
+
out.push({
|
|
158
|
+
role: 'assistant',
|
|
159
|
+
content: calls.map((c, i) => ({
|
|
160
|
+
type: 'tool-call',
|
|
161
|
+
toolCallId: `${idPrefix}-${i}`,
|
|
162
|
+
toolName: c.name,
|
|
163
|
+
input: c.args && typeof c.args === 'object' && !Array.isArray(c.args) ? c.args : {},
|
|
164
|
+
})),
|
|
165
|
+
});
|
|
166
|
+
out.push({
|
|
167
|
+
role: 'tool',
|
|
168
|
+
content: calls.map((c, i) => ({
|
|
169
|
+
type: 'tool-result',
|
|
170
|
+
toolCallId: `${idPrefix}-${i}`,
|
|
171
|
+
toolName: c.name,
|
|
172
|
+
output: c.ok
|
|
173
|
+
? { type: 'text', value: c.result && c.result.length > 0 ? c.result : 'ok' }
|
|
174
|
+
: { type: 'error-text', value: c.result && c.result.length > 0 ? c.result : 'error' },
|
|
175
|
+
})),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const text = entry.content?.trim();
|
|
179
|
+
if (text && text.length > 0)
|
|
180
|
+
out.push({ role: 'assistant', content: entry.content });
|
|
181
|
+
return out;
|
|
182
|
+
}
|
|
183
|
+
function formatFileRef(a) {
|
|
184
|
+
return `${a.name} (${a.url})${a.uid ? ` [fileUid: ${a.uid}]` : ''}`;
|
|
185
|
+
}
|
|
186
|
+
function formatImageRef(a) {
|
|
187
|
+
return `${a.name} (url: ${a.url})${a.uid ? ` [fileUid: ${a.uid}]` : ''}`;
|
|
188
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A steer queued for a running chat turn or task run: what the person typed,
|
|
3
|
+
* and the studio's entry uid for it when the studio waits for the read (a
|
|
4
|
+
* `steerId` on the frame). The runtime acks those ids the moment it reads them,
|
|
5
|
+
* so the line leaves the stack above the input and lands in the transcript at
|
|
6
|
+
* that point. Mirrors the studio's internal-runtime/pending-steers.ts.
|
|
7
|
+
*/
|
|
8
|
+
export interface PendingSteer {
|
|
9
|
+
message: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
/** The steers as one block: a single one as is, several numbered. */
|
|
13
|
+
export declare function steerBody(steers: PendingSteer[]): string;
|
|
14
|
+
/** The entry uids to ack, in the order they were sent. */
|
|
15
|
+
export declare function steerIds(steers: PendingSteer[]): string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The steers as one block: a single one as is, several numbered. */
|
|
2
|
+
export function steerBody(steers) {
|
|
3
|
+
return steers.length === 1
|
|
4
|
+
? steers[0].message
|
|
5
|
+
: steers.map((s, i) => `${i + 1}. ${s.message}`).join('\n');
|
|
6
|
+
}
|
|
7
|
+
/** The entry uids to ack, in the order they were sent. */
|
|
8
|
+
export function steerIds(steers) {
|
|
9
|
+
return steers.flatMap(s => (s.id ? [s.id] : []));
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RunPhaseName, type RunPhasesConfig } from '../contract/phases.js';
|
|
2
|
+
import { type AgenticLoopOpts, type AgenticLoopResult, type CallInference } from './loop.js';
|
|
3
|
+
/**
|
|
4
|
+
* A task run's loop: the single-model loop, or, when the dispatch carries
|
|
5
|
+
* phases (`agentConfig.phases`), the agent contract's `runPhasedLoop` with one
|
|
6
|
+
* `runAgenticLoop` per phase, each on a fresh chain and on the phase's slot.
|
|
7
|
+
* The contract owns the rules; this file only wires the phase's guard into
|
|
8
|
+
* this runtime's tool executor and round hooks. The studio's twin is
|
|
9
|
+
* `server/utils/internal-runtime/phased-loop.ts`: change one, change the other.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runTaskLoop(opts: AgenticLoopOpts, phased: {
|
|
12
|
+
phases?: RunPhasesConfig;
|
|
13
|
+
/** The transport of one phase: the agent's model on that slot, booked under that phase. */
|
|
14
|
+
inferenceFor: (slot: 'plan' | 'exec', phase: RunPhaseName) => CallInference;
|
|
15
|
+
onPhase?: (phase: RunPhaseName, why: string) => void;
|
|
16
|
+
}): Promise<AgenticLoopResult>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { workingSetLedger } from '../contract/loop.js';
|
|
2
|
+
import { runPhasedLoop } from '../contract/phases.js';
|
|
3
|
+
import { runAgenticLoop } from './loop.js';
|
|
4
|
+
/**
|
|
5
|
+
* A task run's loop: the single-model loop, or, when the dispatch carries
|
|
6
|
+
* phases (`agentConfig.phases`), the agent contract's `runPhasedLoop` with one
|
|
7
|
+
* `runAgenticLoop` per phase, each on a fresh chain and on the phase's slot.
|
|
8
|
+
* The contract owns the rules; this file only wires the phase's guard into
|
|
9
|
+
* this runtime's tool executor and round hooks. The studio's twin is
|
|
10
|
+
* `server/utils/internal-runtime/phased-loop.ts`: change one, change the other.
|
|
11
|
+
*/
|
|
12
|
+
export async function runTaskLoop(opts, phased) {
|
|
13
|
+
if (!phased.phases)
|
|
14
|
+
return runAgenticLoop(opts);
|
|
15
|
+
// One clock for the whole run, not one per phase.
|
|
16
|
+
const base = { ...opts, startedAtMs: opts.startedAtMs ?? Date.now() };
|
|
17
|
+
return runPhasedLoop({
|
|
18
|
+
config: phased.phases,
|
|
19
|
+
initialMessages: base.initialMessages,
|
|
20
|
+
registry: base.registry,
|
|
21
|
+
maxRounds: base.limits.maxRounds,
|
|
22
|
+
closeOnLoop: !!base.closeOnLoop,
|
|
23
|
+
writeHandoff: r => typeof base.writeHandoff === 'function' ? base.writeHandoff(r) : (base.writeHandoff ?? false),
|
|
24
|
+
initialPinnedNotes: base.initialPinnedNotes,
|
|
25
|
+
ledger: workingSetLedger,
|
|
26
|
+
onPhase: phased.onPhase,
|
|
27
|
+
// The plan's tool groups, loaded the way the agent loads them (so the load
|
|
28
|
+
// shows on the task like its own), before the exec chain starts.
|
|
29
|
+
loadToolGroups: async (groups) => {
|
|
30
|
+
const def = base.registry.get(LOAD_TOOLSET);
|
|
31
|
+
if (!def)
|
|
32
|
+
return;
|
|
33
|
+
for (const group of groups)
|
|
34
|
+
await base.executeTool({ id: `preload-${group}`, name: LOAD_TOOLSET, arguments: { group } }, def);
|
|
35
|
+
},
|
|
36
|
+
runPhase: run => runAgenticLoop(phaseLoopOpts(base, run, phased.inferenceFor(run.slot, run.phase))),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const LOAD_TOOLSET = 'studio_load_toolset';
|
|
40
|
+
/** The loop options of one phase: the run's own, with the phase's chain, transport, limits and guard. */
|
|
41
|
+
function phaseLoopOpts(base, run, callInference) {
|
|
42
|
+
const hooks = base.hooks ?? {};
|
|
43
|
+
const offset = run.roundOffset;
|
|
44
|
+
return {
|
|
45
|
+
...base,
|
|
46
|
+
initialMessages: run.initialMessages,
|
|
47
|
+
callInference,
|
|
48
|
+
executeTool: async (call, def) => {
|
|
49
|
+
const answered = run.guard.intercept(call.name, call.arguments);
|
|
50
|
+
if (answered)
|
|
51
|
+
return { ...answered, durationMs: 0 };
|
|
52
|
+
const outcome = await base.executeTool(call, def);
|
|
53
|
+
run.guard.observe(call.name, call.arguments, outcome);
|
|
54
|
+
return outcome;
|
|
55
|
+
},
|
|
56
|
+
limits: {
|
|
57
|
+
...base.limits,
|
|
58
|
+
maxRounds: run.maxRounds,
|
|
59
|
+
maxCostMicros: base.limits.maxCostMicros != null ? Math.max(0, base.limits.maxCostMicros - run.spentMicros) : undefined,
|
|
60
|
+
},
|
|
61
|
+
initialPinnedNotes: run.initialPinnedNotes,
|
|
62
|
+
onPinnedNotesChanged: (notes) => {
|
|
63
|
+
run.onPins(notes);
|
|
64
|
+
base.onPinnedNotesChanged?.(notes);
|
|
65
|
+
},
|
|
66
|
+
closeOnLoop: run.closeOnLoop,
|
|
67
|
+
writeHandoff: run.handoffOn,
|
|
68
|
+
hooks: {
|
|
69
|
+
...hooks,
|
|
70
|
+
onInferenceInput: hooks.onInferenceInput ? (round, messages, tools) => hooks.onInferenceInput(round + offset, messages, tools) : undefined,
|
|
71
|
+
onInferenceOutput: hooks.onInferenceOutput ? (round, result) => hooks.onInferenceOutput(round + offset, result) : undefined,
|
|
72
|
+
onAssistantNarration: hooks.onAssistantNarration ? (round, narration, thoughts) => hooks.onAssistantNarration(round + offset, narration, thoughts) : undefined,
|
|
73
|
+
onRoundStart: hooks.onRoundStart ? round => hooks.onRoundStart(round + offset) : undefined,
|
|
74
|
+
onEmptyToolCalls: async (round, reply) => {
|
|
75
|
+
const answer = run.guard.onReply(reply);
|
|
76
|
+
if (typeof answer === 'string')
|
|
77
|
+
return { continueWithUserMessage: answer };
|
|
78
|
+
if (answer === true)
|
|
79
|
+
return undefined;
|
|
80
|
+
return hooks.onEmptyToolCalls?.(round + offset, reply);
|
|
81
|
+
},
|
|
82
|
+
onAfterRound: (round) => {
|
|
83
|
+
const own = hooks.onAfterRound?.(round + offset);
|
|
84
|
+
if (own?.stop) {
|
|
85
|
+
run.guard.cancel();
|
|
86
|
+
return own;
|
|
87
|
+
}
|
|
88
|
+
if (run.guard.endRound())
|
|
89
|
+
return { stop: true };
|
|
90
|
+
const nudge = run.guard.nudge();
|
|
91
|
+
if (!nudge)
|
|
92
|
+
return own;
|
|
93
|
+
return { ...own, injectUserMessage: own?.injectUserMessage ? `${own.injectUserMessage}\n\n${nudge}` : nudge };
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pointer to the project's own standing instructions (`CLAUDE.md`,
|
|
3
|
+
* `AGENTS.md` and the like),
|
|
4
|
+
* appended to the studio-assembled system prompt. The studio can't build this:
|
|
5
|
+
* the file lives in the checkout on this machine. Only the pointer goes in the
|
|
6
|
+
* prompt, never the contents: the agent reads the file itself, so it costs no
|
|
7
|
+
* context on a turn that never touches the project. Whether the file exists is
|
|
8
|
+
* the host's to say (the core stays filesystem-free).
|
|
9
|
+
*/
|
|
10
|
+
/** Instruction files other agent tools read, looked for relative to the
|
|
11
|
+
* project root, in this order. */
|
|
12
|
+
export declare const PROJECT_INSTRUCTION_FILES: readonly ["CLAUDE.md", "AGENTS.md", "GEMINI.md", ".github/copilot-instructions.md", ".cursorrules"];
|
|
13
|
+
/** Host seam: which of `PROJECT_INSTRUCTION_FILES` exist in `projectRoot`,
|
|
14
|
+
* one name per distinct file (a symlinked `AGENTS.md` -> `CLAUDE.md` is one).
|
|
15
|
+
* A frontend without a filesystem omits the seam. */
|
|
16
|
+
export type FindProjectInstructions = (projectRoot: string) => string[];
|
|
17
|
+
/**
|
|
18
|
+
* Text to append to the system prompt (starting with a blank-line separator),
|
|
19
|
+
* or '' when the project has no instruction file. Never throws: a lookup that
|
|
20
|
+
* fails must not stop the run.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildProjectInstructionsNote(find: FindProjectInstructions | undefined, projectRoot: string, agentHome: string): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pointer to the project's own standing instructions (`CLAUDE.md`,
|
|
3
|
+
* `AGENTS.md` and the like),
|
|
4
|
+
* appended to the studio-assembled system prompt. The studio can't build this:
|
|
5
|
+
* the file lives in the checkout on this machine. Only the pointer goes in the
|
|
6
|
+
* prompt, never the contents: the agent reads the file itself, so it costs no
|
|
7
|
+
* context on a turn that never touches the project. Whether the file exists is
|
|
8
|
+
* the host's to say (the core stays filesystem-free).
|
|
9
|
+
*/
|
|
10
|
+
/** Instruction files other agent tools read, looked for relative to the
|
|
11
|
+
* project root, in this order. */
|
|
12
|
+
export const PROJECT_INSTRUCTION_FILES = [
|
|
13
|
+
'CLAUDE.md',
|
|
14
|
+
'AGENTS.md',
|
|
15
|
+
'GEMINI.md',
|
|
16
|
+
'.github/copilot-instructions.md',
|
|
17
|
+
'.cursorrules',
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Text to append to the system prompt (starting with a blank-line separator),
|
|
21
|
+
* or '' when the project has no instruction file. Never throws: a lookup that
|
|
22
|
+
* fails must not stop the run.
|
|
23
|
+
*/
|
|
24
|
+
export function buildProjectInstructionsNote(find, projectRoot, agentHome) {
|
|
25
|
+
// No project behind this dispatch: the root fell back to the agent's own
|
|
26
|
+
// home, which is not a project with instructions of its own.
|
|
27
|
+
if (!find || projectRoot === agentHome)
|
|
28
|
+
return '';
|
|
29
|
+
let files;
|
|
30
|
+
try {
|
|
31
|
+
files = find(projectRoot);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
if (files.length === 0)
|
|
37
|
+
return '';
|
|
38
|
+
const list = files.map(f => `\`${f}\``).join(', ');
|
|
39
|
+
const one = files.length === 1;
|
|
40
|
+
// How to read it is half the instruction: such a file can run to thousands
|
|
41
|
+
// of lines, and read whole it rides along in every later round of the run.
|
|
42
|
+
return `
|
|
43
|
+
|
|
44
|
+
## Project instructions
|
|
45
|
+
|
|
46
|
+
The project you are working in (\`${projectRoot}\`) has its own instructions: ${list} (relative to its root). Before you do any work in this project, read ${one ? 'it' : 'them'} with \`runner_read_file\` and follow ${one ? 'it' : 'them'}: ${one ? 'it describes' : 'they describe'} the project's conventions, commands and hard rules. A short file you read whole. A long one (the first read says how many lines) you read by its headings: list them with \`runner_grep\` (pattern \`^#{1,3} \`, output \`content\`, path the file; without that tool, \`grep -n "^#" <file>\`), then read the sections on hard rules, conventions and commands, plus whatever bears on your task, each once. Where ${one ? 'it conflicts' : 'they conflict'} with the instructions above, the instructions above win.`;
|
|
47
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ToolDefPayload } from '../contract/wire.js';
|
|
2
|
+
import type { ToolDefinition } from '../inference.js';
|
|
3
|
+
/** Tool order on the wire: by name, by code unit, the same on every machine. */
|
|
4
|
+
export declare function byToolName(a: {
|
|
5
|
+
name: string;
|
|
6
|
+
}, b: {
|
|
7
|
+
name: string;
|
|
8
|
+
}): number;
|
|
9
|
+
/**
|
|
10
|
+
* The tools of one round, in the order that keeps the prompt cache's prefix
|
|
11
|
+
* stable. The tools open that prefix, so a tool loaded mid-run must never land
|
|
12
|
+
* between the others: the tools of the chain's start come first, sorted by name
|
|
13
|
+
* (byte-identical to what every earlier round sent), then the tools loaded
|
|
14
|
+
* since, in load order, each tagged with the tool call whose result brought it
|
|
15
|
+
* in (`loadedBy`). The server sends those as deferred tools, referenced from
|
|
16
|
+
* that result, so they stay out of the prefix.
|
|
17
|
+
*/
|
|
18
|
+
export declare function orderRunTools(registry: ReadonlyMap<string, ToolDefPayload>, loadedBy: ReadonlyMap<string, string>): ToolDefinition[];
|
|
19
|
+
/**
|
|
20
|
+
* Wraps `executeTool` so every tool that appears in the registry during a call
|
|
21
|
+
* (an explicit `studio_load_toolset`, a first-use auto-load) is recorded with
|
|
22
|
+
* the call's id. `reset()` forgets them, where a new chain starts.
|
|
23
|
+
*/
|
|
24
|
+
export declare function trackLoadedTools<C extends {
|
|
25
|
+
id: string;
|
|
26
|
+
}, R>(registry: Map<string, ToolDefPayload>, loadedBy: Map<string, string>, executeTool: (call: C, def: ToolDefPayload | undefined) => Promise<R>): (call: C, def: ToolDefPayload | undefined) => Promise<R>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Tool order on the wire: by name, by code unit, the same on every machine. */
|
|
2
|
+
export function byToolName(a, b) {
|
|
3
|
+
return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The tools of one round, in the order that keeps the prompt cache's prefix
|
|
7
|
+
* stable. The tools open that prefix, so a tool loaded mid-run must never land
|
|
8
|
+
* between the others: the tools of the chain's start come first, sorted by name
|
|
9
|
+
* (byte-identical to what every earlier round sent), then the tools loaded
|
|
10
|
+
* since, in load order, each tagged with the tool call whose result brought it
|
|
11
|
+
* in (`loadedBy`). The server sends those as deferred tools, referenced from
|
|
12
|
+
* that result, so they stay out of the prefix.
|
|
13
|
+
*/
|
|
14
|
+
export function orderRunTools(registry, loadedBy) {
|
|
15
|
+
const toDef = (t, by) => ({
|
|
16
|
+
name: t.name,
|
|
17
|
+
description: t.description,
|
|
18
|
+
parameters: t.parametersSchema ?? { type: 'object', properties: {} },
|
|
19
|
+
...(by ? { loadedBy: by } : {}),
|
|
20
|
+
});
|
|
21
|
+
const base = [...registry.values()].filter(t => !loadedBy.has(t.name)).sort(byToolName).map(t => toDef(t));
|
|
22
|
+
const loaded = [];
|
|
23
|
+
for (const [name, by] of loadedBy) {
|
|
24
|
+
const t = registry.get(name);
|
|
25
|
+
if (t)
|
|
26
|
+
loaded.push(toDef(t, by));
|
|
27
|
+
}
|
|
28
|
+
return [...base, ...loaded];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Wraps `executeTool` so every tool that appears in the registry during a call
|
|
32
|
+
* (an explicit `studio_load_toolset`, a first-use auto-load) is recorded with
|
|
33
|
+
* the call's id. `reset()` forgets them, where a new chain starts.
|
|
34
|
+
*/
|
|
35
|
+
export function trackLoadedTools(registry, loadedBy, executeTool) {
|
|
36
|
+
return async (call, def) => {
|
|
37
|
+
const before = new Set(registry.keys());
|
|
38
|
+
const res = await executeTool(call, def);
|
|
39
|
+
for (const name of registry.keys()) {
|
|
40
|
+
if (!before.has(name) && !loadedBy.has(name))
|
|
41
|
+
loadedBy.set(name, call.id);
|
|
42
|
+
}
|
|
43
|
+
for (const name of [...loadedBy.keys()])
|
|
44
|
+
if (!registry.has(name))
|
|
45
|
+
loadedBy.delete(name);
|
|
46
|
+
return res;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime addendum appended to the studio-assembled system prompt, naming this
|
|
3
|
+
* dispatch's concrete scratch dir. The studio can't build this: it doesn't know
|
|
4
|
+
* the runner machine's local paths. Kept short and identical for task and chat
|
|
5
|
+
* dispatches. Returns text starting with a blank-line separator so it can be
|
|
6
|
+
* concatenated straight onto the studio prompt.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildScratchPromptNote(scratchRoot: string, callerScratch?: string | null): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime addendum appended to the studio-assembled system prompt, naming this
|
|
3
|
+
* dispatch's concrete scratch dir. The studio can't build this: it doesn't know
|
|
4
|
+
* the runner machine's local paths. Kept short and identical for task and chat
|
|
5
|
+
* dispatches. Returns text starting with a blank-line separator so it can be
|
|
6
|
+
* concatenated straight onto the studio prompt.
|
|
7
|
+
*/
|
|
8
|
+
export function buildScratchPromptNote(scratchRoot, callerScratch) {
|
|
9
|
+
const callerNote = callerScratch
|
|
10
|
+
? `\n\nYour caller's scratch dir \`${callerScratch}\` is readable for you (read-only): open what it left there for you with \`runner_read_file\`, or copy it into your own scratch first. You cannot write or delete there.`
|
|
11
|
+
: '';
|
|
12
|
+
return `
|
|
13
|
+
|
|
14
|
+
## Scratch space
|
|
15
|
+
|
|
16
|
+
For throwaway or intermediate files (scratch notes, temp scripts, downloaded artifacts you do not need to keep), write under \`${scratchRoot}\` - also exposed to shell commands as \`$NORDHAVN_SCRATCH\`. It sits outside the project checkout and is auto-deleted after 24h, so it never pollutes the repo or shows up in git. Keep everything temporary here.
|
|
17
|
+
|
|
18
|
+
Anything you need to KEEP must not live only in scratch - it is deleted, not saved. Before you finish: commit code/text deliverables into the project checkout, and push assets (images, PDFs, generated files) to the file manager with \`runner_upload_file\` (pass the local path) or \`studio_save_file\`. A file that exists only under \`${scratchRoot}\` at the end of your run is lost.${callerNote}`;
|
|
19
|
+
}
|