@posthog/agent 2.3.663 → 2.3.670
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/adapters/claude/permissions/permission-options.js.map +1 -1
- package/dist/adapters/claude/tools.js.map +1 -1
- package/dist/adapters/codex/local-tools-mcp-server.js +4 -1
- package/dist/adapters/codex/local-tools-mcp-server.js.map +1 -1
- package/dist/agent.js +5 -2
- package/dist/agent.js.map +1 -1
- package/dist/execution-mode.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +6 -2
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +6 -2
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/mcp/local-tools.test.ts +1 -1
- package/src/adapters/claude/types.ts +1 -0
- package/src/adapters/codex/codex-agent.ts +1 -0
- package/src/adapters/local-tools/registry.test.ts +32 -11
- package/src/adapters/local-tools/registry.ts +1 -1
- package/src/server/agent-server.ts +1 -0
- package/src/utils/common.ts +9 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/agent",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.670",
|
|
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": {
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"typescript": "^5.5.0",
|
|
108
108
|
"vitest": "^2.1.8",
|
|
109
109
|
"@posthog/shared": "1.0.0",
|
|
110
|
-
"@posthog/
|
|
111
|
-
"@posthog/
|
|
110
|
+
"@posthog/enricher": "1.0.0",
|
|
111
|
+
"@posthog/git": "1.0.0"
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
114
|
"@agentclientprotocol/sdk": "0.19.0",
|
|
@@ -29,7 +29,7 @@ describe("createLocalToolsMcpServer", () => {
|
|
|
29
29
|
it("exposes git_signed_commit over MCP in a cloud run with a token", async () => {
|
|
30
30
|
const server = createLocalToolsMcpServer(
|
|
31
31
|
{ cwd: "/repo", token: "ghs_x" },
|
|
32
|
-
{
|
|
32
|
+
{ environment: "cloud" },
|
|
33
33
|
);
|
|
34
34
|
if (!server) {
|
|
35
35
|
throw new Error("expected the local-tools server to be registered");
|
|
@@ -10,7 +10,7 @@ describe("local-tools registry", () => {
|
|
|
10
10
|
const savedSandbox = process.env.IS_SANDBOX;
|
|
11
11
|
|
|
12
12
|
beforeEach(() => {
|
|
13
|
-
// isCloudRun also keys off IS_SANDBOX; clear it so meta.
|
|
13
|
+
// isCloudRun also keys off IS_SANDBOX; clear it so meta.environment is the
|
|
14
14
|
// only cloud signal under test.
|
|
15
15
|
delete process.env.IS_SANDBOX;
|
|
16
16
|
});
|
|
@@ -35,23 +35,44 @@ describe("local-tools registry", () => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
it.each([
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
{
|
|
39
|
+
name: "cloud run with a token",
|
|
40
|
+
meta: { environment: "cloud" as const },
|
|
41
|
+
token: "ghs_x",
|
|
42
|
+
expected: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "cloud run without a token",
|
|
46
|
+
meta: { environment: "cloud" as const },
|
|
47
|
+
token: undefined,
|
|
48
|
+
expected: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "desktop run with a token",
|
|
52
|
+
meta: { environment: "local" as const },
|
|
53
|
+
token: "ghs_x",
|
|
54
|
+
expected: false,
|
|
55
|
+
},
|
|
41
56
|
{
|
|
42
57
|
name: "desktop run without a token",
|
|
43
|
-
|
|
58
|
+
meta: { environment: "local" as const },
|
|
44
59
|
token: undefined,
|
|
60
|
+
expected: false,
|
|
45
61
|
},
|
|
46
62
|
])(
|
|
47
63
|
"exposes git_signed_commit only in $name when cloud+token",
|
|
48
|
-
({
|
|
49
|
-
const tools = enabledLocalTools(
|
|
50
|
-
{ cwd: "/repo", token },
|
|
51
|
-
taskRunId ? { taskRunId } : undefined,
|
|
52
|
-
);
|
|
64
|
+
({ meta, token, expected }) => {
|
|
65
|
+
const tools = enabledLocalTools({ cwd: "/repo", token }, meta);
|
|
53
66
|
const hasSignedCommit = tools.some((t) => t.name === "git_signed_commit");
|
|
54
|
-
expect(hasSignedCommit).toBe(
|
|
67
|
+
expect(hasSignedCommit).toBe(expected);
|
|
55
68
|
},
|
|
56
69
|
);
|
|
70
|
+
|
|
71
|
+
it("does not treat legacy taskRunId-only metadata as cloud", () => {
|
|
72
|
+
const tools = enabledLocalTools({ cwd: "/repo", token: "ghs_x" }, {
|
|
73
|
+
taskRunId: "run-1",
|
|
74
|
+
} as unknown as { environment?: "local" | "cloud" });
|
|
75
|
+
const hasSignedCommit = tools.some((t) => t.name === "git_signed_commit");
|
|
76
|
+
expect(hasSignedCommit).toBe(false);
|
|
77
|
+
});
|
|
57
78
|
});
|
|
@@ -976,6 +976,7 @@ export class AgentServer {
|
|
|
976
976
|
sessionId: payload.run_id,
|
|
977
977
|
taskRunId: payload.run_id,
|
|
978
978
|
taskId: payload.task_id,
|
|
979
|
+
environment: "cloud",
|
|
979
980
|
systemPrompt: sessionSystemPrompt,
|
|
980
981
|
...(this.config.model && { model: this.config.model }),
|
|
981
982
|
allowedDomains: this.config.allowedDomains,
|
package/src/utils/common.ts
CHANGED
|
@@ -27,11 +27,16 @@ export const IS_ROOT =
|
|
|
27
27
|
export const ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* A cloud sandbox run, as opposed to a local desktop session.
|
|
31
|
-
*
|
|
30
|
+
* A cloud sandbox run, as opposed to a local desktop session. `taskRunId` is
|
|
31
|
+
* used by both desktop and cloud for persistence, so it must not imply cloud.
|
|
32
32
|
*/
|
|
33
|
-
export function isCloudRun(
|
|
34
|
-
|
|
33
|
+
export function isCloudRun(
|
|
34
|
+
meta: { environment?: "local" | "cloud" } | undefined,
|
|
35
|
+
): boolean {
|
|
36
|
+
if (meta?.environment) {
|
|
37
|
+
return meta.environment === "cloud";
|
|
38
|
+
}
|
|
39
|
+
return !!process.env.IS_SANDBOX;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
/** The GitHub token available to the sandbox, if any. */
|