Skip to main content

Module github_broker_shim

Module github_broker_shim 

Source
Expand description

The gh and git shell functions of an agent whose GitHub access goes through AgentMux Cloud.

srv puts them in the agent’s environment under the name bash imports exported functions from, so they reach every bash the agent runs, whichever provider CLI started it. Both do their work through agentmux-bashwrap (crates/bashwrap/src/github.rs, git_hooks.rs).

Constants§

GH_FUNCTION_BODY
gh, for an agent whose person connected GitHub through AgentMux Cloud (srv sets AGENTMUX_GITHUB_BROKER for those): the command runs with the GitHub App’s token for the repository it is about, or with no token at all, never with one the environment happened to carry. What a gh pr, gh issue, gh release or gh api command sends is scanned for credentials first (github-text-guard: a hit refuses the command, a stdin body reaches gh as a file), and gh pr create and gh pr edit carry the owner tag in the PR’s body. gh auth status says so, instead of “not logged into any GitHub hosts” (the bare command only: with flags such as --json it is gh’s own output a caller parses). A container’s gh pr merge, gh release and gh api first go through github-container: srv does the merge for it, and the API writes its token cannot make are refused with what to do (crates/bashwrap/src/container_verbs.rs). The command word is read after a leading -R/--repo (gh -R o/r pr merge 7), for the container step, the text check and the owner tag alike. Without the variable it is plain gh. The real gh it runs is told (AGENTMUX_GH_SHIM_DONE) that these steps are done: in a container’s image gh on PATH is agentmux-bashwrap too (crates/bashwrap/src/gh_shim.rs, for timeout gh, xargs gh, scripts), and it does the same steps, once, for a caller that did not come through this function.
GH_FUNCTION_NAME
The name bash gives an exported gh function.
GIT_FUNCTION_BODY
git, for the same agents: a push or a command that makes commits first asks agentmux-bashwrap git-env, which refuses what would skip the hooks (git push --no-verify) and names the App’s bot as the commit’s author. Any other git command is plain git.
GIT_FUNCTION_NAME
The name bash gives an exported git function.