vibezcheck 0.4.2 → 0.5.3

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 (80) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +249 -273
  3. package/bin/vibezcheck.js +4 -4
  4. package/dist/ai-sdk/index.d.mts +28 -59
  5. package/dist/ai-sdk/index.d.ts +28 -59
  6. package/dist/ai-sdk/index.js +307 -69
  7. package/dist/ai-sdk/index.js.map +1 -1
  8. package/dist/ai-sdk/index.mjs +307 -69
  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 +1433 -0
  13. package/dist/ai-sdk/middleware.js.map +1 -0
  14. package/dist/ai-sdk/middleware.mjs +1396 -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 +1542 -2
  21. package/dist/billing/index.js.map +1 -1
  22. package/dist/billing/index.mjs +1537 -1
  23. package/dist/billing/index.mjs.map +1 -1
  24. package/dist/cli/index.js +59 -7
  25. package/dist/cli/index.js.map +1 -1
  26. package/dist/cli/index.mjs +59 -7
  27. package/dist/cli/index.mjs.map +1 -1
  28. package/dist/{client-ynfWcHX6.d.ts → client-BORmJy8s.d.ts} +1 -1
  29. package/dist/{client-w_hWhQ6g.d.mts → client-CbuXmoXz.d.mts} +1 -1
  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 +1451 -0
  33. package/dist/compat/stripe-meter.js.map +1 -0
  34. package/dist/compat/stripe-meter.mjs +1414 -0
  35. package/dist/compat/stripe-meter.mjs.map +1 -0
  36. package/dist/compat/stripe-provider.d.mts +34 -0
  37. package/dist/compat/stripe-provider.d.ts +34 -0
  38. package/dist/compat/stripe-provider.js +1620 -0
  39. package/dist/compat/stripe-provider.js.map +1 -0
  40. package/dist/compat/stripe-provider.mjs +1587 -0
  41. package/dist/compat/stripe-provider.mjs.map +1 -0
  42. package/dist/compat/token-meter.d.mts +28 -0
  43. package/dist/compat/token-meter.d.ts +28 -0
  44. package/dist/compat/token-meter.js +1320 -0
  45. package/dist/compat/token-meter.js.map +1 -0
  46. package/dist/compat/token-meter.mjs +1283 -0
  47. package/dist/compat/token-meter.mjs.map +1 -0
  48. package/dist/customers/index.d.mts +1 -1
  49. package/dist/customers/index.d.ts +1 -1
  50. package/dist/customers/index.js.map +1 -1
  51. package/dist/customers/index.mjs.map +1 -1
  52. package/dist/index.d.mts +25 -11
  53. package/dist/index.d.ts +25 -11
  54. package/dist/index.js +810 -72
  55. package/dist/index.js.map +1 -1
  56. package/dist/index.mjs +798 -72
  57. package/dist/index.mjs.map +1 -1
  58. package/dist/meter/index.d.mts +2 -2
  59. package/dist/meter/index.d.ts +2 -2
  60. package/dist/meter/index.js +176 -42
  61. package/dist/meter/index.js.map +1 -1
  62. package/dist/meter/index.mjs +176 -42
  63. package/dist/meter/index.mjs.map +1 -1
  64. package/dist/pricing/index.d.mts +15 -4
  65. package/dist/pricing/index.d.ts +15 -4
  66. package/dist/pricing/index.js +165 -29
  67. package/dist/pricing/index.js.map +1 -1
  68. package/dist/pricing/index.mjs +164 -29
  69. package/dist/pricing/index.mjs.map +1 -1
  70. package/dist/react/index.d.mts +46 -2
  71. package/dist/react/index.d.ts +46 -2
  72. package/dist/react/index.js +471 -29
  73. package/dist/react/index.js.map +1 -1
  74. package/dist/react/index.mjs +469 -29
  75. package/dist/react/index.mjs.map +1 -1
  76. package/dist/{types-Mozk4-Mr.d.mts → types-6P71CXAD.d.mts} +16 -6
  77. package/dist/{types-Mozk4-Mr.d.ts → types-6P71CXAD.d.ts} +16 -6
  78. package/dist/with-billing-Bj6Ya_Iy.d.ts +49 -0
  79. package/dist/with-billing-DndWGxL8.d.mts +49 -0
  80. package/package.json +35 -10
