avantgate 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +41 -41
  2. package/dist/index.mjs +3 -3
  3. package/package.json +13 -13
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # 🛡️ AvantGate (`avantgate`)
2
2
 
3
- > **The Zero-Infrastructure, In-Process LLM Control Plane for TypeScript.**
4
- > Real-time cost control, token budgets, PII redaction, prompt guardrails, and multi-model failover **without hosting Docker, PostgreSQL, ClickHouse, or Redis.**
3
+ > **The Zero-Infrastructure, In-Process AI Application Firewall (AI-WAF) & Privacy Guard for TypeScript.**
4
+ > Real-time prompt guardrails, zero-egress PII redaction, anti-IDOR tool boundary, and pre-flight token defense **without hosting Docker, proxies, PostgreSQL, ClickHouse, or Redis.**
5
5
 
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-Strict-blue?logo=typescript)](https://www.typescriptlang.org/)
@@ -10,25 +10,25 @@
10
10
 
11
11
  ---
12
12
 
13
- ## ⚡ Why AvantGate? (The Problem with Heavy Observability)
13
+ ## ⚡ Why AvantGate? (Active Defense vs. Passive Proxies)
14
14
 
15
- Traditional LLM observability stacks like **Langfuse**, **Helicone**, or **LangSmith** are great, but for 90% of production apps, self-hosting them is a nightmare:
16
- - ❌ **Heavy Infrastructure**: Requires spinning up Next.js + PostgreSQL + ClickHouse + Redis + S3.
17
- - ❌ **VPS & Cloud Costs**: $30 to $100+/month just to monitor API calls.
18
- - ❌ **Passive / Post-Mortem**: They log errors and costs *after* you have already paid for the wasted tokens.
19
- - ❌ **Egress Latency & Privacy**: Sends user prompts over external HTTP networks.
15
+ Most LLM security and observability solutions force you into an unacceptable trade-off:
16
+ - ❌ **Data Egress & Privacy Hazards**: Cloud AI proxies (Helicone, Portkey) require routing your raw prompts through external third-party servers, creating compliance headaches and data leakage risks.
17
+ - ❌ **Network Latency Tax**: External proxies inject **+50ms to 250ms of network overhead** on every single LLM call.
18
+ - ❌ **Passive & Post-Mortem**: Traditional observability platforms (Langfuse, LangSmith) log token leaks and PII exposure *after* the damage is done and the money is spent.
19
+ - ❌ **Heavy Infrastructure**: Self-hosting requires spinning up Next.js + PostgreSQL + ClickHouse + Redis + S3 just to inspect prompt traffic.
20
20
 
21
- ### 🛡️ The AvantGate Philosophy: Active In-Process Control
22
- **AvantGate runs entirely inside your existing application process.** No external containers, no database required, no network latency.
21
+ ### 🛡️ The AvantGate Philosophy: In-Process Security Boundary
22
+ **AvantGate runs entirely inside your existing application process.** No external proxy, no raw prompts leaving your perimeter unredacted, and 0 ms network latency.
23
23
 
24
24
  ```mermaid
25
25
  flowchart LR
26
- App[Your Application] --> InputGuard[🛡️ Input & PII Guard]
27
- InputGuard --> TokenBudget[💰 Token Budget Guard]
28
- TokenBudget --> FallbackRouter[🔀 Fallback Router]
29
- FallbackRouter --> Providers["LLM Providers (DeepSeek / Mistral / Ollama)"]
30
- Providers --> JSONRepair[🔧 Zod JSON Self-Repair]
31
- JSONRepair --> Audit[📊 Local Cost Ledger & Telemetry]
26
+ App[Your Application / Agent] --> InputGuard[🛡️ Ingress Guard<br/>Prompt Injection & Jailbreaks]
27
+ InputGuard --> PIIShield[🔒 In-Flight PII Redactor<br/>EU NIR, SPI, IBAN, Emails]
28
+ PIIShield --> TokenBudget[💰 Denial-of-Wallet Guard<br/>Pre-Flight Budget Bounds]
29
+ TokenBudget --> Providers["External LLM Providers<br/>(DeepSeek / Mistral / OpenAI)"]
30
+ Providers --> ToolBoundary[🛑 Tool Boundary & Anti-IDOR<br/>Dual-Channel DTO + Cycle Shield]
31
+ ToolBoundary --> SafeOutput[✅ Safe, Sanitized Execution]
32
32
  ```
33
33
 
34
34
  ---
@@ -43,34 +43,34 @@ Available as a **Managed Cloud Control Plane** or an **Out-of-Process High-Avail
43
43
 
44
44
  ---
45
45
 
46
- ## 🚀 Key Features
46
+ ## 🚀 Key Security & Defense Features
47
47
 
48
- - 💰 **Pre-Flight Token Budgeting**: Rejects or truncates requests exceeding budget *before* invoking external APIs.
49
- - 🏷️ **Real-Time Cost Ledger**: Exact cent-level cost tracking calculated instantly across models (DeepSeek, Mistral, OpenAI, Anthropic, OpenRouter, and $0 local Ollama).
50
- - 🛡️ **Active Security & PII Redaction**: In-flight masking of emails, phone numbers, and French/EU identifiers before sending to cloud providers. Blocks prompt injection & jailbreaks.
51
- - 🔀 **Zero-Downtime Multi-Model Failover**: If DeepSeek or Mistral returns HTTP 429/500, seamlessly failover to a backup provider (or local Ollama) in milliseconds.
52
- - 🔧 **Self-Repairing Structured Outputs**: Strict Zod runtime validation with automated markdown/JSON repair if the LLM hallucinates formatting.
53
- - 🤖 **Durable Agent Harness & PII Shield (`avantgate/agent`)**: Serverless memoized step execution (`step.run()`), native Human-in-the-Loop approval (`step.waitForApproval()`), and Dual-Channel tool data isolation without Temporal or Redis.
54
- - 📡 **Zero-Dependency Telemetry Bridge (`HttpTelemetryExporter`, `PlatformStorageAdapter`)**: Mirror in-process executions and hierarchical tool traces asynchronously to any HTTP sink or observability endpoint with $0 external npm dependencies.
55
- - 📦 **100% Framework Agnostic**: Works in Next.js, Express, Fastify, NestJS, Cloudflare Workers, AWS Lambda, or CLI scripts.
48
+ - 🛡️ **Active Threat Defense & Prompt Guardrails**: Blocks prompt injections, DAN jailbreaks, adversarial noise, and system prompt exfiltration *before* external API invocation.
49
+ - 🔒 **Zero-Egress Data Loss Prevention (DLP)**: Automated local redaction of emails, phone numbers, IBAN/BIC, and French/EU identifiers (NIR SSN, SPI tax ID) before network egress.
50
+ - 🎭 **Dual-Channel Tool Isolation (`avantgate/agent`)**: Decouples sensitive database records (streamed out-of-band directly to client UIs) from minimal cognitive LLM context (`llmDto`), keeping confidential fields out of context windows.
51
+ - 🛑 **Anti-IDOR & Access Governance**: Enforces Row-Level Security (`dataAccessGuard`), business domain partitioning, and granular role-based permissions at the agent tool boundary.
52
+ - 💰 **Denial-of-Wallet & Pre-Flight Budgeting**: Enforces strict token and cent-level USD budget limits, rejecting abusive requests before paying for upstream inference.
53
+ - 🔀 **Zero-Downtime Multi-Model Failover**: Seamless client-side failover to fallback providers (or local zero-cost Ollama) when upstream APIs return HTTP 429/500 errors.
54
+ - 🔧 **Self-Repairing Structured Outputs**: Strict Zod schema compliance with automated heuristic markdown/JSON repair if the model hallucinates formatting.
55
+ - 📡 **Zero-Dependency Telemetry Bridge (`HttpTelemetryExporter`, `PlatformStorageAdapter`)**: Mirror execution audits and hierarchical tool traces asynchronously without adding heavy external dependencies.
56
+ - 📦 **100% Framework Agnostic**: Works seamlessly in Next.js, Express, Fastify, NestJS, Cloudflare Workers, AWS Lambda, or CLI scripts.
56
57
 
57
58
  ---
58
59
 
59
- ## 📊 Comparison: Langfuse vs. AvantGate
60
-
61
- | Capability | Langfuse (Self-Hosted) | AvantGate (`avantgate`) |
62
- |---|:---:|:---:|
63
- | **Infrastructure Required** | Docker + Postgres + ClickHouse + Redis | **Zero Infrastructure** (Pure npm package) |
64
- | **Hosting Cost** | $30 - $100 / month | **$0 / month** (Runs inside your app) |
65
- | **Token Budget Enforcement** | ❌ Passive logging only | ✅ **Active Pre-Flight Guard** (Blocks before spending) |
66
- | **In-Flight PII Redaction** | ❌ Logs all raw data | ✅ **Automatic local masking** before API dispatch |
67
- | **Multi-Provider Failover** | ❌ No | ✅ **Built-in Fallback Router & Exponential Retry** |
68
- | **Zod Schema Auto-Repair** | ❌ No | ✅ **Built-in JSON Heuristic Repair** |
69
- | **Durable Workflow & HITL** | Requires Temporal / Inngest | ✅ **Built-in In-Process Step Runner & HITL** |
70
- | **Tool PII & Dual-Channel** | ❌ No | ✅ **Built-in `createIsolatedTool`** |
71
- | **Telemetry Network Latency** | ❌ +50ms - 200ms per trace call | ✅ **0 ms** (In-process memory accounting) |
72
- | **Central Web Dashboard** | Heavy self-hosted web app | ✅ **Optional Remote Sink** (Plug any HTTP endpoint via `PlatformStorageAdapter`) |
73
- | **Hierarchical Session Replay** | ❌ Flat span waterfall | ✅ **Causality Tree + Dual-Channel Isolation** |
60
+ ## 📊 Comparison: Direct LLM vs. Cloud AI Proxy vs. AvantGate
61
+
62
+ | Capability & Security Boundary | Direct LLM Calls | Cloud AI Proxy (Helicone / Portkey) | 🛡️ **AvantGate (`avantgate`)** |
63
+ |---|:---:|:---:|:---:|
64
+ | **Security Architecture** | None (Direct HTTP) | External Cloud Proxy | **In-Process Security Boundary** |
65
+ | **Data Privacy & DLP** | ❌ Raw PII leaves perimeter | ⚠️ Unencrypted prompts transit proxy | ✅ **Sanitized in-flight locally (Zero Egress)** |
66
+ | **Network Latency Overhead** | 0 ms | ❌ +50ms - 250ms (Extra hop) | ✅ **0 ms (In-process execution)** |
67
+ | **Prompt Injection Defense** | ❌ None | ⚠️ Passive detection | ✅ **Active Pre-Flight Guard (Blocks before spend)** |
68
+ | **Agent Tool Data Isolation** | ❌ Entire DB entity in LLM | ❌ No agent tool awareness | ✅ **Dual-Channel DTO (`clientDto` vs `llmDto`)** |
69
+ | **Row-Level Security & Anti-IDOR** | ❌ Manual code | ❌ Not supported | ✅ **Native `dataAccessGuard` & Domain Boundary** |
70
+ | **Infrastructure Overhead** | None | SaaS Subscription | ✅ **$0 / Zero Servers (Pure npm package)** |
71
+ | **Multi-Model Failover** | ❌ App crashes | ⚠️ Proxy-dependent | ✅ **Built-in Fallback Router & Exponential Retry** |
72
+ | **Zod Schema Auto-Repair** | ❌ No | ❌ No | ✅ **Built-in JSON Heuristic Repair** |
73
+ | **Hierarchical Session Replay** | ❌ None | ⚠️ Flat span waterfall | ✅ **Causality Tree + Dual-Channel Isolation** |
74
74
 
75
75
  ---
76
76
 
@@ -100,7 +100,7 @@ Comprehensive guides, copy-pasteable integration recipes, and architectural refe
100
100
 
101
101
  | Guide | Description |
102
102
  |---|---|
103
- | **[Code Examples & Recipes](docs/examples.md)** | Full walkthroughs for cost tracking, Zod self-repair, multi-model failover, PII masking, pre-flight budgets, and the prompt engine. |
103
+ | **[Code Examples & Recipes](docs/examples.md)** | End-to-end security guardrails, PII redaction, anti-IDOR tool boundaries, cost tracking, Zod self-repair, and multi-model failover. |
104
104
  | **[Decoupled Pricing & DB Adapters](docs/pricing.md)** | Dynamic token pricing, database integration (Prisma / PostgreSQL / Drizzle), in-memory TTL caching, and runtime overrides. |
105
105
  | **[Durable Agent Harness & Tool Isolation](docs/agent.md)** | Serverless durable step execution, Human-in-the-Loop suspension, dual-channel DTO tool isolation, and telemetry streaming. |
106
106
 
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
+ import {
2
+ sanitizePII
3
+ } from "./chunk-DVCF4CSV.mjs";
1
4
  import {
2
5
  extractAndCleanJSON,
3
6
  validateWithZod
4
7
  } from "./chunk-CO26LNFD.mjs";
5
- import {
6
- sanitizePII
7
- } from "./chunk-DVCF4CSV.mjs";
8
8
 
9
9
  // src/types.ts
10
10
  var ConfigurationError = class extends Error {
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "avantgate",
3
- "version": "1.2.1",
4
- "description": "Zero-infrastructure, in-process LLM control plane & SaaS observability bridge: real-time cost control, token budgets, PII redaction, prompt guardrails, multi-model failover, durable agent workflow harness, and HTTP telemetry without hosting heavy servers.",
3
+ "version": "1.2.2",
4
+ "description": "Zero-infrastructure, in-process AI Application Firewall (AI-WAF) & privacy control plane for TypeScript: real-time prompt guardrails, zero-egress PII redaction, agent tool isolation, anti-IDOR defense, pre-flight token budgets, and multi-model failover.",
5
5
  "author": "Antigravity & LexTalk Team",
6
6
  "license": "MIT",
7
7
  "keywords": [
8
8
  "avantgate",
9
+ "ai-waf",
10
+ "guardrails",
11
+ "prompt-injection",
12
+ "pii-redaction",
13
+ "data-privacy",
14
+ "cybersecurity",
9
15
  "llm",
10
16
  "ai",
11
17
  "agent",
18
+ "dual-channel",
19
+ "token-budget",
20
+ "cost-control",
21
+ "durable-execution",
22
+ "human-in-the-loop",
12
23
  "observability",
13
24
  "telemetry",
14
25
  "session-replay",
15
26
  "helicone-alternative",
16
- "agentops-alternative",
17
- "durable-execution",
18
- "human-in-the-loop",
19
- "dual-channel",
20
- "cost-control",
21
- "token-budget",
22
- "guardrails",
23
- "langfuse-alternative",
24
27
  "failover",
25
- "pii-redaction",
26
28
  "finance",
27
29
  "accounting",
28
- "prompt-builder",
29
- "prompt-template",
30
30
  "deepseek",
31
31
  "mistral",
32
32
  "openai",