@fallom/trace 0.2.0 → 0.2.1

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/dist/index.d.mts CHANGED
@@ -155,12 +155,10 @@ declare class FallomSession {
155
155
  version?: number;
156
156
  }): Promise<string>;
157
157
  /**
158
- * Wrap a Vercel AI SDK model to trace all calls.
158
+ * Wrap a Vercel AI SDK model to trace all calls (PostHog style).
159
+ * Returns the same model type with tracing injected.
159
160
  */
160
- traceModel<T extends {
161
- doGenerate?: (...args: any[]) => Promise<any>;
162
- doStream?: (...args: any[]) => Promise<any>;
163
- }>(model: T): T;
161
+ traceModel<T>(model: T): T;
164
162
  /** Wrap OpenAI client. Delegates to shared wrapper. */
165
163
  wrapOpenAI<T extends {
166
164
  chat: {
package/dist/index.d.ts CHANGED
@@ -155,12 +155,10 @@ declare class FallomSession {
155
155
  version?: number;
156
156
  }): Promise<string>;
157
157
  /**
158
- * Wrap a Vercel AI SDK model to trace all calls.
158
+ * Wrap a Vercel AI SDK model to trace all calls (PostHog style).
159
+ * Returns the same model type with tracing injected.
159
160
  */
160
- traceModel<T extends {
161
- doGenerate?: (...args: any[]) => Promise<any>;
162
- doStream?: (...args: any[]) => Promise<any>;
163
- }>(model: T): T;
161
+ traceModel<T>(model: T): T;
164
162
  /** Wrap OpenAI client. Delegates to shared wrapper. */
165
163
  wrapOpenAI<T extends {
166
164
  chat: {
package/dist/index.js CHANGED
@@ -2021,13 +2021,15 @@ var FallomSession = class {
2021
2021
  return get3(configKey, this.ctx.sessionId, opts);
2022
2022
  }
2023
2023
  /**
2024
- * Wrap a Vercel AI SDK model to trace all calls.
2024
+ * Wrap a Vercel AI SDK model to trace all calls (PostHog style).
2025
+ * Returns the same model type with tracing injected.
2025
2026
  */
2026
2027
  traceModel(model) {
2027
2028
  const ctx = this.ctx;
2028
2029
  const tracedModel = Object.create(model);
2029
- if (model.doGenerate) {
2030
- const originalDoGenerate = model.doGenerate.bind(model);
2030
+ const m = model;
2031
+ if (m.doGenerate) {
2032
+ const originalDoGenerate = m.doGenerate.bind(model);
2031
2033
  tracedModel.doGenerate = async function(...args) {
2032
2034
  if (!isInitialized()) return originalDoGenerate(...args);
2033
2035
  const traceCtx = getTraceContextStorage().getStore() || getFallbackTraceContext();
@@ -2083,8 +2085,8 @@ var FallomSession = class {
2083
2085
  }
2084
2086
  };
2085
2087
  }
2086
- if (model.doStream) {
2087
- const originalDoStream = model.doStream.bind(model);
2088
+ if (m.doStream) {
2089
+ const originalDoStream = m.doStream.bind(model);
2088
2090
  tracedModel.doStream = async function(...args) {
2089
2091
  if (!isInitialized()) return originalDoStream(...args);
2090
2092
  const traceCtx = getTraceContextStorage().getStore() || getFallbackTraceContext();
package/dist/index.mjs CHANGED
@@ -1743,13 +1743,15 @@ var FallomSession = class {
1743
1743
  return get2(configKey, this.ctx.sessionId, opts);
1744
1744
  }
1745
1745
  /**
1746
- * Wrap a Vercel AI SDK model to trace all calls.
1746
+ * Wrap a Vercel AI SDK model to trace all calls (PostHog style).
1747
+ * Returns the same model type with tracing injected.
1747
1748
  */
1748
1749
  traceModel(model) {
1749
1750
  const ctx = this.ctx;
1750
1751
  const tracedModel = Object.create(model);
1751
- if (model.doGenerate) {
1752
- const originalDoGenerate = model.doGenerate.bind(model);
1752
+ const m = model;
1753
+ if (m.doGenerate) {
1754
+ const originalDoGenerate = m.doGenerate.bind(model);
1753
1755
  tracedModel.doGenerate = async function(...args) {
1754
1756
  if (!isInitialized()) return originalDoGenerate(...args);
1755
1757
  const traceCtx = getTraceContextStorage().getStore() || getFallbackTraceContext();
@@ -1805,8 +1807,8 @@ var FallomSession = class {
1805
1807
  }
1806
1808
  };
1807
1809
  }
1808
- if (model.doStream) {
1809
- const originalDoStream = model.doStream.bind(model);
1810
+ if (m.doStream) {
1811
+ const originalDoStream = m.doStream.bind(model);
1810
1812
  tracedModel.doStream = async function(...args) {
1811
1813
  if (!isInitialized()) return originalDoStream(...args);
1812
1814
  const traceCtx = getTraceContextStorage().getStore() || getFallbackTraceContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fallom/trace",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Model A/B testing and tracing for LLM applications. Zero latency, production-ready.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",