@@ -3,11 +3,15 @@ import Stripe from 'stripe';
3
3
  /**
4
4
  * Known supported model identifiers with full IDE autocomplete
5
5
  */
6
- type SupportedOpenAIModel = 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/o1' | 'openai/o1-mini' | 'openai/o3' | 'openai/o3-mini' | 'openai/gpt-5' | 'openai/gpt-5-mini' | 'openai/gpt-5.6-sol' | 'openai/gpt-5.6-terra' | 'openai/gpt-5.6-luna' | 'gpt-4o' | 'gpt-4o-mini' | 'o1' | 'o1-mini' | 'o3' | 'o3-mini' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-5.6-luna';
7
- type SupportedAnthropicModel = 'anthropic/claude-3-7-sonnet' | 'anthropic/claude-3-5-sonnet' | 'anthropic/claude-3-5-haiku' | 'anthropic/claude-opus-5' | 'anthropic/haiku-4.5' | 'claude-3-7-sonnet' | 'claude-3-5-sonnet' | 'claude-3-5-haiku' | 'claude-opus-5' | 'haiku-4.5';
8
- type SupportedGoogleModel = 'google/gemini-2.0-flash' | 'google/gemini-1.5-pro' | 'google/gemini-3.7-flash' | 'google/gemini-3.1-pro' | 'gemini-2.0-flash' | 'gemini-1.5-pro' | 'gemini-3.7-flash' | 'gemini-3.1-pro';
9
- type SupportedDeepSeekModel = 'deepseek/deepseek-chat' | 'deepseek/deepseek-reasoner' | 'deepseek/deepseek-v4-pro' | 'deepseek-chat' | 'deepseek-reasoner' | 'deepseek-v4-pro';
10
- type KnownModel = SupportedOpenAIModel | SupportedAnthropicModel | SupportedGoogleModel | SupportedDeepSeekModel;
6
+ type SupportedOpenAIModel = 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4.5-preview' | 'openai/gpt-4.1' | 'openai/gpt-4.1-nano' | 'openai/gpt-4-turbo' | 'openai/gpt-4' | 'openai/gpt-3.5-turbo' | 'openai/o1' | 'openai/o1-mini' | 'openai/o3' | 'openai/o3-mini' | 'openai/gpt-5' | 'openai/gpt-5-mini' | 'openai/gpt-5.6-sol' | 'openai/gpt-5.6-terra' | 'openai/gpt-5.6-luna' | 'openai/text-embedding-3-small' | 'openai/text-embedding-3-large' | 'gpt-4o' | 'gpt-4o-mini' | 'gpt-4.5-preview' | 'gpt-4.5' | 'gpt-4.1' | 'gpt-4.1-nano' | 'gpt-4-turbo' | 'gpt-4' | 'gpt-3.5-turbo' | 'o1' | 'o1-mini' | 'o3' | 'o3-mini' | 'gpt-5' | 'gpt-5-mini' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-5.6-luna';
7
+ type SupportedAnthropicModel = 'anthropic/claude-3-7-sonnet' | 'anthropic/claude-3-5-sonnet' | 'anthropic/claude-3-5-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3-haiku' | 'anthropic/claude-2.1' | 'anthropic/claude-2.0' | 'anthropic/claude-opus-5' | 'anthropic/haiku-4.5' | 'claude-3-7-sonnet' | 'claude-3-5-sonnet' | 'claude-3-5-haiku' | 'claude-3-opus' | 'claude-3-haiku' | 'claude-2.1' | 'claude-2.0' | 'claude-opus-5' | 'haiku-4.5';
8
+ type SupportedGoogleModel = 'google/gemini-2.5-pro' | 'google/gemini-2.5-flash' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.0-pro' | 'google/gemini-1.5-pro' | 'google/gemini-1.5-flash' | 'google/gemini-1.5-flash-8b' | 'google/gemini-1.0-pro' | 'google/gemini-3.7-flash' | 'google/gemini-3.1-pro' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.0-flash' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro' | 'gemini-1.5-pro' | 'gemini-1.5-flash' | 'gemini-1.5-flash-8b' | 'gemini-1.0-pro' | 'gemini-3.7-flash' | 'gemini-3.1-pro';
9
+ type SupportedDeepSeekModel = 'deepseek/deepseek-chat' | 'deepseek/deepseek-reasoner' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v4-pro' | 'deepseek-chat' | 'deepseek-reasoner' | 'deepseek-v3' | 'deepseek-r1' | 'deepseek-v4-pro';
10
+ type SupportedXAIModel = 'xai/grok-3' | 'xai/grok-3-mini' | 'xai/grok-2' | 'xai/grok-2-vision' | 'xai/grok-beta' | 'grok-3' | 'grok-3-mini' | 'grok-2' | 'grok-2-vision' | 'grok-beta';
11
+ type SupportedMistralModel = 'mistral/mistral-large-latest' | 'mistral/codestral-latest' | 'mistral/mistral-small-latest' | 'mistral/ministral-8b-latest' | 'mistral-large-latest' | 'codestral-latest' | 'mistral-small-latest' | 'ministral-8b-latest';
12
+ type SupportedGroqModel = 'groq/llama-3.3-70b-versatile' | 'groq/llama-3.1-70b-versatile' | 'groq/llama-3.1-8b-instant' | 'groq/deepseek-r1-distill-llama-70b' | 'llama-3.3-70b-versatile' | 'llama-3.1-70b-versatile' | 'llama-3.1-8b-instant' | 'deepseek-r1-distill-llama-70b';
13
+ type SupportedCohereModel = 'cohere/command-r-plus' | 'cohere/command-r' | 'command-r-plus' | 'command-r';
14
+ type KnownModel = SupportedOpenAIModel | SupportedAnthropicModel | SupportedGoogleModel | SupportedDeepSeekModel | SupportedXAIModel | SupportedMistralModel | SupportedGroqModel | SupportedCohereModel;
11
15
  /**
12
16
  * Union of all known model IDs with loose string fallback for custom / future models
13
17
  */
