@posthog/ai 8.14.1 → 8.14.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 (48) hide show
  1. package/README.md +35 -1
  2. package/dist/adk/index.cjs +16 -6
  3. package/dist/adk/index.cjs.map +1 -1
  4. package/dist/adk/index.mjs +16 -6
  5. package/dist/adk/index.mjs.map +1 -1
  6. package/dist/anthropic/index.cjs +156 -15
  7. package/dist/anthropic/index.cjs.map +1 -1
  8. package/dist/anthropic/index.d.ts +1 -0
  9. package/dist/anthropic/index.mjs +156 -15
  10. package/dist/anthropic/index.mjs.map +1 -1
  11. package/dist/claude-agent-sdk/index.cjs +111 -37
  12. package/dist/claude-agent-sdk/index.cjs.map +1 -1
  13. package/dist/claude-agent-sdk/index.mjs +111 -37
  14. package/dist/claude-agent-sdk/index.mjs.map +1 -1
  15. package/dist/gemini/index.cjs +175 -39
  16. package/dist/gemini/index.cjs.map +1 -1
  17. package/dist/gemini/index.d.ts +1 -1
  18. package/dist/gemini/index.mjs +175 -39
  19. package/dist/gemini/index.mjs.map +1 -1
  20. package/dist/index.cjs +15 -8
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.mjs +15 -8
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/langchain/index.cjs +15 -5
  25. package/dist/langchain/index.cjs.map +1 -1
  26. package/dist/langchain/index.mjs +15 -5
  27. package/dist/langchain/index.mjs.map +1 -1
  28. package/dist/langchain/middleware/index.cjs +15 -5
  29. package/dist/langchain/middleware/index.cjs.map +1 -1
  30. package/dist/langchain/middleware/index.mjs +15 -5
  31. package/dist/langchain/middleware/index.mjs.map +1 -1
  32. package/dist/openai/index.cjs +181 -21
  33. package/dist/openai/index.cjs.map +1 -1
  34. package/dist/openai/index.mjs +181 -21
  35. package/dist/openai/index.mjs.map +1 -1
  36. package/dist/openai-agents/index.cjs +15 -5
  37. package/dist/openai-agents/index.cjs.map +1 -1
  38. package/dist/openai-agents/index.mjs +15 -5
  39. package/dist/openai-agents/index.mjs.map +1 -1
  40. package/dist/otel/index.cjs +12 -3
  41. package/dist/otel/index.cjs.map +1 -1
  42. package/dist/otel/index.mjs +12 -3
  43. package/dist/otel/index.mjs.map +1 -1
  44. package/dist/vercel/index.cjs +15 -8
  45. package/dist/vercel/index.cjs.map +1 -1
  46. package/dist/vercel/index.mjs +15 -8
  47. package/dist/vercel/index.mjs.map +1 -1
  48. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -173,17 +173,26 @@ var BinaryContentRedactor = class {
173
173
  this.visited = /* @__PURE__ */ new WeakSet();
174
174
  return this.walk(value, mediaType ? new MediaTypeContext(void 0, void 0, mediaType) : MediaTypeContext.EMPTY);
175
175
  }
176
+ /** Redact one leaf while a caller owns bounded, type-preserving traversal. @internal */
177
+ redactLeaf(value, context) {
178
+ return typeof value === "string" ? this.redactString(value, context) : this.placeholderFor(context.inferMediaType());
179
+ }
176
180
  walk(value, ctx) {
177
181
  if (value === null || value === void 0) return value;
178
- if (typeof value === "string") return this.redactString(value, ctx);
182
+ if (typeof value === "string") return this.redactLeaf(value, ctx);
179
183
  if (typeof value !== "object") return value;
180
- if (typeof Uint8Array !== "undefined" && value instanceof Uint8Array) return this.placeholderFor(ctx.inferMediaType());
184
+ if (typeof Uint8Array !== "undefined" && value instanceof Uint8Array) return this.redactLeaf(value, ctx);
181
185
  if (this.visited.has(value)) return null;
182
186
  this.visited.add(value);
183
187
  if (Array.isArray(value)) return value.map((item) => this.walk(item, ctx));
184
188
  const obj = value;
185
189
  const out = {};
186
- for (const k of Object.keys(obj)) out[k] = this.walk(obj[k], new MediaTypeContext(obj, k));
190
+ for (const k of Object.keys(obj)) Object.defineProperty(out, k, {
191
+ value: this.walk(obj[k], new MediaTypeContext(obj, k)),
192
+ enumerable: true,
193
+ writable: true,
194
+ configurable: true
195
+ });
187
196
  return out;
188
197
  }
189
198
  redactString(value, ctx) {
@@ -281,9 +290,7 @@ const getModelParams = (params, responseServiceTier) => {
281
290
  if (responseServiceTier != null) modelParams.service_tier = responseServiceTier;
282
291
  return modelParams;
283
292
  };
284
- const withPrivacyMode = (client, privacyMode, input) => {
285
- return client.privacy_mode || privacyMode ? null : input;
286
- };
293
+ const isPrivacyModeEnabled = (client, privacyMode) => Boolean(client.privacy_mode || privacyMode);
287
294
  function toSafeString(input) {
288
295
  if (input === void 0 || input === null) return "";
289
296
  if (typeof input === "string") return input;
@@ -395,7 +402,7 @@ function sanitizeValues(obj) {
395
402
  }
396
403
  //#endregion
397
404
  //#region package.json
398
- var version = "8.14.1";
405
+ var version = "8.14.3";
399
406
  //#endregion
400
407
  //#region src/serializeError.ts
401
408
  const DEFAULT_MAX_DEPTH = 3;
@@ -482,7 +489,7 @@ const captureAiGeneration = async (client, options) => {
482
489
  const eventType = options.eventType ?? "$ai_generation";
483
490
  const privacyMode = options.privacyMode ?? false;
484
491
  const usage = options.usage ?? {};
485
- const shouldRedact = withPrivacyMode(client, privacyMode, false) === null;
492
+ const shouldRedact = isPrivacyModeEnabled(client, privacyMode);
486
493
  const safeInput = shouldRedact ? null : toJsonSafeValue(options.input);
487
494
  const safeOutput = shouldRedact ? null : toJsonSafeValue(options.output);
488
495
  let httpStatus = options.httpStatus;