@posthog/agent 2.3.670 → 2.3.678

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.670",
3
+ "version": "2.3.678",
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": {
@@ -106,9 +106,9 @@
106
106
  "tsx": "^4.20.6",
107
107
  "typescript": "^5.5.0",
108
108
  "vitest": "^2.1.8",
109
+ "@posthog/git": "1.0.0",
109
110
  "@posthog/shared": "1.0.0",
110
- "@posthog/enricher": "1.0.0",
111
- "@posthog/git": "1.0.0"
111
+ "@posthog/enricher": "1.0.0"
112
112
  },
113
113
  "dependencies": {
114
114
  "@agentclientprotocol/sdk": "0.19.0",
@@ -34,7 +34,7 @@ describe("createLocalToolsMcpServer", () => {
34
34
  if (!server) {
35
35
  throw new Error("expected the local-tools server to be registered");
36
36
  }
37
- expect(server.name).toBe("posthog-local");
37
+ expect(server.name).toBe("posthog-code-tools");
38
38
 
39
39
  const [clientTransport, serverTransport] =
40
40
  InMemoryTransport.createLinkedPair();
@@ -42,10 +42,10 @@ describe("local-tools registry", () => {
42
42
  expected: true,
43
43
  },
44
44
  {
45
- name: "cloud run without a token",
45
+ name: "cloud run without a token (resolved lazily at call time)",
46
46
  meta: { environment: "cloud" as const },
47
47
  token: undefined,
48
- expected: false,
48
+ expected: true,
49
49
  },
50
50
  {
51
51
  name: "desktop run with a token",
@@ -59,17 +59,14 @@ describe("local-tools registry", () => {
59
59
  token: undefined,
60
60
  expected: false,
61
61
  },
62
- ])(
63
- "exposes git_signed_commit only in $name when cloud+token",
64
- ({ meta, token, expected }) => {
65
- const tools = enabledLocalTools({ cwd: "/repo", token }, meta);
66
- const hasSignedCommit = tools.some((t) => t.name === "git_signed_commit");
67
- expect(hasSignedCommit).toBe(expected);
68
- },
69
- );
62
+ ])("exposes git_signed_commit in $name", ({ meta, token, expected }) => {
63
+ const tools = enabledLocalTools({ cwd: "/repo", token }, meta);
64
+ const hasSignedCommit = tools.some((t) => t.name === "git_signed_commit");
65
+ expect(hasSignedCommit).toBe(expected);
66
+ });
70
67
 
71
68
  it("does not treat legacy taskRunId-only metadata as cloud", () => {
72
- const tools = enabledLocalTools({ cwd: "/repo", token: "ghs_x" }, {
69
+ const tools = enabledLocalTools({ cwd: "/repo", token: undefined }, {
73
70
  taskRunId: "run-1",
74
71
  } as unknown as { environment?: "local" | "cloud" });
75
72
  const hasSignedCommit = tools.some((t) => t.name === "git_signed_commit");
@@ -5,9 +5,9 @@ import type { z } from "zod";
5
5
  * for both adapters: the Claude in-process SDK server and the Codex stdio
6
6
  * server. Adding a tool means adding one entry to `LOCAL_TOOLS` (see
7
7
  * `./index.ts`) — no per-tool server file or adapter wiring. The name appears
8
- * in tool ids as `mcp__posthog-local__<tool>`.
8
+ * in tool ids as `mcp__posthog-code-tools__<tool>`.
9
9
  */
10
- export const LOCAL_TOOLS_MCP_NAME = "posthog-local";
10
+ export const LOCAL_TOOLS_MCP_NAME = "posthog-code-tools";
11
11
 
12
12
  /** Runtime context handed to every local tool's handler and gate. */
13
13
  export interface LocalToolCtx {
@@ -1,4 +1,4 @@
1
- import { isCloudRun } from "../../../utils/common";
1
+ import { isCloudRun, resolveGithubToken } from "../../../utils/common";
2
2
  import {
3
3
  runSignedCommitTool,
4
4
  SIGNED_COMMIT_TOOL_DESCRIPTION,
@@ -8,19 +8,34 @@ import {
8
8
  import { defineLocalTool } from "../registry";
9
9
 
10
10
  /**
11
- * `git_signed_commit` as a local tool. Cloud runs only, and only when a GitHub
12
- * token is available (the commit is created via GitHub's API, which also signs
13
- * it). Committing is core to cloud tasks, so keep it visible past ToolSearch.
11
+ * `git_signed_commit` as a local tool. Cloud-run only; the token is resolved
12
+ * lazily at call time so the tool stays visible even when the GitHub token
13
+ * lands in `process.env` after the session was created (e.g. an orchestrator
14
+ * injecting it post-spawn). Committing is core to cloud tasks, so keep it
15
+ * exposed past ToolSearch via `alwaysLoad`.
14
16
  */
15
17
  export const signedCommitTool = defineLocalTool({
16
18
  name: SIGNED_COMMIT_TOOL_NAME,
17
19
  description: SIGNED_COMMIT_TOOL_DESCRIPTION,
18
20
  schema: signedCommitToolSchema,
19
21
  alwaysLoad: true,
20
- isEnabled: (ctx, meta) => isCloudRun(meta) && !!ctx.token,
21
- handler: (ctx, args) =>
22
- runSignedCommitTool(
23
- { cwd: ctx.cwd, token: ctx.token ?? "", taskId: ctx.taskId },
22
+ isEnabled: (_ctx, meta) => isCloudRun(meta),
23
+ handler: (ctx, args) => {
24
+ const token = ctx.token ?? resolveGithubToken();
25
+ if (!token) {
26
+ return Promise.resolve({
27
+ content: [
28
+ {
29
+ type: "text" as const,
30
+ text: `${SIGNED_COMMIT_TOOL_NAME} failed: no GitHub token in env (GH_TOKEN/GITHUB_TOKEN)`,
31
+ },
32
+ ],
33
+ isError: true,
34
+ });
35
+ }
36
+ return runSignedCommitTool(
37
+ { cwd: ctx.cwd, token, taskId: ctx.taskId },
24
38
  args,
25
- ),
39
+ );
40
+ },
26
41
  });