Enterprise Setup
File storage, remote API, compliance features.
For production deployments, use persistent storage and consider the remote API for centralized audit.
File Storage
Replace in-memory storage with FileStorage for persistence:
import { wrapWithSentinel, FileStorage, standardPolicy } from "@valeo/x402";
const storage = new FileStorage("/var/lib/sentinel/audit.jsonl", 20);
const secureFetch = wrapWithSentinel(fetchWithPayment, {
agentId: "agent-prod-001",
team: "engineering",
budget: standardPolicy(),
audit: {
enabled: true,
storage,
enrichment: {
staticTags: ["production"],
tagRules: [
{ pattern: ".*openai.*", tags: ["llm", "openai"] },
{ pattern: ".*anthropic.*", tags: ["llm", "anthropic"] },
],
},
},
});Call storage.destroy() on process exit to flush pending writes.
Remote API Storage
For centralized audit across multiple nodes, use ApiStorage:
import { ApiStorage, wrapWithSentinel, standardPolicy } from "@valeo/x402";
const storage = new ApiStorage({
apiKey: process.env.VALEO_API_KEY!,
baseUrl: "https://api.valeo.money",
batchSize: 50,
flushIntervalMs: 5000,
});
const secureFetch = wrapWithSentinel(fetchWithPayment, {
agentId: "agent-prod-001",
audit: { storage },
budget: standardPolicy(),
});Redaction
Redact sensitive fields from audit records:
audit: {
storage,
redactFields: ["secret_key", "authorization", "x-api-key"],
}Approval Workflows
budget: customPolicy({
maxPerCall: "10.00",
requireApproval: {
above: "50.00",
handler: async (ctx) => {
const approved = await sendSlackApprovalRequest(ctx);
return approved;
},
},
}),Metadata for Cost Centers
metadata: {
environment: "production",
cost_center: "ENG-2024",
project: "agent-weather",
},Export for Compliance
const logger = new AuditLogger({ storage });
const csv = await logger.exportCSV({
startTime: startOfMonth,
endTime: endOfMonth,
});
await writeToS3("compliance/audit-2024-02.csv", csv);