vibezcheck 0.5.6 → 0.5.8
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 +147 -155
- package/bin/examples.js +0 -0
- package/bin/vibezcheck.js +0 -0
- package/dist/react/index.d.mts +41 -9
- package/dist/react/index.d.ts +41 -9
- package/dist/react/index.js +944 -252
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +944 -252
- package/dist/react/index.mjs.map +1 -1
- package/examples/nextjs-app-router-openai/README.md +8 -6
- package/examples/nextjs-app-router-openai/app/api/chat/route.ts +14 -6
- package/examples/nextjs-app-router-openai/app/page.tsx +68 -22
- package/examples/nextjs-app-router-openai/package.json +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -1,246 +1,238 @@
|
|
|
1
1
|
# ✦ VibezCheck
|
|
2
2
|
|
|
3
|
-
> **
|
|
4
|
-
>
|
|
3
|
+
> **Track AI token spend and bill users in real time. Setup in 1 line.**
|
|
4
|
+
> No database needed. No added latency.
|
|
5
5
|
|
|
6
|
-
[](https://npmjs.org/package/vibezcheck)
|
|
6
|
+
[](https://npmjs.org/package/vibezcheck)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
|
-
[]()
|
|
10
|
+
[]()
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
13
|
-
### The
|
|
14
|
+
### The 1-Line Setup
|
|
14
15
|
|
|
16
|
+
**1. On your server:** wrap your model to track spending and set a profit margin
|
|
15
17
|
```typescript
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const model = vibezcheck(openai('gpt-4o-mini'), { pricing: { margin: 1.3 } });
|
|
19
|
+
```
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
**2. On your frontend:** drop in the component to see spendings in real time
|
|
22
|
+
```tsx
|
|
20
23
|
<VibezCheck messages={messages} />
|
|
21
24
|
```
|
|
22
25
|
|
|
26
|
+
That’s it. You get real-time token tracking, live dollar costs, runaway loop protection, and a sleek spending HUD.
|
|
27
|
+
|
|
23
28
|
---
|
|
24
29
|
|
|
25
|
-
##
|
|
30
|
+
## What VibezCheck does for you
|
|
31
|
+
|
|
32
|
+
When you build an AI app, chatbot, or agent:
|
|
26
33
|
|
|
27
|
-
*
|
|
28
|
-
* **🛡️
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
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`.
|
|
34
|
+
* **👀 See spending in real time**: You and your users can see the exact cost (e.g. `$0.0014`) and token count for every turn as it streams in.
|
|
35
|
+
* **🛡️ Never get a surprise $500 bill**: A built-in `$0.50` circuit breaker stops runaway prompts or infinite agent loops automatically before they drain your credit card.
|
|
36
|
+
* **💰 Turn costs into profit**: Add `pricing: { margin: 1.3 }` to mark up wholesale API prices by 30%. You make money on every message without writing custom billing code.
|
|
37
|
+
* **🤖 Works with multiple models**: If a conversation uses GPT-4o-mini, Claude 3.5, or Gemini, VibezCheck automatically breaks down the spending per model.
|
|
38
|
+
* **🆓 Zero database required**: Test locally on `localhost:3000` with zero database tables and zero Stripe keys. It runs straight in memory.
|
|
39
|
+
* **⚡ 0ms added latency**: Streaming is direct and transparent. Spending telemetry attaches cleanly at the very end of the stream without delaying first-token response time.
|
|
40
|
+
* **🧹 Clean context window**: Telemetry stays out of your prompts. When messages get sent back to the model on the next turn, telemetry is automatically stripped so you never waste tokens.
|
|
36
41
|
|
|
37
42
|
---
|
|
38
43
|
|
|
39
|
-
##
|
|
44
|
+
## 🚀 End-to-End Chatbot Example (Next.js App Router)
|
|
45
|
+
|
|
46
|
+
Here is a complete, copy-paste ready AI chatbot with live per-message spending receipts and the floating financial HUD:
|
|
47
|
+
|
|
48
|
+
### 1. Install Dependencies
|
|
40
49
|
|
|
41
50
|
```bash
|
|
42
51
|
npm install vibezcheck ai @ai-sdk/openai @ai-sdk/react stripe
|
|
43
52
|
```
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
## ⚡ Quickstart: Zero-DB Dev Mode to Production
|
|
48
|
-
|
|
49
|
-
### 1. Next.js 15 API Route (`app/api/chat/route.ts`)
|
|
54
|
+
### 2. Server Route (`app/api/chat/route.ts`)
|
|
50
55
|
|
|
51
56
|
```typescript
|
|
52
|
-
import { streamText } from 'ai';
|
|
57
|
+
import { convertToModelMessages, streamText, UIMessage } from 'ai';
|
|
53
58
|
import { openai } from '@ai-sdk/openai';
|
|
54
59
|
import { vibezcheck } from 'vibezcheck';
|
|
55
60
|
|
|
61
|
+
export const maxDuration = 30;
|
|
62
|
+
|
|
56
63
|
export async function POST(req: Request) {
|
|
57
|
-
const { messages } = await req.json();
|
|
64
|
+
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
58
65
|
|
|
59
66
|
const result = streamText({
|
|
60
|
-
//
|
|
67
|
+
// ✦ 1 Line: track costs, add 30% profit margin, and set $0.50 runaway safety fuse
|
|
61
68
|
model: vibezcheck(openai('gpt-4o-mini'), {
|
|
62
|
-
customer: 'user_alex@example.com', // Stripe customer ID
|
|
69
|
+
customer: 'user_alex@example.com', // User email or Stripe customer ID
|
|
63
70
|
pricing: { margin: 1.3 }, // +30% profit margin
|
|
64
|
-
maxCostPerCallUSD: 0.50, //
|
|
71
|
+
maxCostPerCallUSD: 0.50, // Auto-stops if call exceeds $0.50
|
|
65
72
|
}),
|
|
66
|
-
|
|
73
|
+
instructions: 'You are a helpful AI assistant.',
|
|
74
|
+
messages: await convertToModelMessages(messages),
|
|
67
75
|
});
|
|
68
76
|
|
|
69
|
-
|
|
77
|
+
// ✦ Transmits stream with verified spending telemetry attached
|
|
78
|
+
return vibezcheck.toResponse(result);
|
|
70
79
|
}
|
|
71
80
|
```
|
|
72
81
|
|
|
73
|
-
###
|
|
82
|
+
### 3. Frontend Client (`app/page.tsx`)
|
|
74
83
|
|
|
75
84
|
```tsx
|
|
76
85
|
'use client';
|
|
77
86
|
|
|
78
87
|
import { useChat } from '@ai-sdk/react';
|
|
88
|
+
import { DefaultChatTransport } from 'ai';
|
|
79
89
|
import { useState } from 'react';
|
|
80
|
-
import { VibezCheck } from 'vibezcheck/ui';
|
|
90
|
+
import { VibezReceipt, VibezCheck } from 'vibezcheck/ui';
|
|
81
91
|
|
|
82
|
-
export default function
|
|
92
|
+
export default function ChatPage() {
|
|
83
93
|
const [input, setInput] = useState('');
|
|
84
|
-
const { messages, sendMessage } = useChat(
|
|
94
|
+
const { messages, sendMessage, status } = useChat({
|
|
95
|
+
transport: new DefaultChatTransport({
|
|
96
|
+
api: '/api/chat',
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
85
99
|
|
|
86
100
|
return (
|
|
87
|
-
<div className="flex flex-col w-full max-w-
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
<div className="flex flex-col w-full max-w-lg py-20 mx-auto px-4 min-h-screen">
|
|
102
|
+
{/* Messages Stream */}
|
|
103
|
+
<div className="flex-1 space-y-4 mb-28">
|
|
104
|
+
{messages.map((message) => (
|
|
105
|
+
<div
|
|
106
|
+
key={message.id}
|
|
107
|
+
className={`p-4 rounded-2xl border ${
|
|
108
|
+
message.role === 'user'
|
|
109
|
+
? 'bg-zinc-100 dark:bg-zinc-800 border-zinc-200 dark:border-zinc-700 ml-10'
|
|
110
|
+
: 'bg-white dark:bg-zinc-900 border-zinc-200 dark:border-zinc-800 mr-10 shadow-sm'
|
|
111
|
+
}`}
|
|
112
|
+
>
|
|
113
|
+
<div className="text-xs font-semibold uppercase tracking-wider text-zinc-400 mb-1.5">
|
|
114
|
+
{message.role === 'user' ? 'You' : 'Assistant'}
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
{/* Message Text */}
|
|
118
|
+
<div className="text-sm whitespace-pre-wrap leading-relaxed">
|
|
119
|
+
{message.parts
|
|
120
|
+
? message.parts.map((part, index) => {
|
|
121
|
+
switch (part.type) {
|
|
122
|
+
case 'text':
|
|
123
|
+
return <span key={index}>{part.text}</span>;
|
|
124
|
+
default:
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
: message.content}
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
{/* ✦ 1 Line: Micro-Receipt showing tokens, micro-cost, model, and latency */}
|
|
132
|
+
{message.role === 'assistant' && (
|
|
133
|
+
<div className="mt-3 flex justify-end">
|
|
134
|
+
<VibezReceipt message={message} />
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
))}
|
|
139
|
+
|
|
140
|
+
{status === 'streaming' && (
|
|
141
|
+
<div className="text-xs text-zinc-400 italic">Assistant is typing...</div>
|
|
142
|
+
)}
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
{/* Input Form */}
|
|
100
146
|
<form
|
|
101
|
-
onSubmit={e => {
|
|
147
|
+
onSubmit={(e) => {
|
|
102
148
|
e.preventDefault();
|
|
149
|
+
if (!input.trim()) return;
|
|
103
150
|
sendMessage({ text: input });
|
|
104
151
|
setInput('');
|
|
105
152
|
}}
|
|
153
|
+
className="fixed bottom-0 left-0 right-0 p-4 bg-white/80 dark:bg-zinc-950/80 backdrop-blur-md border-t border-zinc-200 dark:border-zinc-800"
|
|
106
154
|
>
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
155
|
+
<div className="max-w-lg mx-auto flex gap-2">
|
|
156
|
+
<input
|
|
157
|
+
className="flex-1 p-3 text-sm rounded-xl border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-900 shadow-sm focus:outline-none focus:ring-2 focus:ring-zinc-900 dark:focus:ring-zinc-100"
|
|
158
|
+
value={input}
|
|
159
|
+
placeholder="Type your prompt..."
|
|
160
|
+
onChange={(e) => setInput(e.target.value)}
|
|
161
|
+
/>
|
|
162
|
+
<button
|
|
163
|
+
type="submit"
|
|
164
|
+
disabled={status === 'streaming' || !input.trim()}
|
|
165
|
+
className="px-5 py-3 bg-zinc-900 dark:bg-zinc-100 text-white dark:text-zinc-900 text-sm font-semibold rounded-xl hover:opacity-90 disabled:opacity-50 transition"
|
|
166
|
+
>
|
|
167
|
+
Send
|
|
168
|
+
</button>
|
|
169
|
+
</div>
|
|
113
170
|
</form>
|
|
114
171
|
|
|
115
|
-
{/* ✦ 1
|
|
172
|
+
{/* ✦ 1 Line: Floating HUD showing real-time spending and tokens */}
|
|
116
173
|
<VibezCheck messages={messages} />
|
|
117
174
|
</div>
|
|
118
175
|
);
|
|
119
176
|
}
|
|
120
177
|
```
|
|
121
178
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
## 💳 Commercial SaaS Use Cases
|
|
125
|
-
|
|
126
|
-
### 1. Credit Wallet Top-Ups & Checkout (`BillingHelper`)
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { BillingHelper } from 'vibezcheck';
|
|
179
|
+
### 4. Environment Variables (`.env.local`)
|
|
130
180
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// Customer purchases $20 in AI usage credits
|
|
134
|
-
export async function POST(req: Request) {
|
|
135
|
-
const { customerId } = await req.json();
|
|
136
|
-
|
|
137
|
-
const checkoutUrl = await billing.createTopUpSession({
|
|
138
|
-
customerId,
|
|
139
|
-
amountCents: 2000, // $20.00
|
|
140
|
-
returnUrl: 'https://myapp.com/dashboard',
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
return Response.json({ url: checkoutUrl });
|
|
144
|
-
}
|
|
181
|
+
```env
|
|
182
|
+
OPENAI_API_KEY=sk-...
|
|
145
183
|
```
|
|
146
184
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
Issue customer API keys (`vz_live_...`) backed by Stripe customer metadata—zero database required:
|
|
150
|
-
|
|
151
|
-
```typescript
|
|
152
|
-
import { ApiKeyAuth } from 'vibezcheck';
|
|
153
|
-
import Stripe from 'stripe';
|
|
185
|
+
---
|
|
154
186
|
|
|
155
|
-
|
|
156
|
-
const auth = new ApiKeyAuth(stripe);
|
|
187
|
+
## The UI Components (Zero Props Needed)
|
|
157
188
|
|
|
158
|
-
|
|
159
|
-
const { apiKey } = await auth.createKey({
|
|
160
|
-
customerId: 'cus_123',
|
|
161
|
-
name: 'Production Worker Key',
|
|
162
|
-
});
|
|
163
|
-
// => "vz_live_9f83b2..."
|
|
189
|
+
Import from `vibezcheck/ui` or `vibezcheck/react`:
|
|
164
190
|
|
|
165
|
-
|
|
166
|
-
export async function middleware(req: Request) {
|
|
167
|
-
const token = req.headers.get('Authorization')?.replace('Bearer ', '');
|
|
168
|
-
const verification = await auth.verifyKey(token);
|
|
191
|
+
### 1. `<VibezCheck messages={messages} />`
|
|
169
192
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
193
|
+
A floating financial HUD and expandable card:
|
|
194
|
+
* **⇅ Unit Swap**: Click the `⇅` icon to switch between **Dollar Cost** (`$0.0028`) and **Tokens** (`1,420 tok`).
|
|
195
|
+
* **Session vs Turn**: Switch between `[Session]` (total conversation spend) and `[Latest Turn]` (last reply).
|
|
196
|
+
* **Multi-Model Breakdown**: If you use multiple models in one chat, it shows the exact split for each model.
|
|
197
|
+
* **Customer Privacy by Default**: End-users only see their billed cost. Your wholesale costs and profit margins are hidden by default.
|
|
173
198
|
|
|
174
|
-
|
|
175
|
-
|
|
199
|
+
```tsx
|
|
200
|
+
<VibezCheck
|
|
201
|
+
messages={messages}
|
|
202
|
+
remainingBalanceUSD={10.00}
|
|
203
|
+
onTopUp={(amount) => console.log('User wants to top up credits:', amount)}
|
|
204
|
+
/>
|
|
176
205
|
```
|
|
177
206
|
|
|
178
|
-
###
|
|
179
|
-
|
|
180
|
-
Set a hard $1.00 session budget across multiple LLM steps and external tools:
|
|
207
|
+
### 2. `<VibezReceipt message={message} />`
|
|
181
208
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const session = new AgentSession({
|
|
187
|
-
customer: 'cus_agent_user',
|
|
188
|
-
sessionBudgetUSD: 1.00, // Hard ceiling for entire session
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// Wrap external tools with financial tracking
|
|
192
|
-
const webSearchTool = wrapTool({
|
|
193
|
-
name: 'web_search',
|
|
194
|
-
costUSD: 0.01,
|
|
195
|
-
execute: async ({ query }) => fetchSearch(query),
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Run LLM model bound to this session
|
|
199
|
-
const sessionModel = session.model(openai('gpt-4o'));
|
|
209
|
+
A small, elegant badge under each assistant message:
|
|
210
|
+
```tsx
|
|
211
|
+
<VibezReceipt message={message} />
|
|
212
|
+
// Renders: ✦ $0.0001 · 31 tok · gpt-4o-mini
|
|
200
213
|
```
|
|
201
214
|
|
|
202
215
|
---
|
|
203
216
|
|
|
204
|
-
##
|
|
217
|
+
## Multi-Model Sessions (Automatic Breakdown)
|
|
205
218
|
|
|
206
|
-
If
|
|
219
|
+
If your app routes between different models (e.g. `gpt-4o-mini` for quick chat and `claude-3-5-sonnet` for coding):
|
|
207
220
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// Replace: import { stripe } from '@stripe/ai-sdk/provider';
|
|
213
|
-
import { stripe } from 'vibezcheck/stripe/provider';
|
|
221
|
+
VibezCheck automatically detects every model used and lists them in the HUD:
|
|
222
|
+
* `gpt-4o-mini (1 turn)`: 31 tok · $0.0001
|
|
223
|
+
* `claude-3-5-sonnet (1 turn)`: 420 tok · $0.0068
|
|
214
224
|
|
|
215
|
-
|
|
216
|
-
import { createTokenMeter } from 'vibezcheck/stripe/token-meter';
|
|
217
|
-
```
|
|
225
|
+
Click any model to see its specific spending.
|
|
218
226
|
|
|
219
227
|
---
|
|
220
228
|
|
|
221
|
-
##
|
|
222
|
-
|
|
223
|
-
Audit your codebase to detect unmetered AI endpoints before shipping to production:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
npx vibezcheck audit
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### CI/CD Mode
|
|
230
|
-
Fail the build if unmetered AI routes are detected:
|
|
231
|
-
```bash
|
|
232
|
-
npx vibezcheck audit --ci
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
---
|
|
229
|
+
## Need Stripe Billing? (Optional)
|
|
236
230
|
|
|
237
|
-
|
|
231
|
+
When you want to charge real money, VibezCheck has built-in Stripe helpers:
|
|
238
232
|
|
|
239
|
-
* **
|
|
240
|
-
* **
|
|
241
|
-
* **
|
|
242
|
-
* **[Native OpenAI Streaming](examples/03-native-openai-stream.ts)**: Zero-latency stream wrapper for the official `openai` Node SDK.
|
|
243
|
-
* **[Claude 3.7 Reasoning Tokens](examples/04-claude-thinking.ts)**: Tracking hidden thought tokens with Anthropic SDK.
|
|
233
|
+
* **Prepaid Credits**: Let users buy credit balance with Stripe Checkout (`BillingHelper.createTopUpSession`).
|
|
234
|
+
* **Customer API Keys**: Issue `vz_live_...` keys saved in Stripe customer metadata (`ApiKeyAuth`).
|
|
235
|
+
* **Agent Session Ceilings**: Limit a multi-step agent to a hard $1.00 budget with `AgentSession`.
|
|
244
236
|
|
|
245
237
|
---
|
|
246
238
|
|
package/bin/examples.js
CHANGED
|
File without changes
|
package/bin/vibezcheck.js
CHANGED
|
File without changes
|
package/dist/react/index.d.mts
CHANGED
|
@@ -236,6 +236,19 @@ interface VibezBillingModalProps {
|
|
|
236
236
|
*/
|
|
237
237
|
declare const VibezBillingModal: React__default.FC<VibezBillingModalProps>;
|
|
238
238
|
|
|
239
|
+
interface ModelUsageDetail {
|
|
240
|
+
model: string;
|
|
241
|
+
displayName: string;
|
|
242
|
+
tokens: number;
|
|
243
|
+
promptTokens: number;
|
|
244
|
+
completionTokens: number;
|
|
245
|
+
reasoningTokens: number;
|
|
246
|
+
cachedTokens: number;
|
|
247
|
+
billedUSD: number;
|
|
248
|
+
wholesaleUSD: number;
|
|
249
|
+
profitUSD: number;
|
|
250
|
+
turns: number;
|
|
251
|
+
}
|
|
239
252
|
interface VibezCheckProps {
|
|
240
253
|
/** Messages array from AI SDK useChat() — automatically aggregates tokens & costs */
|
|
241
254
|
messages?: any[];
|
|
@@ -245,22 +258,34 @@ interface VibezCheckProps {
|
|
|
245
258
|
model?: string;
|
|
246
259
|
/** Developer profit margin multiplier (default: 1.25 for +25% margin) */
|
|
247
260
|
margin?: number;
|
|
261
|
+
/**
|
|
262
|
+
* Whether to display developer wholesale API costs.
|
|
263
|
+
* Default: false (hidden from end-users)
|
|
264
|
+
*/
|
|
265
|
+
showWholesale?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Whether to display developer profit margin percentage and net profit.
|
|
268
|
+
* Default: false (hidden from end-users)
|
|
269
|
+
*/
|
|
270
|
+
showMargin?: boolean;
|
|
248
271
|
/** Manual total cost override in USD */
|
|
249
272
|
totalCostUSD?: number;
|
|
250
273
|
/** Manual total tokens override */
|
|
251
274
|
totalTokens?: number;
|
|
252
275
|
/** Remaining customer credit balance in USD */
|
|
253
276
|
remainingBalanceUSD?: number;
|
|
254
|
-
/** Screen position (default: 'bottom-
|
|
255
|
-
position?: 'bottom-center' | 'bottom-right' | 'bottom-left' | 'top-center';
|
|
277
|
+
/** Screen position (default: 'bottom-left') */
|
|
278
|
+
position?: 'bottom-center' | 'bottom-right' | 'bottom-left' | 'top-center' | 'top-right' | 'top-left';
|
|
256
279
|
/** Color theme (default: 'auto') */
|
|
257
280
|
theme?: 'dark' | 'light' | 'auto';
|
|
258
281
|
/** Force dev mode banner on/off (defaults to auto-detect) */
|
|
259
282
|
devMode?: boolean;
|
|
260
283
|
/** Additional CSS class names */
|
|
261
284
|
className?: string;
|
|
262
|
-
/**
|
|
263
|
-
|
|
285
|
+
/** Custom header title (default: 'Session Usage') */
|
|
286
|
+
title?: string;
|
|
287
|
+
/** Callback triggered when user clicks 'Top Up' button or preset amount pills */
|
|
288
|
+
onTopUp?: (amount?: number) => void;
|
|
264
289
|
/** Callback fired whenever cost or token counts update */
|
|
265
290
|
onCostUpdate?: (summary: {
|
|
266
291
|
totalCostUSD: number;
|
|
@@ -268,6 +293,7 @@ interface VibezCheckProps {
|
|
|
268
293
|
profitUSD: number;
|
|
269
294
|
totalTokens: number;
|
|
270
295
|
isDevMode: boolean;
|
|
296
|
+
byModel?: Record<string, ModelUsageDetail>;
|
|
271
297
|
}) => void;
|
|
272
298
|
/** Whether popover is initially open (default: false) */
|
|
273
299
|
defaultOpen?: boolean;
|
|
@@ -275,11 +301,17 @@ interface VibezCheckProps {
|
|
|
275
301
|
/**
|
|
276
302
|
* ✦ <VibezCheck /> (from 'vibezcheck/ui' or 'vibezcheck/react')
|
|
277
303
|
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
304
|
+
* An ultra-modern, interactive fintech AI financial HUD inspired by Aztec Web3 design.
|
|
305
|
+
* Features:
|
|
306
|
+
* - Precise token accounting with zero double counting (server telemetry is authoritative)
|
|
307
|
+
* - Multi-model session breakdown (details and distributions across models)
|
|
308
|
+
* - Huge hero typography with interactive USD ⇄ Token unit toggle (⇅)
|
|
309
|
+
* - Segmented Session ⇄ Latest Turn pill switcher
|
|
310
|
+
* - Interactive preset pills ([$5] [$10] [$25] [Max])
|
|
311
|
+
* - Hidden wholesale pricing and margin by default (controlled via showWholesale & showMargin props)
|
|
312
|
+
* - Soft creamy ivory card with rounded-3xl corners and vibrant orchid action buttons
|
|
281
313
|
*/
|
|
282
|
-
declare function VibezCheck({ messages, events, model, margin, totalCostUSD: manualCost, totalTokens: manualTokens, remainingBalanceUSD, position, theme, devMode, className, onTopUp, onCostUpdate, defaultOpen, }: VibezCheckProps): React__default.JSX.Element;
|
|
314
|
+
declare function VibezCheck({ messages, events, model, margin, showWholesale, showMargin, totalCostUSD: manualCost, totalTokens: manualTokens, remainingBalanceUSD, position, theme, devMode, className, title, onTopUp, onCostUpdate, defaultOpen, }: VibezCheckProps): React__default.JSX.Element;
|
|
283
315
|
declare const VibezPill: typeof VibezCheck;
|
|
284
316
|
|
|
285
|
-
export { type CustomStorageAdapter, type SessionPersistenceMode, type SessionState, type SessionTurnRecord, type UseVibezChatOptions, VibezBillingModal, type VibezBillingModalProps, type VibezBillingNotice, type VibezChatMessage, VibezCheck, type VibezCheckProps, VibezPill, VibezReceipt, type VibezReceiptProps, VibezSessionBadge, type VibezSessionBadgeProps, VibezSessionContext, type VibezSessionContextValue, VibezSessionProvider, type VibezSessionProviderProps, VibezSessionWidget, type VibezSessionWidgetProps, useVibez, useVibezChat, useVibezSession };
|
|
317
|
+
export { type CustomStorageAdapter, type ModelUsageDetail, type SessionPersistenceMode, type SessionState, type SessionTurnRecord, type UseVibezChatOptions, VibezBillingModal, type VibezBillingModalProps, type VibezBillingNotice, type VibezChatMessage, VibezCheck, type VibezCheckProps, VibezPill, VibezReceipt, type VibezReceiptProps, VibezSessionBadge, type VibezSessionBadgeProps, VibezSessionContext, type VibezSessionContextValue, VibezSessionProvider, type VibezSessionProviderProps, VibezSessionWidget, type VibezSessionWidgetProps, useVibez, useVibezChat, useVibezSession };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -236,6 +236,19 @@ interface VibezBillingModalProps {
|
|
|
236
236
|
*/
|
|
237
237
|
declare const VibezBillingModal: React__default.FC<VibezBillingModalProps>;
|
|
238
238
|
|
|
239
|
+
interface ModelUsageDetail {
|
|
240
|
+
model: string;
|
|
241
|
+
displayName: string;
|
|
242
|
+
tokens: number;
|
|
243
|
+
promptTokens: number;
|
|
244
|
+
completionTokens: number;
|
|
245
|
+
reasoningTokens: number;
|
|
246
|
+
cachedTokens: number;
|
|
247
|
+
billedUSD: number;
|
|
248
|
+
wholesaleUSD: number;
|
|
249
|
+
profitUSD: number;
|
|
250
|
+
turns: number;
|
|
251
|
+
}
|
|
239
252
|
interface VibezCheckProps {
|
|
240
253
|
/** Messages array from AI SDK useChat() — automatically aggregates tokens & costs */
|
|
241
254
|
messages?: any[];
|
|
@@ -245,22 +258,34 @@ interface VibezCheckProps {
|
|
|
245
258
|
model?: string;
|
|
246
259
|
/** Developer profit margin multiplier (default: 1.25 for +25% margin) */
|
|
247
260
|
margin?: number;
|
|
261
|
+
/**
|
|
262
|
+
* Whether to display developer wholesale API costs.
|
|
263
|
+
* Default: false (hidden from end-users)
|
|
264
|
+
*/
|
|
265
|
+
showWholesale?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Whether to display developer profit margin percentage and net profit.
|
|
268
|
+
* Default: false (hidden from end-users)
|
|
269
|
+
*/
|
|
270
|
+
showMargin?: boolean;
|
|
248
271
|
/** Manual total cost override in USD */
|
|
249
272
|
totalCostUSD?: number;
|
|
250
273
|
/** Manual total tokens override */
|
|
251
274
|
totalTokens?: number;
|
|
252
275
|
/** Remaining customer credit balance in USD */
|
|
253
276
|
remainingBalanceUSD?: number;
|
|
254
|
-
/** Screen position (default: 'bottom-
|
|
255
|
-
position?: 'bottom-center' | 'bottom-right' | 'bottom-left' | 'top-center';
|
|
277
|
+
/** Screen position (default: 'bottom-left') */
|
|
278
|
+
position?: 'bottom-center' | 'bottom-right' | 'bottom-left' | 'top-center' | 'top-right' | 'top-left';
|
|
256
279
|
/** Color theme (default: 'auto') */
|
|
257
280
|
theme?: 'dark' | 'light' | 'auto';
|
|
258
281
|
/** Force dev mode banner on/off (defaults to auto-detect) */
|
|
259
282
|
devMode?: boolean;
|
|
260
283
|
/** Additional CSS class names */
|
|
261
284
|
className?: string;
|
|
262
|
-
/**
|
|
263
|
-
|
|
285
|
+
/** Custom header title (default: 'Session Usage') */
|
|
286
|
+
title?: string;
|
|
287
|
+
/** Callback triggered when user clicks 'Top Up' button or preset amount pills */
|
|
288
|
+
onTopUp?: (amount?: number) => void;
|
|
264
289
|
/** Callback fired whenever cost or token counts update */
|
|
265
290
|
onCostUpdate?: (summary: {
|
|
266
291
|
totalCostUSD: number;
|
|
@@ -268,6 +293,7 @@ interface VibezCheckProps {
|
|
|
268
293
|
profitUSD: number;
|
|
269
294
|
totalTokens: number;
|
|
270
295
|
isDevMode: boolean;
|
|
296
|
+
byModel?: Record<string, ModelUsageDetail>;
|
|
271
297
|
}) => void;
|
|
272
298
|
/** Whether popover is initially open (default: false) */
|
|
273
299
|
defaultOpen?: boolean;
|
|
@@ -275,11 +301,17 @@ interface VibezCheckProps {
|
|
|
275
301
|
/**
|
|
276
302
|
* ✦ <VibezCheck /> (from 'vibezcheck/ui' or 'vibezcheck/react')
|
|
277
303
|
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
304
|
+
* An ultra-modern, interactive fintech AI financial HUD inspired by Aztec Web3 design.
|
|
305
|
+
* Features:
|
|
306
|
+
* - Precise token accounting with zero double counting (server telemetry is authoritative)
|
|
307
|
+
* - Multi-model session breakdown (details and distributions across models)
|
|
308
|
+
* - Huge hero typography with interactive USD ⇄ Token unit toggle (⇅)
|
|
309
|
+
* - Segmented Session ⇄ Latest Turn pill switcher
|
|
310
|
+
* - Interactive preset pills ([$5] [$10] [$25] [Max])
|
|
311
|
+
* - Hidden wholesale pricing and margin by default (controlled via showWholesale & showMargin props)
|
|
312
|
+
* - Soft creamy ivory card with rounded-3xl corners and vibrant orchid action buttons
|
|
281
313
|
*/
|
|
282
|
-
declare function VibezCheck({ messages, events, model, margin, totalCostUSD: manualCost, totalTokens: manualTokens, remainingBalanceUSD, position, theme, devMode, className, onTopUp, onCostUpdate, defaultOpen, }: VibezCheckProps): React__default.JSX.Element;
|
|
314
|
+
declare function VibezCheck({ messages, events, model, margin, showWholesale, showMargin, totalCostUSD: manualCost, totalTokens: manualTokens, remainingBalanceUSD, position, theme, devMode, className, title, onTopUp, onCostUpdate, defaultOpen, }: VibezCheckProps): React__default.JSX.Element;
|
|
283
315
|
declare const VibezPill: typeof VibezCheck;
|
|
284
316
|
|
|
285
|
-
export { type CustomStorageAdapter, type SessionPersistenceMode, type SessionState, type SessionTurnRecord, type UseVibezChatOptions, VibezBillingModal, type VibezBillingModalProps, type VibezBillingNotice, type VibezChatMessage, VibezCheck, type VibezCheckProps, VibezPill, VibezReceipt, type VibezReceiptProps, VibezSessionBadge, type VibezSessionBadgeProps, VibezSessionContext, type VibezSessionContextValue, VibezSessionProvider, type VibezSessionProviderProps, VibezSessionWidget, type VibezSessionWidgetProps, useVibez, useVibezChat, useVibezSession };
|
|
317
|
+
export { type CustomStorageAdapter, type ModelUsageDetail, type SessionPersistenceMode, type SessionState, type SessionTurnRecord, type UseVibezChatOptions, VibezBillingModal, type VibezBillingModalProps, type VibezBillingNotice, type VibezChatMessage, VibezCheck, type VibezCheckProps, VibezPill, VibezReceipt, type VibezReceiptProps, VibezSessionBadge, type VibezSessionBadgeProps, VibezSessionContext, type VibezSessionContextValue, VibezSessionProvider, type VibezSessionProviderProps, VibezSessionWidget, type VibezSessionWidgetProps, useVibez, useVibezChat, useVibezSession };
|