@obsidian-os/swarm-shield
v0.1.0
Published
Zero-trust mathematical execution compiler for AI agent swarms.
Readme
@obsidian-os/swarm-shield
The Zero-Trust Execution Substrate for Autonomous AI Agents.
@obsidian-os/swarm-shield is an embedded Node.js SDK extracted from the Obsidian OS kernel. It provides a mathematically proven, grammatical execution shield that protects multi-agent orchestrators (like LangGraph and CrewAI) from Indirect Prompt Injections, hallucinated tool usage, and privilege escalation.
The Problem
Modern AI frameworks treat Large Language Models (LLMs) as trusted actors. If an LLM is hijacked via prompt injection hidden in a document, it can execute malicious actions (e.g., dropping a database) because the framework blindly passes the LLM's output to the tool.
The Solution
Swarm Shield operates as a terminal middleware boundary. It forces raw LLM intents through a Constitutional State Compiler (CSCC). If an agent attempts to execute an action outside of its cryptographically defined role, the payload mathematically fails to compile, and the shield throws a ConstitutionalViolation, completely blocking the execution.
Installation
npm install @obsidian-os/swarm-shieldQuick Start: LangGraph Integration
You can easily wrap your vulnerable LangChain tools to enforce role immobility.
import { SwarmShield, LangGraphShieldWrapper } from '@obsidian-os/swarm-shield';
async function secureMyAgents() {
// 1. Initialize the Zero-Trust Shield
const shield = await SwarmShield.initialize({ strictMode: true });
const langGraphAdapter = new LangGraphShieldWrapper(shield);
// 2. Your existing vulnerable tool
const myDatabaseTool = async (input) => { /* drops tables */ };
// 3. Wrap it in the Shield
const securedTool = langGraphAdapter.wrapToolExecutor(
'AGENT_001', // The Agent's ID
'DATA_READER', // The exact role they are allowed to play
'execute_query', // The tool name
myDatabaseTool
);
// If an injected agent tries to drop tables, it will fail compilation.
// The underlying tool is never reached!
try {
await securedTool('{ "action": "override", "payload": "DROP TABLES" }');
} catch (e) {
console.log(e.name); // 'ConstitutionalViolation'
console.log(e.receipt.hash); // Cryptographic audit ledger hash
}
}Features
- Zero Prompt Injection: Structural compilation casts out SQL/Code injections.
- Role Immobility: Agents physically cannot execute tools outside their domain.
- Cryptographic Ledger: Every action produces a chained SHA-256 receipt for enterprise auditing.
Built with absolute sovereignty by the Obsidian OS Team.
