Expand description
ai-crew-sync admin … from the operator’s own machine.
Talks to /admin/* with an administrative credential stored by admin login, verifies every token it mints by presenting it to /mcp and
checking whoami answers with the agent and team that were asked for,
and can write the result straight into the per-team token file.
Every function takes the configuration directory explicitly so the
integration tests run the real flow against a temporary directory; the
binary resolves it once with config_dir.
Secrets: the credential is read from a hidden prompt or stdin, never from an argument; a minted token is printed exactly once, or not at all when it is saved to a file. Nothing here logs.
Structs§
- Admin
Config - Endpoint and credential of a logged-in administrator.
- Api
- A logged-in client for
/admin/*. - Issued
- What
/adminminted: the secret plus the identity the server says it has. - Save
Target - Where a saved token goes:
tokens-<team>in the config directory, as the line<repo>=<token>.
Constants§
- CONFIG_
FILE - Name of the file holding the endpoint and credential inside the configuration directory.
Functions§
- config_
dir - Where
admin loginkeeps its state and--savewrites token files.BUS_CONFIG_DIR, else$XDG_CONFIG_HOME/ai-crew-sync, else$HOME/.config/ai-crew-sync. - finish_
issue - Everything after the mint: verify the token on
/mcpas exactly the requested agent and team, then either save it (and say nothing of the secret) or print it once. On a mismatch the token is revoked, nothing is written, and the error says what the server answered. - load_
config - Load the stored configuration.
BUS_ADMIN_URLandBUS_ADMIN_TOKENoverride the file, for scripts and CI that never runadmin login. - login
- Verify the credential against the bus and, only then, persist it. Returns the scope the server reported.
- normalize_
base_ url https://host:8443,https://host:8443/,https://host:8443/mcpandhttps://host:8443/adminall mean the same bus.- read_
credential - Read the credential without it touching argv or shell history: from stdin when asked, else from a hidden prompt.
- remove_
config - save_
config - tokens_
file - upsert_
token_ entry - Set
<name>=<token>in the file, keeping every other line as it is: comments, blank lines, order, and above all_base. A duplicate ofnameleft by a hand edit collapses to the one updated line. Atomic and 0600, and nothing else in the file is touched — a previous token for the same name is replaced in the file but never revoked on the bus. - validate_
repo_ name --reponames a line in a file people edit by hand: one word, no=, no whitespace, and never a path.- whoami_
on_ mcp - Present a freshly minted token to
/mcpand return the agent and team it authenticates as. This is the server’s word, not the request’s. - write_
private - Write
contenttopathatomically (temp file + rename) with mode 0600. A crash mid-write leaves the previous file intact, never a truncated one.