Expand description
A GitHub token from the host’s gh-agent, for a container agent.
A container agent has no GitHub setup of its own, and AgentMux’s own token source (the App
broker, identity::github_tokens) is not live everywhere yet. Where gh-agent is installed on
the host, it already holds the App identity the fleet works under, so gh-agent token --repo owner/repo gives a short-lived installation token narrowed to the repository. srv runs it for
the agent that asked (an agent id and a repository, never a command) and hands the token over
the container route; nothing is written into the container.
Structs§
- Host
Token - A token
gh-agentminted. - Merge
Request - What a container asked srv to merge: one pull request, by number, with the few options a merge takes.
Enums§
- Merge
Method - How a pull request is merged; none lets the repository’s own rule (a merge queue) choose.
- Scan
Outcome - What the host’s publish guard made of a container agent’s push.
- Scope
- What a container’s token may do.
Apireads contents and writes pull requests, issues and the rest; it cannot write contents.Pushwrites contents and nothing else (gh-agent token --scope). There is no third kind: a container is never handed the installation-wide token.
Constants§
- GH_
AGENT_ TOO_ OLD - What a container is told when this machine’s
gh-agentcannot give a narrowed token (it predates--scope, or it gave a wider one than asked): the refusal never falls back to the installation-wide token. - PUBLISH_
GUARD_ ENV - Set to
1in a container’s commands only while this machine has a publish guard (gh-agent installed); the container’s pre-push hook reads it (agentmux-bashwrap’spublish_scan) and asks nothing when it is absent.
Functions§
- bot_
user_ id - The user id of the bot
<slug>[bot], whichgh-agentdoesn’t say: a commit’s author email is<id>+<slug>[bot]@users.noreply.github.com. A public lookup, asked once per bot and kept;Nonewhen GitHub can’t be reached (not asked again for a minute), and then the commit keeps its own author. - installed
gh-agenton the host’s PATH, if it is installed.- is_
too_ old - Whether
error(atoken_forerror) isGH_AGENT_TOO_OLD. - is_
took_ too_ long - Whether
error(atoken_forerror) istook_too_long. - merge_
args - The arguments of the host’s
gh-agent pr merge: fixed, built here from validated parts, never from the container’s text. There is no--adminand no other flag, so GitHub’s own rules (a review, a merge queue, the checks) decide. - merge_
pr - Merge
ras the agentslugwith the host’sgh-agent pr merge. The token it uses stays on the host; the answer is what the command said, first lines, bounded.Okwhen the merge was done or queued,Errwith what GitHub said. - merge_
request_ ok - Whether
rcan be run: names that cannot be read as an option or a path, and a real pull request number. - scan_
push - Judge a container agent’s push with the host’s
gh-agent scan-push --repo owner/repo. Thematerial(JSON) goes in on stdin; the arguments are fixed, there is no shell, and the working directory is the temp folder, never anything of the container’s. gh-agent reads no repository and runs no git for this. - token_
for - A narrowed token for
owner/repo, minted for the agentslug: one repository, andscope’s permissions only. - took_
too_ long - What an agent is told when
gh-agentis installed but did not answer in [TIMEOUT]: not a missing connection.