@posthog/agent 2.1.152 → 2.1.156
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/agent.js +1 -1
- 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.d.ts +35 -0
- package/dist/server/agent-server.js +13 -2
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +39 -4
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/server/agent-server.ts +1 -1
- package/src/server/bin.ts +29 -0
- package/src/server/schemas.test.ts +117 -0
- package/src/server/schemas.ts +16 -0
- package/src/server/types.ts +2 -0
package/dist/server/bin.cjs
CHANGED
|
@@ -904,7 +904,7 @@ var import_hono = require("hono");
|
|
|
904
904
|
// package.json
|
|
905
905
|
var package_default = {
|
|
906
906
|
name: "@posthog/agent",
|
|
907
|
-
version: "2.1.
|
|
907
|
+
version: "2.1.156",
|
|
908
908
|
repository: "https://github.com/PostHog/twig",
|
|
909
909
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
910
910
|
exports: {
|
|
@@ -10947,6 +10947,17 @@ function validateJwt(token, publicKey) {
|
|
|
10947
10947
|
|
|
10948
10948
|
// src/server/schemas.ts
|
|
10949
10949
|
var import_zod3 = require("zod");
|
|
10950
|
+
var httpHeaderSchema = import_zod3.z.object({
|
|
10951
|
+
name: import_zod3.z.string(),
|
|
10952
|
+
value: import_zod3.z.string()
|
|
10953
|
+
});
|
|
10954
|
+
var remoteMcpServerSchema = import_zod3.z.object({
|
|
10955
|
+
type: import_zod3.z.enum(["http", "sse"]),
|
|
10956
|
+
name: import_zod3.z.string().min(1, "MCP server name is required"),
|
|
10957
|
+
url: import_zod3.z.string().url("MCP server url must be a valid URL"),
|
|
10958
|
+
headers: import_zod3.z.array(httpHeaderSchema).default([])
|
|
10959
|
+
});
|
|
10960
|
+
var mcpServersSchema = import_zod3.z.array(remoteMcpServerSchema);
|
|
10950
10961
|
var jsonRpcRequestSchema = import_zod3.z.object({
|
|
10951
10962
|
jsonrpc: import_zod3.z.literal("2.0"),
|
|
10952
10963
|
method: import_zod3.z.string(),
|
|
@@ -11418,7 +11429,7 @@ You MUST NOT create a new branch, close the existing PR, or create a new PR.`
|
|
|
11418
11429
|
}
|
|
11419
11430
|
const sessionResponse = await clientConnection.newSession({
|
|
11420
11431
|
cwd: this.config.repositoryPath,
|
|
11421
|
-
mcpServers: [],
|
|
11432
|
+
mcpServers: this.config.mcpServers ?? [],
|
|
11422
11433
|
_meta: {
|
|
11423
11434
|
sessionId: payload.run_id,
|
|
11424
11435
|
taskRunId: payload.run_id,
|
|
@@ -11884,7 +11895,10 @@ program.name("agent-server").description("PostHog cloud agent server - runs in s
|
|
|
11884
11895
|
"--mode <mode>",
|
|
11885
11896
|
"Execution mode: interactive or background",
|
|
11886
11897
|
"interactive"
|
|
11887
|
-
).requiredOption("--repositoryPath <path>", "Path to the repository").requiredOption("--taskId <id>", "Task ID").requiredOption("--runId <id>", "Task run ID").
|
|
11898
|
+
).requiredOption("--repositoryPath <path>", "Path to the repository").requiredOption("--taskId <id>", "Task ID").requiredOption("--runId <id>", "Task run ID").option(
|
|
11899
|
+
"--mcpServers <json>",
|
|
11900
|
+
"MCP servers config as JSON array (ACP McpServer[] format)"
|
|
11901
|
+
).action(async (options) => {
|
|
11888
11902
|
const envResult = envSchema.safeParse(process.env);
|
|
11889
11903
|
if (!envResult.success) {
|
|
11890
11904
|
const errors = envResult.error.issues.map((issue) => ` - ${issue.message}`).join("\n");
|
|
@@ -11894,6 +11908,26 @@ ${errors}`);
|
|
|
11894
11908
|
}
|
|
11895
11909
|
const env = envResult.data;
|
|
11896
11910
|
const mode = options.mode === "background" ? "background" : "interactive";
|
|
11911
|
+
let mcpServers;
|
|
11912
|
+
if (options.mcpServers) {
|
|
11913
|
+
let parsed;
|
|
11914
|
+
try {
|
|
11915
|
+
parsed = JSON.parse(options.mcpServers);
|
|
11916
|
+
} catch {
|
|
11917
|
+
program.error("--mcpServers must be valid JSON");
|
|
11918
|
+
return;
|
|
11919
|
+
}
|
|
11920
|
+
const result = mcpServersSchema.safeParse(parsed);
|
|
11921
|
+
if (!result.success) {
|
|
11922
|
+
const errors = result.error.issues.map((issue) => ` - ${issue.path.join(".")}: ${issue.message}`).join("\n");
|
|
11923
|
+
program.error(
|
|
11924
|
+
`--mcpServers validation failed (only remote http/sse servers are supported):
|
|
11925
|
+
${errors}`
|
|
11926
|
+
);
|
|
11927
|
+
return;
|
|
11928
|
+
}
|
|
11929
|
+
mcpServers = result.data;
|
|
11930
|
+
}
|
|
11897
11931
|
const server = new AgentServer({
|
|
11898
11932
|
port: parseInt(options.port, 10),
|
|
11899
11933
|
jwtPublicKey: env.JWT_PUBLIC_KEY,
|
|
@@ -11903,7 +11937,8 @@ ${errors}`);
|
|
|
11903
11937
|
projectId: env.POSTHOG_PROJECT_ID,
|
|
11904
11938
|
mode,
|
|
11905
11939
|
taskId: options.taskId,
|
|
11906
|
-
runId: options.runId
|
|
11940
|
+
runId: options.runId,
|
|
11941
|
+
mcpServers
|
|
11907
11942
|
});
|
|
11908
11943
|
process.on("SIGINT", async () => {
|
|
11909
11944
|
await server.stop();
|