README.md

July 9, 2026 ยท View on GitHub

TealTiger Logo

TealTiger SDK

The first open-source AI agent security SDK with client-side guardrails ๐Ÿ›ก๏ธ

npm version npm downloads Tests License: Apache 2.0 TypeScript v1.4.0 Discord

๐Ÿ“– Read the introduction blog post | ๐Ÿ“š Documentation

What's New in v1.4.0 โ€” Observe Mode (Zero-Config Adoption)

TealTiger v1.4 introduces observe() โ€” one line to instrument any LLM client with full visibility and an instant kill switch:

  • observe(client) โ€” Zero-config proxy wrapping for any of 12 supported LLM providers
  • Automatic Cost Tracking โ€” Per-request, per-session, per-agent cost accumulation across all providers
  • Behavioral Baseline โ€” Statistical profiling (P50/P95/P99 latency, token distribution, cost patterns)
  • PII Detection (REPORT_ONLY) โ€” Passive PII scanning without blocking โ€” visibility before enforcement
  • freeze() / unfreeze() โ€” Instant kill switch to halt any agent immediately, zero policy required
  • Structured Audit Trail โ€” Every call logged with correlation IDs, cost, latency, and governance metadata
  • Governance Dashboard โ€” Real-time overview with KPI metrics, defense pipeline, canary alerts, agent matrix
  • Under 5ms overhead โ€” All instrumentation is in-process, deterministic, and offline-capable
npm install tealtiger@1.4.0

๐Ÿš€ Quick Start

npm install tealtiger
import { TealOpenAI, GuardrailEngine, PIIDetectionGuardrail, PromptInjectionGuardrail } from 'tealtiger';

// Set up guardrails
const engine = new GuardrailEngine();
engine.registerGuardrail(new PIIDetectionGuardrail());
engine.registerGuardrail(new PromptInjectionGuardrail());

// Create guarded client โ€” drop-in replacement for OpenAI
const client = new TealOpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  agentId: 'my-agent',
  guardrailEngine: engine
});

const response = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }]
});

console.log(response.choices[0].message.content);
console.log('Guardrails passed:', response.security?.guardrailResult?.passed);

๐ŸŒ Supported Providers

95%+ market coverage with 7 LLM providers:

ProviderClientModelsFeatures
OpenAITealOpenAIGPT-4, GPT-3.5 TurboChat, Completions, Embeddings
AnthropicTealAnthropicClaude 3, Claude 2Chat, Streaming
GoogleTealGeminiGemini Pro, UltraMultimodal, Safety Settings
AWSTealBedrockClaude, Titan, Jurassic, Command, LlamaMulti-model, Regional
AzureTealAzureOpenAIGPT-4, GPT-3.5Deployment-based, Azure AD
MistralTealMistralLarge, Medium, Small, MixtralEU Data Residency, GDPR
CohereTealCohereCommand, EmbedRAG, Citations, Connectors

Multi-Provider Orchestration

import { TealMultiProvider, TealOpenAI, TealAnthropic } from 'tealtiger';

const multiProvider = new TealMultiProvider({
  strategy: 'priority',      // or 'round-robin', 'cost', 'use-case'
  enableFailover: true,
  maxFailoverAttempts: 3
});

multiProvider.registerProvider({
  type: 'openai',
  name: 'openai-primary',
  client: new TealOpenAI({ apiKey: 'key' }),
  priority: 1
});

multiProvider.registerProvider({
  type: 'anthropic',
  name: 'anthropic-backup',
  client: new TealAnthropic({ apiKey: 'key' }),
  priority: 2
});

// Automatic failover if primary fails
const response = await multiProvider.chat({
  messages: [{ role: 'user', content: 'Hello' }]
});

๐Ÿ›ก๏ธ Key Features

TealEngine โ€” Policy Evaluation

Deterministic policy evaluation with multi-mode enforcement:

import { TealEngine, PolicyMode, DecisionAction, ReasonCode } from 'tealtiger';

const engine = new TealEngine({
  policies: myPolicies,
  mode: {
    defaultMode: PolicyMode.ENFORCE,       // or MONITOR, REPORT_ONLY
    policyModes: {
      'tools.file_delete': PolicyMode.ENFORCE,
      'identity.admin_access': PolicyMode.ENFORCE
    }
  }
});

const decision = engine.evaluate({
  agentId: 'agent-001',
  action: 'tool.execute',
  tool: 'file_delete',
  correlation_id: 'req-12345'
});

switch (decision.action) {
  case DecisionAction.ALLOW:
    await executeTool();
    break;
  case DecisionAction.DENY:
    if (decision.reason_codes.includes(ReasonCode.TOOL_NOT_ALLOWED)) {
      throw new ToolNotAllowedError(decision.reason);
    }
    break;
  case DecisionAction.REQUIRE_APPROVAL:
    await requestApproval(decision);
    break;
}

// Risk-based routing
if (decision.risk_score > 80) {
  await escalateToHuman(decision);
}

Decision fields: action (ALLOW, DENY, REDACT, TRANSFORM, REQUIRE_APPROVAL, DEGRADE), reason_codes (standardized enums), risk_score (0-100), correlation_id, metadata

TealGuard โ€” Security Guardrails

Client-side guardrails that run in milliseconds with no server dependency:

import { GuardrailEngine, PIIDetectionGuardrail, PromptInjectionGuardrail, ContentModerationGuardrail } from 'tealtiger';

const engine = new GuardrailEngine({ mode: 'parallel', timeout: 5000 });

