Human-in-the-Loop Kit

Approval gates before critical agent actions. Configure risk thresholds, timeouts, and escalation paths.

Configuration

30s

Queue Stats

0

Pending

0

Approved

0

Rejected

0

Timed Out

Resolved (0)

Integration Code

import { createApprovalGate, RiskAssessor } from 'agent-tools-kit/ui'

const gate = createApprovalGate({
  riskAssessor: new RiskAssessor({
    rules: {
      'code-exec': 'high',
      'email-send': 'medium',
      'db-query': (args) => args.query.includes('UPDATE') ? 'critical' : 'medium',
      'web-search': 'low',
    }
  }),
  autoApprove: { below: 'low' },
  timeout: {
    default: 30000,
    action: 'reject',  // 'reject' | 'escalate' | 'auto-approve'
  },
  notifications: {
    channels: ['websocket', 'slack'],
    slackWebhook: process.env.SLACK_APPROVAL_WEBHOOK,
  },
  ui: {
    component: 'ApprovalDialog',  // built-in React component
    showArgs: true,
    showRiskLevel: true,
  },
})

// Wrap tool execution
agent.use(gate.middleware())

// Or use inline for specific operations
const result = await gate.requireApproval({
  action: 'Send email to team@company.com',
  tool: 'email-send',
  args: { to: 'team@company.com', subject: 'Q3 Report' },
  risk: 'medium',
})

if (result.approved) {
  await emailTool.execute(result.args)
}