@posthog/agent 2.3.286 → 2.3.297

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.286",
3
+ "version": "2.3.297",
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": {
@@ -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();
@@ -693,6 +693,7 @@ export class AgentServer {
693
693
  // After waiting, just attach the SSE controller if needed
694
694
  if (this.session && sseController) {
695
695
  this.session.sseController = sseController;
696
+ this.session.hasDesktopConnected = true;
696
697
  this.replayPendingEvents();
697
698
  }
698
699
  return;
@@ -1265,13 +1266,14 @@ export class AgentServer {
1265
1266
  }
1266
1267
 
1267
1268
  /**
1268
- * Slack-origin cloud runs auto-publish by default. Every other origin is
1269
+ * Automated-origin cloud runs auto-publish by default. Every other origin is
1269
1270
  * review-first unless the user explicitly asks, and createPr=false always
1270
1271
  * disables publishing.
1271
1272
  */
1272
1273
  private shouldAutoPublishCloudChanges(): boolean {
1274
+ const origin = this.getCloudInteractionOrigin();
1273
1275
  return (
1274
- this.getCloudInteractionOrigin() === "slack" &&
1276
+ (origin === "slack" || origin === "signal_report") &&
1275
1277
  this.config.createPr !== false
1276
1278
  );
1277
1279
  }
@@ -1591,22 +1593,27 @@ ${attributionInstructions}
1591
1593
  }
1592
1594
 
1593
1595
  // Relay permission requests to the desktop app when:
1594
- // - Questions: always relay (need human answers regardless of mode)
1595
- // - Plan approvals: always relay
1596
+ // - Plan approvals: always relay because they gate autonomy changes
1597
+ // that require human confirmation (buffered until desktop connects)
1598
+ // - Questions: relay when desktop is connected
1596
1599
  // - Edit/bash in "default" mode: relay for manual approval
1597
- // Other modes auto-approve. No client connected → auto-approve.
1600
+ // Other modes auto-approve. No client connected → auto-approve
1601
+ // (except plan approvals, which wait for a desktop).
1598
1602
  {
1599
1603
  const isQuestion = codeToolKind === "question";
1600
1604
  const sessionPermissionMode = this.getSessionPermissionMode();
1601
- const needsRelay =
1605
+ const needsDesktopApproval =
1602
1606
  isQuestion ||
1603
- isPlanApproval ||
1604
1607
  this.shouldRelayPermissionToClient(sessionPermissionMode);
1605
1608
 
1606
- if (needsRelay && this.session?.hasDesktopConnected) {
1607
- this.logger.info("Relaying permission to connected client", {
1609
+ if (
1610
+ isPlanApproval ||
1611
+ (needsDesktopApproval && this.session?.hasDesktopConnected)
1612
+ ) {
1613
+ this.logger.info("Relaying permission request", {
1608
1614
  kind: params.toolCall?.kind,
1609
1615
  isQuestion,
1616
+ hasDesktopConnected: this.session?.hasDesktopConnected ?? false,
1610
1617
  sessionPermissionMode,
1611
1618
  });
1612
1619
  return this.relayPermissionToClient(params);