IntegrationsAI Agents
AI Agents Integration
SilentAuth is designed for agentic workflows. When an AI agent — whether LangChain, AutoGPT, CrewAI, or a custom agent loop — needs to perform a destructive or irreversible action, SilentAuth ensures a human reviews and approves before execution.
LangChain Tool Example
Wrap any high-risk tool with a SilentAuth approval gate:
import { Tool } from 'langchain/tools';
import { SilentAuth } from '@silentauth/sdk';
const sa = new SilentAuth({
projectId: process.env.SA_PROJECT_ID,
secretKey: process.env.SA_SECRET_KEY,
});
const deleteUserTool = new Tool({
name: 'delete_user',
description: 'Permanently deletes a user account',
func: async (input: string) => {
const { userId } = JSON.parse(input);
// Declare intent — blocks until approved
const intent = await sa.createIntent({
action: 'delete_user',
params: { userId },
approvers: ['admin-team'],
});
const permit = await intent.waitForApproval({ timeout: 300_000 });
if (permit.status !== 'approved') {
return 'Action denied by approver.';
}
// Validate permit before executing
const valid = sa.validatePermit(permit.token);
if (!valid.valid) throw new Error('Invalid permit');
await deleteUser(userId);
return `User ${userId} deleted successfully.`;
},
});Webhook-Based (Async) Pattern
For long-running agent workflows, use webhooks instead of blocking polls:
// 1. Create intent and store its ID
const intent = await sa.createIntent({
action: 'bulk_delete_records',
params: { table: 'users', filter: { inactive: true } },
approvers: ['dba-team'],
metadata: { agentRunId: run.id },
});
await db.saveIntentId(run.id, intent.id);
// 2. Your webhook endpoint receives the decision
// POST /webhooks/silentauth
app.post('/webhooks/silentauth', async (req) => {
const event = sa.verifyWebhook(req.body, req.headers['sa-signature']);
if (event.type === 'intent.approved') {
const { agentRunId } = event.intent.metadata;
const permit = event.permit;
// Resume the agent run with the permit token
await agentQueue.resume(agentRunId, { permitToken: permit.token });
}
if (event.type === 'intent.denied') {
await agentQueue.cancel(event.intent.metadata.agentRunId);
}
});Recommended Actions to Gate
•Database record deletion or truncation
•Sending emails to large user lists
•Creating or deleting cloud infrastructure
•Rotating API keys or secrets
•Making payments or financial transactions
•Exporting user PII or sensitive data