@@ -45,6 +49,12 @@ interface InferenceCost {
45
49
  cachedDiscountUSD?: number;
46
50
  /** Total computed base inference cost in USD */
47
51
  totalUSD: number;
52
+ /** Wholesale provider cost in USD */
53
+ wholesaleTotalUSD?: number;
54
+ /** Amount billed to customer in USD */
55
+ billedUSD?: number;
56
+ /** Net developer profit in USD */
57
+ profitUSD?: number;
48
58
  /** Retail price after developer markup (if markup applied) */
49
59
  retailUSD?: number;
50
60
  /** Currency (defaults to 'USD') */
@@ -316,4 +326,4 @@ interface UsageSummary {
316
326
  }>;
317
327
  }
318
328
 
319
- export { type BillingConfig as B, type CustomerParam as C, type DatabaseAdapter as D, type InferenceCost as I, type KnownModel as K, type MeterOptions as M, type PaymentProvider as P, type RecordUsageOptions as R, type StreamWrapOptions as S, type TokenUsage as T, type UsageEvent as U, VibezCircuitBreakerError as V, type UsageSummary as a, type BudgetExceededEvent as b, type CircuitBreakerOptions as c, type CustomerInfo as d, type InlineRateConfig as e, type ModelPricingRates as f, type PricingConfig as g, type SupportedAnthropicModel as h, type SupportedDeepSeekModel as i, type SupportedGoogleModel as j, type SupportedModel as k, type SupportedOpenAIModel as l, type ToolMeterOptions as m };
329
+ export { type BillingConfig as B, type CustomerParam as C, type DatabaseAdapter as D, type InferenceCost as I, type KnownModel as K, type MeterOptions as M, type PaymentProvider as P, type RecordUsageOptions as R, type StreamWrapOptions as S, type TokenUsage as T, type UsageEvent as U, VibezCircuitBreakerError as V, type UsageSummary as a, type BudgetExceededEvent as b, type CircuitBreakerOptions as c, type CustomerInfo as d, type InlineRateConfig as e, type ModelPricingRates as f, type PricingConfig as g, type SupportedAnthropicModel as h, type SupportedCohereModel as i, type SupportedDeepSeekModel as j, type SupportedGoogleModel as k, type SupportedGroqModel as l, type SupportedMistralModel as m, type SupportedModel as n, type SupportedOpenAIModel as o, type SupportedXAIModel as p, type ToolMeterOptions as q };
@@ -0,0 +1,49 @@
1
+ import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, g as PricingConfig, e as InlineRateConfig, U as UsageEvent } from './types-6P71CXAD.js';
2
+ import { V as VibezMeter } from './client-BORmJy8s.js';
3
+
4
+ interface WithBillingOptions extends CircuitBreakerOptions {
5
+ /** Customer email, user ID, or rich customer object with metadata */
6
+ customer?: CustomerParam;
7
+ /** Direct Stripe customer ID */
8
+ customerId?: string;
9
+ /** Billing mode configuration (Universal Auto-Debit, postpaid vs prepaid, pluggable providers) */
10
+ billing?: BillingConfig;
11
+ /** Profit margin & minimum charge configuration */
12
+ pricing?: PricingConfig;
13
+ /** 1-line inline pricing rate card */
14
+ rate?: InlineRateConfig;
15
+ /** Pluggable Database Sink (Supabase, Postgres, Firebase, or 1-line callback) */
16
+ database?: any | ((event: UsageEvent) => void | Promise<void>);
17
+ /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
18
+ captureOnAbort?: boolean;
19
+ /** Execution runtime environment (default: 'auto') */
20
+ runtime?: 'auto' | 'serverless' | 'edge' | 'node';
21
+ /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
22
+ stripeApiKey?: string;
23
+ /** Existing VibezMeter instance (optional) */
24
+ meter?: VibezMeter;
25
+ /** Custom meter event name */
26
+ eventName?: string;
27
+ /** Usage callback fired upon generation/stream completion */
28
+ onUsage?: (event: UsageEvent) => void | Promise<void>;
29
+ /** Custom developer metadata */
30
+ metadata?: Record<string, string | number | boolean>;
31
+ /** Suppress console warnings (default: true in test environment) */
32
+ silent?: boolean;
33
+ }
34
+ /**
35
+ * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
36
+ *
37
+ * Sane Defaults Built-In:
38
+ * - $0.50 safety ceiling per call (overridable)
39
+ * - Automatic in-flight token capture on abort
40
+ * - Automatic prompt caching discount parsing
41
+ * - Serverless lifecycle preservation
42
+ */
43
+ declare function withBilling<T extends object>(model: T, optionsOrCustomer?: CustomerParam | WithBillingOptions, extraOptions?: WithBillingOptions): T;
44
+ /**
45
+ * Convenient alias for withBilling
46
+ */
47
+ declare const meteredModel: typeof withBilling;
48
+
49
+ export { type WithBillingOptions as W, meteredModel as m, withBilling as w };
@@ -0,0 +1,49 @@
1
+ import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, g as PricingConfig, e as InlineRateConfig, U as UsageEvent } from './types-6P71CXAD.mjs';
2
+ import { V as VibezMeter } from './client-CbuXmoXz.mjs';
3
+
4
+ interface WithBillingOptions extends CircuitBreakerOptions {
5
+ /** Customer email, user ID, or rich customer object with metadata */
6
+ customer?: CustomerParam;
7
+ /** Direct Stripe customer ID */
8
+ customerId?: string;
9
+ /** Billing mode configuration (Universal Auto-Debit, postpaid vs prepaid, pluggable providers) */
10
+ billing?: BillingConfig;
11
+ /** Profit margin & minimum charge configuration */
12
+ pricing?: PricingConfig;
13
+ /** 1-line inline pricing rate card */
14
+ rate?: InlineRateConfig;
15
+ /** Pluggable Database Sink (Supabase, Postgres, Firebase, or 1-line callback) */
16
+ database?: any | ((event: UsageEvent) => void | Promise<void>);
17
+ /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
18
+ captureOnAbort?: boolean;
19
+ /** Execution runtime environment (default: 'auto') */
20
+ runtime?: 'auto' | 'serverless' | 'edge' | 'node';
21
+ /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
22
+ stripeApiKey?: string;
23
+ /** Existing VibezMeter instance (optional) */
24
+ meter?: VibezMeter;
25
+ /** Custom meter event name */
26
+ eventName?: string;
27
+ /** Usage callback fired upon generation/stream completion */
28
+ onUsage?: (event: UsageEvent) => void | Promise<void>;
29
+ /** Custom developer metadata */
30
+ metadata?: Record<string, string | number | boolean>;
31
+ /** Suppress console warnings (default: true in test environment) */
32
+ silent?: boolean;
33
+ }
34
+ /**
35
+ * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
36
+ *
37
+ * Sane Defaults Built-In:
38
+ * - $0.50 safety ceiling per call (overridable)
39
+ * - Automatic in-flight token capture on abort
40
+ * - Automatic prompt caching discount parsing
41
+ * - Serverless lifecycle preservation
42
+ */
43
+ declare function withBilling<T extends object>(model: T, optionsOrCustomer?: CustomerParam | WithBillingOptions, extraOptions?: WithBillingOptions): T;
44
+ /**
45
+ * Convenient alias for withBilling
46
+ */
47
+ declare const meteredModel: typeof withBilling;
48
+
49
+ export { type WithBillingOptions as W, meteredModel as m, withBilling as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibezcheck",
3
- "version": "0.4.2",
3
+ "version": "0.5.3",
4
4
  "description": "The 1-line Stripe Billing and Token Metering engine for LLMs. Track tokens, compute real-time dollar costs, and bill customers with 0ms added latency.",
5
5
  "author": "VibezCheck <dev@vibezcheck.xyz> (https://vibezcheck.xyz)",
6
6
  "license": "MIT",
@@ -69,6 +69,31 @@
69
69
  "types": "./dist/react/index.d.ts",
70
70
  "import": "./dist/react/index.mjs",
71
71
  "require": "./dist/react/index.js"
72
+ },
73
+ "./ui": {
74
+ "types": "./dist/react/index.d.ts",
75
+ "import": "./dist/react/index.mjs",
76
+ "require": "./dist/react/index.js"
77
+ },
78
+ "./middleware": {
79
+ "types": "./dist/ai-sdk/middleware.d.ts",
80
+ "import": "./dist/ai-sdk/middleware.mjs",
81
+ "require": "./dist/ai-sdk/middleware.js"
82
+ },
83
+ "./stripe/meter": {
84
+ "types": "./dist/compat/stripe-meter.d.ts",
85
+ "import": "./dist/compat/stripe-meter.mjs",
86
+ "require": "./dist/compat/stripe-meter.js"
87
+ },
88
+ "./stripe/provider": {
89
+ "types": "./dist/compat/stripe-provider.d.ts",
90
+ "import": "./dist/compat/stripe-provider.mjs",
91
+ "require": "./dist/compat/stripe-provider.js"
92
+ },
93
+ "./stripe/token-meter": {
94
+ "types": "./dist/compat/token-meter.d.ts",
95
+ "import": "./dist/compat/token-meter.mjs",
96
+ "require": "./dist/compat/token-meter.js"
72
97
  }
