@posthog/agent 2.3.285 → 2.3.293

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.3.285",
3
+ "version": "2.3.293",
4
4
  "repository": "https://github.com/PostHog/code",
5
5
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
6
6
  "exports": {
@@ -86,8 +86,8 @@
86
86
  "tsx": "^4.20.6",
87
87
  "typescript": "^5.5.0",
88
88
  "vitest": "^2.1.8",
89
- "@posthog/shared": "1.0.0",
90
- "@posthog/git": "1.0.0"
89
+ "@posthog/git": "1.0.0",
90
+ "@posthog/shared": "1.0.0"
91
91
  },
92
92
  "dependencies": {
93
93
  "@agentclientprotocol/sdk": "0.16.1",
@@ -7,9 +7,9 @@ import type {
7
7
  TaskRun,
8
8
  TaskRunArtifact,
9
9
  } from "./types";
10
- import { getLlmGatewayUrl } from "./utils/gateway";
10
+ import { getGatewayUsageUrl, getLlmGatewayUrl } from "./utils/gateway";
11
11
 
12
- export { getLlmGatewayUrl };
12
+ export { getGatewayUsageUrl, getLlmGatewayUrl };
13
13
 
14
14
  const DEFAULT_USER_AGENT = `posthog/agent.hog.dev; version: ${packageJson.version}`;
15
15
 
@@ -489,6 +489,16 @@ describe("AgentServer HTTP Mode", () => {
489
489
  delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;
490
490
  });
491
491
 
492
+ it("returns auto-PR prompt for signal_report-origin runs", () => {
493
+ process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "signal_report";
494
+ const s = createServer();
495
+ const prompt = (s as unknown as TestableServer).buildCloudSystemPrompt();
496
+ expect(prompt).toContain("posthog-code/");
497
+ expect(prompt).toContain("Create a draft pull request");
498
+ expect(prompt).toContain("gh pr create --draft");
499
+ delete process.env.POSTHOG_CODE_INTERACTION_ORIGIN;
500
+ });
501
+
492
502
  it("returns PR-update prompt for existing PRs on Slack-origin runs", () => {
493
503
  process.env.POSTHOG_CODE_INTERACTION_ORIGIN = "slack";
494
504
  const s = createServer();
@@ -1265,13 +1265,14 @@ export class AgentServer {
1265
1265
  }
1266
1266
 
1267
1267
  /**
1268
- * Slack-origin cloud runs auto-publish by default. Every other origin is
1268
+ * Automated-origin cloud runs auto-publish by default. Every other origin is
1269
1269
  * review-first unless the user explicitly asks, and createPr=false always
1270
1270
  * disables publishing.
1271
1271
  */
1272
1272
  private shouldAutoPublishCloudChanges(): boolean {
1273
+ const origin = this.getCloudInteractionOrigin();
1273
1274
  return (
1274
- this.getCloudInteractionOrigin() === "slack" &&
1275
+ (origin === "slack" || origin === "signal_report") &&
1275
1276
  this.config.createPr !== false
1276
1277
  );
1277
1278
  }
@@ -1,23 +1,31 @@
1
1
  export type GatewayProduct = "posthog_code" | "background_agents";
2
2
 
3
- export function getLlmGatewayUrl(
4
- posthogHost: string,
5
- product: GatewayProduct = "posthog_code",
6
- ): string {
3
+ function getGatewayBaseUrl(posthogHost: string): string {
7
4
  const url = new URL(posthogHost);
8
5
  const hostname = url.hostname;
9
6
 
10
- // Local development (normalize 127.0.0.1 to localhost)
11
7
  if (hostname === "localhost" || hostname === "127.0.0.1") {
12
- return `${url.protocol}//localhost:3308/${product}`;
8
+ return `${url.protocol}//localhost:3308`;
13
9
  }
14
10
 
15
- // Docker containers accessing host
16
11
  if (hostname === "host.docker.internal") {
17
- return `${url.protocol}//host.docker.internal:3308/${product}`;
12
+ return `${url.protocol}//host.docker.internal:3308`;
18
13
  }
19
14
 
20
- // Production - extract region from hostname, default to US
21
15
  const region = hostname.match(/^(us|eu)\.posthog\.com$/)?.[1] ?? "us";
22
- return `https://gateway.${region}.posthog.com/${product}`;
16
+ return `https://gateway.${region}.posthog.com`;
17
+ }
18
+
19
+ export function getLlmGatewayUrl(
20
+ posthogHost: string,
21
+ product: GatewayProduct = "posthog_code",
22
+ ): string {
23
+ return `${getGatewayBaseUrl(posthogHost)}/${product}`;
24
+ }
25
+
26
+ export function getGatewayUsageUrl(
27
+ posthogHost: string,
28
+ product: GatewayProduct = "posthog_code",
29
+ ): string {
30
+ return `${getGatewayBaseUrl(posthogHost)}/v1/usage/${product}`;
23
31
  }