@bongos/core 1.24.76 → 1.24.78

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.
Files changed (58) hide show
  1. package/.bongos-core.json +129 -49
  2. package/clients/bongos-client/README.md +1 -1
  3. package/clients/bongos-client/bongos-client.global.js +8 -0
  4. package/clients/bongos-client/index.cjs +8 -0
  5. package/clients/bongos-client/index.d.ts +12 -1
  6. package/clients/bongos-client/index.mjs +8 -0
  7. package/docs/adr/0307-autobongos-a-deterministic-supervisor-and-agentic-workers.md +45 -0
  8. package/docs/api/openapi.json +209 -4
  9. package/docs/api-reference.md +7 -3
  10. package/docs/copy-inventory.md +109 -92
  11. package/docs/copy-registry.json +291 -108
  12. package/docs/module-api-changelog.md +4 -0
  13. package/docs/page-inventory.json +2 -0
  14. package/docs/page-readings.json +111 -97
  15. package/docs/recipes/autobongos-runner-setup.md +148 -0
  16. package/docs/recipes/autobongos-windows-host.md +10 -7
  17. package/modules/autonomy/cadence.js +3 -0
  18. package/modules/autonomy/db.js +86 -7
  19. package/modules/autonomy/fence.js +20 -5
  20. package/modules/autonomy/gauge.js +25 -1
  21. package/modules/autonomy/migrations/autonomy_006_runner_device.sql +45 -0
  22. package/modules/autonomy/module.json +2 -1
  23. package/modules/autonomy/routes/autonomy.js +165 -3
  24. package/modules/autonomy/runner-health.js +27 -0
  25. package/modules/autonomy/skills/autobongos-setup/SKILL.md +86 -0
  26. package/modules/hall-ui/public/commands-lib.js +1 -1
  27. package/modules/hall-ui/public/gate.js +12 -5
  28. package/modules/hall-ui/public/runner-button.css +55 -0
  29. package/modules/hall-ui/public/runner-button.js +187 -0
  30. package/modules/hall-ui/public/settings-autobongos.js +349 -63
  31. package/modules/hall-ui/public/settings.html +23 -10
  32. package/modules/hall-ui/records/runner-button.md +16 -0
  33. package/package-lock.json +2 -2
  34. package/package.json +1 -1
  35. package/release-notes.json +20 -0
  36. package/scripts/bongos/autobongos-bootstrap.ps1 +169 -0
  37. package/scripts/bongos/autobongos-bootstrap.sh +151 -0
  38. package/scripts/bongos/autobongos-host.js +883 -0
  39. package/scripts/bongos/autobongos-run.js +25 -4
  40. package/scripts/bongos/autonomy-gauge.js +11 -3
  41. package/scripts/bongos/cli-lib.js +5 -1
  42. package/scripts/bongos/stranded-rows.js +39 -2
  43. package/scripts/gds/autobongos-bootstrap.ps1 +8 -0
  44. package/scripts/gds/autobongos-bootstrap.sh +8 -0
  45. package/scripts/gds/autobongos-host.js +7 -0
  46. package/scripts/hall-preview/server.js +7 -0
  47. package/src/instance-config.js +22 -3
  48. package/src/module-api.js +1 -1
  49. package/tests/autobongos_host.mjs +647 -0
  50. package/tests/autobongos_loop.mjs +11 -0
  51. package/tests/autonomy_config_idle.mjs +9 -4
  52. package/tests/autonomy_gauge.mjs +43 -0
  53. package/tests/autonomy_runner_device.mjs +444 -0
  54. package/tests/autonomy_runner_identity.mjs +3 -1
  55. package/tests/cli_sessions.mjs +16 -0
  56. package/tests/hall_runner_button.mjs +467 -0
  57. package/tests/hall_runner_panel_connect.mjs +73 -0
  58. package/tests/stranded_rows.mjs +50 -0
