@aegis-kernel/anthropic
v1.1.0
Published
Anthropic Claude tool_use deterministic invariant safety guard
Maintainers
Readme
🛡️ @aegis-kernel/anthropic
Anthropic Claude Tool-Use Deterministic Safety Clearance Guard
Pre-Execution Clearance • Claudetool_use/tool_resultInterception • Structured Self-Healing Feedback
🚀 Overview
@aegis-kernel/anthropic intercepts Anthropic Claude tool_use content blocks and evaluates deterministic security invariants before tool execution occurs. If a tool call violates a policy invariant, it constructs a standardized tool_result error block containing actionable self-healing guidance for Claude to re-ask safely.
📦 Installation
npm install @aegis-kernel/anthropic @aegis-kernel/core⚡ Quickstart
import Anthropic from '@anthropic-ai/sdk';
import { AegisAnthropicGuard } from '@aegis-kernel/anthropic';
const anthropic = new Anthropic();
const guard = new AegisAnthropicGuard({
mode: 'enforce',
packs: ['@aegis/sql-guard', '@aegis/data-guard'],
});
const response = await anthropic.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Delete records older than 30 days' }],
tools: myClaudeTools,
});
for (const content of response.content) {
if (content.type === 'tool_use') {
// Intercept, evaluate invariants, and execute
const resultBlock = await guard.handleToolUse(content, async (input) => {
return await executeMyTool(content.name, input);
});
// Feed resultBlock back to Claude in next turn
nextTurnMessages.push({ role: 'user', content: [resultBlock] });
}
}📄 License
Distributed under the MIT License. Copyright (c) 2026 Sneh Gabani.
