Skip to main content

Module gh_agent_token

Module gh_agent_token 

Source
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§

HostToken
A token gh-agent minted.
MergeRequest
What a container asked srv to merge: one pull request, by number, with the few options a merge takes.

Enums§

MergeMethod
How a pull request is merged; none lets the repository’s own rule (a merge queue) choose.
ScanOutcome
What the host’s publish guard made of a container agent’s push.
Scope
What a container’s token may do. Api reads contents and writes pull requests, issues and the rest; it cannot write contents. Push writes 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-agent cannot 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 1 in 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’s publish_scan) and asks nothing when it is absent.

Functions§

bot_user_id
The user id of the bot <slug>[bot], which gh-agent doesn’t say: a commit’s author email is <id>+<slug>[bot]@users.noreply.github.com. A public lookup, asked once per bot and kept; None when GitHub can’t be reached (not asked again for a minute), and then the commit keeps its own author.
installed
gh-agent on the host’s PATH, if it is installed.
is_too_old
Whether error (a token_for error) is GH_AGENT_TOO_OLD.
is_took_too_long
Whether error (a token_for error) is took_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 --admin and no other flag, so GitHub’s own rules (a review, a merge queue, the checks) decide.
merge_pr
Merge r as the agent slug with the host’s gh-agent pr merge. The token it uses stays on the host; the answer is what the command said, first lines, bounded. Ok when the merge was done or queued, Err with what GitHub said.
merge_request_ok
Whether r can 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. The material (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 agent slug: one repository, and scope’s permissions only.
took_too_long
What an agent is told when gh-agent is installed but did not answer in [TIMEOUT]: not a missing connection.