@allow-ai/sdk
v0.1.0
Published
ALLOW SDK for TypeScript — network-layer interception for AI agent authorization
Downloads
492
Maintainers
Readme
@allow-ai/sdk
Network-layer and framework-layer authorization SDK for AI agents. ALLOW intercepts outbound HTTP requests and tool calls, evaluating them against OPA/Rego policies before execution. Blocked actions are denied at the network and framework layers, ensuring agents can only perform authorized operations.
Prefer
@visiq/sdk-- the unified VisIQ SDK bundles both ALLOW (authorization) and RECALL (context firewall) into a single package with one wrapper function. Install@visiq/sdkunless you specifically need ALLOW standalone.
Installation
npm install @allow-ai/sdkRequires Node.js >= 20.
Quick Start
Network-Layer Interception
Patches globalThis.fetch and Node.js http/https modules to intercept all outbound requests and evaluate them against ALLOW policies.
import { init, cleanup } from '@allow-ai/sdk';
// Initialize network-layer interception
await init({
apiKey: process.env.ALLOW_API_KEY!,
agentId: 'my-agent',
});
// All outbound HTTP requests are now evaluated against ALLOW policies.
// Unauthorized requests are blocked before they reach the network.
// When finished, remove patches and flush telemetry
cleanup();Framework-Layer Wrapping
Wraps AI framework tool objects to enforce policies at the tool-call interface, before execution begins.
import { withAllow } from '@allow-ai/sdk';
// Wrap a LangChain tool
const tool = withAllow(new SearchTool(), {
agentId: 'research-bot',
});
// Wrap a LlamaIndex tool
const llamaTool = withAllow(new QueryEngineTool(), {
agentId: 'research-bot',
});Configuration
init(options) -- Network-Layer
| Option | Type | Required | Default | Description |
|--------|------|----------|---------|-------------|
| apiKey | string | Yes | -- | ALLOW API key |
| agentId | string | Yes | -- | Unique agent identifier |
| endpoint | string | No | Production URL | ALLOW backend endpoint |
| mode | 'enforce' \| 'audit' \| 'off' | No | 'enforce' | Enforcement mode |
| timeoutMs | number | No | 5000 | Request timeout in ms |
| failBehavior | 'closed' \| 'open' | No | 'closed' | Behavior on evaluation failure |
| passthroughHosts | string[] | No | [] | Hosts to skip evaluation |
| enableLocalEval | boolean | No | true | Enable client-side rule evaluation |
| syncIntervalMs | number | No | 30000 | Bundle sync interval in ms |
withAllow(target, options) -- Framework-Layer
| Option | Type | Required | Default | Description |
|--------|------|----------|---------|-------------|
| agentId | string | Yes | -- | Unique agent identifier |
| apiKey | string | No | ALLOW_API_KEY env var | ALLOW API key |
| endpoint | string | No | ALLOW_ENDPOINT env var | ALLOW backend endpoint |
| mode | 'enforce' \| 'audit' \| 'off' | No | 'enforce' | Enforcement mode |
Supported Frameworks
| Framework | Tool Detection | Adapter |
|-----------|---------------|---------|
| LangChain | _call() + name | LangChainAllowTool |
| LlamaIndex | call() + metadata | LlamaIndexAllowTool |
| Semantic Kernel | functionInvocationFilters | AllowKernelFilter |
| Generic | execute() or run() | Proxy wrapper |
Exports
// Primary API
import { init, cleanup, withAllow } from '@allow-ai/sdk';
// Advanced: OPA engine, client, config
import { AllowEngine, AllowClient, resolveConfig, RuleEngine } from '@allow-ai/sdk';
// Advanced: request inspection
import { shouldIntercept, extractRequestInfo } from '@allow-ai/sdk';
// Advanced: framework detection
import { detectToolFramework, isAllowWrapped, ALLOW_WRAPPED } from '@allow-ai/sdk';
// Adapter classes (for direct use without auto-detection)
import {
LangChainAllowTool,
LlamaIndexAllowTool,
installAllowFilter,
wrapToolWithProxy,
} from '@allow-ai/sdk';Environment Variables
| Variable | Description |
|----------|-------------|
| ALLOW_API_KEY | API key (fallback when not passed programmatically) |
| ALLOW_ENDPOINT | Backend endpoint URL |
| ALLOW_MODE | Enforcement mode (enforce, audit, off) |
License
MIT
