@salimassili/ai-costguard 1.1.5 → 1.1.7
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.
- package/README.md +36 -100
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,112 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @salimassili/ai-costguard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## The 3 Problems We Solve
|
|
8
|
-
|
|
9
|
-
1. **Runaway agent loops** → Infinite recursive calls draining budget
|
|
10
|
-
2. **Uncontrolled API spending** → No visibility into per-request costs
|
|
11
|
-
3. **Production LLM cost spikes** → Sudden $10K+ surprises at month-end
|
|
12
|
-
|
|
13
|
-
## Try It (No Install Required)
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Run interactive demo
|
|
17
|
-
npx ai-firewall demo
|
|
18
|
-
|
|
19
|
-
# Or try the web demo
|
|
20
|
-
open https://ai-firewall.io/demo
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
See live simulations of cost explosions—and how much you save by blocking them.
|
|
24
|
-
|
|
25
|
-
## Integration Example
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import OpenAI from 'openai';
|
|
29
|
-
import { initFirewall, withFirewall } from 'ai-firewall';
|
|
30
|
-
|
|
31
|
-
const firewall = initFirewall({ apiKey: process.env.FIREWALL_API_KEY! });
|
|
32
|
-
const openai = withFirewall(new OpenAI({ apiKey: process.env.OPENAI_API_KEY! }));
|
|
33
|
-
|
|
34
|
-
const decision = firewall.evaluate({
|
|
35
|
-
model: 'gpt-4o-mini',
|
|
36
|
-
prompt: 'Summarize these tickets',
|
|
37
|
-
maxOutputTokens: 240,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (decision.decision !== 'block') {
|
|
41
|
-
await openai.chat.completions.create({
|
|
42
|
-
model: 'gpt-4o-mini',
|
|
43
|
-
messages: [{ role: 'user', content: 'Summarize these tickets' }],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Enterprise Trust Features
|
|
49
|
-
|
|
50
|
-
**Audit & Compliance:**
|
|
51
|
-
- Every decision logged with cryptographic integrity
|
|
52
|
-
- Hash-chained audit trail (tamper-evident)
|
|
53
|
-
- Replay any execution for debugging
|
|
54
|
-
- Compliance certificates for audits
|
|
55
|
-
|
|
56
|
-
**Production Safety:**
|
|
57
|
-
- Circuit breaker on engine failures
|
|
58
|
-
- Always returns a decision (never crashes execution)
|
|
59
|
-
- Automatic fallback to safe defaults
|
|
60
|
-
- Sub-100ms decision latency guaranteed
|
|
61
|
-
|
|
62
|
-
**Deterministic Replay:**
|
|
63
|
-
```ts
|
|
64
|
-
import { replaySession, generateComplianceReport } from 'ai-firewall';
|
|
65
|
-
|
|
66
|
-
// Replay any past decision
|
|
67
|
-
const result = replaySession('session-123');
|
|
68
|
-
console.log(result.summary); // "All 50 decisions replayed identically"
|
|
69
|
-
|
|
70
|
-
// Generate compliance certificate
|
|
71
|
-
const report = generateComplianceReport('session-123');
|
|
72
|
-
console.log(report.certificate); // Tamper-evident proof
|
|
73
|
-
```
|
|
7
|
+
---
|
|
74
8
|
|
|
75
|
-
##
|
|
9
|
+
## ⚡ What it does
|
|
76
10
|
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
import { quickDemo, generateViralPayload } from 'ai-firewall';
|
|
11
|
+
AI execution firewall for cost control and runtime protection.
|
|
80
12
|
|
|
81
|
-
|
|
82
|
-
const { session, link } = quickDemo('Runaway Chatbot');
|
|
83
|
-
console.log(link.url); // https://ai-firewall.io/demo/abc123
|
|
13
|
+
---
|
|
84
14
|
|
|
85
|
-
|
|
86
|
-
const payload = generateViralPayload(session);
|
|
87
|
-
console.log(payload.tweet); // Copy-paste ready
|
|
88
|
-
```
|
|
15
|
+
## 📦 Install
|
|
89
16
|
|
|
90
|
-
**Hosted Demo Server:**
|
|
91
17
|
```bash
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
18
|
+
npm install @salimassili/ai-costguard
|
|
19
|
+
🚀 Quick Start
|
|
20
|
+
import * as ai from "@salimassili/ai-costguard";
|
|
21
|
+
|
|
22
|
+
console.log(ai);
|
|
23
|
+
🧠 Real usage
|
|
24
|
+
Middleware usage
|
|
25
|
+
// example placeholder
|
|
26
|
+
// const protectedAI = ai.withFirewall(model);
|
|
27
|
+
CLI usage
|
|
28
|
+
npx ai-costguard
|
|
29
|
+
Production example
|
|
30
|
+
// server.ts
|
|
31
|
+
// ai protection layer in backend
|
|
32
|
+
📚 API Reference
|
|
33
|
+
Exports
|
|
34
|
+
ExecutionGuard
|
|
35
|
+
CostEstimator
|
|
36
|
+
PolicyEngine
|
|
37
|
+
withFirewall
|
|
100
38
|
|
|
101
|
-
|
|
102
|
-
❌ Model evaluation framework
|
|
103
|
-
❌ Generic "AI guardrails" tool
|
|
104
|
-
❌ Multi-cloud abstraction layer
|
|
39
|
+
---
|
|
105
40
|
|
|
106
|
-
|
|
107
|
-
✅ **Only production API spending control**
|
|
108
|
-
✅ **Only runaway agent detection**
|
|
41
|
+
# 🌍 STEP 2 — Add README to git
|
|
109
42
|
|
|
110
|
-
|
|
43
|
+
Save file, then run:
|
|
111
44
|
|
|
112
|
-
|
|
45
|
+
```bash
|
|
46
|
+
git add README.md
|
|
47
|
+
git commit -m "docs: improve README for production readiness"
|
|
48
|
+
git push origin main
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salimassili/ai-costguard",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "A pre-execution firewall that stops AI agents from wasting money before any API call is made",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"node": ">=18"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"dist
|
|
15
|
+
"dist",
|
|
16
16
|
"README.md",
|
|
17
|
-
"
|
|
17
|
+
"package.json"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc",
|