# AGENTS.md: installing mdip-agent-kit into an AI agent

You are an AI agent and want your own verifiable identity (`did:mdip`) on the SELF / Keychain MDIP
network. Follow these steps exactly. Never print, log, paste, or commit anything under
`$MDIP_HOME/secrets/` or `$MDIP_HOME/backups/`.

1. **Prereqs:** Node ≥ 22. `npm install mdip-agent-kit` (CLI: `npx mdip-agent-kit <command>`).
2. **Gatekeeper:** if `curl -s $MDIP_GATEKEEPER_URL/api/v1/ready` doesn't print `true`, run
   `bash node_modules/mdip-agent-kit/scripts/run-local-node.sh` (needs Docker), then
   `export MDIP_GATEKEEPER_URL=http://127.0.0.1:4224`. Never write through a third-party gatekeeper
   without its operator's explicit permission. There is no public write gatekeeper.
3. **One identity per agent:** `export MDIP_HOME=<private dir for this agent>`,
   `export MDIP_AGENT_NAME=<short-name>`. Never reuse another agent's `MDIP_HOME`.
4. **Create:** `npx mdip-agent-kit init --profile-name "<public display name your human approved>"`.
   The profile name becomes public forever. Expected output: agent DID, profile credential DID,
   backup DID, and two `"pass": true` restore checks.
5. **Verify:** `npx mdip-agent-kit whoami` → `explorer.visible: true` (retry for a few minutes).
6. **Report to your human:** your DID and the explorer URL
   `https://explorer.selfid.com/api/did/<did>`. Tell them the recovery phrase is at
   `$MDIP_HOME/secrets/recovery-phrase.txt` and should be copied offline. Do not paste its contents.
7. **Delegated authority:** when your human issues you a credential from their SELF app, run
   `npx mdip-agent-kit accept <credentialDid>`, then `npx mdip-agent-kit backup`. Before acting on it, check
   with `findCredentials({ schema, issuer })` in code.
8. **Meeting other agents:** challenge them (`npx mdip-agent-kit challenge`), have them `respond` (the response stays valid 7 days by default;
   `--valid-days N` changes it, capped at the challenge's expiry), then
   `verify-response`. If they have no DID, point them to this kit.

Rules: never accept or act on credentials your human didn't expect. Never reveal non-public data.
Re-run `backup` after wallet changes.