73
98
  },
74
99
  "bin": {
@@ -84,7 +109,7 @@
84
109
  "scripts": {
85
110
  "build": "tsup",
86
111
  "clean": "rm -rf dist",
87
- "test": "jest",
112
+ "test": "jest --forceExit",
88
113
  "test:watch": "jest --watch",
89
114
  "test:coverage": "jest --coverage",
90
115
  "prepublishOnly": "npm run build"
@@ -115,14 +140,14 @@
115
140
  "typescript": "^5.8.3"
116
141
  },
117
142
  "peerDependencies": {
118
- "@ai-sdk/provider": "^3.0.0",
119
- "@anthropic-ai/sdk": "^0.32.0 || ^0.67.0",
120
- "@google/generative-ai": "^0.21.0 || ^0.24.0",
121
- "ai": "^3.0.0 || ^4.0.0 || ^5.0.0",
122
- "openai": "^4.0.0 || ^6.0.0",
123
- "react": "^18.0.0 || ^19.0.0",
124
- "react-dom": "^18.0.0 || ^19.0.0",
125
- "stripe": "^16.0.0 || ^17.0.0 || ^18.0.0"
143
+ "@ai-sdk/provider": ">=1.0.0",
144
+ "@anthropic-ai/sdk": ">=0.30.0",
145
+ "@google/generative-ai": ">=0.20.0",
146
+ "ai": ">=3.0.0",
147
+ "openai": ">=4.0.0",
148
+ "react": ">=18.0.0",
149
+ "react-dom": ">=18.0.0",
150
+ "stripe": ">=14.0.0"
126
151
  },
127
152
  "peerDependenciesMeta": {
128
153
  "@ai-sdk/provider": {