@posthog/agent 2.1.114 → 2.1.115

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "2.1.114",
3
+ "version": "2.1.115",
4
4
  "repository": "https://github.com/PostHog/twig",
5
5
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
6
6
  "exports": {
@@ -651,7 +651,10 @@ Important:
651
651
 
652
652
  private configureEnvironment(): void {
653
653
  const { apiKey, apiUrl, projectId } = this.config;
654
- const gatewayUrl = process.env.LLM_GATEWAY_URL || getLlmGatewayUrl(apiUrl);
654
+ const product =
655
+ this.config.mode === "background" ? "background_agents" : "twig";
656
+ const gatewayUrl =
657
+ process.env.LLM_GATEWAY_URL || getLlmGatewayUrl(apiUrl, product);
655
658
  const openaiBaseUrl = gatewayUrl.endsWith("/v1")
656
659
  ? gatewayUrl
657
660
  : `${gatewayUrl}/v1`;
@@ -1,18 +1,23 @@
1
- export function getLlmGatewayUrl(posthogHost: string): string {
1
+ export type GatewayProduct = "twig" | "background_agents";
2
+
3
+ export function getLlmGatewayUrl(
4
+ posthogHost: string,
5
+ product: GatewayProduct = "twig",
6
+ ): string {
2
7
  const url = new URL(posthogHost);
3
8
  const hostname = url.hostname;
4
9
 
5
10
  // Local development (normalize 127.0.0.1 to localhost)
6
11
  if (hostname === "localhost" || hostname === "127.0.0.1") {
7
- return `${url.protocol}//localhost:3308/twig`;
12
+ return `${url.protocol}//localhost:3308/${product}`;
8
13
  }
9
14
 
10
15
  // Docker containers accessing host
11
16
  if (hostname === "host.docker.internal") {
12
- return `${url.protocol}//host.docker.internal:3308/twig`;
17
+ return `${url.protocol}//host.docker.internal:3308/${product}`;
13
18
  }
14
19
 
15
20
  // Production - extract region from hostname, default to US
16
21
  const region = hostname.match(/^(us|eu)\.posthog\.com$/)?.[1] ?? "us";
17
- return `https://gateway.${region}.posthog.com/twig`;
22
+ return `https://gateway.${region}.posthog.com/${product}`;
18
23
  }