@posthog/agent 2.3.655 → 2.3.657

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.
@@ -1,4 +1,34 @@
1
- export type GatewayProduct = "posthog_code" | "background_agents";
1
+ export type GatewayProduct = "posthog_code" | "background_agents" | "signals";
2
+
3
+ export function resolveGatewayProduct({
4
+ isInternal,
5
+ originProduct,
6
+ }: {
7
+ isInternal?: boolean;
8
+ originProduct?: string | null;
9
+ } = {}): GatewayProduct {
10
+ if (isInternal) {
11
+ return originProduct === "signal_report" ? "signals" : "background_agents";
12
+ }
13
+ return "posthog_code";
14
+ }
15
+
16
+ /**
17
+ * Build `x-posthog-property-<name>: <value>` header lines that the LLM
18
+ * gateway lifts onto the `$ai_generation` event it captures for each call
19
+ * (see `services/llm-gateway/src/llm_gateway/request_context.py`).
20
+ *
21
+ * Returns a newline-joined string ready for `ANTHROPIC_CUSTOM_HEADERS`.
22
+ * `null`/`undefined` property values are dropped.
23
+ */
24
+ export function buildGatewayPropertyHeaders(
25
+ properties: Record<string, string | number | boolean | null | undefined>,
26
+ ): string {
27
+ return Object.entries(properties)
28
+ .filter(([, value]) => value !== null && value !== undefined)
29
+ .map(([key, value]) => `x-posthog-property-${key}: ${value}`)
30
+ .join("\n");
31
+ }
2
32
 
3
33
  function getGatewayBaseUrl(posthogHost: string): string {
4
34
  const url = new URL(posthogHost);