vibezcheck 0.5.11 → 0.5.12

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 (57) hide show
  1. package/dist/ai-sdk/index.d.mts +5 -5
  2. package/dist/ai-sdk/index.d.ts +5 -5
  3. package/dist/ai-sdk/index.js +34 -5
  4. package/dist/ai-sdk/index.js.map +1 -1
  5. package/dist/ai-sdk/index.mjs +34 -5
  6. package/dist/ai-sdk/index.mjs.map +1 -1
  7. package/dist/ai-sdk/middleware.d.mts +3 -3
  8. package/dist/ai-sdk/middleware.d.ts +3 -3
  9. package/dist/ai-sdk/middleware.js +26 -3
  10. package/dist/ai-sdk/middleware.js.map +1 -1
  11. package/dist/ai-sdk/middleware.mjs +26 -3
  12. package/dist/ai-sdk/middleware.mjs.map +1 -1
  13. package/dist/billing/index.d.mts +8 -6
  14. package/dist/billing/index.d.ts +8 -6
  15. package/dist/billing/index.js +301 -6
  16. package/dist/billing/index.js.map +1 -1
  17. package/dist/billing/index.mjs +308 -6
  18. package/dist/billing/index.mjs.map +1 -1
  19. package/dist/cli/index.js +1 -1
  20. package/dist/cli/index.js.map +1 -1
  21. package/dist/cli/index.mjs +1 -1
  22. package/dist/cli/index.mjs.map +1 -1
  23. package/dist/{client-eXSwD_kI.d.ts → client-0CuOBECi.d.ts} +1 -1
  24. package/dist/{client-ttJwYM7x.d.mts → client-xP86Qg_b.d.mts} +1 -1
  25. package/dist/customers/index.d.mts +1 -1
  26. package/dist/customers/index.d.ts +1 -1
  27. package/dist/database/index.d.mts +1 -1
  28. package/dist/database/index.d.ts +1 -1
  29. package/dist/index.d.mts +8 -8
  30. package/dist/index.d.ts +8 -8
  31. package/dist/index.js +41 -6
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +41 -6
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/meter/index.d.mts +2 -2
  36. package/dist/meter/index.d.ts +2 -2
  37. package/dist/meter/index.js +24 -2
  38. package/dist/meter/index.js.map +1 -1
  39. package/dist/meter/index.mjs +24 -2
  40. package/dist/meter/index.mjs.map +1 -1
  41. package/dist/pricing/index.d.mts +27 -3
  42. package/dist/pricing/index.d.ts +27 -3
  43. package/dist/pricing/index.js +23 -1
  44. package/dist/pricing/index.js.map +1 -1
  45. package/dist/pricing/index.mjs +23 -1
  46. package/dist/pricing/index.mjs.map +1 -1
  47. package/dist/react/index.d.mts +1 -1
  48. package/dist/react/index.d.ts +1 -1
  49. package/dist/{session-D9fdP255.d.mts → session-CueUIV77.d.mts} +10 -4
  50. package/dist/{session-CUnv_muf.d.ts → session-YF67Yij2.d.ts} +10 -4
  51. package/dist/{types-DHlsaLvI.d.mts → types-CqXTmCNv.d.mts} +2 -0
  52. package/dist/{types-DHlsaLvI.d.ts → types-CqXTmCNv.d.ts} +2 -0
  53. package/dist/{with-billing-DhHGWCAp.d.mts → with-billing-Df6izlJ4.d.mts} +4 -2
  54. package/dist/{with-billing-CVGxl3ot.d.ts → with-billing-DgQ380Zl.d.ts} +4 -2
  55. package/examples/nextjs-app-router-openai/package.json +1 -1
  56. package/examples/nextjs-saas-starter/package.json +1 -1
  57. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import { W as WithBillingOptions } from '../with-billing-DhHGWCAp.mjs';
2
- export { m as meteredModel, w as withBilling } from '../with-billing-DhHGWCAp.mjs';
3
- import { A as AgentSession, a as AgentSessionOptions, c as createAgentSession } from '../session-D9fdP255.mjs';
4
- import { C as CustomerParam } from '../types-DHlsaLvI.mjs';
5
- import '../client-ttJwYM7x.mjs';
1
+ import { W as WithBillingOptions } from '../with-billing-Df6izlJ4.mjs';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-Df6izlJ4.mjs';
3
+ import { A as AgentSession, a as AgentSessionOptions, c as createAgentSession } from '../session-CueUIV77.mjs';
4
+ import { C as CustomerParam } from '../types-CqXTmCNv.mjs';
5
+ import '../client-xP86Qg_b.mjs';
6
6
 
