@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,190 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { resolveForRead } from './host.js';
|
|
6
|
+
import { NAV_TIMEOUT_MS, activePage, emit, ensureSession, resolveDevice, resolveViewport, trackPage, } from './session.js';
|
|
7
|
+
import { attachScreenshot } from './shots.js';
|
|
8
|
+
import { MARKS_MAX, MARK_LABEL_MAX, drawMarks, readMarks } from './marks.js';
|
|
9
|
+
import { errorLine, readTrimmed } from './params.js';
|
|
10
|
+
const NOTE_MAX = 300;
|
|
11
|
+
const HTML_MAX = 2 * 1024 * 1024;
|
|
12
|
+
const SHOW_SCHEMES = new Set(['http:', 'https:', 'file:', 'about:']);
|
|
13
|
+
/** The live view of a session, bare (`/browser/view?session=<agent>:<id>`), or null without a studio URL. */
|
|
14
|
+
export function liveUrlOf(session, context) {
|
|
15
|
+
const base = context?.studioUrl?.replace(/\/+$/, '').replace(/\/api$/, '');
|
|
16
|
+
if (!base)
|
|
17
|
+
return null;
|
|
18
|
+
return `${base}/browser/view?session=${encodeURIComponent(`${session.owner.agentSlug}:${session.id}`)}`;
|
|
19
|
+
}
|
|
20
|
+
const showDefinition = {
|
|
21
|
+
name: 'runner_browser_show',
|
|
22
|
+
description: 'Show a person something in the live browser: a page (url), a local file (path) or HTML you write (html); without them, the page open now. ' +
|
|
23
|
+
'They watch while you keep working (not a handoff). `marks` point at elements with numbered labels; `marks: []` clears them. ' +
|
|
24
|
+
'The way a person sees your browser: never studio_open_page or `headed`. Several stops: runner_browser_tour.',
|
|
25
|
+
parameters: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
note: { type: 'string', description: 'What the person sees and why, in one sentence, in their language.' },
|
|
29
|
+
url: { type: 'string', description: 'A page to open (http/https, also local dev servers).' },
|
|
30
|
+
path: { type: 'string', description: 'A local file to open: an image, a PDF or an HTML file.' },
|
|
31
|
+
html: { type: 'string', description: 'An HTML document to render (a mockup, a comparison, a table). Max 2 MB.' },
|
|
32
|
+
new_tab: { type: 'boolean', description: 'Open it in a new tab next to what is open. Default: true when a page is open already.' },
|
|
33
|
+
viewport: { type: 'string', description: 'Viewport: mobile, tablet, desktop or WIDTHxHEIGHT. Default: the session\'s.' },
|
|
34
|
+
screenshot: { type: 'boolean', description: 'Also return an inline screenshot. Default: false (you know what you showed).' },
|
|
35
|
+
marks: {
|
|
36
|
+
type: 'array',
|
|
37
|
+
description: `Elements to point at, numbered in this order (max ${MARKS_MAX}). Refs come from a runner_browser_snapshot of the page that is shown; with url, path or html use selectors. [] clears the marks.`,
|
|
38
|
+
items: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
ref: { type: 'string', description: 'Element ref from the latest runner_browser_snapshot, e.g. e12.' },
|
|
42
|
+
selector: { type: 'string', description: 'Playwright selector, instead of ref.' },
|
|
43
|
+
label: { type: 'string', description: `What to say about it, short, in the person's language (max ${MARK_LABEL_MAX} chars).` },
|
|
44
|
+
tone: { type: 'string', enum: ['issue', 'good', 'info'], description: 'issue (red), good (green) or info (blue). Default: the plain pink mark.' },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['note'],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
function urlSource(raw) {
|
|
53
|
+
try {
|
|
54
|
+
const u = new URL(raw);
|
|
55
|
+
if (!SHOW_SCHEMES.has(u.protocol))
|
|
56
|
+
return { error: `Error: Unsupported URL scheme "${u.protocol}".` };
|
|
57
|
+
return { url: u.href };
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return { error: `Error: Invalid URL "${raw}"` };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function pathSource(raw, context) {
|
|
64
|
+
let file;
|
|
65
|
+
try {
|
|
66
|
+
file = resolveForRead(raw, context);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
return { error: `Error: ${errorLine(err)}` };
|
|
70
|
+
}
|
|
71
|
+
if (!existsSync(file) || !statSync(file).isFile())
|
|
72
|
+
return { error: `Error: Not found: ${raw}` };
|
|
73
|
+
return { url: pathToFileURL(file).href };
|
|
74
|
+
}
|
|
75
|
+
/** Write the snippet to a temp file: a file URL keeps relative links and a reload working. */
|
|
76
|
+
function htmlSource(html) {
|
|
77
|
+
if (Buffer.byteLength(html) > HTML_MAX)
|
|
78
|
+
return { error: 'Error: `html` is larger than 2 MB: write it to a file and pass `path`.' };
|
|
79
|
+
const dir = join(tmpdir(), 'justmade-browser-show');
|
|
80
|
+
mkdirSync(dir, { recursive: true });
|
|
81
|
+
const file = join(dir, `show-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.html`);
|
|
82
|
+
const doc = /<html[\s>]/i.test(html) ? html : `<!doctype html><meta charset="utf-8">${html}`;
|
|
83
|
+
writeFileSync(file, doc, 'utf8');
|
|
84
|
+
return { url: pathToFileURL(file).href };
|
|
85
|
+
}
|
|
86
|
+
/** What to open, from the one of url, path or html that was passed (null: the current page). */
|
|
87
|
+
function readSource(params, context) {
|
|
88
|
+
const url = readTrimmed(params.url);
|
|
89
|
+
const path = readTrimmed(params.path);
|
|
90
|
+
const html = typeof params.html === 'string' && params.html.trim() ? params.html : '';
|
|
91
|
+
if ([url, path, html].filter(Boolean).length > 1)
|
|
92
|
+
return { error: 'Error: Pass one of `url`, `path` or `html`.' };
|
|
93
|
+
if (url)
|
|
94
|
+
return urlSource(url);
|
|
95
|
+
if (path)
|
|
96
|
+
return pathSource(path, context);
|
|
97
|
+
if (html)
|
|
98
|
+
return htmlSource(html);
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function isBlank(page) {
|
|
102
|
+
const url = page.url();
|
|
103
|
+
return url === '' || url === 'about:blank';
|
|
104
|
+
}
|
|
105
|
+
async function pageFor(session, newTab) {
|
|
106
|
+
const current = activePage(session);
|
|
107
|
+
const wantNew = typeof newTab === 'boolean' ? newTab : !isBlank(current);
|
|
108
|
+
if (!wantNew)
|
|
109
|
+
return current;
|
|
110
|
+
const page = await session.context.newPage();
|
|
111
|
+
trackPage(session, page);
|
|
112
|
+
session.active = session.pages.indexOf(page);
|
|
113
|
+
return page;
|
|
114
|
+
}
|
|
115
|
+
function readViewport(value) {
|
|
116
|
+
if (value === undefined)
|
|
117
|
+
return {};
|
|
118
|
+
const vp = resolveViewport(value);
|
|
119
|
+
return 'error' in vp ? { error: `Error: ${vp.error}` } : { viewport: vp };
|
|
120
|
+
}
|
|
121
|
+
function shownNote(context) {
|
|
122
|
+
return context?.taskUid
|
|
123
|
+
? 'The person of this task got a notice with the live link; put the link in your result too.'
|
|
124
|
+
: 'It opened for the person (beside the chat in the Browser app, else in a window of its own). Carry on; the person watches.';
|
|
125
|
+
}
|
|
126
|
+
/** The parameters of a show, validated: what to open, the marks and the size. */
|
|
127
|
+
function readShow(params, context) {
|
|
128
|
+
const note = readTrimmed(params.note).slice(0, NOTE_MAX);
|
|
129
|
+
if (!note)
|
|
130
|
+
return { error: 'Error: Pass `note`: one sentence on what the person sees, in their language.' };
|
|
131
|
+
const source = readSource(params, context);
|
|
132
|
+
if (source && 'error' in source)
|
|
133
|
+
return source;
|
|
134
|
+
const marks = readMarks(params.marks);
|
|
135
|
+
if (marks && 'error' in marks)
|
|
136
|
+
return marks;
|
|
137
|
+
const sized = readViewport(params.viewport);
|
|
138
|
+
if ('error' in sized)
|
|
139
|
+
return sized;
|
|
140
|
+
return { note, source, marks, viewport: sized.viewport };
|
|
141
|
+
}
|
|
142
|
+
const executeShow = async (params, context) => {
|
|
143
|
+
const request = readShow(params, context);
|
|
144
|
+
if ('error' in request)
|
|
145
|
+
return request.error;
|
|
146
|
+
const { note, source, marks } = request;
|
|
147
|
+
// A viewport given here sets the device too (mobile and tablet emulate one),
|
|
148
|
+
// like runner_browser_navigate: without it the session kept its desktop UA.
|
|
149
|
+
const opened = await ensureSession(context, {
|
|
150
|
+
viewport: request.viewport,
|
|
151
|
+
device: params.viewport === undefined ? undefined : resolveDevice(params.viewport),
|
|
152
|
+
});
|
|
153
|
+
if ('error' in opened)
|
|
154
|
+
return opened.error;
|
|
155
|
+
const { session } = opened;
|
|
156
|
+
// A show of its own ends a tour the agent was giving.
|
|
157
|
+
session.tour = null;
|
|
158
|
+
let page = activePage(session);
|
|
159
|
+
if (source && 'url' in source) {
|
|
160
|
+
page = await pageFor(session, params.new_tab);
|
|
161
|
+
try {
|
|
162
|
+
await page.goto(source.url, { waitUntil: 'load', timeout: NAV_TIMEOUT_MS });
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
return `Error: Could not open it: ${errorLine(err)}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let marked;
|
|
169
|
+
if (marks)
|
|
170
|
+
marked = await drawMarks(page, marks);
|
|
171
|
+
session.shown = { note, at: Date.now() };
|
|
172
|
+
session.lastUsed = Date.now();
|
|
173
|
+
emit({ type: 'changed', session });
|
|
174
|
+
const base = {
|
|
175
|
+
success: true,
|
|
176
|
+
session: session.id,
|
|
177
|
+
liveUrl: liveUrlOf(session, context),
|
|
178
|
+
url: page.url(),
|
|
179
|
+
title: await page.title().catch(() => ''),
|
|
180
|
+
tab: session.active,
|
|
181
|
+
...(marked ? { marked: marked.marked, ...(marked.missed.length ? { missed: marked.missed } : {}) } : {}),
|
|
182
|
+
note: shownNote(context),
|
|
183
|
+
};
|
|
184
|
+
if (params.screenshot !== true)
|
|
185
|
+
return JSON.stringify(base);
|
|
186
|
+
return JSON.stringify(await attachScreenshot(page, params, context, base, String(base.title || 'shown')));
|
|
187
|
+
};
|
|
188
|
+
export const showTools = [
|
|
189
|
+
{ definition: showDefinition, execute: executeShow },
|
|
190
|
+
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Locator, Page } from 'playwright-core';
|
|
2
|
+
/** What an action works on: a ref from the latest snapshot, or a selector. */
|
|
3
|
+
export interface Target {
|
|
4
|
+
locator: Locator;
|
|
5
|
+
/** How the agent named it, for error messages. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** A ref goes stale when the page changes; a selector just matches nothing. */
|
|
8
|
+
kind: 'ref' | 'selector';
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveTarget(page: Page, params: Record<string, unknown>, required?: boolean): Target | {
|
|
11
|
+
error: string;
|
|
12
|
+
} | null;
|
|
13
|
+
/** The error line for a target that is not on the page, by how it was named. */
|
|
14
|
+
export declare function targetGoneError(target: Target): string;
|
|
15
|
+
/**
|
|
16
|
+
* Null when the target is in the page (given a short moment to appear), else
|
|
17
|
+
* the error line. Without this check an action on a target that is not there
|
|
18
|
+
* hangs for the whole action timeout before it fails.
|
|
19
|
+
*/
|
|
20
|
+
export declare function checkTargetAttached(target: Target): Promise<string | null>;
|
|
21
|
+
/** resolveTarget, plus the check that the target is in the page at all. */
|
|
22
|
+
export declare function resolveAttachedTarget(page: Page, params: Record<string, unknown>, required?: boolean): Promise<Target | {
|
|
23
|
+
error: string;
|
|
24
|
+
} | null>;
|
|
25
|
+
/** The hint after a failed action: only a ref can have gone stale. */
|
|
26
|
+
export declare function staleHint(target: Target): string;
|
|
27
|
+
/** The visible label of an element and whether it submits a form: input for
|
|
28
|
+
* the confirm-first gate. Never throws. */
|
|
29
|
+
export declare function describeTarget(locator: Locator): Promise<{
|
|
30
|
+
label: string;
|
|
31
|
+
submits: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
/** Whether pressing Enter in this element submits a form. */
|
|
34
|
+
export declare function enterSubmits(locator: Locator): Promise<{
|
|
35
|
+
label: string;
|
|
36
|
+
submits: boolean;
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** How long an action waits for its target to show up before it says so. */
|
|
2
|
+
const ATTACH_WAIT_MS = 2_000;
|
|
3
|
+
export function resolveTarget(page, params, required = true) {
|
|
4
|
+
const ref = typeof params.ref === 'string' ? params.ref.trim().replace(/^\[?ref=/, '').replace(/\]$/, '') : '';
|
|
5
|
+
if (ref) {
|
|
6
|
+
if (!/^(f\d+)?e\d+$/.test(ref))
|
|
7
|
+
return { error: `Error: Invalid ref "${ref}". Use a ref from the latest runner_browser_snapshot, like e12 or f1e3.` };
|
|
8
|
+
return { locator: page.getByRef(ref), name: `ref ${ref}`, kind: 'ref' };
|
|
9
|
+
}
|
|
10
|
+
const selector = typeof params.selector === 'string' ? params.selector.trim() : '';
|
|
11
|
+
if (selector)
|
|
12
|
+
return { locator: page.locator(selector).first(), name: `"${selector}"`, kind: 'selector' };
|
|
13
|
+
if (!required)
|
|
14
|
+
return null;
|
|
15
|
+
return { error: 'Error: Pass `ref` (from runner_browser_snapshot) or `selector`.' };
|
|
16
|
+
}
|
|
17
|
+
/** The error line for a target that is not on the page, by how it was named. */
|
|
18
|
+
export function targetGoneError(target) {
|
|
19
|
+
return target.kind === 'ref'
|
|
20
|
+
? `Error: ${target.name} is not on the page any more. Take a fresh runner_browser_snapshot: refs go stale when the page changes.`
|
|
21
|
+
: `Error: Nothing on the page matches ${target.name}. Check the selector against a runner_browser_snapshot.`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Null when the target is in the page (given a short moment to appear), else
|
|
25
|
+
* the error line. Without this check an action on a target that is not there
|
|
26
|
+
* hangs for the whole action timeout before it fails.
|
|
27
|
+
*/
|
|
28
|
+
export async function checkTargetAttached(target) {
|
|
29
|
+
try {
|
|
30
|
+
await target.locator.waitFor({ state: 'attached', timeout: ATTACH_WAIT_MS });
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return targetGoneError(target);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** resolveTarget, plus the check that the target is in the page at all. */
|
|
38
|
+
export async function resolveAttachedTarget(page, params, required = true) {
|
|
39
|
+
const target = resolveTarget(page, params, required);
|
|
40
|
+
if (!target || 'error' in target)
|
|
41
|
+
return target;
|
|
42
|
+
const gone = await checkTargetAttached(target);
|
|
43
|
+
return gone ? { error: gone } : target;
|
|
44
|
+
}
|
|
45
|
+
/** The hint after a failed action: only a ref can have gone stale. */
|
|
46
|
+
export function staleHint(target) {
|
|
47
|
+
return target.kind === 'ref' ? ' Take a fresh runner_browser_snapshot: refs go stale when the page changes.' : '';
|
|
48
|
+
}
|
|
49
|
+
/** The visible label of an element and whether it submits a form: input for
|
|
50
|
+
* the confirm-first gate. Never throws. */
|
|
51
|
+
export async function describeTarget(locator) {
|
|
52
|
+
try {
|
|
53
|
+
return await locator.evaluate((el) => {
|
|
54
|
+
const pick = (...vals) => vals.find(v => typeof v === 'string' && v.trim());
|
|
55
|
+
const label = pick(el.getAttribute?.('aria-label'), el.innerText, el.value, el.getAttribute?.('title'), el.getAttribute?.('alt')) ?? '';
|
|
56
|
+
const tag = String(el.tagName || '').toLowerCase();
|
|
57
|
+
const type = String(el.getAttribute?.('type') || '').toLowerCase();
|
|
58
|
+
const submits = (tag === 'button' && (type === '' || type === 'submit') && !!el.form)
|
|
59
|
+
|| (tag === 'input' && (type === 'submit' || type === 'image'));
|
|
60
|
+
return { label: label.slice(0, 200), submits };
|
|
61
|
+
}, undefined, { timeout: 3_000 });
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return { label: '', submits: false };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Whether pressing Enter in this element submits a form. */
|
|
68
|
+
export async function enterSubmits(locator) {
|
|
69
|
+
try {
|
|
70
|
+
return await locator.evaluate((el) => {
|
|
71
|
+
const form = el.form;
|
|
72
|
+
if (!form)
|
|
73
|
+
return { label: '', submits: false };
|
|
74
|
+
const btn = form.querySelector('button[type=submit], button:not([type]), input[type=submit]');
|
|
75
|
+
const label = btn ? String(btn.getAttribute('aria-label') || btn.innerText || btn.value || '').trim() : '';
|
|
76
|
+
return { label: label.slice(0, 200), submits: true };
|
|
77
|
+
}, undefined, { timeout: 3_000 });
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return { label: '', submits: false };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ToolContext, ToolDefinition } from '@nordhavnhq/runner-runtime';
|
|
2
|
+
import { type BrowserSession, type TourState, type TourStop } from './session.js';
|
|
3
|
+
type Exec = (params: Record<string, unknown>, context?: ToolContext) => Promise<string>;
|
|
4
|
+
export declare const TOUR_STOPS_MAX = 12;
|
|
5
|
+
/** Validate `stops`. */
|
|
6
|
+
export declare function readStops(raw: unknown): TourStop[] | {
|
|
7
|
+
error: string;
|
|
8
|
+
};
|
|
9
|
+
/** The page a stop is on: its own url, else that of the nearest stop before it, else the start. */
|
|
10
|
+
export declare function stopUrl(tour: TourState, index: number): string;
|
|
11
|
+
/** Put a stop on screen: go to its page when the tab is elsewhere, draw its marks. */
|
|
12
|
+
export declare function goToStop(session: BrowserSession, index: number): Promise<void>;
|
|
13
|
+
/** Stop the tour (the person closed it, or the agent moved on): its marks go too. */
|
|
14
|
+
export declare function endTour(session: BrowserSession): Promise<void>;
|
|
15
|
+
export declare const tourTools: {
|
|
16
|
+
definition: ToolDefinition;
|
|
17
|
+
execute: Exec;
|
|
18
|
+
}[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { NAV_TIMEOUT_MS, activePage, emit, ensureSession, } from './session.js';
|
|
2
|
+
import { MARKS_MAX, MARK_LABEL_MAX, clearMarks, drawMarks, readMarks } from './marks.js';
|
|
3
|
+
import { errorLine, readTrimmed } from './params.js';
|
|
4
|
+
import { liveUrlOf } from './show.js';
|
|
5
|
+
export const TOUR_STOPS_MAX = 12;
|
|
6
|
+
const NOTE_MAX = 300;
|
|
7
|
+
const TOUR_SCHEMES = new Set(['http:', 'https:', 'file:']);
|
|
8
|
+
const tourDefinition = {
|
|
9
|
+
name: 'runner_browser_tour',
|
|
10
|
+
description: 'Walk a person through a site in the live browser: stops they step through themselves, at their own pace, without a turn of yours per stop. ' +
|
|
11
|
+
'Each stop: a page, one line for the person, and marks with a tone (issue, good, info). For a review, walkthrough or demo; one thing to look at: runner_browser_show.',
|
|
12
|
+
parameters: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
note: { type: 'string', description: 'What the tour is about, one sentence in the person\'s language.' },
|
|
16
|
+
stops: {
|
|
17
|
+
type: 'array',
|
|
18
|
+
description: `The stops in order (1 to ${TOUR_STOPS_MAX}).`,
|
|
19
|
+
items: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
url: { type: 'string', description: 'The page of this stop (http/https, also local dev servers). Omit to stay on the page of the stop before.' },
|
|
23
|
+
note: { type: 'string', description: 'What the person sees at this stop and what you think of it, in their language (max 300 chars).' },
|
|
24
|
+
marks: {
|
|
25
|
+
type: 'array',
|
|
26
|
+
description: `Elements to point at on this stop (max ${MARKS_MAX}).`,
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
ref: { type: 'string', description: 'Element ref from the latest runner_browser_snapshot; only on stops before any url.' },
|
|
31
|
+
selector: { type: 'string', description: 'Playwright selector, instead of ref.' },
|
|
32
|
+
label: { type: 'string', description: `What to say about it, short (max ${MARK_LABEL_MAX} chars).` },
|
|
33
|
+
tone: { type: 'string', enum: ['issue', 'good', 'info'], description: 'issue (red), good (green) or info (blue). Default info.' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['note'],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
required: ['note', 'stops'],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
function readStopUrl(raw, n) {
|
|
46
|
+
const url = readTrimmed(raw);
|
|
47
|
+
if (!url)
|
|
48
|
+
return null;
|
|
49
|
+
try {
|
|
50
|
+
const u = new URL(url);
|
|
51
|
+
if (!TOUR_SCHEMES.has(u.protocol))
|
|
52
|
+
return { error: `Error: Stop ${n}: unsupported URL scheme "${u.protocol}".` };
|
|
53
|
+
return u.href;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return { error: `Error: Stop ${n}: invalid URL "${url}".` };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** One stop of `stops`, or why it is wrong. `navigated`: a stop before (or this one) opens a page. */
|
|
60
|
+
function readStop(raw, n, navigated) {
|
|
61
|
+
if (!raw || typeof raw !== 'object')
|
|
62
|
+
return { error: `Error: Stop ${n} must be an object with a note.` };
|
|
63
|
+
const s = raw;
|
|
64
|
+
const note = readTrimmed(s.note).slice(0, NOTE_MAX);
|
|
65
|
+
if (!note)
|
|
66
|
+
return { error: `Error: Stop ${n} needs a \`note\` for the person.` };
|
|
67
|
+
const url = readStopUrl(s.url, n);
|
|
68
|
+
if (url && typeof url === 'object')
|
|
69
|
+
return url;
|
|
70
|
+
const marks = readMarks(s.marks);
|
|
71
|
+
if (marks && 'error' in marks)
|
|
72
|
+
return { error: marks.error.replace(/^Error: /, `Error: Stop ${n}: `) };
|
|
73
|
+
if ((navigated || url) && marks?.some(m => m.ref)) {
|
|
74
|
+
return { error: `Error: Stop ${n}: a ref does not survive a navigation, point with a selector on this stop.` };
|
|
75
|
+
}
|
|
76
|
+
return { url, note, marks: (marks ?? []).map(m => ({ ...m, tone: m.tone ?? 'info' })), missed: [] };
|
|
77
|
+
}
|
|
78
|
+
/** Validate `stops`. */
|
|
79
|
+
export function readStops(raw) {
|
|
80
|
+
if (!Array.isArray(raw) || raw.length === 0)
|
|
81
|
+
return { error: 'Error: Pass `stops`: at least one { note, url?, marks? }.' };
|
|
82
|
+
if (raw.length > TOUR_STOPS_MAX)
|
|
83
|
+
return { error: `Error: At most ${TOUR_STOPS_MAX} stops.` };
|
|
84
|
+
const stops = [];
|
|
85
|
+
let navigated = false;
|
|
86
|
+
for (const [i, item] of raw.entries()) {
|
|
87
|
+
const stop = readStop(item, i + 1, navigated);
|
|
88
|
+
if ('error' in stop)
|
|
89
|
+
return stop;
|
|
90
|
+
if (stop.url)
|
|
91
|
+
navigated = true;
|
|
92
|
+
stops.push(stop);
|
|
93
|
+
}
|
|
94
|
+
return stops;
|
|
95
|
+
}
|
|
96
|
+
/** The page a stop is on: its own url, else that of the nearest stop before it, else the start. */
|
|
97
|
+
export function stopUrl(tour, index) {
|
|
98
|
+
for (let i = index; i >= 0; i--) {
|
|
99
|
+
const url = tour.stops[i]?.url;
|
|
100
|
+
if (url)
|
|
101
|
+
return url;
|
|
102
|
+
}
|
|
103
|
+
return tour.startUrl;
|
|
104
|
+
}
|
|
105
|
+
/** Put a stop on screen: go to its page when the tab is elsewhere, draw its marks. */
|
|
106
|
+
export async function goToStop(session, index) {
|
|
107
|
+
const tour = session.tour;
|
|
108
|
+
if (!tour)
|
|
109
|
+
return;
|
|
110
|
+
const i = Math.min(Math.max(Math.trunc(index), 0), tour.stops.length - 1);
|
|
111
|
+
const stop = tour.stops[i];
|
|
112
|
+
const page = activePage(session);
|
|
113
|
+
const url = stopUrl(tour, i);
|
|
114
|
+
if (url && page.url() !== url)
|
|
115
|
+
await page.goto(url, { waitUntil: 'load', timeout: NAV_TIMEOUT_MS });
|
|
116
|
+
if (stop.marks.length) {
|
|
117
|
+
const drawn = await drawMarks(page, stop.marks);
|
|
118
|
+
stop.missed = drawn.missed.map(m => m.mark);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
await clearMarks(page);
|
|
122
|
+
stop.missed = [];
|
|
123
|
+
}
|
|
124
|
+
tour.index = i;
|
|
125
|
+
session.lastUsed = Date.now();
|
|
126
|
+
emit({ type: 'changed', session });
|
|
127
|
+
}
|
|
128
|
+
/** Stop the tour (the person closed it, or the agent moved on): its marks go too. */
|
|
129
|
+
export async function endTour(session) {
|
|
130
|
+
if (!session.tour)
|
|
131
|
+
return;
|
|
132
|
+
session.tour = null;
|
|
133
|
+
await clearMarks(activePage(session));
|
|
134
|
+
emit({ type: 'changed', session });
|
|
135
|
+
}
|
|
136
|
+
const executeTour = async (params, context) => {
|
|
137
|
+
const title = readTrimmed(params.note).slice(0, NOTE_MAX);
|
|
138
|
+
if (!title)
|
|
139
|
+
return 'Error: Pass `note`: one sentence on what the tour is about, in the person\'s language.';
|
|
140
|
+
const stops = readStops(params.stops);
|
|
141
|
+
if ('error' in stops)
|
|
142
|
+
return stops.error;
|
|
143
|
+
const opened = await ensureSession(context);
|
|
144
|
+
if ('error' in opened)
|
|
145
|
+
return opened.error;
|
|
146
|
+
const { session } = opened;
|
|
147
|
+
const startUrl = activePage(session).url();
|
|
148
|
+
if (!stops[0].url && (!startUrl || startUrl === 'about:blank')) {
|
|
149
|
+
return 'Error: Nothing is open: give the first stop a `url`.';
|
|
150
|
+
}
|
|
151
|
+
session.handoff = null;
|
|
152
|
+
session.tour = { title, stops, index: 0, startUrl, at: Date.now() };
|
|
153
|
+
try {
|
|
154
|
+
await goToStop(session, 0);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
session.tour = null;
|
|
158
|
+
return `Error: Could not open stop 1: ${errorLine(err)}`;
|
|
159
|
+
}
|
|
160
|
+
// Announced like a show: the chat opens it beside the person.
|
|
161
|
+
session.shown = { note: title, at: Date.now() };
|
|
162
|
+
emit({ type: 'changed', session });
|
|
163
|
+
const first = stops[0];
|
|
164
|
+
return JSON.stringify({
|
|
165
|
+
success: true,
|
|
166
|
+
session: session.id,
|
|
167
|
+
liveUrl: liveUrlOf(session, context),
|
|
168
|
+
stops: stops.length,
|
|
169
|
+
url: activePage(session).url(),
|
|
170
|
+
...(first.missed.length ? { missedOnStop1: first.missed } : {}),
|
|
171
|
+
note: context?.taskUid
|
|
172
|
+
? 'The person of this task got a notice with the live link; put the link in your result too. They step through the stops themselves.'
|
|
173
|
+
: 'It opened beside the person. They step through the stops themselves; what they point at reaches you as a chat message. End your turn unless there is more to do.',
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
export const tourTools = [
|
|
177
|
+
{ definition: tourDefinition, execute: executeTour },
|
|
178
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nordhavnhq/runner-browser",
|
|
3
|
+
"version": "0.95.0",
|
|
4
|
+
"description": "Nordhavn OS agent browser: Playwright sessions, the browser tools, the confirm-first guard and the live view, for the runner and the browser host",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config *shape* shared by the core and every frontend. The core reads a few
|
|
3
|
+
* fields off `Config` (studioUrl, home, projects, filesystem) when handling a
|
|
4
|
+
* dispatch; it does not load or persist the file. Reading/writing the on-disk
|
|
5
|
+
* config (`~/.nordhavn-os/config.json` on the CLI) is a frontend concern and
|
|
6
|
+
* lives in the frontend package.
|
|
7
|
+
*
|
|
8
|
+
* Filesystem model (mirrors how Claude Code works in a terminal):
|
|
9
|
+
* - Each agent has a private **home** at `<home>/agent_<slug>` for artefacts it
|
|
10
|
+
* builds for itself. Always available, the same across every project.
|
|
11
|
+
* - Agents are **cross-project**: a single agent works on any project. Every
|
|
12
|
+
* chat/task dispatch carries the project it concerns (the studio passes the
|
|
13
|
+
* project slug on the frame), so the project is resolved *per dispatch*, never
|
|
14
|
+
* fixed to the agent. On the CLI, `projects` maps each studio project slug to
|
|
15
|
+
* its local checkout on this machine (managed with `nordhavn project
|
|
16
|
+
* link`); the VS Code frontend instead uses the open editor folder. Relative
|
|
17
|
+
* tool paths resolve against that project root, like a shell `cwd`.
|
|
18
|
+
* The host `runner_*` tools are jailed to {project root, agent home}; the two
|
|
19
|
+
* together are the agent's allowed filesystem surface for that dispatch.
|
|
20
|
+
*/
|
|
21
|
+
export interface AgentConfig {
|
|
22
|
+
slug: string;
|
|
23
|
+
token: string;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Organisation this agent belongs to, from the `link` response. Decides
|
|
27
|
+
* which host token the agent connects under, and disambiguates it from a
|
|
28
|
+
* same-slugged agent in another organisation (agent slugs are unique only
|
|
29
|
+
* *within* an organisation).
|
|
30
|
+
*
|
|
31
|
+
* Null only for agents added before this field existed. Such an agent pairs
|
|
32
|
+
* with the equally nameless legacy host, so `null` is a working key rather
|
|
33
|
+
* than a missing one; it resolves itself on the next `nordhavn link`.
|
|
34
|
+
*/
|
|
35
|
+
organisationSlug: string | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A pairing between this machine and ONE organisation in the studio.
|
|
39
|
+
* Populated by the pairing flow: `uuid` is the public host id, `token` is the
|
|
40
|
+
* per-host secret the studio issued at pair time, `name` is the studio-owned
|
|
41
|
+
* display label (cached locally so status commands can show it offline). All
|
|
42
|
+
* fields are server-sourced - the operator does not pick them locally.
|
|
43
|
+
*
|
|
44
|
+
* A machine can hold several of these at once (your own studio plus a client's).
|
|
45
|
+
* Each is a separate `Runner` row in its own organisation, with its own token
|
|
46
|
+
* and its own project<->folder mapping; nothing is shared between them
|
|
47
|
+
* server-side. `organisationSlug` is null only for a pairing made before the
|
|
48
|
+
* field existed.
|
|
49
|
+
*/
|
|
50
|
+
export interface HostConfig {
|
|
51
|
+
uuid: string;
|
|
52
|
+
token: string;
|
|
53
|
+
name: string;
|
|
54
|
+
organisationSlug: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface Config {
|
|
57
|
+
studioUrl: string;
|
|
58
|
+
/** Root under which each agent gets its private home at `<home>/agent_<slug>`.
|
|
59
|
+
* The agent's own space for things it builds for itself. */
|
|
60
|
+
home: string;
|
|
61
|
+
/** The folders on this machine the runner may open projects from - its access
|
|
62
|
+
* scope. For a dispatched project the runner uses `<folder>/<slug>` for the
|
|
63
|
+
* first folder where that directory exists. Managed from the CLI with
|
|
64
|
+
* `nordhavn folder add/rm`; the actual project<->folder coupling is done in
|
|
65
|
+
* the studio UI. This is runner access scope, not the agent's: the agent still
|
|
66
|
+
* only ever gets its single project folder.
|
|
67
|
+
* The project<->folder coupling is set in the studio UI and shipped on the
|
|
68
|
+
* dispatch; the runner only validates the sent folder is inside this scope. */
|
|
69
|
+
projectsRoots?: string[];
|
|
70
|
+
/** Every organisation this machine is paired with. Empty until the first
|
|
71
|
+
* `nordhavn link`; a host frontend refuses to start while it is. */
|
|
72
|
+
hosts: HostConfig[];
|
|
73
|
+
/**
|
|
74
|
+
* The organisation whose agents keep the original flat home layout
|
|
75
|
+
* (`<home>/agent_<slug>`); every other organisation is nested one level down
|
|
76
|
+
* (`<home>/<org>/agent_<slug>`).
|
|
77
|
+
*
|
|
78
|
+
* Agent slugs collide across organisations, so the home dirs have to be
|
|
79
|
+
* separated somehow. Nesting *everything* would be tidier but would move the
|
|
80
|
+
* existing folders of every current install - and a studio-side rename can
|
|
81
|
+
* make a slug collide at any moment, so that migration would sometimes have
|
|
82
|
+
* to run against a live agent. Keeping one organisation flat avoids the move
|
|
83
|
+
* entirely and is still collision-free by construction: a flat name always
|
|
84
|
+
* starts with `agent_`, a nested one always sits under an organisation dir,
|
|
85
|
+
* and two nested organisations have different dirs.
|
|
86
|
+
*
|
|
87
|
+
* Pinned to a named organisation rather than "whichever is first" so
|
|
88
|
+
* unlinking a pairing can never silently hand the flat layout - and with it
|
|
89
|
+
* another organisation's existing files - to someone else. Null when nothing
|
|
90
|
+
* has claimed it yet; agents with a null organisation also use the flat
|
|
91
|
+
* layout, which is where they already live.
|
|
92
|
+
*/
|
|
93
|
+
flatHomeOrg: string | null;
|
|
94
|
+
agents: AgentConfig[];
|
|
95
|
+
connections?: Record<string, string>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config *shape* shared by the core and every frontend. The core reads a few
|
|
3
|
+
* fields off `Config` (studioUrl, home, projects, filesystem) when handling a
|
|
4
|
+
* dispatch; it does not load or persist the file. Reading/writing the on-disk
|
|
5
|
+
* config (`~/.nordhavn-os/config.json` on the CLI) is a frontend concern and
|
|
6
|
+
* lives in the frontend package.
|
|
7
|
+
*
|
|
8
|
+
* Filesystem model (mirrors how Claude Code works in a terminal):
|
|
9
|
+
* - Each agent has a private **home** at `<home>/agent_<slug>` for artefacts it
|
|
10
|
+
* builds for itself. Always available, the same across every project.
|
|
11
|
+
* - Agents are **cross-project**: a single agent works on any project. Every
|
|
12
|
+
* chat/task dispatch carries the project it concerns (the studio passes the
|
|
13
|
+
* project slug on the frame), so the project is resolved *per dispatch*, never
|
|
14
|
+
* fixed to the agent. On the CLI, `projects` maps each studio project slug to
|
|
15
|
+
* its local checkout on this machine (managed with `nordhavn project
|
|
16
|
+
* link`); the VS Code frontend instead uses the open editor folder. Relative
|
|
17
|
+
* tool paths resolve against that project root, like a shell `cwd`.
|
|
18
|
+
* The host `runner_*` tools are jailed to {project root, agent home}; the two
|
|
19
|
+
* together are the agent's allowed filesystem surface for that dispatch.
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
22
|
+
// The dispatch's project is resolved to a local path by a host-provided resolver
|
|
23
|
+
// (see `resolveProjectRoot` in the runner package) rather than here, so the core
|
|
24
|
+
// stays free of any filesystem access - the projectsRoot convention needs an
|
|
25
|
+
// existence check the browser edition can't perform.
|