@@ -0,0 +1,169 @@
1
+ # scripts/bongos/autobongos-bootstrap.ps1 -- the first lines of Autobongos setup
2
+ # on a Windows PC (tasks 1005095, 1005094; goal 1000139).
3
+ #
4
+ # autobongos-bootstrap.ps1 -Code abr_... -ApiBase https://... -Repo https://github.com/owner/name
5
+ #
6
+ # and, as the hall hands it out, with no file on the PC at all:
7
+ #
8
+ # & ([scriptblock]::Create((irm 'https://<project>/api/bongos/autonomy/runner-setup.ps1'))) -Code '...' -ApiBase '...' -Repo '...'
9
+ #
10
+ # WHY THIS IS POWERSHELL AND SO SHORT. Everything that sets a runner up is one
11
+ # Node program (autobongos-host.js), the same on Windows and Mac. But Node cannot
12
+ # install Node, and the program lives in a copy of the project that does not exist
13
+ # yet. So this does only what must happen before Node can take over: find or
14
+ # install git, Node and Claude Code, make the runner ITS OWN copy of the project,
15
+ # and hand over. The hall serves this file and Settings puts the one-time code in
16
+ # the command, so the person copies one line.
17
+ #
18
+ # NO ADMINISTRATOR SHELL. It runs as the person, in an ordinary PowerShell window.
19
+ # winget may show Windows' own "allow this app to make changes" prompt while it
20
+ # installs git or Node; that is the installer asking, not this script.
21
+ #
22
+ # EVERY STOP IS A SENTENCE. A failure it cannot fix itself ends with what
23
+ # happened and what to do, never a stack trace. Safe to run again: each step
24
+ # checks before it acts, and a copy that already exists is brought current
25
+ # instead of cloned twice.
26
+ #
27
+ # IT NEVER CALLS exit WHEN IT WAS PASTED (task 1005094). Run as a script block --
28
+ # which is how the pasted line runs it -- `exit` ends the PowerShell WINDOW, so
29
+ # the person would see their window vanish instead of the sentence telling them
30
+ # what to do. Every stop therefore unwinds to the bottom of this file, which
31
+ # calls `exit` only when this is running as a file.
32
+
33
+ [CmdletBinding()]
34
+ param(
35
+ [string]$Code,
36
+ [string]$ApiBase,
37
+ [string]$Repo,
38
+ # Where the runner keeps its own files. One folder, so removing the runner is
39
+ # deleting it. $HOME, not $env:USERPROFILE: it is the same folder on Windows,
40
+ # and it also exists where this file is only ever tested (PowerShell on Linux
41
+ # has no USERPROFILE, and a null default stops the script before its first line).
42
+ [string]$RunnerHome = (Join-Path $HOME '.cloudbongos-runner'),
43
+ # Say what would be done and stop before changing anything.
44
+ [switch]$DryRun
45
+ )
46
+
47
+ $ErrorActionPreference = 'Stop'
48
+ $StopMark = 'autobongos-setup-stopped'
49
+
50
+ function Stop-Setup([string]$What, [string]$Fix) {
51
+ Write-Host ''
52
+ Write-Host "Autobongos setup stopped here: $What" -ForegroundColor Yellow
53
+ Write-Host "What to do: $Fix"
54
+ throw $StopMark
55
+ }
56
+
57
+ function Say([string]$Text) { Write-Host $Text }
58
+
59
+ # A fresh install changes PATH in the registry, not in this window.
60
+ function Update-PathFromRegistry {
61
+ $machine = [Environment]::GetEnvironmentVariable('Path', 'Machine')
62
+ $user = [Environment]::GetEnvironmentVariable('Path', 'User')
63
+ $env:Path = (@($machine, $user) | Where-Object { $_ }) -join ';'
64
+ }
65
+
66
+ function Test-Tool([string]$Name) { return [bool](Get-Command $Name -ErrorAction SilentlyContinue) }
67
+
68
+ # Find a tool, or install it with winget and look again.
69
+ function Assert-Tool([string]$Name, [string]$WingetId, [string]$Url) {
70
+ if (Test-Tool $Name) { Say " found $Name"; return }
71
+ if ($DryRun) { Say " would install $Name ($WingetId)"; return }
72
+ if (-not (Test-Tool 'winget')) {
73
+ Stop-Setup "$Name is not installed, and this PC has no winget to install it with." "Install $Name from $Url, open a new PowerShell window, and paste the setup command again."
74
+ }
75
+ Say " installing $Name (Windows may ask you to allow it)..."
76
+ & winget install --id $WingetId -e --source winget --accept-package-agreements --accept-source-agreements --silent | Out-Null
77
+ Update-PathFromRegistry
78
+ if (-not (Test-Tool $Name)) {
79
+ Stop-Setup "$Name did not install." "Install $Name from $Url, open a new PowerShell window, and paste the setup command again."
80
+ }
81
+ Say " installed $Name"
82
+ }
83
+
84
+ # The whole setup, in the open (not a function): what node and git print must
85
+ # reach the person as it happens, and node must keep the keyboard for the Claude
86
+ # sign-in. A stop it can explain throws $StopMark and lands in the catch below.
87
+ $SetupExit = 1
88
+ try {
89
+ if (-not $Code -or -not $ApiBase -or -not $Repo) {
90
+ Stop-Setup 'the setup command is incomplete.' 'Copy the whole command again from Settings > Your Autobongos runner.'
91
+ }
92
+ if ($Repo -notmatch '^https://[A-Za-z0-9.-]+/[A-Za-z0-9._/-]+$') {
93
+ Stop-Setup 'the project address in the command does not look right.' 'Copy the whole command again from Settings > Your Autobongos runner.'
94
+ }
95
+ # The one-time code is sent to this address and the runner's login comes back
96
+ # from it, so it must be https. Plain http is for this machine alone (a
97
+ # developer's own instance); autobongos-host.js applies the same rule again.
98
+ if ($ApiBase -notmatch '^https://[A-Za-z0-9.-]+(:\d+)?/?$' -and $ApiBase -notmatch '^http://(localhost|127\.0\.0\.1)(:\d+)?/?$') {
99
+ Stop-Setup "the project's address in the command is not a secure (https) address." 'Copy the whole command again from Settings > Your Autobongos runner.'
100
+ }
101
+
102
+ Say 'Setting this PC up as an Autobongos runner.'
103
+ Say 'It gets its own copy of the project and its own sign-in; your own work on this PC is not touched.'
104
+ Say ''
105
+ Say 'Checking the three programs it needs...'
106
+ Assert-Tool 'git' 'Git.Git' 'https://git-scm.com/download/win'
107
+ Assert-Tool 'node' 'OpenJS.NodeJS.LTS' 'https://nodejs.org'
108
+
109
+ if (Test-Tool 'claude') {
110
+ Say ' found claude'
111
+ } elseif ($DryRun) {
112
+ Say ' would install Claude Code'
113
+ } else {
114
+ Say ' installing Claude Code...'
115
+ # npm.cmd, not npm: PowerShell blocks npm.ps1 by default (task 1005033).
116
+ & npm.cmd install -g '@anthropic-ai/claude-code' | Out-Null
117
+ Update-PathFromRegistry
118
+ if (-not (Test-Tool 'claude')) {
119
+ Stop-Setup 'Claude Code did not install.' 'Install it from https://claude.com/claude-code, open a new PowerShell window, and paste the setup command again.'
120
+ }
121
+ Say ' installed Claude Code'
122
+ }
123
+
124
+ $RepoDir = Join-Path $RunnerHome 'repo'
125
+ Say ''
126
+ if ($DryRun) {
127
+ Say "Would make the runner's copy of the project in $RepoDir and hand over to autobongos-host.js."
128
+ $SetupExit = 0
129
+ } else {
130
+
131
+ New-Item -ItemType Directory -Force -Path $RunnerHome | Out-Null
132
+ if (Test-Path (Join-Path $RepoDir '.git')) {
133
+ Say "The runner's copy is already here; bringing it up to date..."
134
+ & git -C $RepoDir fetch --quiet origin main
135
+ if ($LASTEXITCODE -ne 0) {
136
+ Stop-Setup "this PC could not fetch the project's code from GitHub." 'Sign in to GitHub when Windows asks, then paste the setup command again.'
137
+ }
138
+ & git -C $RepoDir reset --quiet --hard origin/main
139
+ } else {
140
+ Say "Making the runner's own copy of the project (GitHub may ask you to sign in)..."
141
+ & git clone --quiet $Repo $RepoDir
142
+ if ($LASTEXITCODE -ne 0) {
143
+ Stop-Setup 'this PC could not copy the project from GitHub.' 'Sign in to GitHub in the window that opens (use an account that can see the project), then paste the setup command again.'
144
+ }
145
+ }
146
+
147
+ $HostJs = Join-Path $RepoDir 'scripts\bongos\autobongos-host.js'
148
+ if (-not (Test-Path $HostJs)) {
149
+ Stop-Setup "the project's copy has no runner program in it." 'The project is on an older version. Ask the project owner to update it, then try again.'
150
+ }
151
+
152
+ $env:AUTOBONGOS_HOME = $RunnerHome
153
+ & node $HostJs setup --code $Code --api-base $ApiBase --mark-runner-copy
154
+ $SetupExit = $LASTEXITCODE
155
+
156
+ }
157
+ } catch {
158
+ if ("$($_.Exception.Message)" -ne $StopMark) {
159
+ Write-Host ''
160
+ Write-Host 'Autobongos setup stopped on something unexpected.' -ForegroundColor Yellow
161
+ Write-Host 'What to do: paste the setup command again. If it stops here twice, tell the project owner.'
162
+ }
163
+ $SetupExit = 1
164
+ }
165
+
166
+ # As a FILE, report the result the way a script does. PASTED (a script block has
167
+ # no file of its own), leave the window open and only record the result.
168
+ if ($MyInvocation.MyCommand.Path) { exit $SetupExit }
169
+ $global:LASTEXITCODE = $SetupExit
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env bash
2
+ # scripts/bongos/autobongos-bootstrap.sh — the first lines of Autobongos setup on
3
+ # a Mac (task 1005095, goal 1000139). The Windows twin is autobongos-bootstrap.ps1.
4
+ #
5
+ # autobongos-bootstrap.sh --code abr_… --api-base https://… --repo https://github.com/owner/name
6
+ #
7
+ # WHY THIS IS SHELL AND SO SHORT. Everything that sets a runner up is one Node
8
+ # program (autobongos-host.js), the same on Windows and Mac. But Node cannot
9
+ # install Node, and the program lives in a copy of the project that does not exist
10
+ # yet. So this does only what must happen before Node can take over: find or
11
+ # install git, Node and Claude Code, make the runner ITS OWN copy of the project,
12
+ # and hand over.
13
+ #
14
+ # NO sudo, ANYWHERE. git comes from Apple's own command-line tools (macOS asks
15
+ # with its own window), Node is unpacked into the runner's folder when the Mac has
16
+ # none, and Claude Code installs into the person's own account.
17
+ #
18
+ # EVERY STOP IS A SENTENCE: what happened and what to do, never raw tool output.
19
+ # Safe to run again — each step checks before it acts.
20
+ #
21
+ # It also runs on Linux, where the runner then has no start-at-sign-in entry (the
22
+ # goal covers Windows and Mac); that is what lets CI exercise this file.
23
+
24
+ set -u
25
+
26
+ CODE=""; API_BASE=""; REPO=""; DRY_RUN=0
27
+ RUNNER_HOME="${AUTOBONGOS_HOME:-$HOME/.cloudbongos-runner}"
28
+
29
+ stop_setup() {
30
+ printf '\nAutobongos setup stopped here: %s\nWhat to do: %s\n' "$1" "$2" >&2
31
+ exit 1
32
+ }
33
+
34
+ while [ $# -gt 0 ]; do
35
+ case "$1" in
36
+ --code) CODE="${2:-}"; shift 2 ;;
37
+ --api-base) API_BASE="${2:-}"; shift 2 ;;
38
+ --repo) REPO="${2:-}"; shift 2 ;;
39
+ --home) RUNNER_HOME="${2:-}"; shift 2 ;;
40
+ --dry-run) DRY_RUN=1; shift ;;
41
+ *) shift ;;
42
+ esac
43
+ done
44
+
45
+ if [ -z "$CODE" ] || [ -z "$API_BASE" ] || [ -z "$REPO" ]; then
46
+ stop_setup "the setup command is incomplete." "Copy the whole command again from Settings > Your Autobongos runner."
47
+ fi
48
+ case "$REPO" in
49
+ https://*) : ;;
50
+ *) stop_setup "the project address in the command does not look right." "Copy the whole command again from Settings > Your Autobongos runner." ;;
51
+ esac
52
+ # The one-time code is sent to this address and the runner's login comes back
53
+ # from it, so it must be https. Plain http is for this machine alone (a
54
+ # developer's own instance); autobongos-host.js applies the same rule again.
55
+ case "$API_BASE" in
56
+ https://*|http://localhost|http://localhost:*|http://127.0.0.1|http://127.0.0.1:*) : ;;
57
+ *) stop_setup "the project's address in the command is not a secure (https) address." "Copy the whole command again from Settings > Your Autobongos runner." ;;
58
+ esac
59
+
60
+ have() { command -v "$1" >/dev/null 2>&1; }
61
+
62
+ # The setup command is piped into bash, so the keyboard is /dev/tty, not stdin.
63
+ # OPENED, not just tested: with no terminal at all (CI, a remote command) the
64
+ # device node still exists and reads as readable, and opening it is what fails.
65
+ if { true </dev/tty; } 2>/dev/null; then HAVE_TTY=1; else HAVE_TTY=0; fi
66
+
67
+ echo "Setting this device up as an Autobongos runner."
68
+ echo "It gets its own copy of the project and its own sign-in; your own work here is not touched."
69
+ echo
70
+ echo "Checking the three programs it needs..."
71
+
72
+ # --- git ---------------------------------------------------------------------
73
+ # On a Mac /usr/bin/git exists even with no tools installed (it is a stub that
74
+ # opens the installer), so ask xcode-select, not the PATH.
75
+ if [ "$(uname -s)" = "Darwin" ] && ! xcode-select -p >/dev/null 2>&1; then
76
+ if [ "$DRY_RUN" = 1 ]; then echo " would install Apple's command-line tools (git)"
77
+ else
78
+ xcode-select --install >/dev/null 2>&1 || true
79
+ stop_setup "this Mac needs Apple's command-line tools, which include git." "A window has opened asking to install them. Press Install, wait for it to finish, then paste the setup command again."
80
+ fi
81
+ elif have git; then echo " found git"
82
+ elif [ "$DRY_RUN" = 1 ]; then echo " would need git"
83
+ else stop_setup "git is not installed." "Install git, open a new terminal window, and paste the setup command again."
84
+ fi
85
+
86
+ # --- node --------------------------------------------------------------------
87
+ # Unpacked into the runner's own folder when the device has none: no installer,
88
+ # no password, and removing the runner removes it.
89
+ NODE_DIR="$RUNNER_HOME/node"
90
+ if [ -x "$NODE_DIR/bin/node" ]; then PATH="$NODE_DIR/bin:$PATH"; fi
91
+ if have node; then echo " found node"
92
+ elif [ "$DRY_RUN" = 1 ]; then echo " would install Node into $NODE_DIR"
93
+ else
94
+ echo " installing Node into the runner's folder..."
95
+ case "$(uname -s)" in Darwin) NODE_OS=darwin ;; Linux) NODE_OS=linux ;; *) NODE_OS="" ;; esac
96
+ case "$(uname -m)" in arm64|aarch64) NODE_ARCH=arm64 ;; x86_64|amd64) NODE_ARCH=x64 ;; *) NODE_ARCH="" ;; esac
97
+ if [ -z "$NODE_OS" ] || [ -z "$NODE_ARCH" ]; then
98
+ stop_setup "Node is not installed, and this kind of device is not one this setup can install it on." "Install Node from https://nodejs.org, open a new terminal window, and paste the setup command again."
99
+ fi
100
+ NODE_BASE="https://nodejs.org/dist/latest-v22.x"
101
+ NODE_TAR="$(curl -fsSL "$NODE_BASE/SHASUMS256.txt" 2>/dev/null | awk '{print $2}' | grep -E "^node-v[0-9.]+-${NODE_OS}-${NODE_ARCH}\.tar\.gz$" | head -n 1)"
102
+ if [ -z "$NODE_TAR" ]; then
103
+ stop_setup "Node could not be downloaded." "Check this device is online, or install Node from https://nodejs.org, then paste the setup command again."
104
+ fi
105
+ mkdir -p "$NODE_DIR"
106
+ if ! curl -fsSL "$NODE_BASE/$NODE_TAR" | tar -xz -C "$NODE_DIR" --strip-components 1; then
107
+ stop_setup "Node could not be unpacked." "Install Node from https://nodejs.org, open a new terminal window, and paste the setup command again."
108
+ fi
109
+ PATH="$NODE_DIR/bin:$PATH"
110
+ have node || stop_setup "Node did not install." "Install Node from https://nodejs.org, open a new terminal window, and paste the setup command again."
111
+ echo " installed node"
112
+ fi
113
+
114
+ # --- claude ------------------------------------------------------------------
115
+ if [ -x "$HOME/.local/bin/claude" ]; then PATH="$HOME/.local/bin:$PATH"; fi
116
+ if have claude; then echo " found claude"
117
+ elif [ "$DRY_RUN" = 1 ]; then echo " would install Claude Code"
118
+ else
119
+ echo " installing Claude Code..."
120
+ npm install -g @anthropic-ai/claude-code >/dev/null 2>&1 || true
121
+ have claude || stop_setup "Claude Code did not install." "Install it from https://claude.com/claude-code, open a new terminal window, and paste the setup command again."
122
+ echo " installed Claude Code"
123
+ fi
124
+
125
+ REPO_DIR="$RUNNER_HOME/repo"
126
+ echo
127
+ if [ "$DRY_RUN" = 1 ]; then
128
+ echo "Would make the runner's copy of the project in $REPO_DIR and hand over to autobongos-host.js."
129
+ exit 0
130
+ fi
131
+
132
+ mkdir -p "$RUNNER_HOME"
133
+ if [ -d "$REPO_DIR/.git" ]; then
134
+ echo "The runner's copy is already here; bringing it up to date..."
135
+ if [ "$HAVE_TTY" = 1 ]; then git -C "$REPO_DIR" fetch --quiet origin main </dev/tty; else git -C "$REPO_DIR" fetch --quiet origin main; fi \
136
+ || stop_setup "this device could not fetch the project's code from GitHub." "Sign in to GitHub on this device (the GitHub CLI's gh auth login is the simplest way), then paste the setup command again."
137
+ git -C "$REPO_DIR" reset --quiet --hard origin/main
138
+ else
139
+ echo "Making the runner's own copy of the project (GitHub may ask you to sign in)..."
140
+ if [ "$HAVE_TTY" = 1 ]; then git clone --quiet "$REPO" "$REPO_DIR" </dev/tty; else git clone --quiet "$REPO" "$REPO_DIR"; fi \
141
+ || stop_setup "this device could not copy the project from GitHub." "Sign in to GitHub on this device with an account that can see the project (the GitHub CLI's gh auth login is the simplest way), then paste the setup command again."
142
+ fi
143
+
144
+ HOST_JS="$REPO_DIR/scripts/bongos/autobongos-host.js"
145
+ [ -f "$HOST_JS" ] || stop_setup "the project's copy has no runner program in it." "The project is on an older version. Ask the project owner to update it, then try again."
146
+
147
+ export AUTOBONGOS_HOME="$RUNNER_HOME" PATH
148
+ if [ "$HAVE_TTY" = 1 ]; then
149
+ exec node "$HOST_JS" setup --code "$CODE" --api-base "$API_BASE" --mark-runner-copy </dev/tty
150
+ fi
151
+ exec node "$HOST_JS" setup --code "$CODE" --api-base "$API_BASE" --mark-runner-copy