vibezcheck 0.2.0 → 0.4.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 (45) hide show
  1. package/README.md +131 -197
  2. package/bin/vibezcheck.js +4 -0
  3. package/dist/ai-sdk/index.d.mts +78 -9
  4. package/dist/ai-sdk/index.d.ts +78 -9
  5. package/dist/ai-sdk/index.js +278 -64
  6. package/dist/ai-sdk/index.js.map +1 -1
  7. package/dist/ai-sdk/index.mjs +282 -64
  8. package/dist/ai-sdk/index.mjs.map +1 -1
  9. package/dist/cli/index.d.mts +1 -0
  10. package/dist/cli/index.d.ts +1 -0
  11. package/dist/cli/index.js +232 -0
  12. package/dist/cli/index.js.map +1 -0
  13. package/dist/cli/index.mjs +209 -0
  14. package/dist/cli/index.mjs.map +1 -0
  15. package/dist/{client-MJ3tl7bz.d.mts → client--iq93FQg.d.mts} +1 -1
  16. package/dist/{client-txrE0D_D.d.ts → client-kJN_Znan.d.ts} +1 -1
  17. package/dist/index.d.mts +50 -26
  18. package/dist/index.d.ts +50 -26
  19. package/dist/index.js +299 -104
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +303 -104
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/meter/index.d.mts +2 -2
  24. package/dist/meter/index.d.ts +2 -2
  25. package/dist/meter/index.js +28 -7
  26. package/dist/meter/index.js.map +1 -1
  27. package/dist/meter/index.mjs +28 -7
  28. package/dist/meter/index.mjs.map +1 -1
  29. package/dist/pricing/index.d.mts +8 -2
  30. package/dist/pricing/index.d.ts +8 -2
  31. package/dist/pricing/index.js +28 -7
  32. package/dist/pricing/index.js.map +1 -1
  33. package/dist/pricing/index.mjs +28 -7
  34. package/dist/pricing/index.mjs.map +1 -1
  35. package/dist/react/index.d.mts +95 -17
  36. package/dist/react/index.d.ts +95 -17
  37. package/dist/react/index.js +468 -7
  38. package/dist/react/index.js.map +1 -1
  39. package/dist/react/index.mjs +468 -10
  40. package/dist/react/index.mjs.map +1 -1
  41. package/dist/types-Zbzxg-Ka.d.mts +261 -0
  42. package/dist/types-Zbzxg-Ka.d.ts +261 -0
  43. package/package.json +6 -2
  44. package/dist/types-CSrSmsd1.d.mts +0 -159
  45. package/dist/types-CSrSmsd1.d.ts +0 -159
package/dist/index.d.mts CHANGED
@@ -1,16 +1,17 @@
1
- import { M as MeterOptions, S as StreamWrapOptions, C as CustomerParam, U as UsageEvent, a as UsageSummary } from './types-CSrSmsd1.mjs';
2
- export { I as InferenceCost, b as ModelPricingRates, R as RecordUsageOptions, T as TokenUsage } from './types-CSrSmsd1.mjs';
3
- import { V as VibezMeter } from './client-MJ3tl7bz.mjs';
4
- export { c as createMeter } from './client-MJ3tl7bz.mjs';
1
+ export { AnthropicStreamAccumulator, ExtractedUsage, MeterBatcher, UsageDispatchedCallback, detectAndExtractUsage, extractAnthropicResponseUsage, extractGeminiResponseUsage, extractGenericResponseUsage, extractOpenAIResponseUsage, inspectOpenAIStreamChunk, trackTokens, wrapAnthropicStream, wrapGeminiStream, wrapOpenAIStream, wrapStream, wrapUniversalStream } from './meter/index.mjs';
2
+ import { VibezCheckModelOptions, withBilling, createVibezSession } from './ai-sdk/index.mjs';
3
+ export { VibezSession, VibezSessionOptions, WithBillingOptions, createVibezModel, meteredModel } from './ai-sdk/index.mjs';
4
+ import { calculateCost, getModelPricing, registerModelPricing } from './pricing/index.mjs';
5
+ export { CalculateCostParams, MODEL_PRICING_TABLE, calculateUsageCost, normalizeModelKey } from './pricing/index.mjs';
6
+ import { M as MeterOptions, S as StreamWrapOptions, C as CustomerParam, U as UsageEvent, a as UsageSummary } from './types-Zbzxg-Ka.mjs';
7
+ export { B as BillingConfig, b as BudgetExceededEvent, c as CircuitBreakerOptions, I as InferenceCost, d as InlineRateConfig, K as KnownModel, e as ModelPricingRates, P as PricingConfig, R as RecordUsageOptions, f as SupportedAnthropicModel, g as SupportedDeepSeekModel, h as SupportedGoogleModel, i as SupportedModel, j as SupportedOpenAIModel, T as TokenUsage, k as ToolMeterOptions, V as VibezCircuitBreakerError } from './types-Zbzxg-Ka.mjs';
8
+ import { V as VibezMeter, c as createMeter } from './client--iq93FQg.mjs';
5
9
  import { CustomerManager } from './customers/index.mjs';
