@posthog/agent 2.3.22 → 2.3.24
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 +13 -0
- package/dist/server/agent-server.js +33 -2
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +65 -24
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/server/agent-server.ts +30 -1
- package/src/server/bin.ts +40 -23
- package/src/server/schemas.ts +16 -0
- package/src/server/types.ts +8 -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.3.
|
|
907
|
+
version: "2.3.24",
|
|
908
908
|
repository: "https://github.com/PostHog/code",
|
|
909
909
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
910
910
|
exports: {
|
|
@@ -11377,6 +11377,17 @@ var remoteMcpServerSchema = import_zod3.z.object({
|
|
|
11377
11377
|
headers: import_zod3.z.array(httpHeaderSchema).default([])
|
|
11378
11378
|
});
|
|
11379
11379
|
var mcpServersSchema = import_zod3.z.array(remoteMcpServerSchema);
|
|
11380
|
+
var claudeCodeConfigSchema = import_zod3.z.object({
|
|
11381
|
+
systemPrompt: import_zod3.z.union([
|
|
11382
|
+
import_zod3.z.string(),
|
|
11383
|
+
import_zod3.z.object({
|
|
11384
|
+
type: import_zod3.z.literal("preset"),
|
|
11385
|
+
preset: import_zod3.z.literal("claude_code"),
|
|
11386
|
+
append: import_zod3.z.string().optional()
|
|
11387
|
+
})
|
|
11388
|
+
]).optional(),
|
|
11389
|
+
plugins: import_zod3.z.array(import_zod3.z.object({ type: import_zod3.z.literal("local"), path: import_zod3.z.string() })).optional()
|
|
11390
|
+
});
|
|
11380
11391
|
var jsonRpcRequestSchema = import_zod3.z.object({
|
|
11381
11392
|
jsonrpc: import_zod3.z.literal("2.0"),
|
|
11382
11393
|
method: import_zod3.z.string(),
|
|
@@ -11881,7 +11892,14 @@ You MUST NOT create a new branch, close the existing PR, or create a new PR.`
|
|
|
11881
11892
|
_meta: {
|
|
11882
11893
|
sessionId: payload.run_id,
|
|
11883
11894
|
taskRunId: payload.run_id,
|
|
11884
|
-
systemPrompt:
|
|
11895
|
+
systemPrompt: this.buildSessionSystemPrompt(prUrl),
|
|
11896
|
+
...this.config.claudeCode?.plugins?.length && {
|
|
11897
|
+
claudeCode: {
|
|
11898
|
+
options: {
|
|
11899
|
+
plugins: this.config.claudeCode.plugins
|
|
11900
|
+
}
|
|
11901
|
+
}
|
|
11902
|
+
}
|
|
11885
11903
|
}
|
|
11886
11904
|
});
|
|
11887
11905
|
const acpSessionId = sessionResponse.sessionId;
|
|
@@ -12111,6 +12129,19 @@ ${toolSummary}`);
|
|
|
12111
12129
|
const stateRunId = state?.resume_from_run_id;
|
|
12112
12130
|
return typeof stateRunId === "string" && stateRunId.trim().length > 0 ? stateRunId.trim() : null;
|
|
12113
12131
|
}
|
|
12132
|
+
buildSessionSystemPrompt(prUrl) {
|
|
12133
|
+
const cloudAppend = this.buildCloudSystemPrompt(prUrl);
|
|
12134
|
+
const userPrompt = this.config.claudeCode?.systemPrompt;
|
|
12135
|
+
if (typeof userPrompt === "string") {
|
|
12136
|
+
return [userPrompt, cloudAppend].join("\n\n");
|
|
12137
|
+
}
|
|
12138
|
+
if (typeof userPrompt === "object") {
|
|
12139
|
+
return {
|
|
12140
|
+
append: [userPrompt.append, cloudAppend].filter(Boolean).join("\n\n")
|
|
12141
|
+
};
|
|
12142
|
+
}
|
|
12143
|
+
return { append: cloudAppend };
|
|
12144
|
+
}
|
|
12114
12145
|
buildCloudSystemPrompt(prUrl) {
|
|
12115
12146
|
if (prUrl) {
|
|
12116
12147
|
return `
|
|
@@ -12485,6 +12516,22 @@ var envSchema = import_zod4.z.object({
|
|
|
12485
12516
|
}).regex(/^\d+$/, "POSTHOG_PROJECT_ID must be a numeric string").transform((val) => parseInt(val, 10))
|
|
12486
12517
|
});
|
|
12487
12518
|
var program = new import_commander.Command();
|
|
12519
|
+
function parseJsonOption(raw, schema, flag) {
|
|
12520
|
+
if (!raw) return void 0;
|
|
12521
|
+
let parsed;
|
|
12522
|
+
try {
|
|
12523
|
+
parsed = JSON.parse(raw);
|
|
12524
|
+
} catch {
|
|
12525
|
+
program.error(`${flag} must be valid JSON`);
|
|
12526
|
+
}
|
|
12527
|
+
const result = schema.safeParse(parsed);
|
|
12528
|
+
if (!result.success) {
|
|
12529
|
+
const errors = result.error.issues.map((issue) => ` - ${issue.path.join(".")}: ${issue.message}`).join("\n");
|
|
12530
|
+
program.error(`${flag} validation failed:
|
|
12531
|
+
${errors}`);
|
|
12532
|
+
}
|
|
12533
|
+
return result.data;
|
|
12534
|
+
}
|
|
12488
12535
|
program.name("agent-server").description("PostHog cloud agent server - runs in sandbox environments").option("--port <port>", "HTTP server port", "3001").option(
|
|
12489
12536
|
"--mode <mode>",
|
|
12490
12537
|
"Execution mode: interactive or background",
|
|
@@ -12492,7 +12539,10 @@ program.name("agent-server").description("PostHog cloud agent server - runs in s
|
|
|
12492
12539
|
).option("--repositoryPath <path>", "Path to the repository").requiredOption("--taskId <id>", "Task ID").requiredOption("--runId <id>", "Task run ID").option(
|
|
12493
12540
|
"--mcpServers <json>",
|
|
12494
12541
|
"MCP servers config as JSON array (ACP McpServer[] format)"
|
|
12495
|
-
).option("--baseBranch <branch>", "Base branch for PR creation").
|
|
12542
|
+
).option("--baseBranch <branch>", "Base branch for PR creation").option(
|
|
12543
|
+
"--claudeCodeConfig <json>",
|
|
12544
|
+
"Claude Code config as JSON (systemPrompt, systemPromptAppend, plugins)"
|
|
12545
|
+
).action(async (options) => {
|
|
12496
12546
|
const envResult = envSchema.safeParse(process.env);
|
|
12497
12547
|
if (!envResult.success) {
|
|
12498
12548
|
const errors = envResult.error.issues.map((issue) => ` - ${issue.message}`).join("\n");
|
|
@@ -12502,26 +12552,16 @@ ${errors}`);
|
|
|
12502
12552
|
}
|
|
12503
12553
|
const env = envResult.data;
|
|
12504
12554
|
const mode = options.mode === "background" ? "background" : "interactive";
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
if (!result.success) {
|
|
12516
|
-
const errors = result.error.issues.map((issue) => ` - ${issue.path.join(".")}: ${issue.message}`).join("\n");
|
|
12517
|
-
program.error(
|
|
12518
|
-
`--mcpServers validation failed (only remote http/sse servers are supported):
|
|
12519
|
-
${errors}`
|
|
12520
|
-
);
|
|
12521
|
-
return;
|
|
12522
|
-
}
|
|
12523
|
-
mcpServers = result.data;
|
|
12524
|
-
}
|
|
12555
|
+
const mcpServers = parseJsonOption(
|
|
12556
|
+
options.mcpServers,
|
|
12557
|
+
mcpServersSchema,
|
|
12558
|
+
"--mcpServers"
|
|
12559
|
+
);
|
|
12560
|
+
const claudeCode = parseJsonOption(
|
|
12561
|
+
options.claudeCodeConfig,
|
|
12562
|
+
claudeCodeConfigSchema,
|
|
12563
|
+
"--claudeCodeConfig"
|
|
12564
|
+
);
|
|
12525
12565
|
const server = new AgentServer({
|
|
12526
12566
|
port: parseInt(options.port, 10),
|
|
12527
12567
|
jwtPublicKey: env.JWT_PUBLIC_KEY,
|
|
@@ -12533,7 +12573,8 @@ ${errors}`
|
|
|
12533
12573
|
taskId: options.taskId,
|
|
12534
12574
|
runId: options.runId,
|
|
12535
12575
|
mcpServers,
|
|
12536
|
-
baseBranch: options.baseBranch
|
|
12576
|
+
baseBranch: options.baseBranch,
|
|
12577
|
+
claudeCode
|
|
12537
12578
|
});
|
|
12538
12579
|
process.on("SIGINT", async () => {
|
|
12539
12580
|
await server.stop();
|