engine.registerGuardrail(new PIIDetectionGuardrail({ action: 'redact' }));
engine.registerGuardrail(new PromptInjectionGuardrail({ sensitivity: 'high' }));
engine.registerGuardrail(new ContentModerationGuardrail({ threshold: 0.7 }));

const result = await engine.execute(userInput);
console.log('Passed:', result.passed);
console.log('Risk Score:', result.riskScore);

Detects: PII (emails, phones, SSNs, credit cards), prompt injection, jailbreaks, harmful content, custom patterns.

TealCircuit โ€” Circuit Breaker

Cascading failure prevention with automatic failover:

import { TealCircuit } from 'tealtiger';

const circuit = new TealCircuit({
  failureThreshold: 5,
  resetTimeout: 30000,
  monitorInterval: 10000
});

// Wraps provider calls with circuit breaker protection
const response = await circuit.execute(() =>
  client.chat.completions.create({ model: 'gpt-4', messages })
);

TealAudit โ€” Audit Logging & Redaction

Versioned audit events with security-by-default PII redaction:

import { TealAudit, RedactionLevel } from 'tealtiger';

const audit = new TealAudit({
  outputs: [new FileOutput('./audit.log')],
  config: {
    input_redaction: RedactionLevel.HASH,    // SHA-256 hash + size (default)
    output_redaction: RedactionLevel.HASH,
    detect_pii: true,
    debug_mode: false
  }
});

Redaction levels: HASH (default, production-safe), SIZE_ONLY, CATEGORY_ONLY, FULL, NONE (debug only).

Correlation IDs & Traceability

End-to-end request tracking across all components:

import { ContextManager } from 'tealtiger';

const context = ContextManager.createContext({
  tenant_id: 'acme-corp',
  app: 'customer-support',
  env: 'production'
});

// Context propagates through TealEngine, TealAudit, and all providers
const response = await client.chat.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello' }],
  context: context
});

// Query audit logs by correlation_id
const events = audit.query({ correlation_id: context.correlation_id });

Features: Auto-generated UUID v4 correlation IDs, OpenTelemetry-compatible trace IDs, HTTP header propagation, multi-tenant support.

Policy Test Harness

Validate policy behavior before production deployment:

import { PolicyTester, TestCorpora } from 'tealtiger';

const tester = new PolicyTester(engine);
const report = tester.runSuite({
  name: 'Customer Support Policy Tests',
  tests: [
    {
      name: 'Block file deletion',
      context: { agentId: 'support-001', action: 'tool.execute', tool: 'file_delete' },
      expected: { action: DecisionAction.DENY, reason_codes: [ReasonCode.TOOL_NOT_ALLOWED] }
    },
    ...TestCorpora.promptInjection(),
    ...TestCorpora.piiDetection()
  ]
});

console.log(`Tests: ${report.passed}/${report.total} passed`);

// Export for CI/CD
const junitXml = tester.exportReport(report, 'junit');
# CLI usage
npx tealtiger test ./policies/*.test.json --coverage --format=junit --output=./results.xml

Cost Tracking & Budget Management

Track costs across 50+ models and enforce spending limits:

import { CostTracker, BudgetManager, InMemoryCostStorage } from 'tealtiger';

const storage = new InMemoryCostStorage();
const tracker = new CostTracker({ enabled: true });
const budgetManager = new BudgetManager(storage);

budgetManager.createBudget({
  name: 'Daily GPT-4 Budget',
  limit: 10.0,
  period: 'daily',
  alertThresholds: [50, 75, 90, 100],
  action: 'block',
  enabled: true
});

// Estimate before request
const estimate = tracker.estimateCost('gpt-4', { inputTokens: 1000, outputTokens: 500 }, 'openai');

// Check budget
const check = await budgetManager.checkBudget('agent-123', estimate);
if (!check.allowed) {
  console.log(`Blocked by: ${check.blockedBy?.name}`);
}

๐Ÿ›ก๏ธ OWASP Top 10 for Agentic Applications Coverage

TealTiger v1.2.0 covers 7 out of 10 OWASP ASIs through its SDK-only architecture:

ASIVulnerabilityCoverageComponents
ASI01Goal Hijacking & Prompt Injection๐ŸŸก PartialTealGuard, TealEngine
ASI02Tool Misuse & Unauthorized Actions๐ŸŸข FullTealEngine
ASI03Identity & Access Control Failures๐ŸŸข FullTealEngine
ASI04Supply Chain Vulnerabilities๐Ÿ”ง SupportTealAudit
ASI05Unsafe Code Execution๐ŸŸข FullTealEngine
ASI06Memory & Context Corruption๐ŸŸข FullTealEngine, TealGuard
ASI07Inter-Agent Communication SecurityโŒ PlatformN/A
ASI08Cascading Failures & Resource Exhaustion๐ŸŸข FullTealCircuit
ASI09Harmful Content Generation๐Ÿ”ง SupportTealGuard
ASI10Rogue Agent Behavior๐ŸŸข FullTealAudit

๐Ÿ“– Complete OWASP ASI Mapping | OWASP Top 10 for Agentic Applications

๐ŸŽฏ Use Cases

  • Customer Support Bots โ€” Protect customer PII
  • Healthcare AI โ€” HIPAA compliance
  • Financial Services โ€” Prevent data leakage
  • E-commerce โ€” Secure payment information
  • Enterprise AI โ€” Policy enforcement and audit trails
  • Education Platforms โ€” Content safety

๐Ÿ“š Documentation

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide.

๐Ÿ“„ License

Apache 2.0 โ€” see LICENSE


Made with โค๏ธ by the TealTiger team