Skip to main content

Module cli_bridge

Module cli_bridge 

Source
Expand description

The copy of agent-hub-cli that agents are told to run.

The build wrapper explicitly stages the CLI as a Tauri sidecar, but the desktop bundle is not a stable location an agent can discover. On Linux the .deb/.rpm land it in /usr/bin, which is already on PATH; on macOS it sits inside the .app, and on Windows inside the install directory. Neither is on PATH, and putting it there is not ours to do: /usr/local/bin needs an admin prompt, ~/.local/bin is not on the default macOS PATH at all, and Windows reserves symlink creation for administrators.

So the app maintains its own copy at a fixed, predictable path instead, and the agent-hub-cli skill looks there first. A copy, not a symlink: an AppImage is mounted at a temporary path, and a .app the user drags elsewhere would leave a dangling link.

§Why the stamp file

The copy can fail — on Windows the old binary may be running (an agent mid-command) or held by a virus scanner, and then the rename cannot replace it. A stale bridge is not merely out of date: before #363 the deploy path deleted a user’s unmanaged directory outright, so an old binary can be one that destroys data a new one refuses to touch. The database’s own user_version gate does not catch this, because such a fix carries no schema change.

The stamp is therefore written last and removed first. Its presence means “a copy of exactly this version completed and ran”; its absence means the bridge must not be used, whether or not a binary is sitting there. It is a small text file, so it can still be removed when the locked binary cannot.

Functions§

bridge_dir
Where the bridge lives. Deliberately the home directory rather than central_repo::base_dir(): the library can be relocated to anywhere the user likes, and the skill has to be able to name this path without asking. Development build hooks may explicitly override it with AGENT_HUB_BRIDGE_DIR.
bridge_path
ensure_bridge
Publish the bundled CLI to the bridge path, replacing whatever is there.
publish_current
Publish the running CLI, even when Cargo gave it the unbranded target name.