@salimassili/ai-costguard 1.1.9 → 1.2.0
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 +143 -174
- package/dist/core/CostGuard.d.ts +4 -10
- package/dist/core/CostGuard.d.ts.map +1 -1
- package/dist/core/CostGuard.js +2 -10
- package/dist/core/CostGuard.js.map +1 -1
- package/dist/core/GuardCore.d.ts +1 -4
- package/dist/core/GuardCore.d.ts.map +1 -1
- package/dist/core/GuardCore.js +7 -16
- package/dist/core/GuardCore.js.map +1 -1
- package/dist/core/GuardFree.d.ts +1 -5
- package/dist/core/GuardFree.d.ts.map +1 -1
- package/dist/core/GuardFree.js +6 -16
- package/dist/core/GuardFree.js.map +1 -1
- package/dist/core/GuardPro.d.ts +23 -105
- package/dist/core/GuardPro.d.ts.map +1 -1
- package/dist/core/GuardPro.js +147 -248
- package/dist/core/GuardPro.js.map +1 -1
- package/dist/index.d.ts +4 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -13
- package/dist/index.js.map +1 -1
- package/dist/pricing/index.d.ts +11 -0
- package/dist/pricing/index.d.ts.map +1 -0
- package/dist/pricing/index.js +103 -0
- package/dist/pricing/index.js.map +1 -0
- package/package.json +12 -12
- package/dist/core/AgentFailureKernel.d.ts +0 -52
- package/dist/core/AgentFailureKernel.d.ts.map +0 -1
- package/dist/core/AgentFailureKernel.js +0 -357
- package/dist/core/AgentFailureKernel.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,233 +1,202 @@
|
|
|
1
|
-
# AI CostGuard
|
|
1
|
+
# AI CostGuard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AI CostGuard is a small TypeScript library that wraps OpenAI-like clients and blocks requests before they run when local safety checks predict unsafe AI API spend.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
It is ESM-only, targets Node.js 18+, and is built with `tsc`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## What Works Today
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- `guard()` wraps a client with budget, loop, and retry protection.
|
|
10
|
+
- `GuardError` is thrown when a request is blocked.
|
|
11
|
+
- Budget blocking estimates request cost before the API call.
|
|
12
|
+
- Loop detection blocks repeated prompts within the current process.
|
|
13
|
+
- Retry detection blocks repeated failure/retry prompts within the current process.
|
|
14
|
+
- `middleware()` adds the same local checks to web request flows.
|
|
15
|
+
- `getPricing()` returns known built-in model pricing.
|
|
16
|
+
- `registerPricing()` and `listPricing()` let you manage runtime pricing entries.
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
## Install
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
**Emergency brake for AI agents.**
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 🟦 FREE VERSION - SMOKE DETECTOR
|
|
20
|
+
```bash
|
|
21
|
+
npm install @salimassili/ai-costguard
|
|
22
|
+
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
## Basic Usage
|
|
24
25
|
|
|
25
26
|
```ts
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
import OpenAI from 'openai';
|
|
28
|
+
import { guard, GuardError } from '@salimassili/ai-costguard';
|
|
29
|
+
|
|
30
|
+
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
31
|
+
const ai = guard(client, { budget: 1 });
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const response = await ai.chat.completions.create({
|
|
35
|
+
model: 'gpt-4o-mini',
|
|
36
|
+
messages: [{ role: 'user', content: 'Write a short project summary.' }],
|
|
37
|
+
max_tokens: 200
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log(response);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error instanceof GuardError) {
|
|
43
|
+
console.error('AI request blocked:', error.message, error.context);
|
|
44
|
+
} else {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
```
|
|
30
49
|
|
|
31
|
-
|
|
32
|
-
- Hard budget limits
|
|
33
|
-
- Infinite loops (2x repetition)
|
|
34
|
-
- Retry storms (1x failure pattern)
|
|
35
|
-
- Token explosions (20x spikes)
|
|
36
|
-
|
|
37
|
-
**Output:**
|
|
38
|
-
```
|
|
39
|
-
🚨 SMOKE DETECTOR: Infinite loop → saved $18.42
|
|
40
|
-
```
|
|
50
|
+
## How `guard()` Works
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
`guard(client, config)` returns a `Proxy` around your client. When code calls a method such as `client.chat.completions.create(...)`, CostGuard:
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
1. Reads the request model, messages, and `max_tokens`.
|
|
55
|
+
2. Estimates input tokens from message length and combines them with the requested output limit.
|
|
56
|
+
3. Looks up pricing for the model.
|
|
57
|
+
4. Estimates the request cost.
|
|
58
|
+
5. Blocks the call with `GuardError` if the local budget would be exceeded.
|
|
59
|
+
6. Blocks repeated prompts that look like loops.
|
|
60
|
+
7. Blocks repeated prompts that look like retry storms.
|
|
61
|
+
8. Lets the original client method run when checks pass.
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
The free guard state is process-local. Separate Node.js processes do not share budget state.
|
|
47
64
|
|
|
48
|
-
|
|
65
|
+
## Budget Blocking
|
|
49
66
|
|
|
50
67
|
```ts
|
|
51
|
-
import {
|
|
68
|
+
import { guard } from '@salimassili/ai-costguard';
|
|
52
69
|
|
|
53
|
-
const
|
|
54
|
-
slack: { webhook: "webhook_url", channel: "#alerts" }
|
|
55
|
-
});
|
|
70
|
+
const ai = guard(openai, { budget: 0.25 });
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
await ai.chat.completions.create({
|
|
73
|
+
model: 'gpt-4o-mini',
|
|
74
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
75
|
+
max_tokens: 100
|
|
60
76
|
});
|
|
61
|
-
|
|
62
|
-
breaker.panicShutdown("production"); // Panic button
|
|
63
77
|
```
|
|
64
78
|
|
|
65
|
-
|
|
66
|
-
- Hard global budget limits (cross-instance)
|
|
67
|
-
- Instant emergency shutdown
|
|
68
|
-
- Global usage caps
|
|
69
|
-
- Real-time spend tracking
|
|
70
|
-
- Slack/Discord panic alerts
|
|
71
|
-
- Distributed coordination (2-second sync)
|
|
72
|
-
- Simple policy rules
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## 💥 TERRIFYING DEMO
|
|
77
|
-
|
|
78
|
-
**Scenario:** AI agent processing user data goes into infinite retry loop.
|
|
79
|
+
When the estimated cumulative spend in the current process would exceed `budget`, CostGuard throws `GuardError` before calling the underlying AI client.
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
## Loop And Retry Detection
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
CostGuard keeps a short in-memory history of recent prompts for the wrapped client:
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
- Loop detection blocks repeated prompt hashes.
|
|
86
|
+
- Retry detection blocks repeated prompts containing retry/failure language such as `retry`, `again`, `repeat`, `error`, `fail`, or `timeout`.
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
These checks are intentionally local and lightweight.
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
npm install @salimassili/ai-costguard
|
|
90
|
-
```
|
|
90
|
+
## Middleware
|
|
91
91
|
|
|
92
|
-
### Development (FREE)
|
|
93
92
|
```ts
|
|
94
|
-
import
|
|
95
|
-
import
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
import express from 'express';
|
|
94
|
+
import { middleware, GuardError } from '@salimassili/ai-costguard';
|
|
95
|
+
|
|
96
|
+
const app = express();
|
|
97
|
+
|
|
98
|
+
app.use(middleware({ budget: 2 }));
|
|
99
|
+
|
|
100
|
+
app.post('/chat', async (req, res, next) => {
|
|
101
|
+
try {
|
|
102
|
+
req.localSafety.check({
|
|
103
|
+
model: 'gpt-4o-mini',
|
|
104
|
+
tokens: 1000,
|
|
105
|
+
estimatedCost: 0.001,
|
|
106
|
+
timestamp: Date.now(),
|
|
107
|
+
prompt: req.body?.prompt ?? ''
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
res.json({ ok: true });
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof GuardError) {
|
|
113
|
+
res.status(402).json({ error: error.message, context: error.context });
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
next(error);
|
|
118
|
+
}
|
|
103
119
|
});
|
|
104
120
|
```
|
|
105
121
|
|
|
106
|
-
|
|
122
|
+
## Pricing
|
|
123
|
+
|
|
107
124
|
```ts
|
|
108
|
-
import {
|
|
125
|
+
import { getPricing, listPricing, registerPricing } from '@salimassili/ai-costguard';
|
|
109
126
|
|
|
110
|
-
|
|
111
|
-
const breaker = getProGuard(process.env.COSTGUARD_LICENSE, {
|
|
112
|
-
slack: { webhook: process.env.SLACK_WEBHOOK, channel: "#ai-alerts" }
|
|
113
|
-
});
|
|
127
|
+
console.log(getPricing('gpt-4o-mini'));
|
|
114
128
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
registerPricing([
|
|
130
|
+
{
|
|
131
|
+
model: 'custom-model',
|
|
132
|
+
inputPer1kTokens: 0.001,
|
|
133
|
+
outputPer1kTokens: 0.002,
|
|
134
|
+
lastUpdated: '2026-05-21',
|
|
135
|
+
source: 'internal'
|
|
136
|
+
}
|
|
137
|
+
]);
|
|
119
138
|
|
|
120
|
-
|
|
139
|
+
console.log(listPricing());
|
|
121
140
|
```
|
|
122
141
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
## 🎯 TARGET USERS
|
|
126
|
-
|
|
127
|
-
- **AI agent startups** - Can't afford $10k mistakes
|
|
128
|
-
- **Founders using OpenAI/Claude in production** - Need sleep at night
|
|
129
|
-
- **Teams running autonomous workflows** - Multiple instances, high risk
|
|
130
|
-
- **Companies spending $1k+/month on AI APIs** - High exposure
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## 💰 ROI
|
|
135
|
-
|
|
136
|
-
**Free:** Saves $100s in development, proves value immediately
|
|
137
|
-
**Paid:** Prevents $5,000-$50,000 production disasters
|
|
138
|
-
|
|
139
|
-
**Question:** Can you afford NOT to have this installed?
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
## 🔧 CORE FEATURES (ONLY 10)
|
|
144
|
-
|
|
145
|
-
1. **Hard global budget limits** - Stop spending instantly
|
|
146
|
-
2. **Instant kill switch** - Emergency shutdown button
|
|
147
|
-
3. **Infinite loop detection** - Stop runaway agents
|
|
148
|
-
4. **Retry storm detection** - Kill retry explosions
|
|
149
|
-
5. **Token explosion detection** - Prevent cost spikes
|
|
150
|
-
6. **Emergency execution shutdown** - Panic button for all instances
|
|
151
|
-
7. **Global usage caps** - Cross-instance coordination
|
|
152
|
-
8. **Slack/Discord panic alerts** - Real-time emergency notifications
|
|
153
|
-
9. **Real-time spend tracking** - Live monitoring
|
|
154
|
-
10. **Simple policy rules** - Configurable thresholds
|
|
142
|
+
`getPricing(model)` returns an exact match when available, then falls back to simple fuzzy matching. Unknown models return `undefined`.
|
|
155
143
|
|
|
156
|
-
|
|
144
|
+
## Pro Features (Coming Soon)
|
|
157
145
|
|
|
158
|
-
|
|
146
|
+
> These features are under active development and not yet available:
|
|
147
|
+
> - Distributed Redis-backed budget state
|
|
148
|
+
> - Real Slack/Discord webhook alerts
|
|
149
|
+
> - Multi-instance coordination
|
|
150
|
+
> - Production license validation
|
|
159
151
|
|
|
160
|
-
|
|
161
|
-
- **Redis-ready** - Distributed state management
|
|
162
|
-
- **Proxy-based** - Zero integration overhead
|
|
163
|
-
- **OpenAI + Anthropic** - Major providers supported
|
|
164
|
-
- **Minimal dependencies** - Lightweight, secure
|
|
165
|
-
- **Serverless-friendly** - Works anywhere
|
|
166
|
-
- **Production-ready** - Battle tested
|
|
152
|
+
## API
|
|
167
153
|
|
|
168
|
-
|
|
154
|
+
### `guard(client, config)`
|
|
169
155
|
|
|
170
|
-
|
|
156
|
+
Wraps an OpenAI-like client.
|
|
171
157
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
❌ No governance systems
|
|
176
|
-
❌ No features nobody pays for
|
|
177
|
-
|
|
178
|
-
**We do ONE thing: Prevent catastrophic AI cost disasters.**
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## 🎯 POSITIONING
|
|
183
|
-
|
|
184
|
-
**"Every production AI system should have this installed."**
|
|
185
|
-
|
|
186
|
-
**This is not a tool. This is insurance.**
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## 💥 MARKETING STORIES
|
|
191
|
-
|
|
192
|
-
### Story 1: The $15,000 Mistake
|
|
193
|
-
"AI agent processing customer feedback entered infinite retry loop. Free version on each server thought everything was fine. Cost exploded to $15,000/hour. Circuit breaker killed all instances in 8 seconds. Company saved $12,000."
|
|
158
|
+
```ts
|
|
159
|
+
guard(client, { budget: 10 });
|
|
160
|
+
```
|
|
194
161
|
|
|
195
|
-
###
|
|
196
|
-
"Background job processing user data got stuck in recursive tool calls. Each server kept retrying independently. Free version didn't coordinate across instances. Paid version detected global pattern and panic shutdown. Saved $3,000."
|
|
162
|
+
### `GuardError`
|
|
197
163
|
|
|
198
|
-
|
|
199
|
-
"Autonomous workflow system went into runaway execution chain. 12 servers burning $4,000/hour each. Circuit breaker detected anomaly across all instances and emergency shutdown. Prevented $50,000 disaster."
|
|
164
|
+
Thrown when CostGuard blocks a request.
|
|
200
165
|
|
|
201
|
-
|
|
166
|
+
```ts
|
|
167
|
+
try {
|
|
168
|
+
await ai.chat.completions.create(params);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
if (error instanceof GuardError) {
|
|
171
|
+
console.log(error.context);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
202
175
|
|
|
203
|
-
|
|
176
|
+
### `middleware(config)`
|
|
204
177
|
|
|
205
|
-
|
|
178
|
+
Creates request middleware with local budget, loop, and retry checks.
|
|
206
179
|
|
|
207
|
-
|
|
208
|
-
✅ **Trust** - Saves companies thousands, proves value instantly
|
|
209
|
-
✅ **Integration** - One-line installation, zero overhead
|
|
210
|
-
✅ **Emergency response** - Panic button works in seconds
|
|
211
|
-
✅ **Distributed coordination** - Handles multi-instance disasters
|
|
180
|
+
### `getPricing(model, overrides?)`
|
|
212
181
|
|
|
213
|
-
|
|
182
|
+
Returns pricing for a model from overrides, runtime registrations, or built-in entries.
|
|
214
183
|
|
|
215
|
-
|
|
184
|
+
### `registerPricing(entries)`
|
|
216
185
|
|
|
217
|
-
|
|
186
|
+
Registers or replaces runtime pricing entries by model name.
|
|
218
187
|
|
|
219
|
-
|
|
220
|
-
2. **Production incidents create urgency** - Real disasters create immediate need
|
|
221
|
-
3. **Paid version becomes unavoidable** - Can't safely run AI in production without it
|
|
222
|
-
4. **Emergency alerts prove value** - Slack notifications save thousands
|
|
223
|
-
5. **Trust creates lock-in** - Reliable circuit breaker becomes infrastructure
|
|
188
|
+
### `listPricing()`
|
|
224
189
|
|
|
225
|
-
|
|
190
|
+
Returns built-in and runtime pricing entries, deduplicated by model name.
|
|
226
191
|
|
|
227
|
-
##
|
|
192
|
+
## Limitations
|
|
228
193
|
|
|
229
|
-
|
|
194
|
+
- Free guard state is stored in memory only.
|
|
195
|
+
- Budget checks are estimates, not billing records.
|
|
196
|
+
- Token estimation is approximate.
|
|
197
|
+
- Pricing entries are static until the package or runtime registry is updated.
|
|
198
|
+
- The library does not include dashboards, analytics, governance workflows, or hosted services.
|
|
230
199
|
|
|
231
|
-
|
|
200
|
+
## License
|
|
232
201
|
|
|
233
|
-
MIT
|
|
202
|
+
MIT
|
package/dist/core/CostGuard.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* CostGuard.ts - RUNTIME FINANCIAL EXECUTION CONTROL LAYER
|
|
3
|
-
*
|
|
4
|
-
* 🟦 FREE: Local illusion of safety (each process thinks it is safe)
|
|
5
|
-
* 🟥 PAID: System-wide financial control (the system sees everything as one budget)
|
|
6
|
-
*
|
|
7
|
-
* NOT: logging, monitoring, middleware, analytics
|
|
8
|
-
* IS: distributed cost firewall for AI systems
|
|
9
|
-
*/
|
|
10
|
-
export { guard, GuardError, middleware, getPricing } from './GuardFree.js';
|
|
1
|
+
export { guard, GuardError, middleware } from './GuardFree.js';
|
|
11
2
|
export { GuardPro, validateLicense, getProGuard } from './GuardPro.js';
|
|
3
|
+
export type { GuardProConfig } from './GuardPro.js';
|
|
4
|
+
export { getPricing, registerPricing, listPricing } from '../pricing/index.js';
|
|
5
|
+
export type { ModelPricing } from '../pricing/index.js';
|
|
12
6
|
export type { GuardConfig } from './types.js';
|
|
13
7
|
//# sourceMappingURL=CostGuard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CostGuard.d.ts","sourceRoot":"","sources":["../../src/core/CostGuard.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CostGuard.d.ts","sourceRoot":"","sources":["../../src/core/CostGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/core/CostGuard.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* CostGuard.ts - RUNTIME FINANCIAL EXECUTION CONTROL LAYER
|
|
3
|
-
*
|
|
4
|
-
* 🟦 FREE: Local illusion of safety (each process thinks it is safe)
|
|
5
|
-
* 🟥 PAID: System-wide financial control (the system sees everything as one budget)
|
|
6
|
-
*
|
|
7
|
-
* NOT: logging, monitoring, middleware, analytics
|
|
8
|
-
* IS: distributed cost firewall for AI systems
|
|
9
|
-
*/
|
|
10
|
-
export { guard, GuardError, middleware, getPricing } from './GuardFree.js';
|
|
1
|
+
export { guard, GuardError, middleware } from './GuardFree.js';
|
|
11
2
|
export { GuardPro, validateLicense, getProGuard } from './GuardPro.js';
|
|
3
|
+
export { getPricing, registerPricing, listPricing } from '../pricing/index.js';
|
|
12
4
|
//# sourceMappingURL=CostGuard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CostGuard.js","sourceRoot":"","sources":["../../src/core/CostGuard.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CostGuard.js","sourceRoot":"","sources":["../../src/core/CostGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/core/GuardCore.d.ts
CHANGED
|
@@ -18,8 +18,5 @@ export declare class GuardError extends Error {
|
|
|
18
18
|
context: RequestContext;
|
|
19
19
|
constructor(message: string, context: RequestContext);
|
|
20
20
|
}
|
|
21
|
-
export
|
|
22
|
-
input: number;
|
|
23
|
-
output: number;
|
|
24
|
-
} | undefined;
|
|
21
|
+
export { getPricing } from '../pricing/index.js';
|
|
25
22
|
//# sourceMappingURL=GuardCore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardCore.d.ts","sourceRoot":"","sources":["../../src/core/GuardCore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"GuardCore.d.ts","sourceRoot":"","sources":["../../src/core/GuardCore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE;;;GAGG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,UAAU,OAgF/E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,IAGpC,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG,UAiCtC;AAiED,qBAAa,UAAW,SAAQ,KAAK;IACnC,OAAO,EAAE,cAAc,CAAC;gBACZ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;CAKrD;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/core/GuardCore.js
CHANGED
|
@@ -4,15 +4,7 @@
|
|
|
4
4
|
* Maximum simplicity. Maximum virality. Zero complexity.
|
|
5
5
|
* Instant safety layer every AI developer installs by default.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
'gpt-4': { input: 0.03, output: 0.06 },
|
|
9
|
-
'gpt-4o': { input: 0.005, output: 0.015 },
|
|
10
|
-
'gpt-4o-mini': { input: 0.00015, output: 0.0006 },
|
|
11
|
-
'gpt-3.5-turbo': { input: 0.0005, output: 0.0015 },
|
|
12
|
-
'claude-3-opus': { input: 0.015, output: 0.075 },
|
|
13
|
-
'claude-3-sonnet': { input: 0.003, output: 0.015 },
|
|
14
|
-
'claude-3-haiku': { input: 0.00025, output: 0.00125 },
|
|
15
|
-
};
|
|
7
|
+
import { getPricing as lookupPricing } from '../pricing/index.js';
|
|
16
8
|
/**
|
|
17
9
|
* Guard your AI client from wasting money
|
|
18
10
|
* FREE CORE: Local protection + viral logs + real-time risk warnings
|
|
@@ -158,9 +150,11 @@ function extractContext(args, prop) {
|
|
|
158
150
|
const estimatedInputTokens = Math.ceil(inputText.length / 4);
|
|
159
151
|
const maxOutputTokens = params.max_tokens || 1000;
|
|
160
152
|
const tokens = estimatedInputTokens + maxOutputTokens;
|
|
161
|
-
const pricing =
|
|
162
|
-
const
|
|
163
|
-
|
|
153
|
+
const pricing = lookupPricing(model);
|
|
154
|
+
const inputPer1kTokens = pricing?.inputPer1kTokens ?? 0.01;
|
|
155
|
+
const outputPer1kTokens = pricing?.outputPer1kTokens ?? 0.03;
|
|
156
|
+
const estimatedCost = (estimatedInputTokens / 1000) * inputPer1kTokens +
|
|
157
|
+
(maxOutputTokens / 1000) * outputPer1kTokens;
|
|
164
158
|
return {
|
|
165
159
|
model,
|
|
166
160
|
tokens,
|
|
@@ -178,8 +172,5 @@ export class GuardError extends Error {
|
|
|
178
172
|
this.context = context;
|
|
179
173
|
}
|
|
180
174
|
}
|
|
181
|
-
|
|
182
|
-
export function getPricing(model) {
|
|
183
|
-
return MODEL_PRICING[model];
|
|
184
|
-
}
|
|
175
|
+
export { getPricing } from '../pricing/index.js';
|
|
185
176
|
//# sourceMappingURL=GuardCore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardCore.js","sourceRoot":"","sources":["../../src/core/GuardCore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"GuardCore.js","sourceRoot":"","sources":["../../src/core/GuardCore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,MAAW,EAAE,MAAmB,EAAE,WAAwB;IAC9E,MAAM,QAAQ,GAAgB;QAC5B,MAAM,EA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AAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/core/GuardFree.d.ts
CHANGED
|
@@ -22,10 +22,6 @@ export declare function guard(client: any, config: GuardConfig, sharedState?: Gu
|
|
|
22
22
|
export declare function middleware(config: GuardConfig): (req: any, res: any, next: any) => void;
|
|
23
23
|
export declare class GuardError extends Error {
|
|
24
24
|
context: RequestContext;
|
|
25
|
-
constructor(message: string, context
|
|
25
|
+
constructor(message: string, context?: RequestContext);
|
|
26
26
|
}
|
|
27
|
-
export declare function getPricing(model: string): {
|
|
28
|
-
input: number;
|
|
29
|
-
output: number;
|
|
30
|
-
} | undefined;
|
|
31
27
|
//# sourceMappingURL=GuardFree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardFree.d.ts","sourceRoot":"","sources":["../../src/core/GuardFree.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"GuardFree.d.ts","sourceRoot":"","sources":["../../src/core/GuardFree.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,UAAU,OAmE/E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,IAGpC,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG,UAwBtC;AA+DD,qBAAa,UAAW,SAAQ,KAAK;IACnC,OAAO,EAAE,cAAc,CAAC;gBACZ,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;CAKtD"}
|
package/dist/core/GuardFree.js
CHANGED
|
@@ -6,15 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* INSTALL: const ai = guard(openai)
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
'gpt-4': { input: 0.03, output: 0.06 },
|
|
11
|
-
'gpt-4o': { input: 0.005, output: 0.015 },
|
|
12
|
-
'gpt-4o-mini': { input: 0.00015, output: 0.0006 },
|
|
13
|
-
'gpt-3.5-turbo': { input: 0.0005, output: 0.0015 },
|
|
14
|
-
'claude-3-opus': { input: 0.015, output: 0.075 },
|
|
15
|
-
'claude-3-sonnet': { input: 0.003, output: 0.015 },
|
|
16
|
-
'claude-3-haiku': { input: 0.00025, output: 0.00125 },
|
|
17
|
-
};
|
|
9
|
+
import { getPricing as lookupPricing } from '../pricing/index.js';
|
|
18
10
|
/**
|
|
19
11
|
* Local Safety Illusion - FREE VERSION
|
|
20
12
|
*
|
|
@@ -142,9 +134,11 @@ function extractContext(args, prop) {
|
|
|
142
134
|
const estimatedInputTokens = Math.ceil(inputText.length / 4);
|
|
143
135
|
const maxOutputTokens = params.max_tokens || 1000;
|
|
144
136
|
const tokens = estimatedInputTokens + maxOutputTokens;
|
|
145
|
-
const pricing =
|
|
146
|
-
const
|
|
147
|
-
|
|
137
|
+
const pricing = lookupPricing(model);
|
|
138
|
+
const inputPer1kTokens = pricing?.inputPer1kTokens ?? 0.01;
|
|
139
|
+
const outputPer1kTokens = pricing?.outputPer1kTokens ?? 0.03;
|
|
140
|
+
const estimatedCost = (estimatedInputTokens / 1000) * inputPer1kTokens +
|
|
141
|
+
(maxOutputTokens / 1000) * outputPer1kTokens;
|
|
148
142
|
return {
|
|
149
143
|
model,
|
|
150
144
|
tokens,
|
|
@@ -162,8 +156,4 @@ export class GuardError extends Error {
|
|
|
162
156
|
this.context = context;
|
|
163
157
|
}
|
|
164
158
|
}
|
|
165
|
-
// Get pricing for model (local only)
|
|
166
|
-
export function getPricing(model) {
|
|
167
|
-
return MODEL_PRICING[model];
|
|
168
|
-
}
|
|
169
159
|
//# sourceMappingURL=GuardFree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardFree.js","sourceRoot":"","sources":["../../src/core/GuardFree.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"GuardFree.js","sourceRoot":"","sources":["../../src/core/GuardFree.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,MAAW,EAAE,MAAmB,EAAE,WAAwB;IAC9E,MAAM,QAAQ,GAAgB;QAC5B,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,MAAM,WAAW,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;IAE/C,2DAA2D;IAC3D,MAAM,KAAK,GAAe,WAAW,IAAI;QACvC,YAAY,EAAE,CAAC;QACf,SAAS,EAAE,CAAC;QACZ,eAAe,EAAE,CAAC;QAClB,YAAY,EAAE,CAAC;KAChB,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,MAAM,KAAK,GAAG,MAAM,CAAC,IAAc,CAAC,CAAC;YAErC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;oBACxB,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,EAAE,IAAc,CAAC,CAAC;oBAEjD,qDAAqD;oBACrD,IAAI,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;wBAC7D,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;wBACnD,KAAK,CAAC,YAAY,EAAE,CAAC;wBAErB,OAAO,CAA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