Repository navigation
fix(worker): find agent CLIs from any package manager - #146
Merged
Merged
Conversation
A worker started from the desktop app, launchd or systemd missed the user's shell PATH, so a CLI installed with bun, Volta, nvm or pnpm was not found. Discovery took the first match on PATH even when it did not run, classified npm packages under Homebrew's prefix as Homebrew, and dropped the reason a version probe failed. The updates center then showed "Not installed", the Agents list no version and the CLI tools section "Up to date" for the same CLI. - Resolve the login-shell env once per start ($SHELL -l -i -c through the process governor, 8 s limit, NUL-separated output between markers) and merge PATH and package-manager variables into the worker env; append a known node when PATH has none. - Search PATH, then Bun, Volta, pnpm, npm prefixes (~/.npmrc), Yarn, nvm, fnm, mise, asdf and Homebrew; use the first copy that answers --version and report the others as alternatives. - Detect Volta, pnpm and Yarn from real paths and shims; add Volta and pnpm recipes; npm under Homebrew's prefix updates with npm. - Report version_error; never show "Up to date" for an unknown version. - The CLI report, ConfigApplied and harness lookups share one choice.
nixuuu
added a commit
that referenced
this pull request
Nov 5, 2026
`computer-relay.test.ts` ("explicit reciprocal sharing … without a
routing loop") failed on CI in #146 and #147 (attempt 1), on line 258.
After the reciprocal share was turned off, W's mirror state existed
again as `{ cursor: "", overview: null }`.
**Cause:** a race on P2.
1. P1 revokes the grant and cancels the relayed `WatchThreadMirror`
stream before the new catalog reaches P2.
2. P2 still has W as `both`, so the next emit starts a new mirror task.
3. The new catalog then deletes W's `both` row, with its mirror, and
inserts W as `origin`.
4. The late `INSERT INTO computer_mirror_state` lands after that. The
new `origin` row satisfies the foreign key, so the empty state comes
back.
Before #36, a removed peer stayed removed and the late insert failed on
the foreign key.
**Fix**
- `mirror.ts` creates mirror state only for a direct peer or a relay
`home`/`both`. The check runs in the same statement, with the peer row
locked. Otherwise `consume` ends as superseded.
- `bot-mirror.ts` checkpoints use the same role check.
- The test adds a check that does not depend on timing: a late `consume`
for the revoked home is rejected and leaves no state. No assertion is
changed; no sleeps, retries or longer timeouts.
**Evidence**
- The new check fails on the old code (1/1) and passes with the fix:
15/15 runs under load.
- The other mirror suites pass: `thread-mirrors.test.ts` and
`linked-agents.test.ts`, 32/32.
Fixes: #36
This was referenced Nov 13, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 27, 2026
## Summary - Read the worker snapshot once more when the accepted report changes during local skill preview on the same connection. Validate the original revision and copy token against the new snapshot before contacting the worker. - Add an integration test that accepts an identical report during the read and checks the previewed bytes. Update the agent environment documentation. Push CI [#146](https://github.com/itsoltech/canopy/actions/runs/45864889405/job/140065136848) and [#147](https://github.com/itsoltech/canopy/actions/runs/45870599390/job/140084790023) reported the same `FAILED_PRECONDITION`. The controlled regression reproduces that error. The original CI logs do not identify which validation condition rejected those requests. ## Verification - The new integration test failed with `FAILED_PRECONDITION` before the fix and passed afterwards. - Four focused integration cases passed via `check:tmp`, including rejection of an on-disk change and preview through a linked computer. - Lint and formatting passed for the two edited TypeScript files. `git diff --check` passed. - The remaining repository checks run in GitHub CI. Fixes: #1303
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a Mac, Codex installed with bun was reported three different ways: "Not installed" in the updates center, "Codex" with no version under Agents, and "Homebrew · /opt/homebrew/bin/codex · version unknown · Up to date" under CLI tools.
Causes
~/.bun/bin,~/.volta/bin, nvm/fnm shims and npm prefixes are missing./opt/homebrew/counted as Homebrew, including npm packages installed with Homebrew's node.--versionfailed was discarded; JS shims withoutnodeon PATH fail there.Fixes
Login-shell environment: the worker resolves the user's login shell once per start (
$SHELL -l -i -c, through the process governor, 8 s limit, output between random markers). It takes PATH plus a fixed list of package-manager variables (BUN_INSTALL,VOLTA_HOME,PNPM_HOME,NVM_DIR, …). Provider or secret variables are never imported, and secret-looking variables are kept out of the shell. If PATH has nonode, one from a known place is added. "Check for updates" refreshes it, at most once a minute. It can be turned off withCANOPY_LOGIN_SHELL_ENV=0.Search order:
~/.local/binand vendor folders.npmrcread as a file)Windows adds npm, Volta and scoop.
Choosing a copy: the first copy that answers
--versionwins, so a working copy beats a stale or broken one. Other copies are listed in details.Manager detection uses the real path, the shim type and the package path, and gives the right update command:
volta install,pnpm add -g,bun add -g,npm,brew upgrade, and so on. New install methods: Volta, pnpm, Yarn.One source of truth: the Agents list uses the same discovery and probe as the CLI report.
Contract: additive proto:
CliTool.version_error,CliTool.alternatives, and install methodsVOLTA,PNPMandYARN.Tests:
tests/integration/cli-discovery.test.tscovers bun, Volta, an npm prefix from.npmrc, npm under the Homebrew prefix, pnpm, a stale Homebrew copy versus a working bun copy, a JS shim that needs node, a broken symlink, and noisy, slow and missing login shells. The full suite passed locally with provider variables unset.Still needs a real macOS check: zsh/fish profiles started from the GUI, and real Volta and pnpm shim layouts.
Copy audit (
docs/copy.md§8):