@posthog/agent 2.3.670 → 2.3.675
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/codex/local-tools-mcp-server.js +22 -5
- package/dist/adapters/codex/local-tools-mcp-server.js.map +1 -1
- package/dist/agent.js +20 -6
- package/dist/agent.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 +20 -6
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +20 -6
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/local-tools/registry.test.ts +8 -11
- package/src/adapters/local-tools/tools/signed-commit.ts +24 -9
package/package.json
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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:
|
|
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");
|
|
@@ -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
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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: (
|
|
21
|
-
handler: (ctx, args) =>
|
|
22
|
-
|
|
23
|
-
|
|
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
|
});
|