@posthog/agent 2.1.152 → 2.1.157

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.
@@ -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.152",
907
+ version: "2.1.157",
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,
@@ -11541,7 +11552,7 @@ After completing the requested changes:
11541
11552
  1. Create a new branch with a descriptive name based on the work done
11542
11553
  2. Stage and commit all changes with a clear commit message
11543
11554
  3. Push the branch to origin
11544
- 4. Create a draft pull request using \`gh pr create --draft\` with a descriptive title and body
11555
+ 4. Create a draft pull request using \`gh pr create --draft${this.config.baseBranch ? ` --base ${this.config.baseBranch}` : ""}\` with a descriptive title and body
11545
11556
 
11546
11557
  Important:
11547
11558
  - Always create the PR as a draft. Do not ask for confirmation.
@@ -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").action(async (options) => {
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
+ ).option("--baseBranch <branch>", "Base branch for PR creation").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,9 @@ ${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,
11942
+ baseBranch: options.baseBranch
11907
11943
  });
11908
11944
  process.on("SIGINT", async () => {
11909
11945
  await server.stop();