Skip to content

feat: @epilot/agent-auth package and Agent Auth Protocol login for the CLI - #505

Open
anttiviljami wants to merge 5 commits into
mainfrom
feat/agent-auth-protocol
Open

anttiviljami wants to merge 5 commits into
mainfrom
feat/agent-auth-protocol

Conversation

@anttiviljami

Copy link
Copy Markdown
Member

Summary

Second client of epilot's Agent Auth Protocol (RFC with resolved decisions: https://claude.ai/artifact/7rKkSL589k59uXyYik9rNa).

  • New package @epilot/agent-auth (packages/agent-auth, zero runtime deps, Node ≥ 18): Ed25519 keypairs, RFC 7638 thumbprints, host/agent JWT signing, AgentAuthClient (discover, registerAgent, requestCapability, getAgentStatus, waitForApproval, execute, capabilities, revoke/reactivate/rotate/introspect) and epilot helpers (EPILOT_CAPABILITIES, organizationAccessCapability, listEpilotOrganizations, issueEpilotAccessToken, epilotAgentAuthIssuerhttps://access-token.sls.epilot.io/v1/access-tokens/agent-auth).
  • CLI (@epilot/cli): epilot auth login now registers an agent (host key per machine, agent per profile under ~/.config/epilot/agent-auth/), shows the user code, opens the approval page, polls, picks the org and stores a token. Tokens refresh silently while the agent is active. New epilot org list | use <id> | request <id> [--write] [--full-pii] | current. auth status shows agent + per-org grants; auth logout revokes the agent. --token kept; --legacy keeps the old browser flow for one release. --json --no-interactive supported for agents driving the CLI.

Server side lives in access-token-api (GitLab, branch feat/agent-auth-protocol); the MCP gateway vendors this package's core until it is published.

Test plan

  • pnpm --filter @epilot/agent-auth build test lint (23 tests)
  • pnpm --filter @epilot/cli test (128 tests), root pnpm lint clean
  • CI green
  • Manual: pnpm --filter @epilot/cli dev auth login --use-dev against the dev issuer once access-token-api is deployed

🤖 Generated with Claude Code

https://claude.ai/code/session_01CBojHN7n7Y2Vx8caWb3kCR


Generated by Claude Code

anttiviljami and others added 5 commits September 8, 2026 14:27
New zero-dependency package implementing the AAP v1.0-draft client side:
Ed25519 key pairs and RFC 7638 thumbprints, host/agent JWT signing,
discovery with caching, register/request-capability/status/execute,
waitForApproval polling, agent and host lifecycle calls, plus the epilot
capability helpers (organizations.list, access_token.issue, grant mapping,
issuer per stage).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBojHN7n7Y2Vx8caWb3kCR
…refresh

- `epilot auth login` registers this machine as a host and the CLI as an
  agent, shows the verification code, opens the approval page, polls until
  approved, then issues and stores a token for the chosen organization.
  `--org`, `--readonly`, `--anonymize`, `--no-interactive`, `--json`;
  `--token` stays manual mode and `--legacy` keeps the previous browser
  callback flow (legacyBrowserLogin).
- New `epilot org list|use|request|current` commands built on the
  organizations.list / access_token.issue capabilities; `org request`
  prints the approval object with status "pending" in --json/--no-interactive.
- `auth status` shows agent, host, issuer and per-organization grants;
  `auth logout` revokes the agent before deleting local state.
- resolveTokenAsync() silently re-issues tokens that are missing or expire
  within two minutes; callApi awaits it.
- Host/agent key storage under ~/.config/epilot/agent-auth (mode 0600).
- Tests with an msw fake AAP server for storage, login and org flows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBojHN7n7Y2Vx8caWb3kCR
… workspace deps in CI

- README: new Authentication section (AAP flow, organizations, silent
  refresh, --legacy, local state, issuer override).
- Root help lists `auth login --org` and the `org` commands.
- CI: `pnpm --filter @epilot/cli... build` so @epilot/agent-auth is built
  before the CLI bundles it.
- Changeset for @epilot/cli.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBojHN7n7Y2Vx8caWb3kCR
… template

`pnpm generate` rewrites src/index.ts and the README usage block, so the
`org` subcommand and the updated auth/org help lines need to live in
scripts/generate.ts as well; the README usage block is updated to match.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBojHN7n7Y2Vx8caWb3kCR
…r base path

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBojHN7n7Y2Vx8caWb3kCR
pendingGrantIds?: string[];
}

const trimSlash = (value: string) => value.replace(/\/+$/, '');
process.exit(1);
}
const token = await legacyBrowserLogin(profileName, env, readonly, anonymize);
if (token) {
const path = join(tmp.configDir, 'agent-auth', 'host.json');
expect(existsSync(path)).toBe(true);
expect(statSync(path).mode & 0o777).toBe(0o600);
const stored = JSON.parse(readFileSync(path, 'utf-8'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants