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
@@ -1,54 +1,13 @@
1
- import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, g as PricingConfig, e as InlineRateConfig, U as UsageEvent } from '../types-Mozk4-Mr.mjs';
2
- import { V as VibezMeter } from '../client-w_hWhQ6g.mjs';
1
+ import { W as WithBillingOptions } from '../with-billing-DndWGxL8.mjs';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-DndWGxL8.mjs';
3
+ import { C as CustomerParam } from '../types-6P71CXAD.mjs';
4
+ import { V as VibezMeter } from '../client-CbuXmoXz.mjs';
3
5
  import 'stripe';
4
6
 
5
- interface WithBillingOptions extends CircuitBreakerOptions {
6
- /** Customer email, user ID, or rich customer object with metadata */
7
- customer?: CustomerParam;
8
- /** Direct Stripe customer ID */
9
- customerId?: string;
10
- /** Billing mode configuration (Universal Auto-Debit, postpaid vs prepaid, pluggable providers) */
11
- billing?: BillingConfig;
12
- /** Profit margin & minimum charge configuration */
13
- pricing?: PricingConfig;
14
- /** 1-line inline pricing rate card */
15
- rate?: InlineRateConfig;
16
- /** Pluggable Database Sink (Supabase, Postgres, Firebase, or 1-line callback) */
17
- database?: any | ((event: UsageEvent) => void | Promise<void>);
18
- /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
19
- captureOnAbort?: boolean;
20
- /** Execution runtime environment (default: 'auto') */
21
- runtime?: 'auto' | 'serverless' | 'edge' | 'node';
22
- /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
23
- stripeApiKey?: string;
24
- /** Existing VibezMeter instance (optional) */
25
- meter?: VibezMeter;
26
- /** Custom meter event name */
27
- eventName?: string;
28
- /** Usage callback fired upon generation/stream completion */
29
- onUsage?: (event: UsageEvent) => void | Promise<void>;
30
- /** Custom developer metadata */
31
- metadata?: Record<string, string | number | boolean>;
32
- }
33
- /**
34
- * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
35
- *
36
- * Sane Defaults Built-In:
37
- * - $0.50 safety ceiling per call (overridable)
38
- * - Automatic in-flight token capture on abort
39
- * - Automatic prompt caching discount parsing
40
- * - Serverless lifecycle preservation
41
- */
42
- declare function withBilling<T extends object>(model: T, options?: WithBillingOptions): T;
43
- /**
44
- * Convenient alias for withBilling
45
- */
46
- declare const meteredModel: typeof withBilling;
47
-
48
7
  interface VibezCheckModelOptions extends WithBillingOptions {
49
- /** OpenAI / AI Gateway API Key override */
8
+ /** OpenAI / Anthropic / AI Gateway API Key override */
50
9
  apiKey?: string;
51
- /** AI Gateway / OpenAI Base URL override */
10
+ /** AI Gateway / Provider Base URL override */
52
11
  baseURL?: string;
53
12
  }
54
13
  interface VibezSessionOptions {
@@ -72,23 +31,33 @@ interface VibezSession {
72
31
  /**
73
32
  * Creates or resolves an AI SDK compatible LanguageModel with built-in VibezCheck billing & metering.
74
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
+ *
75
39
  * @example
76
40
  * ```typescript
77
- * import { generateText, streamText } from 'ai';
41
+ * import { streamText } from 'ai';
42
+ * import { openai } from '@ai-sdk/openai';
43
+ * import { anthropic } from '@ai-sdk/anthropic';
78
44
  * import { vibezcheck } from 'vibezcheck';
79
45
  *
80
- * // 1. Declarative string model identifier:
81
- * const { text } = await generateText({
82
- * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
83
- * 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,
84
50
  * });
85
51
  *
86
- * // 2. Works with all Vercel AI SDK primitives (streamText, generateObject, streamObject):
87
- * const result = streamText({
88
- * model: vibezcheck('gpt-4o', {
89
- * customer: 'alex@example.com',
90
- * pricing: { margin: 1.5 }, // 50% profit margin
91
- * }),
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' }),
92
61
  * messages,
93
62
  * });
94
63
  * ```
@@ -102,4 +71,4 @@ declare const vibezcheck: typeof createVibezModel & {
102
71
  session: typeof createVibezSession;
103
72
  };
104
73
 
105
- 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,54 +1,13 @@
1
- import { c as CircuitBreakerOptions, C as CustomerParam, B as BillingConfig, g as PricingConfig, e as InlineRateConfig, U as UsageEvent } from '../types-Mozk4-Mr.js';
2
- import { V as VibezMeter } from '../client-ynfWcHX6.js';
1
+ import { W as WithBillingOptions } from '../with-billing-Bj6Ya_Iy.js';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-Bj6Ya_Iy.js';
3
+ import { C as CustomerParam } from '../types-6P71CXAD.js';
4
+ import { V as VibezMeter } from '../client-BORmJy8s.js';
3
5
  import 'stripe';
4
6
 
5
- interface WithBillingOptions extends CircuitBreakerOptions {
6
- /** Customer email, user ID, or rich customer object with metadata */
7
- customer?: CustomerParam;
8
- /** Direct Stripe customer ID */
9
- customerId?: string;
10
- /** Billing mode configuration (Universal Auto-Debit, postpaid vs prepaid, pluggable providers) */
11
- billing?: BillingConfig;
12
- /** Profit margin & minimum charge configuration */
13
- pricing?: PricingConfig;
14
- /** 1-line inline pricing rate card */
15
- rate?: InlineRateConfig;
16
- /** Pluggable Database Sink (Supabase, Postgres, Firebase, or 1-line callback) */
17
- database?: any | ((event: UsageEvent) => void | Promise<void>);
18
- /** Whether to capture tokens if the client aborts or closes tab mid-stream (default: true) */
19
- captureOnAbort?: boolean;
20
- /** Execution runtime environment (default: 'auto') */
21
- runtime?: 'auto' | 'serverless' | 'edge' | 'node';
22
- /** Stripe API Key override (uses STRIPE_SECRET_KEY env by default) */
23
- stripeApiKey?: string;
24
- /** Existing VibezMeter instance (optional) */
25
- meter?: VibezMeter;
26
- /** Custom meter event name */
27
- eventName?: string;
28
- /** Usage callback fired upon generation/stream completion */
29
- onUsage?: (event: UsageEvent) => void | Promise<void>;
30
- /** Custom developer metadata */
31
- metadata?: Record<string, string | number | boolean>;
32
- }
33
- /**
34
- * Wraps any Vercel AI SDK LanguageModel (v2 or v3) with automated Stripe billing, token metering, and agent circuit breakers.
35
- *
36
- * Sane Defaults Built-In:
37
- * - $0.50 safety ceiling per call (overridable)
38
- * - Automatic in-flight token capture on abort
39
- * - Automatic prompt caching discount parsing
40
- * - Serverless lifecycle preservation
41
- */
42
- declare function withBilling<T extends object>(model: T, options?: WithBillingOptions): T;
43
- /**
44
- * Convenient alias for withBilling
45
- */
46
- declare const meteredModel: typeof withBilling;
47
-
48
7
  interface VibezCheckModelOptions extends WithBillingOptions {
49
- /** OpenAI / AI Gateway API Key override */
8
+ /** OpenAI / Anthropic / AI Gateway API Key override */
50
9
  apiKey?: string;
51
- /** AI Gateway / OpenAI Base URL override */
10
+ /** AI Gateway / Provider Base URL override */
52
11
  baseURL?: string;
53
12
  }
54
13
  interface VibezSessionOptions {
@@ -72,23 +31,33 @@ interface VibezSession {
72
31
  /**
73
32
  * Creates or resolves an AI SDK compatible LanguageModel with built-in VibezCheck billing & metering.
74
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
+ *
75
39
  * @example
76
40
  * ```typescript
77
- * import { generateText, streamText } from 'ai';
41
+ * import { streamText } from 'ai';
42
+ * import { openai } from '@ai-sdk/openai';
43
+ * import { anthropic } from '@ai-sdk/anthropic';
78
44
  * import { vibezcheck } from 'vibezcheck';
79
45
  *
80
- * // 1. Declarative string model identifier:
81
- * const { text } = await generateText({
82
- * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
83
- * 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,
84
50
  * });
85
51
  *
86
- * // 2. Works with all Vercel AI SDK primitives (streamText, generateObject, streamObject):
87
- * const result = streamText({
88
- * model: vibezcheck('gpt-4o', {
89
- * customer: 'alex@example.com',
90
- * pricing: { margin: 1.5 }, // 50% profit margin
91
- * }),
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' }),
92
61
  * messages,
93
62
  * });
94
63
  * ```
@@ -102,4 +71,4 @@ declare const vibezcheck: typeof createVibezModel & {
102
71
  session: typeof createVibezSession;
103
72
  };
104
73
 
105
- 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 };