@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.
- package/README.md +35 -1
- package/dist/adk/index.cjs +16 -6
- package/dist/adk/index.cjs.map +1 -1
- package/dist/adk/index.mjs +16 -6
- package/dist/adk/index.mjs.map +1 -1
- package/dist/anthropic/index.cjs +156 -15
- package/dist/anthropic/index.cjs.map +1 -1
- package/dist/anthropic/index.d.ts +1 -0
- package/dist/anthropic/index.mjs +156 -15
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/claude-agent-sdk/index.cjs +111 -37
- package/dist/claude-agent-sdk/index.cjs.map +1 -1
- package/dist/claude-agent-sdk/index.mjs +111 -37
- package/dist/claude-agent-sdk/index.mjs.map +1 -1
- package/dist/gemini/index.cjs +175 -39
- package/dist/gemini/index.cjs.map +1 -1
- package/dist/gemini/index.d.ts +1 -1
- package/dist/gemini/index.mjs +175 -39
- package/dist/gemini/index.mjs.map +1 -1
- package/dist/index.cjs +15 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +15 -8
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +15 -5
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +15 -5
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/langchain/middleware/index.cjs +15 -5
- package/dist/langchain/middleware/index.cjs.map +1 -1
- package/dist/langchain/middleware/index.mjs +15 -5
- package/dist/langchain/middleware/index.mjs.map +1 -1
- package/dist/openai/index.cjs +181 -21
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +181 -21
- package/dist/openai/index.mjs.map +1 -1
- package/dist/openai-agents/index.cjs +15 -5
- package/dist/openai-agents/index.cjs.map +1 -1
- package/dist/openai-agents/index.mjs +15 -5
- package/dist/openai-agents/index.mjs.map +1 -1
- package/dist/otel/index.cjs +12 -3
- package/dist/otel/index.cjs.map +1 -1
- package/dist/otel/index.mjs +12 -3
- package/dist/otel/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +15 -8
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +15 -8
- package/dist/vercel/index.mjs.map +1 -1
- 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.
|
|
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.
|
|
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))
|
|
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
|
|
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.
|
|
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 =
|
|
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;
|