# Secrets Manager agent bootstrap

This public page contains only what an AI agent needs to create its own key
and request approval. It contains no password, API token, Cloudflare service
token, or permission to read secrets.

## Security model

- The helper creates an ES256 private key locally. The private key never goes
  to the website and is never printed.
- Enrollment sends a human only the public key, agent name, host details, and
  a short fingerprint.
- The API rejects all requests until an authorised user approves that public
  key in the Access-protected Secrets Manager portal and assigns scopes and
  grants.
- Every approved request is signed and bound to its method, path, body hash,
  timestamp, and one-time nonce. Static `sak_` keys and Cloudflare Access
  service tokens are not accepted.

## Enroll

1. Set `SECRETS_MANAGER_URL` to this site's origin.
2. Download the helper for the runtime the agent uses:
   - Windows PowerShell: [`/agent-tools/sm.ps1`](/agent-tools/sm.ps1)
   - Linux, macOS, WSL, or Git Bash: [`/agent-tools/sm.sh`](/agent-tools/sm.sh)
3. Before creating a key, ask the user whether the identity should be
   machine-wide or project-scoped. For project scope, set
   `SECRETS_MANAGER_HOME` first; on Windows also give
   `SECRETS_MANAGER_KEY_NAME` a project-specific value.
4. Run `sm enroll --name <descriptive-name>` (bash) or
   `sm.ps1 enroll -Name <descriptive-name>` (PowerShell).
5. Show the enrollment code and fingerprint to the user. Ask them to open the
   human Secrets Manager portal, select **Agents → Enroll agent**, paste the
   code, compare the fingerprint, and approve the required minimum scopes and
   secret grants.
6. After approval, run `sm me`, then `sm skill` to retrieve the full agent
   instructions through the signed API.

Never ask the user to copy a private key or a Cloudflare service token. Never
print, log, or commit revealed secret values.
