@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,83 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { constants } from 'node:os';
|
|
3
|
+
// ─── Foreground supervisor ───────────────────
|
|
4
|
+
//
|
|
5
|
+
// A foreground `nordhavn up` of a global install is a thin parent that runs the
|
|
6
|
+
// real runtime (the worker) as a child on the same terminal. A worker that
|
|
7
|
+
// installed an update exits with RESTART_EXIT_CODE and the parent starts the
|
|
8
|
+
// entry script again, which is now the new version. Any other exit ends the
|
|
9
|
+
// parent with the same code; Ctrl+C and SIGTERM reach the worker and end both.
|
|
10
|
+
/** EX_TEMPFAIL: "restart me". */
|
|
11
|
+
export const RESTART_EXIT_CODE = 75;
|
|
12
|
+
/** Set on the worker, so it knows a restart is its parent's job. */
|
|
13
|
+
export const SUPERVISED_ENV = 'NORDHAVN_SUPERVISED';
|
|
14
|
+
const FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
15
|
+
/** More restarts than this within RESTART_WINDOW_MS is a loop, not an update. */
|
|
16
|
+
const MAX_RESTARTS = 5;
|
|
17
|
+
const RESTART_WINDOW_MS = 60_000;
|
|
18
|
+
/** What the supervisor does when its worker ends. */
|
|
19
|
+
export function decideOnExit(code, signal) {
|
|
20
|
+
if (code === RESTART_EXIT_CODE)
|
|
21
|
+
return { action: 'restart' };
|
|
22
|
+
if (code !== null)
|
|
23
|
+
return { action: 'exit', code };
|
|
24
|
+
const signo = signal ? constants.signals[signal] : undefined;
|
|
25
|
+
return { action: 'exit', code: signo ? 128 + signo : 1 };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Runs the worker until it ends with anything but a restart; resolves with the
|
|
29
|
+
* code to exit with. Never calls process.exit itself.
|
|
30
|
+
*/
|
|
31
|
+
export function supervise(opts) {
|
|
32
|
+
const now = opts.now ?? Date.now;
|
|
33
|
+
const restarts = [];
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let child = null;
|
|
36
|
+
const forward = (signal) => () => {
|
|
37
|
+
// The terminal already sent Ctrl+C to the whole process group; forwarding
|
|
38
|
+
// covers a signal aimed at this pid alone. The worker's shutdown is idempotent.
|
|
39
|
+
try {
|
|
40
|
+
child?.kill(signal);
|
|
41
|
+
}
|
|
42
|
+
catch { /* gone */ }
|
|
43
|
+
};
|
|
44
|
+
const handlers = FORWARDED_SIGNALS.map(signal => [signal, forward(signal)]);
|
|
45
|
+
for (const [signal, handler] of handlers)
|
|
46
|
+
process.on(signal, handler);
|
|
47
|
+
let done = false;
|
|
48
|
+
const finish = (code) => {
|
|
49
|
+
if (done)
|
|
50
|
+
return;
|
|
51
|
+
done = true;
|
|
52
|
+
for (const [signal, handler] of handlers)
|
|
53
|
+
process.off(signal, handler);
|
|
54
|
+
resolve(code);
|
|
55
|
+
};
|
|
56
|
+
const start = () => {
|
|
57
|
+
child = spawn(opts.command, opts.args, {
|
|
58
|
+
stdio: 'inherit',
|
|
59
|
+
env: { ...(opts.env ?? process.env), [SUPERVISED_ENV]: '1' },
|
|
60
|
+
});
|
|
61
|
+
child.on('error', (err) => {
|
|
62
|
+
opts.log?.(`cannot start the runtime: ${err.message}`);
|
|
63
|
+
finish(1);
|
|
64
|
+
});
|
|
65
|
+
child.on('exit', (code, signal) => {
|
|
66
|
+
const next = decideOnExit(code, signal);
|
|
67
|
+
if (next.action === 'exit')
|
|
68
|
+
return finish(next.code);
|
|
69
|
+
const t = now();
|
|
70
|
+
restarts.push(t);
|
|
71
|
+
while (restarts.length && t - restarts[0] > RESTART_WINDOW_MS)
|
|
72
|
+
restarts.shift();
|
|
73
|
+
if (restarts.length > MAX_RESTARTS) {
|
|
74
|
+
opts.log?.(`the runtime asked for ${restarts.length} restarts within a minute, stopping`);
|
|
75
|
+
return finish(1);
|
|
76
|
+
}
|
|
77
|
+
opts.log?.('restarting into the updated runner');
|
|
78
|
+
start();
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
start();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReleaseManifest } from './manifest.js';
|
|
2
|
+
import type { PerformUpdateResult } from './install.js';
|
|
3
|
+
export declare const UPDATE_CHECK_INTERVAL_MS: number;
|
|
4
|
+
export interface UpdaterDeps {
|
|
5
|
+
currentVersion: string;
|
|
6
|
+
/** Global install and not opted out: install on its own. Otherwise only `requestRestart` acts. */
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
isIdle: () => boolean;
|
|
9
|
+
fetchLatest: () => Promise<ReleaseManifest>;
|
|
10
|
+
install: (manifest: ReleaseManifest) => Promise<PerformUpdateResult>;
|
|
11
|
+
/** The version on disk now (it changes under a running process once installed). */
|
|
12
|
+
installedVersion: () => string | null;
|
|
13
|
+
restart: () => void;
|
|
14
|
+
log: (msg: string) => void;
|
|
15
|
+
now?: () => number;
|
|
16
|
+
}
|
|
17
|
+
export declare class Updater {
|
|
18
|
+
private readonly deps;
|
|
19
|
+
private target;
|
|
20
|
+
private manifest;
|
|
21
|
+
private installing;
|
|
22
|
+
private restartPending;
|
|
23
|
+
private restarted;
|
|
24
|
+
private failedAt;
|
|
25
|
+
constructor(deps: UpdaterDeps);
|
|
26
|
+
get enabled(): boolean;
|
|
27
|
+
get busy(): boolean;
|
|
28
|
+
get pendingRestart(): boolean;
|
|
29
|
+
private now;
|
|
30
|
+
/** A newer version was announced (the studio's `connected` frame). */
|
|
31
|
+
offer(version: string | null | undefined): Promise<void>;
|
|
32
|
+
/** The periodic check: read the manifest itself. */
|
|
33
|
+
check(): Promise<void>;
|
|
34
|
+
/** A chat or task ended: an install or restart that waited for idle may go now. */
|
|
35
|
+
runEnded(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Somebody installed a newer version on disk (`nordhavn update`, another
|
|
38
|
+
* runtime): restart into it once idle. Works without `enabled`, so an
|
|
39
|
+
* opted-out runner still picks up a manual update.
|
|
40
|
+
*/
|
|
41
|
+
requestRestart(): void;
|
|
42
|
+
private attempt;
|
|
43
|
+
private tryRestart;
|
|
44
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isNewerVersion } from '../utils/format.js';
|
|
2
|
+
// ─── Auto update ─────────────────────────────
|
|
3
|
+
//
|
|
4
|
+
// The state of one runtime process: it learns of a newer release (the studio's
|
|
5
|
+
// `connected` frame, or its own periodic manifest check), installs it once no
|
|
6
|
+
// chat or task is running, and restarts into it once idle again (a run may
|
|
7
|
+
// have started during the install). A failure is logged and left for the next
|
|
8
|
+
// trigger; the process keeps running the version it has.
|
|
9
|
+
export const UPDATE_CHECK_INTERVAL_MS = 6 * 60 * 60_000;
|
|
10
|
+
/** After a failed attempt, triggers within this window are ignored (the periodic check is not). */
|
|
11
|
+
const FAILURE_BACKOFF_MS = 60 * 60_000;
|
|
12
|
+
export class Updater {
|
|
13
|
+
deps;
|
|
14
|
+
target = null;
|
|
15
|
+
manifest = null;
|
|
16
|
+
installing = false;
|
|
17
|
+
restartPending = false;
|
|
18
|
+
restarted = false;
|
|
19
|
+
failedAt = 0;
|
|
20
|
+
constructor(deps) {
|
|
21
|
+
this.deps = deps;
|
|
22
|
+
}
|
|
23
|
+
get enabled() { return this.deps.enabled; }
|
|
24
|
+
get busy() { return this.installing; }
|
|
25
|
+
get pendingRestart() { return this.restartPending; }
|
|
26
|
+
now() { return this.deps.now?.() ?? Date.now(); }
|
|
27
|
+
/** A newer version was announced (the studio's `connected` frame). */
|
|
28
|
+
offer(version) {
|
|
29
|
+
if (!this.deps.enabled || !version || !isNewerVersion(version, this.deps.currentVersion))
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
if (!this.target || isNewerVersion(version, this.target))
|
|
32
|
+
this.target = version;
|
|
33
|
+
return this.attempt(false);
|
|
34
|
+
}
|
|
35
|
+
/** The periodic check: read the manifest itself. */
|
|
36
|
+
async check() {
|
|
37
|
+
if (!this.deps.enabled || this.installing || this.restartPending)
|
|
38
|
+
return;
|
|
39
|
+
let manifest;
|
|
40
|
+
try {
|
|
41
|
+
manifest = await this.deps.fetchLatest();
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
this.deps.log(`update check failed: ${err.message}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!isNewerVersion(manifest.version, this.deps.currentVersion))
|
|
48
|
+
return;
|
|
49
|
+
this.manifest = manifest;
|
|
50
|
+
this.target = manifest.version;
|
|
51
|
+
await this.attempt(true);
|
|
52
|
+
}
|
|
53
|
+
/** A chat or task ended: an install or restart that waited for idle may go now. */
|
|
54
|
+
runEnded() {
|
|
55
|
+
if (this.restartPending) {
|
|
56
|
+
this.tryRestart();
|
|
57
|
+
return Promise.resolve();
|
|
58
|
+
}
|
|
59
|
+
return this.attempt(false);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Somebody installed a newer version on disk (`nordhavn update`, another
|
|
63
|
+
* runtime): restart into it once idle. Works without `enabled`, so an
|
|
64
|
+
* opted-out runner still picks up a manual update.
|
|
65
|
+
*/
|
|
66
|
+
requestRestart() {
|
|
67
|
+
const onDisk = this.deps.installedVersion();
|
|
68
|
+
if (!onDisk || !isNewerVersion(onDisk, this.deps.currentVersion))
|
|
69
|
+
return;
|
|
70
|
+
this.restartPending = true;
|
|
71
|
+
this.tryRestart();
|
|
72
|
+
}
|
|
73
|
+
async attempt(fromSchedule) {
|
|
74
|
+
if (this.installing || this.restartPending || !this.target)
|
|
75
|
+
return;
|
|
76
|
+
if (!fromSchedule && this.failedAt && this.now() - this.failedAt < FAILURE_BACKOFF_MS)
|
|
77
|
+
return;
|
|
78
|
+
if (!this.deps.isIdle())
|
|
79
|
+
return;
|
|
80
|
+
this.installing = true;
|
|
81
|
+
const from = this.deps.currentVersion;
|
|
82
|
+
try {
|
|
83
|
+
let manifest = this.manifest && this.manifest.version === this.target ? this.manifest : null;
|
|
84
|
+
if (!manifest)
|
|
85
|
+
manifest = await this.deps.fetchLatest();
|
|
86
|
+
this.manifest = manifest;
|
|
87
|
+
if (!isNewerVersion(manifest.version, from)) {
|
|
88
|
+
// The announcement was ahead of the manifest (or rolled back): nothing to do.
|
|
89
|
+
this.target = null;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const result = await this.deps.install(manifest);
|
|
93
|
+
this.deps.log(result === 'installed'
|
|
94
|
+
? `updated ${from} -> ${manifest.version}`
|
|
95
|
+
: `${manifest.version} is already installed, restarting into it`);
|
|
96
|
+
this.target = null;
|
|
97
|
+
this.failedAt = 0;
|
|
98
|
+
this.restartPending = true;
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
this.failedAt = this.now();
|
|
102
|
+
this.target = null;
|
|
103
|
+
this.deps.log(`update failed, keeps running ${from}: ${err.message}`);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
this.installing = false;
|
|
107
|
+
}
|
|
108
|
+
this.tryRestart();
|
|
109
|
+
}
|
|
110
|
+
tryRestart() {
|
|
111
|
+
if (!this.restartPending || this.restarted || this.installing || !this.deps.isIdle())
|
|
112
|
+
return;
|
|
113
|
+
this.restarted = true;
|
|
114
|
+
this.deps.restart();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type AgentConfig, type Config } from '../config.js';
|
|
2
|
+
export declare const VERSION: string;
|
|
3
|
+
export declare const dim: (s: string) => string;
|
|
4
|
+
export declare const bold: (s: string) => string;
|
|
5
|
+
/** Primary highlight - bold in the terminal's foreground colour. Use for
|
|
6
|
+
* headings and primary highlights. */
|
|
7
|
+
export declare const accent: (s: string) => string;
|
|
8
|
+
/** Secondary highlight - gray-300, for values, names and tool names. */
|
|
9
|
+
export declare const cyan: (s: string) => string;
|
|
10
|
+
/** Success / agent-online - green-500 (--color-agent-online). */
|
|
11
|
+
export declare const green: (s: string) => string;
|
|
12
|
+
/** Danger / error - red-500 (--color-danger). Errors only, not branding. */
|
|
13
|
+
export declare const red: (s: string) => string;
|
|
14
|
+
/** Warning - amber-500 (--color-warning). */
|
|
15
|
+
export declare const yellow: (s: string) => string;
|
|
16
|
+
export type LogSymbol = '◆' | '←' | '→' | '⚡' | '✗' | '↻' | '·' | '⊘';
|
|
17
|
+
/** Numeric semver-ish compare of `major.minor.patch`. True when `a` is strictly
|
|
18
|
+
* newer than `b`. Non-numeric / missing segments count as 0, so "0.1.0" beats
|
|
19
|
+
* "0.0.0" and a malformed version never falsely reads as an update. */
|
|
20
|
+
export declare function isNewerVersion(a: string, b: string): boolean;
|
|
21
|
+
/** Amber "update available" notice, matching the warning colour convention.
|
|
22
|
+
* Printed once at connect when the studio reports a newer runner version and
|
|
23
|
+
* this runner does not install it by itself. `how` is the command or step
|
|
24
|
+
* that updates this kind of install (see update/policy.ts). */
|
|
25
|
+
export declare function updateNotice(current: string, latest: string, how?: string): void;
|
|
26
|
+
export declare function contractNotice(ours: string, studios: string): void;
|
|
27
|
+
export declare function welcome(agent: string): void;
|
|
28
|
+
export declare function log(sym: LogSymbol, agent: string, msg: string): void;
|
|
29
|
+
export declare function truncate(s: string, len?: number): string;
|
|
30
|
+
export declare function formatCost(micros: number): string;
|
|
31
|
+
/** Strip ANSI escapes for accurate width calculations. */
|
|
32
|
+
export declare function stripAnsi(s: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The logo mark in half blocks, drawn by hand after
|
|
35
|
+
* the brand mark (`packages/lib/brand/assets/brandmark.svg`). The product name is plain text
|
|
36
|
+
* beside it (`BRAND.name`), so a rename needs no redraw; a new mark does. All
|
|
37
|
+
* rows have the same width, so the text beside them lines up.
|
|
38
|
+
*/
|
|
39
|
+
export declare const LOGO_ROWS: readonly [" ██▄ ", "▄▄▄▀███▄", "███ ▀██"];
|
|
40
|
+
export declare function logo(version?: string): void;
|
|
41
|
+
export declare function showHelp(usage: string, description: string, options?: string[], examples?: string[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Report a bare slug that names more than one agent on this machine. Agent
|
|
44
|
+
* slugs are unique only within an organisation, so acting on whichever came
|
|
45
|
+
* first is exactly the ambiguity the qualified `slug@organisation` ref exists
|
|
46
|
+
* to remove - the CLI refuses and shows the candidates instead.
|
|
47
|
+
*/
|
|
48
|
+
export declare function printAmbiguous(config: Config, ref: string, candidates: AgentConfig[]): void;
|
|
49
|
+
/** Build an aligned option string: strips ANSI for width calc */
|
|
50
|
+
export declare function helpOpt(cmd: string, desc: string, col?: number): string;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// ─── Format / UI Helpers ─────────────────────
|
|
2
|
+
//
|
|
3
|
+
// ANSI colors, gradients, the logo, session summary, and other
|
|
4
|
+
// purely-cosmetic helpers used by the CLI. Kept out of index.ts so the
|
|
5
|
+
// entry point stays focused on orchestration.
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { profileLabel } from '../paths.js';
|
|
9
|
+
import { agentRef } from '../config.js';
|
|
10
|
+
import { BRAND } from '../brand.js';
|
|
11
|
+
import { readRunnerVersion } from '../version.js';
|
|
12
|
+
// Single source for the displayed version: the build stamp (dist/version.json,
|
|
13
|
+
// the release tag of a checkout) or else the package's own package.json. The
|
|
14
|
+
// package root sits two levels above this file in both `src` (tsx in dev) and
|
|
15
|
+
// the built `dist`. Falls back if unreadable.
|
|
16
|
+
export const VERSION = readRunnerVersion(join(dirname(fileURLToPath(import.meta.url)), '..', '..')) ?? '0.0.0';
|
|
17
|
+
// ─── Colors ──────────────────────────────────
|
|
18
|
+
//
|
|
19
|
+
// 24-bit truecolor, greyscale only (Tailwind gray scale): the runner carries no
|
|
20
|
+
// colour at all. The exports keep their old colour names to avoid churn across
|
|
21
|
+
// the importers; status is told apart by brightness, weight and the symbol.
|
|
22
|
+
// `red` (bold, brightest) is reserved for genuine errors/danger.
|
|
23
|
+
const rgb = (r, g, b) => (s) => `\x1b[38;2;${r};${g};${b}m${s}\x1b[0m`;
|
|
24
|
+
export const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
25
|
+
export const bold = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
26
|
+
/** Primary highlight - bold in the terminal's foreground colour. Use for
|
|
27
|
+
* headings and primary highlights. */
|
|
28
|
+
export const accent = bold;
|
|
29
|
+
/** Secondary highlight - gray-300, for values, names and tool names. */
|
|
30
|
+
export const cyan = rgb(209, 213, 219);
|
|
31
|
+
/** Success / agent-online - green-500 (--color-agent-online). */
|
|
32
|
+
export const green = rgb(229, 231, 235);
|
|
33
|
+
/** Danger / error - red-500 (--color-danger). Errors only, not branding. */
|
|
34
|
+
export const red = (s) => bold(rgb(249, 250, 251)(s));
|
|
35
|
+
/** Warning - amber-500 (--color-warning). */
|
|
36
|
+
export const yellow = rgb(156, 163, 175);
|
|
37
|
+
const SYM_COLOR = {
|
|
38
|
+
'◆': green,
|
|
39
|
+
'←': cyan,
|
|
40
|
+
'→': green,
|
|
41
|
+
'⚡': cyan,
|
|
42
|
+
'✗': red,
|
|
43
|
+
'↻': yellow,
|
|
44
|
+
'·': dim,
|
|
45
|
+
'⊘': yellow,
|
|
46
|
+
};
|
|
47
|
+
/** Numeric semver-ish compare of `major.minor.patch`. True when `a` is strictly
|
|
48
|
+
* newer than `b`. Non-numeric / missing segments count as 0, so "0.1.0" beats
|
|
49
|
+
* "0.0.0" and a malformed version never falsely reads as an update. */
|
|
50
|
+
export function isNewerVersion(a, b) {
|
|
51
|
+
const pa = a.split('.').map(n => parseInt(n, 10) || 0);
|
|
52
|
+
const pb = b.split('.').map(n => parseInt(n, 10) || 0);
|
|
53
|
+
for (let i = 0; i < 3; i++) {
|
|
54
|
+
const x = pa[i] ?? 0;
|
|
55
|
+
const y = pb[i] ?? 0;
|
|
56
|
+
if (x !== y)
|
|
57
|
+
return x > y;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
/** Amber "update available" notice, matching the warning colour convention.
|
|
62
|
+
* Printed once at connect when the studio reports a newer runner version and
|
|
63
|
+
* this runner does not install it by itself. `how` is the command or step
|
|
64
|
+
* that updates this kind of install (see update/policy.ts). */
|
|
65
|
+
export function updateNotice(current, latest, how = 'nordhavn update') {
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log(` ${yellow('▲')} ${yellow('update available')} ${dim('·')} v${current} ${dim('→')} ${bold(`v${latest}`)}`);
|
|
68
|
+
console.log(` ${dim('run')} ${cyan(how)} ${dim('to update')}`);
|
|
69
|
+
console.log('');
|
|
70
|
+
}
|
|
71
|
+
export function contractNotice(ours, studios) {
|
|
72
|
+
console.log('');
|
|
73
|
+
console.log(` ${yellow('▲')} ${yellow('agent contract differs from the studio')} ${dim('·')} runner ${ours} ${dim('·')} studio ${bold(studios)}`);
|
|
74
|
+
console.log(` ${dim('one of the two is behind; update the runner with')} ${cyan('nordhavn update')}`);
|
|
75
|
+
console.log('');
|
|
76
|
+
}
|
|
77
|
+
export function welcome(agent) {
|
|
78
|
+
const agentStr = `${agent} online`;
|
|
79
|
+
console.log('');
|
|
80
|
+
console.log(` ${dim('─'.repeat(54))}`);
|
|
81
|
+
console.log(` ${green('◆')} ${accent('welcome to nordhavn')} ${dim('·')} ${cyan(agentStr)}`);
|
|
82
|
+
console.log(` ${dim('─'.repeat(54))}`);
|
|
83
|
+
console.log('');
|
|
84
|
+
}
|
|
85
|
+
export function log(sym, agent, msg) {
|
|
86
|
+
const time = dim(new Date().toLocaleTimeString('en-GB', { hour12: false }));
|
|
87
|
+
const symbol = SYM_COLOR[sym](sym);
|
|
88
|
+
const tag = dim(`[${agent}]`);
|
|
89
|
+
// ⚡ is double-width in most terminals - compensate with 1 fewer trailing space
|
|
90
|
+
const gap = sym === '⚡' ? ' ' : ' ';
|
|
91
|
+
console.log(` ${time} ${symbol}${gap}${tag} ${msg}`);
|
|
92
|
+
}
|
|
93
|
+
export function truncate(s, len = 80) {
|
|
94
|
+
const clean = s.replace(/\n/g, ' ').trim();
|
|
95
|
+
if (clean.length <= len)
|
|
96
|
+
return clean;
|
|
97
|
+
return clean.slice(0, len) + '…';
|
|
98
|
+
}
|
|
99
|
+
// MIRROR: studio packages/os/os-shared/utils/cost.ts formatCostMicros (precision 3).
|
|
100
|
+
// The runner cannot import packages/os/os-shared, so it carries a copy.
|
|
101
|
+
export function formatCost(micros) {
|
|
102
|
+
const dollars = micros / 1_000_000;
|
|
103
|
+
if (dollars > 0 && dollars < 0.01)
|
|
104
|
+
return '<$0.01';
|
|
105
|
+
return `$${dollars.toFixed(dollars < 1 ? 3 : 2)}`;
|
|
106
|
+
}
|
|
107
|
+
/** Strip ANSI escapes for accurate width calculations. */
|
|
108
|
+
export function stripAnsi(s) {
|
|
109
|
+
return s.replace(/\x1b\[[0-9;]*m/g, '');
|
|
110
|
+
}
|
|
111
|
+
// ─── Logo ────────────────────────────────────
|
|
112
|
+
/** "Nordhavn OS Runner" as `N O R D H A V N O S R U N N E R`. */
|
|
113
|
+
function spaced(text) {
|
|
114
|
+
return text.toUpperCase().split(' ').map(word => word.split('').join(' ')).join(' ');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The logo mark in half blocks, drawn by hand after
|
|
118
|
+
* the brand mark (`packages/lib/brand/assets/brandmark.svg`). The product name is plain text
|
|
119
|
+
* beside it (`BRAND.name`), so a rename needs no redraw; a new mark does. All
|
|
120
|
+
* rows have the same width, so the text beside them lines up.
|
|
121
|
+
*/
|
|
122
|
+
export const LOGO_ROWS = [
|
|
123
|
+
' ██▄ ',
|
|
124
|
+
'▄▄▄▀███▄',
|
|
125
|
+
'███ ▀██',
|
|
126
|
+
];
|
|
127
|
+
/**
|
|
128
|
+
* The block logo everywhere (a terminal, a piped dev log, a log file); only a
|
|
129
|
+
* dumb terminal gets the one-line wordmark.
|
|
130
|
+
*/
|
|
131
|
+
function canDrawBlocks() {
|
|
132
|
+
return process.env.TERM !== 'dumb';
|
|
133
|
+
}
|
|
134
|
+
export function logo(version = VERSION) {
|
|
135
|
+
console.log('');
|
|
136
|
+
const profile = profileLabel();
|
|
137
|
+
if (canDrawBlocks()) {
|
|
138
|
+
const sep = dim(' · ');
|
|
139
|
+
const badge = profile ? sep + yellow(`${profile} profile`) : '';
|
|
140
|
+
// The logo stays in the terminal's own foreground colour, like logo-dark.svg:
|
|
141
|
+
// no brand accent on the mark or the name.
|
|
142
|
+
console.log(` ${LOGO_ROWS[0]}`);
|
|
143
|
+
console.log(` ${LOGO_ROWS[1]} ${bold(BRAND.name)}${sep}runner ${dim('cli')}`);
|
|
144
|
+
console.log(` ${LOGO_ROWS[2]} ${dim(`v${version}`)}${badge}`);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const badge = profile ? dim(' · ') + yellow(`${profile} profile`) : '';
|
|
148
|
+
console.log(' ' + bold(spaced(BRAND.runner)) + dim(' · ') + 'CLI' + dim(` · v${version}`) + badge);
|
|
149
|
+
}
|
|
150
|
+
console.log('');
|
|
151
|
+
}
|
|
152
|
+
// ─── Help formatting ─────────────────────────
|
|
153
|
+
export function showHelp(usage, description, options, examples) {
|
|
154
|
+
console.log('');
|
|
155
|
+
console.log(bold(` ${description}\n`));
|
|
156
|
+
console.log(` ${dim('Usage:')} ${usage}\n`);
|
|
157
|
+
if (options && options.length > 0) {
|
|
158
|
+
console.log(dim(' Options:'));
|
|
159
|
+
for (const opt of options)
|
|
160
|
+
console.log(` ${opt}`);
|
|
161
|
+
console.log('');
|
|
162
|
+
}
|
|
163
|
+
if (examples && examples.length > 0) {
|
|
164
|
+
console.log(dim(' Examples:'));
|
|
165
|
+
for (const ex of examples)
|
|
166
|
+
console.log(` ${dim('$')} ${ex}`);
|
|
167
|
+
console.log('');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Report a bare slug that names more than one agent on this machine. Agent
|
|
172
|
+
* slugs are unique only within an organisation, so acting on whichever came
|
|
173
|
+
* first is exactly the ambiguity the qualified `slug@organisation` ref exists
|
|
174
|
+
* to remove - the CLI refuses and shows the candidates instead.
|
|
175
|
+
*/
|
|
176
|
+
export function printAmbiguous(config, ref, candidates) {
|
|
177
|
+
console.log(red(` "${ref}" matches ${candidates.length} agents on this machine.`));
|
|
178
|
+
console.log('');
|
|
179
|
+
for (const candidate of candidates) {
|
|
180
|
+
console.log(` ${cyan(agentRef(config, candidate))} ${dim(`· organisation ${candidate.organisationSlug ?? 'unknown'}`)}`);
|
|
181
|
+
}
|
|
182
|
+
console.log('');
|
|
183
|
+
console.log(dim(' Repeat the command with one of those.\n'));
|
|
184
|
+
}
|
|
185
|
+
/** Build an aligned option string: strips ANSI for width calc */
|
|
186
|
+
export function helpOpt(cmd, desc, col = 22) {
|
|
187
|
+
const plain = stripAnsi(cmd);
|
|
188
|
+
const pad = Math.max(1, col - plain.length);
|
|
189
|
+
return `${cmd}${' '.repeat(pad)}${dim(desc)}`;
|
|
190
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The file the build writes next to the compiled code. */
|
|
2
|
+
export declare const VERSION_FILE = "version.json";
|
|
3
|
+
/** `v0.75.0` or `0.75.0` as `0.75.0`; null for anything else (a `deploy-*` tag, a describe suffix). */
|
|
4
|
+
export declare function normaliseTag(tag: string | null | undefined): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* The version a build reports: the newest release tag when it is ahead of
|
|
7
|
+
* package.json (a checkout after a release), otherwise package.json (a stamped
|
|
8
|
+
* release build, or a branch already bumped past the last tag).
|
|
9
|
+
*/
|
|
10
|
+
export declare function pickBuildVersion(packageVersion: string, tag: string | null | undefined): string;
|
|
11
|
+
/**
|
|
12
|
+
* The version of the runner package at `packageDir`: the higher of the build
|
|
13
|
+
* stamp in `dist/version.json` and package.json. A stamp is never lower than
|
|
14
|
+
* the package.json it was built from, so a lower one is a stale `dist` beside
|
|
15
|
+
* newer sources (`tsx src` in dev after a bump) and package.json wins.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readRunnerVersion(packageDir: string): string | null;
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
// ─── Runner version ──────────────────────────
|
|
4
|
+
//
|
|
5
|
+
// The release tag (`v<x.y.z>`) is the one source of the runner's version. The
|
|
6
|
+
// release workflow stamps it into the manifests of its own build; a local build
|
|
7
|
+
// of a checkout reads it from git instead: `scripts/stamp-version.mjs` runs after
|
|
8
|
+
// `tsc` and writes `dist/version.json`, the higher of the newest `v*` tag and
|
|
9
|
+
// package.json. So a linked checkout reports the version it was built from
|
|
10
|
+
// without anybody bumping package.json. Without git or tags (a release tarball,
|
|
11
|
+
// a shallow CI checkout) the stamp is package.json's version, as before.
|
|
12
|
+
//
|
|
13
|
+
// Kept free of other runner modules: the stamp script imports it from dist.
|
|
14
|
+
/** The file the build writes next to the compiled code. */
|
|
15
|
+
export const VERSION_FILE = 'version.json';
|
|
16
|
+
const SEMVER = /^v?(\d+)\.(\d+)\.(\d+)$/;
|
|
17
|
+
/** `v0.75.0` or `0.75.0` as `0.75.0`; null for anything else (a `deploy-*` tag, a describe suffix). */
|
|
18
|
+
export function normaliseTag(tag) {
|
|
19
|
+
const m = tag?.trim().match(SEMVER);
|
|
20
|
+
return m ? `${m[1]}.${m[2]}.${m[3]}` : null;
|
|
21
|
+
}
|
|
22
|
+
function newer(a, b) {
|
|
23
|
+
const pa = a.split('.').map(n => parseInt(n, 10) || 0);
|
|
24
|
+
const pb = b.split('.').map(n => parseInt(n, 10) || 0);
|
|
25
|
+
for (let i = 0; i < 3; i++) {
|
|
26
|
+
const x = pa[i] ?? 0;
|
|
27
|
+
const y = pb[i] ?? 0;
|
|
28
|
+
if (x !== y)
|
|
29
|
+
return x > y;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The version a build reports: the newest release tag when it is ahead of
|
|
35
|
+
* package.json (a checkout after a release), otherwise package.json (a stamped
|
|
36
|
+
* release build, or a branch already bumped past the last tag).
|
|
37
|
+
*/
|
|
38
|
+
export function pickBuildVersion(packageVersion, tag) {
|
|
39
|
+
const fromTag = normaliseTag(tag);
|
|
40
|
+
return fromTag && newer(fromTag, packageVersion) ? fromTag : packageVersion;
|
|
41
|
+
}
|
|
42
|
+
function readVersionField(file) {
|
|
43
|
+
try {
|
|
44
|
+
const v = JSON.parse(readFileSync(file, 'utf-8')).version;
|
|
45
|
+
return typeof v === 'string' && v ? v : null;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The version of the runner package at `packageDir`: the higher of the build
|
|
53
|
+
* stamp in `dist/version.json` and package.json. A stamp is never lower than
|
|
54
|
+
* the package.json it was built from, so a lower one is a stale `dist` beside
|
|
55
|
+
* newer sources (`tsx src` in dev after a bump) and package.json wins.
|
|
56
|
+
*/
|
|
57
|
+
export function readRunnerVersion(packageDir) {
|
|
58
|
+
const stamp = readVersionField(join(packageDir, 'dist', VERSION_FILE));
|
|
59
|
+
const pkg = readVersionField(join(packageDir, 'package.json'));
|
|
60
|
+
if (!stamp || !pkg)
|
|
61
|
+
return stamp ?? pkg;
|
|
62
|
+
return newer(pkg, stamp) ? pkg : stamp;
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolContext, ToolDefinition } from '@nordhavnhq/runner-runtime';
|
|
2
|
+
type Exec = (params: Record<string, unknown>, context?: ToolContext) => Promise<string>;
|
|
3
|
+
/**
|
|
4
|
+
* Playwright runs a string as an expression, so "el => el.tagName" came back
|
|
5
|
+
* as the function itself (serialised to null). A function expression becomes
|
|
6
|
+
* a real function here, called with the element; with an element any other
|
|
7
|
+
* expression sees it as `el`. Null: run the string as it is (page scripts with
|
|
8
|
+
* statements). Throws a SyntaxError for code that does not parse.
|
|
9
|
+
*/
|
|
10
|
+
export declare function evalFunction(expression: string, withElement: boolean): ((el?: unknown) => unknown) | null;
|
|
11
|
+
export declare const actTools: {
|
|
12
|
+
definition: ToolDefinition;
|
|
13
|
+
execute: Exec;
|
|
14
|
+
}[];
|
|
15
|
+
export {};
|