6
10
  export { CustomerCache, CustomerManagerOptions, GetOrCreateCustomerParams, createCustomerManager } from './customers/index.mjs';
7
11
  import { ApiKeyAuth } from './auth/index.mjs';
8
12
  export { ApiKeyRecord, CreateApiKeyParams, VerifyAuthResult, createApiKeyAuth, extractAuthToken } from './auth/index.mjs';
9
13
  import { BillingHelper } from './billing/index.mjs';
10
14
  export { CreateCheckoutSessionParams, CreatePortalSessionParams, CreateTopUpSessionParams, createBillingHelper } from './billing/index.mjs';
11
- export { AnthropicStreamAccumulator, ExtractedUsage, MeterBatcher, UsageDispatchedCallback, detectAndExtractUsage, extractAnthropicResponseUsage, extractGeminiResponseUsage, extractGenericResponseUsage, extractOpenAIResponseUsage, inspectOpenAIStreamChunk, trackTokens, wrapAnthropicStream, wrapGeminiStream, wrapOpenAIStream, wrapStream, wrapUniversalStream } from './meter/index.mjs';
12
- export { CalculateCostParams, MODEL_PRICING_TABLE, calculateCost, calculateUsageCost, getModelPricing, normalizeModelKey, registerModelPricing } from './pricing/index.mjs';
13
- export { WithBillingOptions, meteredModel, withBilling } from './ai-sdk/index.mjs';
14
15
  import 'stripe';
15
16
 
16
17
  /**
@@ -48,17 +49,9 @@ declare class VibezCheckClient {
48
49
  customer?: CustomerParam;
49
50
  }): T;
50
51
  /**
51
- * 1-Line Universal Stream Responder for API Routes (Next.js, Express, Hono)
52
+ * Declarative model resolver for Vercel AI SDK
52
53
  */
53
- stream(params: {
54
- model: string;
55
- messages: Array<{
56
- role: string;
57
- content: string;
58
- }>;
59
- customer?: CustomerParam;
60
- temperature?: number;
61
- }): Promise<Response>;
54
+ model(modelOrId: any, options?: VibezCheckModelOptions): any;
62
55
  /**
63
56
  * Flush pending meter events (vital for serverless runtimes)
64
57
  */
