@posthog/ai 8.6.0 → 8.6.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/anthropic/index.cjs +1 -1
- package/dist/anthropic/index.mjs +1 -1
- package/dist/gemini/index.cjs +1 -1
- package/dist/gemini/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/langchain/index.cjs +22 -3
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +22 -3
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/openai/index.cjs +1 -1
- package/dist/openai/index.mjs +1 -1
- package/dist/openai-agents/index.cjs +1 -1
- package/dist/openai-agents/index.mjs +1 -1
- package/dist/vercel/index.cjs +1 -1
- package/dist/vercel/index.mjs +1 -1
- package/package.json +4 -4
package/dist/anthropic/index.cjs
CHANGED
package/dist/anthropic/index.mjs
CHANGED
package/dist/gemini/index.cjs
CHANGED
package/dist/gemini/index.mjs
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
package/dist/langchain/index.cjs
CHANGED
|
@@ -217,7 +217,7 @@ function sanitizeValues(obj) {
|
|
|
217
217
|
return jsonSafe;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
var version = "8.6.
|
|
220
|
+
var version = "8.6.1";
|
|
221
221
|
|
|
222
222
|
const DEFAULT_MAX_DEPTH = 3;
|
|
223
223
|
const MAX_STACK_LINES = 20;
|
|
@@ -308,6 +308,13 @@ const warnIfPostHogAiGateway = baseURL => {
|
|
|
308
308
|
console.warn('[PostHog] The PostHog AI wrapper is pointed at the PostHog AI Gateway. ' + 'Both capture $ai_generation, so every call is double-counted and double-billed. ' + `Use one or the other — see ${GATEWAY_DOCS_URL}.`);
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
+
// Mirror LangGraph's isGraphBubbleUp guard without adding LangGraph as a dependency. Every
|
|
312
|
+
// LangGraph control-flow exception (GraphInterrupt, NodeInterrupt, ParentCommand, GraphDrained,
|
|
313
|
+
// and future subclasses) exposes a prototype getter `is_bubble_up` that returns true, which the
|
|
314
|
+
// LangGraph runtime itself uses to distinguish control flow from real failures. The getter reads
|
|
315
|
+
// as undefined on ordinary Errors and works across duplicated LangGraph package copies.
|
|
316
|
+
const isLangGraphControlFlow = error => error.is_bubble_up === true;
|
|
317
|
+
|
|
311
318
|
/** A run may either be a Span or a Generation */
|
|
312
319
|
|
|
313
320
|
/** Storage for run metadata */
|
|
@@ -559,8 +566,20 @@ class LangChainCallbackHandler extends base.BaseCallbackHandler {
|
|
|
559
566
|
eventProperties['$process_person_profile'] = false;
|
|
560
567
|
}
|
|
561
568
|
if (outputs instanceof Error) {
|
|
562
|
-
|
|
563
|
-
|
|
569
|
+
if (isLangGraphControlFlow(outputs)) {
|
|
570
|
+
// GraphInterrupt carries the pending interrupts (e.g. the question posed to a human).
|
|
571
|
+
// Surface them under the same `__interrupt__` key LangGraph hands back to the caller,
|
|
572
|
+
// so an interrupted span stays distinguishable from a node that returned nothing.
|
|
573
|
+
const interrupts = outputs.interrupts;
|
|
574
|
+
if (interrupts !== undefined) {
|
|
575
|
+
eventProperties['$ai_output_state'] = withPrivacyMode(this.client, this.privacyMode, sanitizeLangChain({
|
|
576
|
+
__interrupt__: interrupts
|
|
577
|
+
}));
|
|
578
|
+
}
|
|
579
|
+
} else {
|
|
580
|
+
eventProperties['$ai_error'] = stringifyError(outputs);
|
|
581
|
+
eventProperties['$ai_is_error'] = true;
|
|
582
|
+
}
|
|
564
583
|
} else if (outputs !== undefined) {
|
|
565
584
|
eventProperties['$ai_output_state'] = withPrivacyMode(this.client, this.privacyMode, sanitizeLangChain(outputs));
|
|
566
585
|
}
|