@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/dist/agent.js +5 -5
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.d.ts +2 -1
- package/dist/posthog-api.js +5 -5
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +7 -6
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +7 -6
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/server/agent-server.ts +4 -1
- package/src/utils/gateway.ts +9 -4
package/package.json
CHANGED
|
@@ -651,7 +651,10 @@ Important:
|
|
|
651
651
|
|
|
652
652
|
private configureEnvironment(): void {
|
|
653
653
|
const { apiKey, apiUrl, projectId } = this.config;
|
|
654
|
-
const
|
|
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`;
|
package/src/utils/gateway.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
export
|
|
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
|
|
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
|
|
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
|
|
22
|
+
return `https://gateway.${region}.posthog.com/${product}`;
|
|
18
23
|
}
|