7
7
  /**
8
8
  * ✦ VibezCheck Universal Telemetry Response Stream Injector
@@ -1,8 +1,8 @@
1
- import { W as WithBillingOptions } from '../with-billing-CVGxl3ot.js';
2
- export { m as meteredModel, w as withBilling } from '../with-billing-CVGxl3ot.js';
3
- import { A as AgentSession, a as AgentSessionOptions, c as createAgentSession } from '../session-CUnv_muf.js';
4
- import { C as CustomerParam } from '../types-DHlsaLvI.js';
5
- import '../client-eXSwD_kI.js';
1
+ import { W as WithBillingOptions } from '../with-billing-DgQ380Zl.js';
2
+ export { m as meteredModel, w as withBilling } from '../with-billing-DgQ380Zl.js';
3
+ import { A as AgentSession, a as AgentSessionOptions, c as createAgentSession } from '../session-YF67Yij2.js';
4
+ import { C as CustomerParam } from '../types-CqXTmCNv.js';
5
+ import '../client-0CuOBECi.js';
6
6
 
7
7
  /**
8
8
  * ✦ VibezCheck Universal Telemetry Response Stream Injector
@@ -800,7 +800,29 @@ function getModelPricing(modelName) {
800
800
  }
801
801
 
802
802
  // src/pricing/calculator.ts
803
- function calculateCost(params) {
803
+ function calculateCost(modelOrParams, usage, optionsOrMarkup) {
804
+ let params;
805
+ if (typeof modelOrParams === "string") {
806
+ const opts = typeof optionsOrMarkup === "number" ? { markupMultiplier: optionsOrMarkup } : optionsOrMarkup || {};
807
+ params = {
808
+ model: modelOrParams,
809
+ inputTokens: usage?.inputTokens ?? usage?.promptTokens ?? 0,
810
+ outputTokens: usage?.outputTokens ?? usage?.completionTokens ?? 0,
811
+ reasoningTokens: usage?.reasoningTokens,
812
+ cachedTokens: usage?.cachedTokens,
813
+ cacheWriteTokens: usage?.cacheWriteTokens,
814
+ markupMultiplier: opts.markupMultiplier ?? opts.markup ?? opts.margin,
815
+ minimumChargeUSD: opts.minimumChargeUSD,
816
+ customRate: opts.customRate
817
+ };
818
+ } else {
819
+ params = {
820
+ ...modelOrParams,
821
+ inputTokens: modelOrParams.inputTokens ?? modelOrParams.promptTokens ?? 0,
822
+ outputTokens: modelOrParams.outputTokens ?? modelOrParams.completionTokens ?? 0,
823
+ markupMultiplier: modelOrParams.markupMultiplier ?? modelOrParams.markup ?? modelOrParams.margin
824
+ };
825
+ }
804
826
  let rates;
805
827
  if (params.customRate) {
806
828
  const outRate = params.customRate.out ?? params.customRate.output ?? 0;
@@ -1085,7 +1107,7 @@ var VibezMeter = class {
1085
1107
  batcher;
1086
1108
  markupMultiplier;
1087
1109
  constructor(options = {}) {
1088
- this.markupMultiplier = options.pricing?.margin ?? options.markupMultiplier;
1110
+ this.markupMultiplier = options.pricing?.margin ?? options.pricing?.markup ?? options.markupMultiplier;
1089
1111
  this.batcher = new MeterBatcher(options);
1090
1112
  }
1091
1113
  /**
@@ -1277,7 +1299,7 @@ function withBilling(model, optionsOrCustomer, extraOptions = {}) {
1277
1299
  cacheWriteTokens: cacheWriteTokens > 0 ? cacheWriteTokens : void 0
1278
1300
  };
1279
1301
  const cost = calculateUsageCost(modelId, usage, {
1280
- markupMultiplier: options.pricing?.margin,
1302
+ markupMultiplier: options.pricing?.margin ?? options.pricing?.markup,
1281
1303
  minimumChargeUSD: options.pricing?.minimumChargeUSD,
1282
1304
  customRate: options.rate
1283
1305
  });
@@ -1316,6 +1338,7 @@ function withBilling(model, optionsOrCustomer, extraOptions = {}) {
1316
1338
  const mergedMetadata = {
1317
1339
  ...customerMetadata,
1318
1340
  ...options.metadata,
1341
+ ...options.threadId ? { threadId: options.threadId } : {},
1319
1342
  ...extraMeta
1320
1343
  };
1321
1344
  const event = {
@@ -1684,7 +1707,7 @@ var AgentSession = class {
1684
1707
  */
1685
1708
  model(modelOrId, modelOptions = {}) {
1686
1709
  const session = this;
1687
- return withBilling(modelOrId, {
1710
+ return createVibezModel(modelOrId, {
1688
1711
  ...modelOptions,
1689
1712
  customer: this.customer,
1690
1713
  pricing: modelOptions.pricing || this.options.pricing,
@@ -1776,7 +1799,13 @@ var AgentSession = class {
1776
1799
  const defaultCost = options.costPerActionUSD ?? 5e-3;
1777
1800
  const instrumented = {};
1778
1801
  for (const [name, toolDef] of Object.entries(toolsRecord)) {
1779
- const costUSD = options.costs?.[name] ?? defaultCost;
1802
+ let costUSD = defaultCost;
1803
+ if (options && "costs" in options && options.costs?.[name] !== void 0) {
1804
+ costUSD = options.costs[name];
1805
+ } else if (options && name in options) {
1806
+ const val = options[name];
1807
+ costUSD = typeof val === "number" ? val : val?.costUSD ?? defaultCost;
1808
+ }
1780
1809
  instrumented[name] = this.wrapTool(toolDef, { name, costUSD });
1781
1810
  }
1782
1811
  return instrumented;