How infisical/agent-vault works
Purpose and Entry Points
Agent Vault is a Go-based credential vault and HTTP/HTTPS MITM broker for AI agents. It prevents agents from receiving real credentials: agents use dummy values or proxy authentication, while the broker injects credentials into permitted outbound requests. The single binary exposes CLI, management API/UI, and proxy modes through main.go, cmd/root.go, and cmd/server.go.
Management Plane
The management server owns authenticated administration of users, vaults, agents, credentials, service rules, proposals, sessions, logs, and instance settings. HTTP handlers are organized under internal/server/server.go, internal/server/handle_vaults.go, and internal/server/handle_services.go. The React SPA is compiled into/served by this server, with application routing and API client code in web/src/router.tsx, web/src/App.tsx, and web/src/lib/api.ts.
Proxy and Credential-Brokering Plane
A distinct proxy listener accepts HTTP forward-proxy traffic and HTTPS CONNECT, authenticates the requesting agent/session, applies vault service policy, resolves credentials, then forwards the transformed request upstream. Core routing and proxy behavior live in internal/broker/broker.go, internal/brokercore/brokercore.go, and internal/mitm/proxy.go. Request rewriting includes dummy-value substitution and auth-header injection (internal/brokercore/substitution.go, internal/brokercore/proxyauth.go); unmatched hosts can forward normally or be denied by vault policy.
Trust, Authentication, and Authorization
The system separates operator authentication from proxy-agent authorization. User login/session and password flows are implemented in internal/auth/auth.go and internal/session/session.go; agent/session credentials and proxy authorization are modeled in internal/brokercore/session.go and management handlers. Vault-scoped roles, agents, temporary sessions, and approval-backed proposals establish the boundary between management changes and live proxy access (internal/proposal/proposal.go, internal/proposal/merge.go).
Data, Encryption, and Credential Sources
Persistent state defaults to SQLite and can switch to shared PostgreSQL for replicas. Store opening, dialect selection, and schema evolution reside in internal/store/open.go, internal/store/postgres.go, and internal/store/migrate.go. Credentials are encrypted using the master-password-derived cryptographic layer (internal/crypto/crypto.go, internal/crypto/kdf.go). Vaults may instead resolve credentials from Infisical, including dynamic secret support, through internal/infisical/client.go, internal/infisical/dynamic.go, and internal/infisical/sync.go.
Agent Execution and Isolation
CLI execution commands bootstrap agent processes with proxy configuration, token/vault context, and trust material; key paths are cmd/run.go, cmd/run_container.go, and cmd/agent.go. Optional Docker isolation creates a controlled container/network path and distributes the local CA, using internal/isolation/docker.go, internal/isolation/gateway.go, and internal/isolation/cacopy.go. The MITM certificate authority is managed by internal/ca/provider.go and internal/ca/soft.go, establishing TLS interception trust for agent runtimes.
Integrations and Operational Surfaces
External boundaries are upstream API hosts, optional Infisical, SMTP notifications, Docker, SQLite/PostgreSQL, and OAuth providers. Cross-cutting controls include egress filtering (internal/netguard/netguard.go), per-request auditing/retention (internal/requestlog/sink.go, internal/requestlog/retention.go), rate limiting (internal/ratelimit/middleware.go), notifications (internal/notify/notify.go), and telemetry (internal/telemetry/telemetry.go). Orchestrators can use the TypeScript SDK to mint scoped sessions and construct proxy/CA environment configuration via sdks/sdk-typescript/src/client.ts, sdks/sdk-typescript/src/resources/sessions.ts, and sdks/sdk-typescript/src/vault.ts.
Main entry points: brokercore.go Broker policy engine · server.go Management server · run.go Agent runner · broker.go Proxy listener
Components 20
Entry & Execution
- CLI binary · Selects server, proxy, and agent execution modes.
main.go - Agent runner · Starts agents with scoped proxy and trust configuration.
cmd/run.go - Docker isolation · Creates controlled agent network and distributes the local CA.
internal/isolation/docker.go
Management Plane
- Management server · Authenticated administration for vaults, agents, credentials, and settings.
internal/server/server.go - Management SPA
web/src/App.tsx - Operator auth · Handles operator login, passwords, and sessions.
internal/auth/auth.go - Proposals & approval · Separates approved management changes from live access.
internal/proposal/proposal.go
Credential Broker
- Proxy listener · Accepts forward-proxy traffic and CONNECT tunnels.
internal/broker/broker.go - Broker policy engine · Authenticates agents, applies vault policy, and resolves credentials.
internal/brokercore/brokercore.go - Request rewriter · Substitutes dummy values and injects upstream authentication.
internal/brokercore/substitution.go - TLS MITM proxy
internal/mitm/proxy.go - Request audit · Records broker requests with retention controls.
internal/requestlog/sink.go
Trust & Policy
- Agent sessions · Models agent and temporary session credentials.
internal/brokercore/session.go - MITM certificate authority · Issues interception certificates for agent runtimes.
internal/ca/provider.go - Egress guard
internal/netguard/netguard.go
Data & Integrations
- Encrypted vault data · Encrypts persisted credentials with a master-password-derived key.
internal/crypto/crypto.go - Persistent store · Selects dialect and evolves persistent schema.
internal/store/open.go - Infisical source · Optional synced and dynamic credential source.
internal/infisical/client.go - Upstream API hosts
- TypeScript SDK · Mints scoped sessions and proxy/CA environment configuration.
sdks/sdk-typescript/src/client.ts
Connections 23
- CLI binary → Management server: starts
- CLI binary → Agent runner: runs
- Agent runner → Proxy listener: configures agent proxy
- Agent runner → MITM certificate authority: installs trust
- Agent runner → Docker isolation: optional isolation
- Docker isolation → Proxy listener: controlled network path
- Management SPA → Management server: management API
- Management server → Operator auth: authenticates operators
- Management server → Proposals & approval: manages changes
- Management server → Persistent store: reads and writes
- Proposals & approval → Persistent store: merges approved state
- TypeScript SDK → Management server: mints sessions
- Proxy listener → TLS MITM proxy: CONNECT traffic
- Proxy listener → Broker policy engine: proxy requests
- TLS MITM proxy → MITM certificate authority: issues TLS certificates
- Broker policy engine → Agent sessions: authorizes agent
- Broker policy engine → Request rewriter: permitted request
- Broker policy engine → Egress guard: checks destination
- Broker policy engine → Encrypted vault data: resolves credentials
- Broker policy engine → Infisical source: optional secret resolution
- Request rewriter → Upstream API hosts: forwards transformed request
- Broker policy engine → Request audit: audits request
- Encrypted vault data → Persistent store: persists encrypted values