vibezcheck 0.4.1 → 0.5.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.
Files changed (82) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +140 -113
  3. package/bin/vibezcheck.js +4 -4
  4. package/dist/ai-sdk/index.d.mts +28 -57
  5. package/dist/ai-sdk/index.d.ts +28 -57
  6. package/dist/ai-sdk/index.js +262 -53
  7. package/dist/ai-sdk/index.js.map +1 -1
  8. package/dist/ai-sdk/index.mjs +262 -53
  9. package/dist/ai-sdk/index.mjs.map +1 -1
  10. package/dist/ai-sdk/middleware.d.mts +15 -0
  11. package/dist/ai-sdk/middleware.d.ts +15 -0
  12. package/dist/ai-sdk/middleware.js +1280 -0
  13. package/dist/ai-sdk/middleware.js.map +1 -0
  14. package/dist/ai-sdk/middleware.mjs +1243 -0
  15. package/dist/ai-sdk/middleware.mjs.map +1 -0
  16. package/dist/auth/index.js.map +1 -1
  17. package/dist/auth/index.mjs.map +1 -1
  18. package/dist/billing/index.d.mts +90 -1
  19. package/dist/billing/index.d.ts +90 -1
  20. package/dist/billing/index.js +1391 -2
  21. package/dist/billing/index.js.map +1 -1
  22. package/dist/billing/index.mjs +1386 -1
  23. package/dist/billing/index.mjs.map +1 -1
  24. package/dist/cli/index.js +2 -2
  25. package/dist/cli/index.js.map +1 -1
  26. package/dist/cli/index.mjs +2 -2
  27. package/dist/cli/index.mjs.map +1 -1
  28. package/dist/{client--iq93FQg.d.mts → client-CJ2Dj8ID.d.ts} +4 -2
  29. package/dist/{client-kJN_Znan.d.ts → client-Dmwb3hQt.d.mts} +4 -2
  30. package/dist/compat/stripe-meter.d.mts +21 -0
  31. package/dist/compat/stripe-meter.d.ts +21 -0
  32. package/dist/compat/stripe-meter.js +1281 -0
  33. package/dist/compat/stripe-meter.js.map +1 -0
  34. package/dist/compat/stripe-meter.mjs +1244 -0
  35. package/dist/compat/stripe-meter.mjs.map +1 -0
  36. package/dist/compat/stripe-provider.d.mts +54 -0
  37. package/dist/compat/stripe-provider.d.ts +54 -0
  38. package/dist/compat/stripe-provider.js +1304 -0
  39. package/dist/compat/stripe-provider.js.map +1 -0
  40. package/dist/compat/stripe-provider.mjs +1264 -0
  41. package/dist/compat/stripe-provider.mjs.map +1 -0
  42. package/dist/compat/token-meter.d.mts +16 -0
  43. package/dist/compat/token-meter.d.ts +16 -0
  44. package/dist/compat/token-meter.js +1095 -0
  45. package/dist/compat/token-meter.js.map +1 -0
  46. package/dist/compat/token-meter.mjs +1058 -0
  47. package/dist/compat/token-meter.mjs.map +1 -0
  48. package/dist/customers/index.d.mts +30 -4
  49. package/dist/customers/index.d.ts +30 -4
  50. package/dist/customers/index.js +108 -8
  51. package/dist/customers/index.js.map +1 -1
  52. package/dist/customers/index.mjs +106 -7
  53. package/dist/customers/index.mjs.map +1 -1
  54. package/dist/index.d.mts +23 -12
  55. package/dist/index.d.ts +23 -12
  56. package/dist/index.js +506 -60
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.mjs +501 -60
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/meter/index.d.mts +2 -2
  61. package/dist/meter/index.d.ts +2 -2
  62. package/dist/meter/index.js +138 -37
  63. package/dist/meter/index.js.map +1 -1
  64. package/dist/meter/index.mjs +138 -37
  65. package/dist/meter/index.mjs.map +1 -1
  66. package/dist/pricing/index.d.mts +5 -2
  67. package/dist/pricing/index.d.ts +5 -2
  68. package/dist/pricing/index.js +43 -21
  69. package/dist/pricing/index.js.map +1 -1
  70. package/dist/pricing/index.mjs +43 -21
  71. package/dist/pricing/index.mjs.map +1 -1
  72. package/dist/react/index.d.mts +46 -2
  73. package/dist/react/index.d.ts +46 -2
  74. package/dist/react/index.js +351 -21
  75. package/dist/react/index.js.map +1 -1
  76. package/dist/react/index.mjs +349 -21
  77. package/dist/react/index.mjs.map +1 -1
  78. package/dist/{types-Zbzxg-Ka.d.mts → types-BVGqbKnY.d.mts} +76 -12
  79. package/dist/{types-Zbzxg-Ka.d.ts → types-BVGqbKnY.d.ts} +76 -12
  80. package/dist/with-billing-CDqKIAQ6.d.ts +47 -0
  81. package/dist/with-billing-mci2vtFS.d.mts +47 -0
  82. package/package.json +186 -153
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 VibezCheck <dev@vibezcheck.xyz> (https://vibezcheck.xyz)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VibezCheck <dev@vibezcheck.xyz> (https://vibezcheck.xyz)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,29 +1,38 @@
1
- # vibezcheck
1
+ # VibezCheck
2
2
 
3
- > **Give your AI app a financial mind.**
4
- > The declarative 1-line Stripe Billing and Token Metering engine for LLMs. Measure tokens, compute real-time dollar costs, and bill customers with **0ms added latency**.
3
+ > **The 1-Line Token Meter & Real-Time Billing Engine for AI.**
4
+ > Track tokens, compute real-time dollar costs, set profit margins, and bill customers with **0ms added latency**.
5
5
 
6
6
  [![npm version](https://img.shields.io/npm/v/vibezcheck.svg)](https://npmjs.org/package/vibezcheck)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-Strict-blue.svg)](https://www.typescriptlang.org/)
9
- [![Tests](https://img.shields.io/badge/Tests-31%20Passed-brightgreen.svg)]()
9
+ [![Tests](https://img.shields.io/badge/Tests-62%20Passed-brightgreen.svg)]()
10
10
 
11
11
  ---
12
12
 
13
- ## 🍌 The Electric Meter for Artificial Intelligence
13
+ ### The 2-Line Promise
14
14
 
15
- When you turn on the lights in your bedroom, your electric meter spins. When users prompt your AI, **VibezCheck** is the smart meter that counts every word and hidden thought — converting it into pennies with Stripe so your app actually looks out for your margins.
15
+ ```typescript
16
+ // 1. Server: Wrap your model with automated billing
17
+ const model = vibezcheck('openai/gpt-4o', { customer: 'cus_alex' });
18
+
19
+ // 2. Client: Drop in the financial HUD
20
+ <VibezCheck messages={messages} />
21
+ ```
22
+
23
+ ---
24
+
25
+ ## 🚀 Features
16
26
 
17
- ### 🛡️ Sane Defaults (Zero Configuration Required)
18
- * **⚡ 0ms Added Latency**: Streams pass directly to your user's browser with zero intermediate proxy buffering.
19
- * **🛡️ Default $0.50 Fuse Box**: Automatically prevents runaway loops without requiring manual ceilings.
20
- * **🛟 In-Flight Abort Trapper**: Captures and bills partial tokens even if a user closes their browser tab mid-stream.
21
- * **🏷️ Automatic 85% Prompt Cache Discounts**: Detects cache hits on Claude 3.7, GPT-4o, and DeepSeek and passes real savings through.
22
- * **🚀 Serverless Lifecycle Protection**: Seamlessly keeps serverless containers alive until telemetry is acknowledged.
23
- * **💰 1-Line Profit Margins**: Turn wholesale provider costs into guaranteed net profit with `pricing: { margin: 1.5 }`.
24
- * **💳 Prepaid & Postpaid**: Choose between monthly metered invoices or zero-debt credit wallets.
25
- * **🧠 Reasoning Token Aware**: Captures hidden thinking tokens in o3-mini and Claude 3.7 Thinking.
26
- * **🆓 Free Vibe Mode**: Works 100% out of the box in local development with no Stripe account required.
27
+ * **⚡ 0ms Added Latency**: Direct transparent proxy stream; no external server redirects or buffering.
28
+ * **🛡️ Built-in $0.50 Circuit Breaker**: Prevents infinite loops and runaway bills automatically.
29
+ * **🛟 In-Flight Abort Trapper**: Catches and bills tokens even if the customer closes their tab mid-stream.
30
+ * **🪙 BigInt Nano-USD Precision**: Sub-cent financial math ($1 = $10^9$ Nano-USD) eliminating IEEE 754 float drift.
31
+ * **💰 1-Line Profit Margins**: Turn wholesale API costs into retail profits with `pricing: { margin: 1.5 }` (+50% profit).
32
+ * **🆓 Zero-DB Dev Mode**: Run locally on `localhost:3000` with NO database and NO Stripe keys required.
33
+ * **💳 Pluggable SaaS Billing**: Top-ups, checkout sessions, customer portal, and user API keys (`vz_live_...`).
34
+ * **🤖 Multi-Tool Agent Sessions**: Cumulative session budgets across models, Python sandboxes, and web scrapers.
35
+ * **🔄 100% Drop-In Polyfills**: Direct replacement for `@stripe/ai-sdk/meter`, `@stripe/ai-sdk/provider`, and `@stripe/token-meter`.
27
36
 
28
37
  ---
29
38
 
@@ -35,45 +44,49 @@ npm install vibezcheck ai @ai-sdk/openai stripe
35
44
 
36
45
  ---
37
46
 
38
- ## ⚡ 1. The 60-Second Quickstart
47
+ ## ⚡ Quickstart: Zero-DB Dev Mode to Production
48
+
49
+ ### 1. Next.js 15 API Route (`app/api/chat/route.ts`)
39
50
 
40
- ### Backend API Route (`app/api/chat/route.ts`)
41
51
  ```typescript
42
52
  import { streamText } from 'ai';
53
+ import { openai } from '@ai-sdk/openai';
43
54
  import { vibezcheck } from 'vibezcheck';
44
55
 
45
56
  export async function POST(req: Request) {
46
- const { messages, userEmail = 'alex@company.com' } = await req.json();
47
-
48
- return streamText({
49
- // 1 Line. All 6 sane defaults run automatically.
50
- model: vibezcheck('openai/gpt-4o-mini', { customer: userEmail }),
57
+ const { messages } = await req.json();
58
+
59
+ const result = streamText({
60
+ // Wrap any AI SDK model or use string identifier
61
+ model: vibezcheck(openai('gpt-4o-mini'), {
62
+ customer: 'user_alex@example.com', // Stripe customer ID or user email
63
+ pricing: { margin: 1.3 }, // +30% profit margin
64
+ maxCostPerCallUSD: 0.50, // Safety fuse box
65
+ }),
51
66
  messages,
52
- }).toDataStreamResponse();
67
+ });
68
+
69
+ return result.toDataStreamResponse();
53
70
  }
54
71
  ```
55
72
 
56
- ### Frontend Chat UI (`app/page.tsx`)
73
+ ### 2. Frontend React Client (`app/page.tsx`)
74
+
57
75
  ```tsx
58
76
  'use client';
59
- import { useVibezChat, VibezReceipt, VibezSessionWidget } from 'vibezcheck/react';
77
+ import { useChat } from 'ai/react';
78
+ import { VibezCheck } from 'vibezcheck/ui';
60
79
 
61
80
  export default function ChatPage() {
62
- const { messages, input, handleInputChange, handleSubmit } = useVibezChat();
81
+ const { messages, input, handleInputChange, handleSubmit } = useChat();
63
82
 
64
83
  return (
65
- <main className="max-w-xl mx-auto py-10 px-4 space-y-6">
66
- {/* 1. Floating live token & dollar counter */}
67
- <VibezSessionWidget position="bottom-right" />
68
-
69
- {/* 2. Messages with micro-receipts */}
70
- <div className="space-y-4">
84
+ <main className="max-w-2xl mx-auto p-6 space-y-4">
85
+ <div className="space-y-3">
71
86
  {messages.map((m) => (
72
- <div key={m.id} className="p-4 rounded-2xl bg-white border border-slate-200">
73
- <p className="text-slate-900 text-sm">{m.content}</p>
74
-
75
- {/* Micro-Receipt under assistant answers */}
76
- {m.role === 'assistant' && <VibezReceipt message={m} />}
87
+ <div key={m.id} className="p-3 rounded-lg bg-slate-100 dark:bg-slate-800">
88
+ <strong>{m.role}: </strong>
89
+ <span>{m.content}</span>
77
90
  </div>
78
91
  ))}
79
92
  </div>
@@ -82,13 +95,16 @@ export default function ChatPage() {
82
95
  <input
83
96
  value={input}
84
97
  onChange={handleInputChange}
85
- placeholder="Ask a question..."
86
- className="flex-1 px-4 py-2 rounded-xl border border-slate-200 text-sm"
98
+ placeholder="Ask anything..."
99
+ className="flex-1 p-2 border rounded-lg"
87
100
  />
88
- <button type="submit" className="px-5 py-2 rounded-xl bg-slate-950 text-white font-bold text-sm">
101
+ <button type="submit" className="px-4 py-2 bg-blue-600 text-white rounded-lg">
89
102
  Send
90
103
  </button>
91
104
  </form>
105
+
106
+ {/* ✦ 1-Line HUD: Works with zero database & zero Stripe in Dev Mode */}
107
+ <VibezCheck messages={messages} model="gpt-4o-mini" margin={1.3} />
92
108
  </main>
93
109
  );
94
110
  }
@@ -96,108 +112,119 @@ export default function ChatPage() {
96
112
 
97
113
  ---
98
114
 
99
- ## 🛠️ Real-World Implementation Patterns
115
+ ## 💳 Commercial SaaS Use Cases
100
116
 
101
- ### Pattern A: 50% Profit Margin Engine
102
- Turn wholesale provider costs into guaranteed net profit:
117
+ ### 1. Credit Wallet Top-Ups & Checkout (`BillingHelper`)
103
118
 
104
119
  ```typescript
105
- model: vibezcheck('openai/gpt-4o-mini', {
106
- customer: 'sarah@acme.com',
107
- pricing: {
108
- margin: 1.5, // 👈 Cost + 50% margin automatically billed to Stripe!
109
- minimumChargeUSD: 0.01, // 👈 Minimum charge 1 cent per question
110
- },
111
- })
112
- ```
120
+ import { BillingHelper } from 'vibezcheck';
113
121
 
114
- ---
122
+ const billing = new BillingHelper({ apiKey: process.env.STRIPE_SECRET_KEY });
115
123
 
116
- ### Pattern B: Prepaid Credit Wallets (Zero Debt Risk)
117
- User pre-purchases $10; stream cleanly halts when balance hits $0 without invoice debt:
124
+ // Customer purchases $20 in AI usage credits
125
+ export async function POST(req: Request) {
126
+ const { customerId } = await req.json();
118
127
 
119
- ```typescript
120
- model: vibezcheck('openai/gpt-4o-mini', {
121
- customer: 'alex@gmail.com',
122
- billing: {
123
- mode: 'prepaid', // 👈 Deducts from prepaid credit balance in real time
124
- },
125
- // Gracefully downshift when credits run low instead of crashing
126
- fallbackModelOnBudget: 'openai/gpt-4o-mini',
127
- })
128
+ const checkoutUrl = await billing.createTopUpSession({
129
+ customerId,
130
+ amountCents: 2000, // $20.00
131
+ returnUrl: 'https://myapp.com/dashboard',
132
+ });
133
+
134
+ return Response.json({ url: checkoutUrl });
135
+ }
128
136
  ```
129
137
 
130
- ---
138
+ ### 2. Customer API Keys (`ApiKeyAuth`)
131
139
 
132
- ### Pattern C: Frontier Reasoning Models (Claude 3.7 & o3-mini)
133
- Automatically extracts hidden thinking tokens and applies 85% prompt cache discounts:
140
+ Issue customer API keys (`vz_live_...`) backed by Stripe customer metadata—zero database required:
134
141
 
135
142
  ```typescript
136
- model: vibezcheck('anthropic/claude-3-7-sonnet', {
137
- customer: 'alex@company.com',
138
- maxCostPerCallUSD: 0.75, // Extended ceiling for multi-minute deep reasoning
139
- })
140
- ```
143
+ import { ApiKeyAuth } from 'vibezcheck';
144
+ import Stripe from 'stripe';
141
145
 
142
- ---
146
+ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
147
+ const auth = new ApiKeyAuth(stripe);
143
148
 
144
- ### Pattern D: Unified Agent Tool Call Metering
145
- Bill external tools (web searches, scrapers, Python sandboxes) and LLM streams into one invoice:
149
+ // 1. Generate key for customer
150
+ const { apiKey } = await auth.createKey({
151
+ customerId: 'cus_123',
152
+ name: 'Production Worker Key',
153
+ });
154
+ // => "vz_live_9f83b2..."
146
155
 
147
- ```typescript
148
- // app/api/agent/route.ts
149
- import { generateText, tool } from 'ai';
150
- import { vibezcheck } from 'vibezcheck';
151
- import { z } from 'zod';
156
+ // 2. Authenticate API requests in middleware
157
+ export async function middleware(req: Request) {
158
+ const token = req.headers.get('Authorization')?.replace('Bearer ', '');
159
+ const verification = await auth.verifyKey(token);
152
160
 
153
- export async function POST(req: Request) {
154
- const { prompt, customer = 'alex@company.com' } = await req.json();
155
-
156
- // Create unified customer session
157
- const session = vibezcheck.session({ customer });
158
-
159
- const result = await generateText({
160
- model: session.model('openai/gpt-4o-mini'),
161
- tools: {
162
- searchGoogle: tool({
163
- description: 'Live Google Search',
164
- parameters: z.object({ query: z.string() }),
165
- execute: async ({ query }) => {
166
- // ⚡ Bill non-LLM tool execution ($0.01) into the same customer balance
167
- await session.trackTool('google_search', { costUSD: 0.01 });
168
- return `Search results for: ${query}`;
169
- },
170
- }),
171
- },
172
- prompt,
173
- });
161
+ if (!verification.valid) {
162
+ return new Response('Unauthorized', { status: 401 });
163
+ }
174
164
 
175
- return Response.json(result);
165
+ // verification.customerId is verified against Stripe!
176
166
  }
177
167
  ```
178
168
 
169
+ ### 3. Multi-Tool Agent Sessions (`AgentSession`)
170
+
171
+ Set a hard $1.00 session budget across multiple LLM steps and external tools:
172
+
173
+ ```typescript
174
+ import { AgentSession, wrapTool } from 'vibezcheck';
175
+ import { openai } from '@ai-sdk/openai';
176
+
177
+ const session = new AgentSession({
178
+ customer: 'cus_agent_user',
179
+ sessionBudgetUSD: 1.00, // Hard ceiling for entire session
180
+ });
181
+
182
+ // Wrap external tools with financial tracking
183
+ const webSearchTool = wrapTool({
184
+ name: 'web_search',
185
+ costUSD: 0.01,
186
+ execute: async ({ query }) => fetchSearch(query),
187
+ });
188
+
189
+ // Run LLM model bound to this session
190
+ const sessionModel = session.model(openai('gpt-4o'));
191
+ ```
192
+
179
193
  ---
180
194
 
181
- ### Pattern E: Brand-New Model (1-Line Inline Rate Card)
182
- Use newly released or fine-tuned models with zero wait for package updates:
195
+ ## 🔄 100% Drop-In Compatibility with `@stripe/ai-sdk`
196
+
197
+ If you are migrating from `@stripe/ai-sdk` or `@stripe/token-meter`, swap your imports:
183
198
 
184
199
  ```typescript
185
- model: vibezcheck('deepseek/deepseek-r2', {
186
- rate: { in: 0.20, out: 0.80 }, // $0.20/M in, $0.80/M out
187
- })
200
+ // Replace: import { meteredModel } from '@stripe/ai-sdk/meter';
201
+ import { meteredModel } from 'vibezcheck/stripe/meter';
202
+
203
+ // Replace: import { stripe } from '@stripe/ai-sdk/provider';
204
+ import { stripe } from 'vibezcheck/stripe/provider';
205
+
206
+ // Replace: import { createTokenMeter } from '@stripe/token-meter';
207
+ import { createTokenMeter } from 'vibezcheck/stripe/token-meter';
188
208
  ```
189
209
 
190
210
  ---
191
211
 
192
- ## 🎨 React UI Suite (`vibezcheck/react`)
212
+ ## 🛡️ Route Auditor CLI
213
+
214
+ Audit your codebase to detect unmetered AI endpoints before shipping to production:
193
215
 
194
- * **`useVibezChat`**: 1-hook drop-in chat streaming with live session cost sync.
195
- * **`<VibezReceipt />`**: Micro-badge rendered below assistant responses (*"⚡ gpt-4o-mini • 342 tokens • $0.0005 • Verified by VibezCheck"*).
196
- * **`<VibezSessionWidget />`**: Floating live token & dollar speedometer in the screen corner.
197
- * **`<VibezBillingModal />`**: Drop-in 1-click Stripe Checkout top-up modal.
216
+ ```bash
217
+ npx vibezcheck audit
218
+ ```
219
+
220
+ ### CI/CD Mode
221
+ Fail the build if unmetered AI routes are detected:
222
+ ```bash
223
+ npx vibezcheck audit --ci
224
+ ```
198
225
 
199
226
  ---
200
227
 
201
228
  ## 📄 License
202
229
 
203
- MIT © [VibezCheck](https://vibezcheck.app)
230
+ MIT © [VibezCheck](https://vibezcheck.xyz)
package/bin/vibezcheck.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
2
-
3
- // Forward execution to compiled CLI entrypoint
4
- require('../dist/cli/index.js');
1
+ #!/usr/bin/env node
2
+
3
+ // Forward execution to compiled CLI entrypoint
4
+ require('../dist/cli/index.js');
@@ -1,52 +1,13 @@
1
- import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, P as PricingConfig, d as InlineRateConfig, U as UsageEvent } from '../types-Zbzxg-Ka.mjs';
2
- import { V as VibezMeter } from '../client--iq93FQg.mjs';
1
+ import { W as WithBillingOptions } from '../with-billing-mci2vtFS.mjs';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-mci2vtFS.mjs';
3
+ import { C as CustomerParam } from '../types-BVGqbKnY.mjs';
4
+ import { V as VibezMeter } from '../client-Dmwb3hQt.mjs';
3
5
  import 'stripe';
4
6
 
5
- interface WithBillingOptions extends CircuitBreakerOptions {
6
- /** Customer email, user ID, or Stripe customer ID */
7
- customer?: CustomerParam;
8
- /** Direct Stripe customer ID */
9
- customerId?: string;
10
- /** Billing mode configuration (postpaid vs prepaid) */
11
- billing?: BillingConfig;
12
- /** Profit margin & minimum charge configuration */
13
- pricing?: PricingConfig;
14
- /** 1-line inline pricing rate card */
15
- rate?: InlineRateConfig;
16
- /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
17
- captureOnAbort?: boolean;
18
- /** Execution runtime environment (default: 'auto') */
19
- runtime?: 'auto' | 'serverless' | 'edge' | 'node';
20
- /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
21
- stripeApiKey?: string;
22
- /** Existing VibezMeter instance (optional) */
23
- meter?: VibezMeter;
24
- /** Custom meter event name */
25
- eventName?: string;
26
- /** Usage callback fired upon generation/stream completion */
27
- onUsage?: (event: UsageEvent) => void | Promise<void>;
28
- /** Custom developer metadata */
29
- metadata?: Record<string, string | number | boolean>;
30
- }
31
- /**
32
- * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
33
- *
34
- * Sane Defaults Built-In:
35
- * - $0.50 safety ceiling per call (overridable)
36
- * - Automatic in-flight token capture on abort
37
- * - Automatic prompt caching discount parsing
38
- * - Serverless lifecycle preservation
39
- */
40
- declare function withBilling<T extends object>(model: T, options?: WithBillingOptions): T;
41
- /**
42
- * Convenient alias for withBilling
43
- */
44
- declare const meteredModel: typeof withBilling;
45
-
46
7
  interface VibezCheckModelOptions extends WithBillingOptions {
47
- /** OpenAI / AI Gateway API Key override */
8
+ /** OpenAI / Anthropic / AI Gateway API Key override */
48
9
  apiKey?: string;
49
- /** AI Gateway / OpenAI Base URL override */
10
+ /** AI Gateway / Provider Base URL override */
50
11
  baseURL?: string;
51
12
  }
52
13
  interface VibezSessionOptions {
@@ -70,23 +31,33 @@ interface VibezSession {
70
31
  /**
71
32
  * Creates or resolves an AI SDK compatible LanguageModel with built-in VibezCheck billing & metering.
72
33
  *
34
+ * Supports:
35
+ * - Direct instances: `vibezcheck(openai('gpt-4o'))`, `vibezcheck(anthropic('claude-3-7-sonnet'))`
36
+ * - String identifiers: `vibezcheck('openai/gpt-4o-mini')`, `vibezcheck('anthropic/claude-3-5-sonnet')`, `vibezcheck('gpt-4o')`
37
+ * - Vercel AI SDK primitives: `generateText`, `streamText`, `generateObject`, `streamObject`
38
+ *
73
39
  * @example
74
40
  * ```typescript
75
- * import { generateText, streamText } from 'ai';
41
+ * import { streamText } from 'ai';
42
+ * import { openai } from '@ai-sdk/openai';
43
+ * import { anthropic } from '@ai-sdk/anthropic';
76
44
  * import { vibezcheck } from 'vibezcheck';
77
45
  *
78
- * // 1. Declarative string model identifier:
79
- * const { text } = await generateText({
80
- * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
81
- * prompt: 'What is love?',
46
+ * // 1. Pass wrapped OpenAI instance:
47
+ * const result = streamText({
48
+ * model: vibezcheck(openai('gpt-4o-mini'), { customer: 'alex@example.com' }),
49
+ * messages,
82
50
  * });
83
51
  *
84
- * // 2. Works with all Vercel AI SDK primitives (streamText, generateObject, streamObject):
85
- * const result = streamText({
86
- * model: vibezcheck('gpt-4o', {
87
- * customer: 'alex@example.com',
88
- * pricing: { margin: 1.5 }, // 50% profit margin
89
- * }),
52
+ * // 2. Pass wrapped Anthropic instance:
53
+ * const result2 = streamText({
54
+ * model: vibezcheck(anthropic('claude-3-7-sonnet'), { customer: 'alex@example.com' }),
55
+ * messages,
56
+ * });
57
+ *
58
+ * // 3. Use 1-line string identifier:
59
+ * const result3 = streamText({
60
+ * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
90
61
  * messages,
91
62
  * });
92
63
  * ```
@@ -100,4 +71,4 @@ declare const vibezcheck: typeof createVibezModel & {
100
71
  session: typeof createVibezSession;
101
72
  };
102
73
 
103
- export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, type WithBillingOptions, createVibezModel, createVibezSession, meteredModel, vibezcheck, withBilling };
74
+ export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, WithBillingOptions, createVibezModel, createVibezSession, vibezcheck };
@@ -1,52 +1,13 @@
1
- import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, P as PricingConfig, d as InlineRateConfig, U as UsageEvent } from '../types-Zbzxg-Ka.js';
2
- import { V as VibezMeter } from '../client-kJN_Znan.js';
1
+ import { W as WithBillingOptions } from '../with-billing-CDqKIAQ6.js';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-CDqKIAQ6.js';
3
+ import { C as CustomerParam } from '../types-BVGqbKnY.js';
4
+ import { V as VibezMeter } from '../client-CJ2Dj8ID.js';
3
5
  import 'stripe';
4
6
 
5
- interface WithBillingOptions extends CircuitBreakerOptions {
6
- /** Customer email, user ID, or Stripe customer ID */
7
- customer?: CustomerParam;
8
- /** Direct Stripe customer ID */
9
- customerId?: string;
10
- /** Billing mode configuration (postpaid vs prepaid) */
11
- billing?: BillingConfig;
12
- /** Profit margin & minimum charge configuration */
13
- pricing?: PricingConfig;
14
- /** 1-line inline pricing rate card */
15
- rate?: InlineRateConfig;
16
- /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
17
- captureOnAbort?: boolean;
18
- /** Execution runtime environment (default: 'auto') */
19
- runtime?: 'auto' | 'serverless' | 'edge' | 'node';
20
- /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
21
- stripeApiKey?: string;
22
- /** Existing VibezMeter instance (optional) */
23
- meter?: VibezMeter;
24
- /** Custom meter event name */
25
- eventName?: string;
26
- /** Usage callback fired upon generation/stream completion */
27
- onUsage?: (event: UsageEvent) => void | Promise<void>;
28
- /** Custom developer metadata */
29
- metadata?: Record<string, string | number | boolean>;
30
- }
31
- /**
32
- * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
33
- *
34
- * Sane Defaults Built-In:
35
- * - $0.50 safety ceiling per call (overridable)
36
- * - Automatic in-flight token capture on abort
37
- * - Automatic prompt caching discount parsing
38
- * - Serverless lifecycle preservation
39
- */
40
- declare function withBilling<T extends object>(model: T, options?: WithBillingOptions): T;
41
- /**
42
- * Convenient alias for withBilling
43
- */
44
- declare const meteredModel: typeof withBilling;
45
-
46
7
  interface VibezCheckModelOptions extends WithBillingOptions {
47
- /** OpenAI / AI Gateway API Key override */
8
+ /** OpenAI / Anthropic / AI Gateway API Key override */
48
9
  apiKey?: string;
49
- /** AI Gateway / OpenAI Base URL override */
10
+ /** AI Gateway / Provider Base URL override */
50
11
  baseURL?: string;
51
12
  }
52
13
  interface VibezSessionOptions {
@@ -70,23 +31,33 @@ interface VibezSession {
70
31
  /**
71
32
  * Creates or resolves an AI SDK compatible LanguageModel with built-in VibezCheck billing & metering.
72
33
  *
34
+ * Supports:
35
+ * - Direct instances: `vibezcheck(openai('gpt-4o'))`, `vibezcheck(anthropic('claude-3-7-sonnet'))`
36
+ * - String identifiers: `vibezcheck('openai/gpt-4o-mini')`, `vibezcheck('anthropic/claude-3-5-sonnet')`, `vibezcheck('gpt-4o')`
37
+ * - Vercel AI SDK primitives: `generateText`, `streamText`, `generateObject`, `streamObject`
38
+ *
73
39
  * @example
74
40
  * ```typescript
75
- * import { generateText, streamText } from 'ai';
41
+ * import { streamText } from 'ai';
42
+ * import { openai } from '@ai-sdk/openai';
43
+ * import { anthropic } from '@ai-sdk/anthropic';
76
44
  * import { vibezcheck } from 'vibezcheck';
77
45
  *
78
- * // 1. Declarative string model identifier:
79
- * const { text } = await generateText({
80
- * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
81
- * prompt: 'What is love?',
46
+ * // 1. Pass wrapped OpenAI instance:
47
+ * const result = streamText({
48
+ * model: vibezcheck(openai('gpt-4o-mini'), { customer: 'alex@example.com' }),
49
+ * messages,
82
50
  * });
83
51
  *
84
- * // 2. Works with all Vercel AI SDK primitives (streamText, generateObject, streamObject):
85
- * const result = streamText({
86
- * model: vibezcheck('gpt-4o', {
87
- * customer: 'alex@example.com',
88
- * pricing: { margin: 1.5 }, // 50% profit margin
89
- * }),
52
+ * // 2. Pass wrapped Anthropic instance:
53
+ * const result2 = streamText({
54
+ * model: vibezcheck(anthropic('claude-3-7-sonnet'), { customer: 'alex@example.com' }),
55
+ * messages,
56
+ * });
57
+ *
58
+ * // 3. Use 1-line string identifier:
59
+ * const result3 = streamText({
60
+ * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
90
61
  * messages,
91
62
  * });
92
63
  * ```
@@ -100,4 +71,4 @@ declare const vibezcheck: typeof createVibezModel & {
100
71
  session: typeof createVibezSession;
101
72
  };
102
73
 
103
- export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, type WithBillingOptions, createVibezModel, createVibezSession, meteredModel, vibezcheck, withBilling };
74
+ export { type VibezCheckModelOptions, type VibezSession, type VibezSessionOptions, WithBillingOptions, createVibezModel, createVibezSession, vibezcheck };