@infisical/agent-vault-sdk
v0.5.0
Published
The official TypeScript SDK for Agent Vault
Maintainers
Readme
Agent Vault TypeScript SDK
The official TypeScript SDK for Agent Vault, an open-source credential brokerage layer for AI agents. Agent Vault sits between development agents and target services, proxying requests and injecting credentials so agents never see raw keys or tokens.
Installation
npm install @infisical/agent-vault-sdkQuickstart
Configure a sandbox with transparent proxy
The primary use case: your backend orchestrates agent sandboxes (Docker, Daytona, E2B, etc.) and needs to route their HTTPS traffic through Agent Vault so agents never see credentials. One call gives you everything you need.
import { AgentVault, buildProxyEnv } from "@infisical/agent-vault-sdk";
const av = new AgentVault({
token: "YOUR_AGENT_TOKEN",
address: "http://localhost:14321",
});
const vault = av.vault("my-project");
// Mint a scoped session — returns the token + container config in one call
const session = await vault.sessions!.create({ ttlSeconds: 3600 });
// Build the full env var set with your chosen CA cert mount path
const certPath = "/etc/ssl/agent-vault-ca.pem";
const env = buildProxyEnv(session.containerConfig!, certPath);
// Pass to your container runtime — the agent inside just calls
// fetch("https://api.stripe.com/v1/charges") normally.
// Agent Vault intercepts, injects credentials, and forwards.session.containerConfig includes:
| Field | Description |
|---|---|
| env.HTTPS_PROXY | MITM proxy URL with the scoped token embedded |
| env.NO_PROXY | Bypass list (localhost,127.0.0.1) |
| caCertificate | Root CA PEM content — mount this into the container |
buildProxyEnv() expands the config with NODE_USE_ENV_PROXY=1 (for Node.js v22.21.0+ native proxy support) and CA trust variables (SSL_CERT_FILE, NODE_EXTRA_CA_CERTS, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE, GIT_SSL_CAINFO, DENO_CERT) all pointing at certPath.
containerConfig is null when the server has MITM disabled (--mitm-port 0).
Example: Docker
import { execSync } from "child_process";
import { writeFileSync } from "fs";
const certPath = "/etc/ssl/agent-vault-ca.pem";
const env = buildProxyEnv(session.containerConfig!, certPath);
// Write the CA cert to a temp file for mounting
const tmpCert = "/tmp/agent-vault-ca.pem";
writeFileSync(tmpCert, session.containerConfig!.caCertificate);
const envFlags = Object.entries(env).map(([k, v]) => `-e ${k}=${v}`).join(" ");
execSync(`docker run --rm ${envFlags} -v ${tmpCert}:${certPath}:ro my-agent-image`);Example: Daytona
import { Daytona } from "@daytonaio/sdk";
const daytona = new Daytona();
const certPath = "/etc/ssl/agent-vault-ca.pem";
const env = buildProxyEnv(session.containerConfig!, certPath);
const workspace = await daytona.create({
image: "my-agent-image",
envVars: env,
// Mount session.containerConfig.caCertificate at certPath
});Set up a vault
Depending on your use case, vault setup may already be done via the CLI or dashboard. Here's the programmatic equivalent:
import { AgentVault } from "@infisical/agent-vault-sdk";
const av = new AgentVault({
token: "YOUR_AGENT_TOKEN",
address: "http://localhost:14321",
});
// Create a vault and get a scoped client
await av.createVault({ name: "my-project" });
const vault = av.vault("my-project");
// Store a credential
await vault.credentials.set({ STRIPE_KEY: "sk_live_abc" });
// Configure a proxy rule — the token field references the credential key above
await vault.services!.set([
{
host: "api.stripe.com",
description: "Stripe API",
auth: { type: "bearer", token: "STRIPE_KEY" },
},
]);Error handling
The SDK throws ApiError for non-2xx responses from Agent Vault control-plane endpoints. Upstream HTTP errors from agent-issued traffic — which travels through HTTPS_PROXY, not the SDK — surface in the agent's normal HTTP client.
Documentation
For comprehensive SDK reference and advanced usage, see the documentation.
Releasing
Releases are automated via GitHub Actions using npm OIDC trusted publishing. Push a git tag matching node-sdk/v<version> (e.g., node-sdk/v0.2.0) to trigger a publish.