@@ -73,20 +66,51 @@ declare class VibezCheckClient {
73
66
  */
74
67
  declare function createVibezCheck(config?: VibezCheckConfig): VibezCheckClient;
75
68
  /**
76
- * vibezcheck factory alias
69
+ * Declarative 1-line factory & model resolver for Vercel AI SDK
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { generateText, streamText } from 'ai';
74
+ * import { vibezcheck } from 'vibezcheck';
75
+ *
76
+ * // 1. Use string model identifier:
77
+ * const { text } = await generateText({
78
+ * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
79
+ * prompt: 'What is love?',
80
+ * });
81
+ *
82
+ * // 2. Use with streamText:
83
+ * const result = streamText({
84
+ * model: vibezcheck('gpt-4o-mini', { customer: 'alex@example.com' }),
85
+ * messages,
86
+ * });
87
+ *
88
+ * // 3. Wrap existing model instance:
89
+ * const result = streamText({
90
+ * model: vibezcheck(openai('gpt-4o-mini'), { customer: 'alex@example.com' }),
91
+ * messages,
92
+ * });
93
+ * ```
77
94
  */
78
- declare const vibezcheck: typeof createVibezCheck;
79
- /**
80
- * vibescheck alias (tolerates spelling difference)
81
- */
82
- declare const vibescheck: typeof createVibezCheck;
95
+ declare function vibezcheck(modelOrId: any, options?: VibezCheckModelOptions): any;
96
+ declare function vibezcheck(config?: VibezCheckConfig): VibezCheckClient;
97
+ declare namespace vibezcheck {
98
+ var calculateCost: typeof calculateCost;
99
+ var getModelPricing: typeof getModelPricing;
100
+ var registerModelPricing: typeof registerModelPricing;
101
+ var create: typeof createVibezCheck;
102
+ var withBilling: typeof withBilling;
103
+ var createMeter: typeof createMeter;
104
+ var session: typeof createVibezSession;
105
+ }
83
106
  /**
84
- * Singleton instance initialized with process.env
107
+ * Singleton client instance
85
108
  */
86
109
  declare const vibez: VibezCheckClient;
87
110
  /**
88
- * Singleton alias
111
+ * Aliases for developer typing convenience
89
112
  */
113
+ declare const vibescheck: typeof vibezcheck;
90
114
  declare const vibes: VibezCheckClient;
91
115
 
92
- export { ApiKeyAuth, BillingHelper, CustomerManager, CustomerParam, MeterOptions, StreamWrapOptions, UsageEvent, UsageSummary, VibezCheckClient, type VibezCheckConfig, VibezMeter, createVibezCheck, vibes, vibescheck, vibez, vibezcheck };
116
+ export { ApiKeyAuth, BillingHelper, CustomerManager, CustomerParam, MeterOptions, StreamWrapOptions, UsageEvent, UsageSummary, VibezCheckClient, type VibezCheckConfig, VibezCheckModelOptions, VibezMeter, calculateCost, createMeter, createVibezCheck, createVibezSession, getModelPricing, registerModelPricing, vibes, vibescheck, vibez, vibezcheck, withBilling };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { M as MeterOptions, S as StreamWrapOptions, C as CustomerParam, U as UsageEvent, a as UsageSummary } from './types-CSrSmsd1.js';
2
- export { I as InferenceCost, b as ModelPricingRates, R as RecordUsageOptions, T as TokenUsage } from './types-CSrSmsd1.js';
3
- import { V as VibezMeter } from './client-txrE0D_D.js';
4
- export { c as createMeter } from './client-txrE0D_D.js';
1
+ export { AnthropicStreamAccumulator, ExtractedUsage, MeterBatcher, UsageDispatchedCallback, detectAndExtractUsage, extractAnthropicResponseUsage, extractGeminiResponseUsage, extractGenericResponseUsage, extractOpenAIResponseUsage, inspectOpenAIStreamChunk, trackTokens, wrapAnthropicStream, wrapGeminiStream, wrapOpenAIStream, wrapStream, wrapUniversalStream } from './meter/index.js';
2
+ import { VibezCheckModelOptions, withBilling, createVibezSession } from './ai-sdk/index.js';
3
+ export { VibezSession, VibezSessionOptions, WithBillingOptions, createVibezModel, meteredModel } from './ai-sdk/index.js';
4
+ import { calculateCost, getModelPricing, registerModelPricing } from './pricing/index.js';
5
+ export { CalculateCostParams, MODEL_PRICING_TABLE, calculateUsageCost, normalizeModelKey } from './pricing/index.js';
6
+ import { M as MeterOptions, S as StreamWrapOptions, C as CustomerParam, U as UsageEvent, a as UsageSummary } from './types-Zbzxg-Ka.js';
7
+ export { B as BillingConfig, b as BudgetExceededEvent, c as CircuitBreakerOptions, I as InferenceCost, d as InlineRateConfig, K as KnownModel, e as ModelPricingRates, P as PricingConfig, R as RecordUsageOptions, f as SupportedAnthropicModel, g as SupportedDeepSeekModel, h as SupportedGoogleModel, i as SupportedModel, j as SupportedOpenAIModel, T as TokenUsage, k as ToolMeterOptions, V as VibezCircuitBreakerError } from './types-Zbzxg-Ka.js';
8
+ import { V as VibezMeter, c as createMeter } from './client-kJN_Znan.js';
5
9
  import { CustomerManager } from './customers/index.js';
6
10
  export { CustomerCache, CustomerManagerOptions, GetOrCreateCustomerParams, createCustomerManager } from './customers/index.js';
7
11
  import { ApiKeyAuth } from './auth/index.js';
8
12
  export { ApiKeyRecord, CreateApiKeyParams, VerifyAuthResult, createApiKeyAuth, extractAuthToken } from './auth/index.js';
9
13
  import { BillingHelper } from './billing/index.js';
10
14
  export { CreateCheckoutSessionParams, CreatePortalSessionParams, CreateTopUpSessionParams, createBillingHelper } from './billing/index.js';
11
- export { AnthropicStreamAccumulator, ExtractedUsage, MeterBatcher, UsageDispatchedCallback, detectAndExtractUsage, extractAnthropicResponseUsage, extractGeminiResponseUsage, extractGenericResponseUsage, extractOpenAIResponseUsage, inspectOpenAIStreamChunk, trackTokens, wrapAnthropicStream, wrapGeminiStream, wrapOpenAIStream, wrapStream, wrapUniversalStream } from './meter/index.js';
12
- export { CalculateCostParams, MODEL_PRICING_TABLE, calculateCost, calculateUsageCost, getModelPricing, normalizeModelKey, registerModelPricing } from './pricing/index.js';
13
- export { WithBillingOptions, meteredModel, withBilling } from './ai-sdk/index.js';
14
15
  import 'stripe';
15
16
 
16
17
  /**
@@ -48,17 +49,9 @@ declare class VibezCheckClient {
48
49
  customer?: CustomerParam;
49
50
  }): T;
50
51
  /**
51
- * 1-Line Universal Stream Responder for API Routes (Next.js, Express, Hono)
52
+ * Declarative model resolver for Vercel AI SDK
52
53
  */
53
- stream(params: {
54
- model: string;
55
- messages: Array<{
56
- role: string;
57
- content: string;
58
- }>;
59
- customer?: CustomerParam;
60
- temperature?: number;
61
- }): Promise<Response>;
54
+ model(modelOrId: any, options?: VibezCheckModelOptions): any;
62
55
  /**
63
56
  * Flush pending meter events (vital for serverless runtimes)
64
57
  */
@@ -73,20 +66,51 @@ declare class VibezCheckClient {
73
66
  */
74
67
  declare function createVibezCheck(config?: VibezCheckConfig): VibezCheckClient;
75
68
  /**
76
- * vibezcheck factory alias
69
+ * Declarative 1-line factory & model resolver for Vercel AI SDK
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { generateText, streamText } from 'ai';
74
+ * import { vibezcheck } from 'vibezcheck';
75
+ *
76
+ * // 1. Use string model identifier:
77
+ * const { text } = await generateText({
78
+ * model: vibezcheck('openai/gpt-4o-mini', { customer: 'alex@example.com' }),
79
+ * prompt: 'What is love?',
80
+ * });
81
+ *
82
+ * // 2. Use with streamText:
83
+ * const result = streamText({
84
+ * model: vibezcheck('gpt-4o-mini', { customer: 'alex@example.com' }),
85
+ * messages,
86
+ * });
87
+ *
88
+ * // 3. Wrap existing model instance:
89
+ * const result = streamText({
90
+ * model: vibezcheck(openai('gpt-4o-mini'), { customer: 'alex@example.com' }),
91
+ * messages,
92
+ * });
93
+ * ```
77
94
  */
78
- declare const vibezcheck: typeof createVibezCheck;
79
- /**
80
- * vibescheck alias (tolerates spelling difference)
81
- */
82
- declare const vibescheck: typeof createVibezCheck;
95
+ declare function vibezcheck(modelOrId: any, options?: VibezCheckModelOptions): any;
96
+ declare function vibezcheck(config?: VibezCheckConfig): VibezCheckClient;
97
+ declare namespace vibezcheck {
98
+ var calculateCost: typeof calculateCost;
99
+ var getModelPricing: typeof getModelPricing;
100
+ var registerModelPricing: typeof registerModelPricing;
101
+ var create: typeof createVibezCheck;
102
+ var withBilling: typeof withBilling;
103
+ var createMeter: typeof createMeter;
104
+ var session: typeof createVibezSession;
105
+ }
83
106
  /**
84
- * Singleton instance initialized with process.env
107
+ * Singleton client instance
85
108
  */
86
109
  declare const vibez: VibezCheckClient;
87
110
  /**
88
- * Singleton alias
111
+ * Aliases for developer typing convenience
89
112
  */
113
+ declare const vibescheck: typeof vibezcheck;
90
114
  declare const vibes: VibezCheckClient;
91
115
 
92
- export { ApiKeyAuth, BillingHelper, CustomerManager, CustomerParam, MeterOptions, StreamWrapOptions, UsageEvent, UsageSummary, VibezCheckClient, type VibezCheckConfig, VibezMeter, createVibezCheck, vibes, vibescheck, vibez, vibezcheck };
116
+ export { ApiKeyAuth, BillingHelper, CustomerManager, CustomerParam, MeterOptions, StreamWrapOptions, UsageEvent, UsageSummary, VibezCheckClient, type VibezCheckConfig, VibezCheckModelOptions, VibezMeter, calculateCost, createMeter, createVibezCheck, createVibezSession, getModelPricing, registerModelPricing, vibes, vibescheck, vibez, vibezcheck, withBilling };