@posthog/agent 2.3.388 → 2.3.398
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/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/adapters/claude/mcp/tool-metadata.d.ts +24 -0
- package/dist/adapters/claude/mcp/tool-metadata.js +165 -0
- package/dist/adapters/claude/mcp/tool-metadata.js.map +1 -0
- package/dist/adapters/claude/tools.js.map +1 -1
- package/dist/agent.js +113 -3
- package/dist/agent.js.map +1 -1
- package/dist/index.d.ts +7 -9
- package/dist/index.js.map +1 -1
- package/dist/posthog-api.js +5 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +113 -3
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +113 -3
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +6 -2
- package/src/adapters/claude/claude-agent.ts +5 -0
- package/src/adapters/claude/mcp/tool-metadata.test.ts +93 -0
- package/src/adapters/claude/mcp/tool-metadata.ts +33 -0
- package/src/adapters/claude/permissions/permission-handlers.test.ts +165 -0
- package/src/adapters/claude/permissions/permission-handlers.ts +105 -0
- package/src/adapters/claude/session/instructions.ts +9 -1
- package/src/adapters/claude/types.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export { McpToolMetadata, getMcpToolMetadata, isMcpToolReadOnly } from './adapters/claude/mcp/tool-metadata.js';
|
|
2
|
+
import '@anthropic-ai/claude-agent-sdk';
|
|
3
|
+
import './logger-RC7sPv0S.js';
|
|
4
|
+
import './types.js';
|
|
5
|
+
import '@posthog/git/handoff';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* PostHog-specific ACP extensions.
|
|
3
9
|
*
|
|
@@ -57,12 +63,4 @@ type PosthogNotification = (typeof POSTHOG_NOTIFICATIONS)[keyof typeof POSTHOG_N
|
|
|
57
63
|
/** Dispatcher check for incoming `extNotification` calls on the agent side. */
|
|
58
64
|
declare function isNotification(method: string | undefined, expected: PosthogNotification): boolean;
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
readOnly: boolean;
|
|
62
|
-
name: string;
|
|
63
|
-
description?: string;
|
|
64
|
-
}
|
|
65
|
-
declare function getMcpToolMetadata(toolName: string): McpToolMetadata | undefined;
|
|
66
|
-
declare function isMcpToolReadOnly(toolName: string): boolean;
|
|
67
|
-
|
|
68
|
-
export { type McpToolMetadata, POSTHOG_NOTIFICATIONS, getMcpToolMetadata, isMcpToolReadOnly, isNotification };
|
|
66
|
+
export { POSTHOG_NOTIFICATIONS, isNotification };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/acp-extensions.ts","../src/adapters/claude/mcp/tool-metadata.ts"],"sourcesContent":["/**\n * PostHog-specific ACP extensions.\n *\n * These follow the ACP extensibility model:\n * - Custom notification methods are prefixed with `_posthog/`\n * - Custom data can be attached via `_meta` fields\n *\n * See: https://agentclientprotocol.com/docs/extensibility\n */\n\n/**\n * Custom notification methods for PostHog-specific events.\n * Used with AgentSideConnection.extNotification() or Client.extNotification()\n */\nexport const POSTHOG_NOTIFICATIONS = {\n /** Git branch was created for a task */\n BRANCH_CREATED: \"_posthog/branch_created\",\n\n /** Task run has started execution */\n RUN_STARTED: \"_posthog/run_started\",\n\n /** Task has completed (success or failure) */\n TASK_COMPLETE: \"_posthog/task_complete\",\n\n /** Agent finished processing a turn (prompt returned, waiting for next input) */\n TURN_COMPLETE: \"_posthog/turn_complete\",\n\n /** Error occurred during task execution */\n ERROR: \"_posthog/error\",\n\n /** Console/log output from the agent */\n CONSOLE: \"_posthog/console\",\n\n /** Maps taskRunId to agent's sessionId and adapter type (for resumption) */\n SDK_SESSION: \"_posthog/sdk_session\",\n\n /** Tree state snapshot captured (git tree hash + file archive) */\n TREE_SNAPSHOT: \"_posthog/tree_snapshot\",\n\n /** Git checkpoint captured for handoff */\n GIT_CHECKPOINT: \"_posthog/git_checkpoint\",\n\n /** Agent mode changed (interactive/background) */\n MODE_CHANGE: \"_posthog/mode_change\",\n\n /** Request to resume a session from previous state */\n SESSION_RESUME: \"_posthog/session/resume\",\n\n /** User message sent from client to agent */\n USER_MESSAGE: \"_posthog/user_message\",\n\n /** Request to cancel current operation */\n CANCEL: \"_posthog/cancel\",\n\n /** Request to close the session */\n CLOSE: \"_posthog/close\",\n\n /** Agent status update (thinking, working, etc.) */\n STATUS: \"_posthog/status\",\n\n /** Structured backend progress notification; events in the same turn group into one card on the client */\n PROGRESS: \"_posthog/progress\",\n\n /** Task-level notification (progress, milestones) */\n TASK_NOTIFICATION: \"_posthog/task_notification\",\n\n /** Marks a boundary for log compaction */\n COMPACT_BOUNDARY: \"_posthog/compact_boundary\",\n\n /** Token usage update for a session turn */\n USAGE_UPDATE: \"_posthog/usage_update\",\n\n /** Response to a relayed permission request (plan approval, question) */\n PERMISSION_RESPONSE: \"_posthog/permission_response\",\n} as const;\n\n/**\n * Custom request methods for PostHog-specific operations that need a response\n * (request/response, not fire-and-forget). Used with\n * ClientSideConnection.extMethod() on the sender and Agent.extMethod() on the\n * receiver.\n */\nexport const POSTHOG_METHODS = {\n /**\n * Client requests a session refresh between turns. Payload may include\n * `mcpServers` to trigger a resume-with-new-options reinit; future fields\n * can extend this without adding new methods. Returns once the refresh has\n * completed so the caller can safely send the next prompt.\n */\n REFRESH_SESSION: \"_posthog/refresh_session\",\n} as const;\n\ntype PosthogNotification =\n (typeof POSTHOG_NOTIFICATIONS)[keyof typeof POSTHOG_NOTIFICATIONS];\n\ntype PosthogMethod = (typeof POSTHOG_METHODS)[keyof typeof POSTHOG_METHODS];\n\n/**\n * Does `method` match `expected`? Shared by notification and method matchers.\n * Handles the `__posthog/` double-prefix that extNotification() can produce.\n */\nfunction matchesExt(method: string | undefined, expected: string): boolean {\n if (!method) return false;\n return method === expected || method === `_${expected}`;\n}\n\n/** Dispatcher check for incoming `extNotification` calls on the agent side. */\nexport function isNotification(\n method: string | undefined,\n expected: PosthogNotification,\n): boolean {\n return matchesExt(method, expected);\n}\n\n/** Dispatcher check for incoming `extMethod` calls on the agent side. */\nexport function isMethod(\n method: string | undefined,\n expected: PosthogMethod,\n): boolean {\n return matchesExt(method, expected);\n}\n","import type { McpServerStatus, Query } from \"@anthropic-ai/claude-agent-sdk\";\nimport { Logger } from \"../../../utils/logger\";\n\nexport interface McpToolMetadata {\n readOnly: boolean;\n name: string;\n description?: string;\n}\n\nconst mcpToolMetadataCache: Map<string, McpToolMetadata> = new Map();\n\nconst PENDING_RETRY_INTERVAL_MS = 1_000;\nconst PENDING_MAX_RETRIES = 10;\n\nfunction buildToolKey(serverName: string, toolName: string): string {\n return `mcp__${serverName}__${toolName}`;\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function fetchMcpToolMetadata(\n q: Query,\n logger: Logger = new Logger({ debug: false, prefix: \"[McpToolMetadata]\" }),\n): Promise<void> {\n let retries = 0;\n\n while (retries <= PENDING_MAX_RETRIES) {\n let statuses: McpServerStatus[];\n try {\n statuses = await q.mcpServerStatus();\n } catch (error) {\n logger.error(\"Failed to fetch MCP server status\", {\n error: error instanceof Error ? error.message : String(error),\n });\n return;\n }\n\n const pendingServers = statuses.filter((s) => s.status === \"pending\");\n\n for (const server of statuses) {\n if (server.status !== \"connected\" || !server.tools) {\n continue;\n }\n\n let readOnlyCount = 0;\n for (const tool of server.tools) {\n const toolKey = buildToolKey(server.name, tool.name);\n const readOnly = tool.annotations?.readOnly === true;\n\n mcpToolMetadataCache.set(toolKey, {\n readOnly,\n name: tool.name,\n description: tool.description,\n });\n if (readOnly) readOnlyCount++;\n }\n\n logger.info(\"Fetched MCP tool metadata\", {\n serverName: server.name,\n toolCount: server.tools.length,\n readOnlyCount,\n });\n }\n\n if (pendingServers.length === 0) {\n return;\n }\n\n retries++;\n if (retries > PENDING_MAX_RETRIES) {\n logger.warn(\"Gave up waiting for pending MCP servers\", {\n pendingServers: pendingServers.map((s) => s.name),\n });\n return;\n }\n\n logger.info(\"Waiting for pending MCP servers\", {\n pendingServers: pendingServers.map((s) => s.name),\n retry: retries,\n });\n await delay(PENDING_RETRY_INTERVAL_MS);\n }\n}\n\nexport function getMcpToolMetadata(\n toolName: string,\n): McpToolMetadata | undefined {\n return mcpToolMetadataCache.get(toolName);\n}\n\nexport function isMcpToolReadOnly(toolName: string): boolean {\n const metadata = mcpToolMetadataCache.get(toolName);\n return metadata?.readOnly === true;\n}\n\nexport function getConnectedMcpServerNames(): string[] {\n const names = new Set<string>();\n for (const key of mcpToolMetadataCache.keys()) {\n const parts = key.split(\"__\");\n if (parts.length >= 3) names.add(parts[1]);\n }\n return [...names];\n}\n\nexport function clearMcpToolMetadataCache(): void {\n mcpToolMetadataCache.clear();\n}\n"],"mappings":";AAcO,IAAM,wBAAwB;AAAA;AAAA,EAEnC,gBAAgB;AAAA;AAAA,EAGhB,aAAa;AAAA;AAAA,EAGb,eAAe;AAAA;AAAA,EAGf,eAAe;AAAA;AAAA,EAGf,OAAO;AAAA;AAAA,EAGP,SAAS;AAAA;AAAA,EAGT,aAAa;AAAA;AAAA,EAGb,eAAe;AAAA;AAAA,EAGf,gBAAgB;AAAA;AAAA,EAGhB,aAAa;AAAA;AAAA,EAGb,gBAAgB;AAAA;AAAA,EAGhB,cAAc;AAAA;AAAA,EAGd,QAAQ;AAAA;AAAA,EAGR,OAAO;AAAA;AAAA,EAGP,QAAQ;AAAA;AAAA,EAGR,UAAU;AAAA;AAAA,EAGV,mBAAmB;AAAA;AAAA,EAGnB,kBAAkB;AAAA;AAAA,EAGlB,cAAc;AAAA;AAAA,EAGd,qBAAqB;AACvB;AA2BA,SAAS,WAAW,QAA4B,UAA2B;AACzE,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,WAAW,YAAY,WAAW,IAAI,QAAQ;AACvD;AAGO,SAAS,eACd,QACA,UACS;AACT,SAAO,WAAW,QAAQ,QAAQ;AACpC;;;
|
|
1
|
+
{"version":3,"sources":["../src/acp-extensions.ts","../src/adapters/claude/mcp/tool-metadata.ts"],"sourcesContent":["/**\n * PostHog-specific ACP extensions.\n *\n * These follow the ACP extensibility model:\n * - Custom notification methods are prefixed with `_posthog/`\n * - Custom data can be attached via `_meta` fields\n *\n * See: https://agentclientprotocol.com/docs/extensibility\n */\n\n/**\n * Custom notification methods for PostHog-specific events.\n * Used with AgentSideConnection.extNotification() or Client.extNotification()\n */\nexport const POSTHOG_NOTIFICATIONS = {\n /** Git branch was created for a task */\n BRANCH_CREATED: \"_posthog/branch_created\",\n\n /** Task run has started execution */\n RUN_STARTED: \"_posthog/run_started\",\n\n /** Task has completed (success or failure) */\n TASK_COMPLETE: \"_posthog/task_complete\",\n\n /** Agent finished processing a turn (prompt returned, waiting for next input) */\n TURN_COMPLETE: \"_posthog/turn_complete\",\n\n /** Error occurred during task execution */\n ERROR: \"_posthog/error\",\n\n /** Console/log output from the agent */\n CONSOLE: \"_posthog/console\",\n\n /** Maps taskRunId to agent's sessionId and adapter type (for resumption) */\n SDK_SESSION: \"_posthog/sdk_session\",\n\n /** Tree state snapshot captured (git tree hash + file archive) */\n TREE_SNAPSHOT: \"_posthog/tree_snapshot\",\n\n /** Git checkpoint captured for handoff */\n GIT_CHECKPOINT: \"_posthog/git_checkpoint\",\n\n /** Agent mode changed (interactive/background) */\n MODE_CHANGE: \"_posthog/mode_change\",\n\n /** Request to resume a session from previous state */\n SESSION_RESUME: \"_posthog/session/resume\",\n\n /** User message sent from client to agent */\n USER_MESSAGE: \"_posthog/user_message\",\n\n /** Request to cancel current operation */\n CANCEL: \"_posthog/cancel\",\n\n /** Request to close the session */\n CLOSE: \"_posthog/close\",\n\n /** Agent status update (thinking, working, etc.) */\n STATUS: \"_posthog/status\",\n\n /** Structured backend progress notification; events in the same turn group into one card on the client */\n PROGRESS: \"_posthog/progress\",\n\n /** Task-level notification (progress, milestones) */\n TASK_NOTIFICATION: \"_posthog/task_notification\",\n\n /** Marks a boundary for log compaction */\n COMPACT_BOUNDARY: \"_posthog/compact_boundary\",\n\n /** Token usage update for a session turn */\n USAGE_UPDATE: \"_posthog/usage_update\",\n\n /** Response to a relayed permission request (plan approval, question) */\n PERMISSION_RESPONSE: \"_posthog/permission_response\",\n} as const;\n\n/**\n * Custom request methods for PostHog-specific operations that need a response\n * (request/response, not fire-and-forget). Used with\n * ClientSideConnection.extMethod() on the sender and Agent.extMethod() on the\n * receiver.\n */\nexport const POSTHOG_METHODS = {\n /**\n * Client requests a session refresh between turns. Payload may include\n * `mcpServers` to trigger a resume-with-new-options reinit; future fields\n * can extend this without adding new methods. Returns once the refresh has\n * completed so the caller can safely send the next prompt.\n */\n REFRESH_SESSION: \"_posthog/refresh_session\",\n} as const;\n\ntype PosthogNotification =\n (typeof POSTHOG_NOTIFICATIONS)[keyof typeof POSTHOG_NOTIFICATIONS];\n\ntype PosthogMethod = (typeof POSTHOG_METHODS)[keyof typeof POSTHOG_METHODS];\n\n/**\n * Does `method` match `expected`? Shared by notification and method matchers.\n * Handles the `__posthog/` double-prefix that extNotification() can produce.\n */\nfunction matchesExt(method: string | undefined, expected: string): boolean {\n if (!method) return false;\n return method === expected || method === `_${expected}`;\n}\n\n/** Dispatcher check for incoming `extNotification` calls on the agent side. */\nexport function isNotification(\n method: string | undefined,\n expected: PosthogNotification,\n): boolean {\n return matchesExt(method, expected);\n}\n\n/** Dispatcher check for incoming `extMethod` calls on the agent side. */\nexport function isMethod(\n method: string | undefined,\n expected: PosthogMethod,\n): boolean {\n return matchesExt(method, expected);\n}\n","import type { McpServerStatus, Query } from \"@anthropic-ai/claude-agent-sdk\";\nimport { Logger } from \"../../../utils/logger\";\n\nexport type McpToolApprovalState = \"approved\" | \"needs_approval\" | \"do_not_use\";\n\n/** Maps MCP tool keys (e.g. `mcp__server__tool`) to their backend approval state. */\nexport type McpToolApprovals = Record<string, McpToolApprovalState>;\n\nexport interface McpToolMetadata {\n readOnly: boolean;\n name: string;\n description?: string;\n approvalState?: McpToolApprovalState;\n}\n\nconst mcpToolMetadataCache: Map<string, McpToolMetadata> = new Map();\n\nconst PENDING_RETRY_INTERVAL_MS = 1_000;\nconst PENDING_MAX_RETRIES = 10;\n\nexport function sanitizeMcpServerName(name: string): string {\n return name.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction buildToolKey(serverName: string, toolName: string): string {\n return `mcp__${serverName}__${toolName}`;\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function fetchMcpToolMetadata(\n q: Query,\n logger: Logger = new Logger({ debug: false, prefix: \"[McpToolMetadata]\" }),\n): Promise<void> {\n let retries = 0;\n\n while (retries <= PENDING_MAX_RETRIES) {\n let statuses: McpServerStatus[];\n try {\n statuses = await q.mcpServerStatus();\n } catch (error) {\n logger.error(\"Failed to fetch MCP server status\", {\n error: error instanceof Error ? error.message : String(error),\n });\n return;\n }\n\n const pendingServers = statuses.filter((s) => s.status === \"pending\");\n\n for (const server of statuses) {\n if (server.status !== \"connected\" || !server.tools) {\n continue;\n }\n\n let readOnlyCount = 0;\n for (const tool of server.tools) {\n const toolKey = buildToolKey(server.name, tool.name);\n const readOnly = tool.annotations?.readOnly === true;\n\n const existing = mcpToolMetadataCache.get(toolKey);\n mcpToolMetadataCache.set(toolKey, {\n readOnly,\n name: tool.name,\n description: tool.description,\n approvalState: existing?.approvalState,\n });\n if (readOnly) readOnlyCount++;\n }\n\n logger.info(\"Fetched MCP tool metadata\", {\n serverName: server.name,\n toolCount: server.tools.length,\n readOnlyCount,\n });\n }\n\n if (pendingServers.length === 0) {\n return;\n }\n\n retries++;\n if (retries > PENDING_MAX_RETRIES) {\n logger.warn(\"Gave up waiting for pending MCP servers\", {\n pendingServers: pendingServers.map((s) => s.name),\n });\n return;\n }\n\n logger.info(\"Waiting for pending MCP servers\", {\n pendingServers: pendingServers.map((s) => s.name),\n retry: retries,\n });\n await delay(PENDING_RETRY_INTERVAL_MS);\n }\n}\n\nexport function getMcpToolMetadata(\n toolName: string,\n): McpToolMetadata | undefined {\n return mcpToolMetadataCache.get(toolName);\n}\n\nexport function isMcpToolReadOnly(toolName: string): boolean {\n const metadata = mcpToolMetadataCache.get(toolName);\n return metadata?.readOnly === true;\n}\n\nexport function getConnectedMcpServerNames(): string[] {\n const names = new Set<string>();\n for (const key of mcpToolMetadataCache.keys()) {\n const parts = key.split(\"__\");\n if (parts.length >= 3) names.add(parts[1]);\n }\n return [...names];\n}\n\nexport function getMcpToolApprovalState(\n toolName: string,\n): McpToolApprovalState | undefined {\n return mcpToolMetadataCache.get(toolName)?.approvalState;\n}\n\nexport function setMcpToolApprovalStates(approvals: McpToolApprovals): void {\n for (const [toolKey, approvalState] of Object.entries(approvals)) {\n const existing = mcpToolMetadataCache.get(toolKey);\n if (existing) {\n existing.approvalState = approvalState;\n } else {\n mcpToolMetadataCache.set(toolKey, {\n readOnly: false,\n name: toolKey,\n approvalState,\n });\n }\n }\n}\n\nexport function clearMcpToolMetadataCache(): void {\n mcpToolMetadataCache.clear();\n}\n"],"mappings":";AAcO,IAAM,wBAAwB;AAAA;AAAA,EAEnC,gBAAgB;AAAA;AAAA,EAGhB,aAAa;AAAA;AAAA,EAGb,eAAe;AAAA;AAAA,EAGf,eAAe;AAAA;AAAA,EAGf,OAAO;AAAA;AAAA,EAGP,SAAS;AAAA;AAAA,EAGT,aAAa;AAAA;AAAA,EAGb,eAAe;AAAA;AAAA,EAGf,gBAAgB;AAAA;AAAA,EAGhB,aAAa;AAAA;AAAA,EAGb,gBAAgB;AAAA;AAAA,EAGhB,cAAc;AAAA;AAAA,EAGd,QAAQ;AAAA;AAAA,EAGR,OAAO;AAAA;AAAA,EAGP,QAAQ;AAAA;AAAA,EAGR,UAAU;AAAA;AAAA,EAGV,mBAAmB;AAAA;AAAA,EAGnB,kBAAkB;AAAA;AAAA,EAGlB,cAAc;AAAA;AAAA,EAGd,qBAAqB;AACvB;AA2BA,SAAS,WAAW,QAA4B,UAA2B;AACzE,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,WAAW,YAAY,WAAW,IAAI,QAAQ;AACvD;AAGO,SAAS,eACd,QACA,UACS;AACT,SAAO,WAAW,QAAQ,QAAQ;AACpC;;;ACjGA,IAAM,uBAAqD,oBAAI,IAAI;AAmF5D,SAAS,mBACd,UAC6B;AAC7B,SAAO,qBAAqB,IAAI,QAAQ;AAC1C;AAEO,SAAS,kBAAkB,UAA2B;AAC3D,QAAM,WAAW,qBAAqB,IAAI,QAAQ;AAClD,SAAO,UAAU,aAAa;AAChC;","names":[]}
|
package/dist/posthog-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@posthog/agent",
|
|
4
|
-
version: "2.3.
|
|
4
|
+
version: "2.3.398",
|
|
5
5
|
repository: "https://github.com/PostHog/code",
|
|
6
6
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
7
7
|
exports: {
|
|
@@ -53,6 +53,10 @@ var package_default = {
|
|
|
53
53
|
types: "./dist/adapters/reasoning-effort.d.ts",
|
|
54
54
|
import: "./dist/adapters/reasoning-effort.js"
|
|
55
55
|
},
|
|
56
|
+
"./adapters/claude/mcp/tool-metadata": {
|
|
57
|
+
types: "./dist/adapters/claude/mcp/tool-metadata.d.ts",
|
|
58
|
+
import: "./dist/adapters/claude/mcp/tool-metadata.js"
|
|
59
|
+
},
|
|
56
60
|
"./execution-mode": {
|
|
57
61
|
types: "./dist/execution-mode.d.ts",
|
|
58
62
|
import: "./dist/execution-mode.js"
|
package/dist/posthog-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/utils/gateway.ts","../src/posthog-api.ts"],"sourcesContent":["{\n \"name\": \"@posthog/agent\",\n \"version\": \"2.3.388\",\n \"repository\": \"https://github.com/PostHog/code\",\n \"description\": \"TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./agent\": {\n \"types\": \"./dist/agent.d.ts\",\n \"import\": \"./dist/agent.js\"\n },\n \"./gateway-models\": {\n \"types\": \"./dist/gateway-models.d.ts\",\n \"import\": \"./dist/gateway-models.js\"\n },\n \"./posthog-api\": {\n \"types\": \"./dist/posthog-api.d.ts\",\n \"import\": \"./dist/posthog-api.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\",\n \"import\": \"./dist/types.js\"\n },\n \"./adapters/claude/questions/utils\": {\n \"types\": \"./dist/adapters/claude/questions/utils.d.ts\",\n \"import\": \"./dist/adapters/claude/questions/utils.js\"\n },\n \"./adapters/claude/permissions/permission-options\": {\n \"types\": \"./dist/adapters/claude/permissions/permission-options.d.ts\",\n \"import\": \"./dist/adapters/claude/permissions/permission-options.js\"\n },\n \"./adapters/claude/tools\": {\n \"types\": \"./dist/adapters/claude/tools.d.ts\",\n \"import\": \"./dist/adapters/claude/tools.js\"\n },\n \"./adapters/claude/conversion/tool-use-to-acp\": {\n \"types\": \"./dist/adapters/claude/conversion/tool-use-to-acp.d.ts\",\n \"import\": \"./dist/adapters/claude/conversion/tool-use-to-acp.js\"\n },\n \"./adapters/claude/session/jsonl-hydration\": {\n \"types\": \"./dist/adapters/claude/session/jsonl-hydration.d.ts\",\n \"import\": \"./dist/adapters/claude/session/jsonl-hydration.js\"\n },\n \"./adapters/claude/session/models\": {\n \"types\": \"./dist/adapters/claude/session/models.d.ts\",\n \"import\": \"./dist/adapters/claude/session/models.js\"\n },\n \"./adapters/reasoning-effort\": {\n \"types\": \"./dist/adapters/reasoning-effort.d.ts\",\n \"import\": \"./dist/adapters/reasoning-effort.js\"\n },\n \"./execution-mode\": {\n \"types\": \"./dist/execution-mode.d.ts\",\n \"import\": \"./dist/execution-mode.js\"\n },\n \"./resume\": {\n \"types\": \"./dist/resume.d.ts\",\n \"import\": \"./dist/resume.js\"\n },\n \"./handoff-checkpoint\": {\n \"types\": \"./dist/handoff-checkpoint.d.ts\",\n \"import\": \"./dist/handoff-checkpoint.js\"\n },\n \"./tree-tracker\": {\n \"types\": \"./dist/tree-tracker.d.ts\",\n \"import\": \"./dist/tree-tracker.js\"\n },\n \"./server\": {\n \"types\": \"./dist/server/agent-server.d.ts\",\n \"import\": \"./dist/server/agent-server.js\"\n },\n \"./server/schemas\": {\n \"types\": \"./dist/server/schemas.d.ts\",\n \"import\": \"./dist/server/schemas.js\"\n }\n },\n \"bin\": {\n \"agent-server\": \"./dist/server/bin.cjs\"\n },\n \"type\": \"module\",\n \"keywords\": [\n \"posthog\",\n \"claude\",\n \"agent\",\n \"ai\",\n \"git\",\n \"typescript\"\n ],\n \"author\": \"PostHog\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"scripts\": {\n \"build\": \"node ../../scripts/rimraf.mjs dist && tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"pnpm exec tsc --noEmit\",\n \"prepublishOnly\": \"pnpm run build\",\n \"clean\": \"node ../../scripts/rimraf.mjs dist .turbo\"\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"devDependencies\": {\n \"@posthog/shared\": \"workspace:*\",\n \"@posthog/git\": \"workspace:*\",\n \"@posthog/enricher\": \"workspace:*\",\n \"@types/bun\": \"latest\",\n \"@types/tar\": \"^6.1.13\",\n \"msw\": \"^2.12.7\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.5.0\",\n \"vitest\": \"^2.1.8\"\n },\n \"dependencies\": {\n \"@agentclientprotocol/sdk\": \"0.19.0\",\n \"ajv\": \"^8.17.1\",\n \"@anthropic-ai/claude-agent-sdk\": \"0.2.112\",\n \"@anthropic-ai/sdk\": \"0.89.0\",\n \"@hono/node-server\": \"^1.19.9\",\n \"@opentelemetry/api-logs\": \"^0.208.0\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"^0.208.0\",\n \"@opentelemetry/resources\": \"^2.0.0\",\n \"@opentelemetry/sdk-logs\": \"^0.208.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.0\",\n \"@types/jsonwebtoken\": \"^9.0.10\",\n \"commander\": \"^14.0.2\",\n \"hono\": \"^4.11.7\",\n \"jsonwebtoken\": \"^9.0.2\",\n \"minimatch\": \"^10.0.3\",\n \"tar\": \"^7.5.0\",\n \"uuid\": \"13.0.0\",\n \"yoga-wasm-web\": \"^0.3.3\",\n \"zod\": \"^4.2.0\"\n },\n \"files\": [\n \"dist/**/*\",\n \"src/**/*\",\n \"README.md\",\n \"CLAUDE.md\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export type GatewayProduct = \"posthog_code\" | \"background_agents\";\n\nfunction getGatewayBaseUrl(posthogHost: string): string {\n const url = new URL(posthogHost);\n const hostname = url.hostname;\n\n if (hostname === \"localhost\" || hostname === \"127.0.0.1\") {\n return `${url.protocol}//localhost:3308`;\n }\n\n if (hostname === \"host.docker.internal\") {\n return `${url.protocol}//host.docker.internal:3308`;\n }\n\n const region = hostname.match(/^(us|eu)\\.posthog\\.com$/)?.[1] ?? \"us\";\n return `https://gateway.${region}.posthog.com`;\n}\n\nexport function getLlmGatewayUrl(\n posthogHost: string,\n product: GatewayProduct = \"posthog_code\",\n): string {\n return `${getGatewayBaseUrl(posthogHost)}/${product}`;\n}\n\nexport function getGatewayUsageUrl(\n posthogHost: string,\n product: GatewayProduct = \"posthog_code\",\n): string {\n return `${getGatewayBaseUrl(posthogHost)}/v1/usage/${product}`;\n}\n\nexport function getGatewayInvalidatePlanCacheUrl(\n posthogHost: string,\n product: GatewayProduct = \"posthog_code\",\n): string {\n return `${getGatewayBaseUrl(posthogHost)}/v1/usage/${product}/invalidate-plan-cache`;\n}\n","import packageJson from \"../package.json\" with { type: \"json\" };\nimport type {\n ArtifactType,\n PostHogAPIConfig,\n StoredEntry,\n Task,\n TaskRun,\n TaskRunArtifact,\n} from \"./types\";\nimport {\n getGatewayInvalidatePlanCacheUrl,\n getGatewayUsageUrl,\n getLlmGatewayUrl,\n} from \"./utils/gateway\";\n\nexport {\n getGatewayInvalidatePlanCacheUrl,\n getGatewayUsageUrl,\n getLlmGatewayUrl,\n};\n\nconst DEFAULT_USER_AGENT = `posthog/agent.hog.dev; version: ${packageJson.version}`;\n\nexport interface TaskArtifactUploadPayload {\n name: string;\n type: ArtifactType;\n content: string;\n content_type?: string;\n}\n\nexport type TaskRunUpdate = Partial<\n Pick<\n TaskRun,\n | \"status\"\n | \"branch\"\n | \"stage\"\n | \"error_message\"\n | \"output\"\n | \"state\"\n | \"environment\"\n >\n> & {\n state_remove_keys?: string[];\n};\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\")\n ? this.config.apiUrl.slice(0, -1)\n : this.config.apiUrl;\n return host;\n }\n\n private isAuthFailure(status: number): boolean {\n return status === 401 || status === 403;\n }\n\n private async resolveApiKey(forceRefresh = false): Promise<string> {\n if (forceRefresh && this.config.refreshApiKey) {\n return this.config.refreshApiKey();\n }\n\n return this.config.getApiKey();\n }\n\n private async buildHeaders(\n options: RequestInit,\n forceRefresh = false,\n ): Promise<Headers> {\n const headers = new Headers(options.headers);\n headers.set(\n \"Authorization\",\n `Bearer ${await this.resolveApiKey(forceRefresh)}`,\n );\n headers.set(\"Content-Type\", \"application/json\");\n headers.set(\"User-Agent\", this.config.userAgent ?? DEFAULT_USER_AGENT);\n return headers;\n }\n\n private async performRequest(\n endpoint: string,\n options: RequestInit,\n forceRefresh = false,\n ): Promise<Response> {\n const url = `${this.baseUrl}${endpoint}`;\n\n return fetch(url, {\n ...options,\n headers: await this.buildHeaders(options, forceRefresh),\n });\n }\n\n private async performRequestWithRetry(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<Response> {\n let response = await this.performRequest(endpoint, options);\n\n if (!response.ok && this.isAuthFailure(response.status)) {\n response = await this.performRequest(endpoint, options, true);\n }\n\n return response;\n }\n\n private async apiRequest<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n const response = await this.performRequestWithRetry(endpoint, options);\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n private getTeamId(): number {\n return this.config.projectId;\n }\n\n async getApiKey(forceRefresh = false): Promise<string> {\n return this.resolveApiKey(forceRefresh);\n }\n\n getLlmGatewayUrl(): string {\n return getLlmGatewayUrl(this.baseUrl);\n }\n\n async getTask(taskId: string): Promise<Task> {\n const teamId = this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\n }\n\n async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`,\n );\n }\n\n async resumeRunInCloud(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/resume_in_cloud/`,\n { method: \"POST\" },\n );\n }\n\n async updateTaskRun(\n taskId: string,\n runId: string,\n payload: TaskRunUpdate,\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`,\n {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n },\n );\n }\n\n async setTaskRunOutput(\n taskId: string,\n runId: string,\n output: Record<string, unknown>,\n ): Promise<TaskRun> {\n return this.apiRequest(\n `/api/projects/${this.getTeamId()}/tasks/${taskId}/runs/${runId}/set_output/`,\n {\n method: \"PATCH\",\n body: JSON.stringify(output),\n },\n );\n }\n\n async appendTaskRunLog(\n taskId: string,\n runId: string,\n entries: StoredEntry[],\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`,\n {\n method: \"POST\",\n body: JSON.stringify({ entries }),\n },\n );\n }\n\n async relayMessage(\n taskId: string,\n runId: string,\n text: string,\n ): Promise<void> {\n const teamId = this.getTeamId();\n await this.apiRequest<{ status: string }>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/relay_message/`,\n {\n method: \"POST\",\n body: JSON.stringify({ text }),\n },\n );\n }\n\n async uploadTaskArtifacts(\n taskId: string,\n runId: string,\n artifacts: TaskArtifactUploadPayload[],\n ): Promise<TaskRunArtifact[]> {\n if (!artifacts.length) {\n return [];\n }\n\n const teamId = this.getTeamId();\n const response = await this.apiRequest<{ artifacts: TaskRunArtifact[] }>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/`,\n {\n method: \"POST\",\n body: JSON.stringify({ artifacts }),\n },\n );\n\n const manifest = response.artifacts ?? [];\n\n // The backend returns the full run artifact manifest after each upload.\n // Callers want the artifacts corresponding to this upload request only.\n return manifest.slice(-artifacts.length);\n }\n\n /**\n * Download artifact content by storage path\n * Streams the file through the PostHog backend so the sandbox does not need\n * direct access to object storage.\n */\n async downloadArtifact(\n taskId: string,\n runId: string,\n storagePath: string,\n ): Promise<ArrayBuffer | null> {\n const teamId = this.getTeamId();\n\n try {\n const response = await this.performRequestWithRetry(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/download/`,\n {\n method: \"POST\",\n body: JSON.stringify({ storage_path: storagePath }),\n },\n );\n if (!response.ok) {\n throw new Error(`Failed to download artifact: ${response.status}`);\n }\n return response.arrayBuffer();\n } catch {\n return null;\n }\n }\n\n /**\n * Fetch logs for a task run via the logs API endpoint\n * @param taskRun - The task run to fetch logs for\n * @returns Array of stored entries, or empty array if no logs available\n */\n async fetchTaskRunLogs(taskRun: TaskRun): Promise<StoredEntry[]> {\n const teamId = this.getTeamId();\n const endpoint = `/api/projects/${teamId}/tasks/${taskRun.task}/runs/${taskRun.id}/logs`;\n\n try {\n const response = await this.performRequestWithRetry(endpoint);\n\n if (!response.ok) {\n if (response.status === 404) {\n return [];\n }\n throw new Error(\n `Failed to fetch logs: ${response.status} ${response.statusText}`,\n );\n }\n\n const content = await response.text();\n\n if (!content.trim()) {\n return [];\n }\n\n // Parse newline-delimited JSON\n return content\n .trim()\n .split(\"\\n\")\n .map((line) => JSON.parse(line) as StoredEntry);\n } catch (error) {\n throw new Error(\n `Failed to fetch task run logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,YAAc;AAAA,EACd,aAAe;AAAA,EACf,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,oBAAoB;AAAA,MAClB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACf,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,qCAAqC;AAAA,MACnC,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,oDAAoD;AAAA,MAClD,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,2BAA2B;AAAA,MACzB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,gDAAgD;AAAA,MAC9C,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,6CAA6C;AAAA,MAC3C,OAAS;AAA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,WAAW,MAAM,KAAK;AAAA,QAC1B,iBAAiB,MAAM,UAAU,MAAM,SAAS,KAAK;AAAA,QACrD;AAAA,UACE,QAAQ;AAAA,UACR,MAAM,KAAK,UAAU,EAAE,cAAc,YAAY,CAAC;AAAA,QACpD;AAAA,MACF;AACA,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,gCAAgC,SAAS,MAAM,EAAE;AAAA,MACnE;AACA,aAAO,SAAS,YAAY;AAAA,IAC9B,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAiB,SAA0C;AAC/D,UAAM,SAAS,KAAK,UAAU;AAC9B,UAAM,WAAW,iBAAiB,MAAM,UAAU,QAAQ,IAAI,SAAS,QAAQ,EAAE;AAEjF,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,wBAAwB,QAAQ;AAE5D,UAAI,CAAC,SAAS,IAAI;AAChB,YAAI,SAAS,WAAW,KAAK;AAC3B,iBAAO,CAAC;AAAA,QACV;AACA,cAAM,IAAI;AAAA,UACR,yBAAyB,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,QACjE;AAAA,MACF;AAEA,YAAM,UAAU,MAAM,SAAS,KAAK;AAEpC,UAAI,CAAC,QAAQ,KAAK,GAAG;AACnB,eAAO,CAAC;AAAA,MACV;AAGA,aAAO,QACJ,KAAK,EACL,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,MAAM,IAAI,CAAgB;AAAA,IAClD,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,kCAAkC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAC1F;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/utils/gateway.ts","../src/posthog-api.ts"],"sourcesContent":["{\n \"name\": \"@posthog/agent\",\n \"version\": \"2.3.398\",\n \"repository\": \"https://github.com/PostHog/code\",\n \"description\": \"TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./agent\": {\n \"types\": \"./dist/agent.d.ts\",\n \"import\": \"./dist/agent.js\"\n },\n \"./gateway-models\": {\n \"types\": \"./dist/gateway-models.d.ts\",\n \"import\": \"./dist/gateway-models.js\"\n },\n \"./posthog-api\": {\n \"types\": \"./dist/posthog-api.d.ts\",\n \"import\": \"./dist/posthog-api.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\",\n \"import\": \"./dist/types.js\"\n },\n \"./adapters/claude/questions/utils\": {\n \"types\": \"./dist/adapters/claude/questions/utils.d.ts\",\n \"import\": \"./dist/adapters/claude/questions/utils.js\"\n },\n \"./adapters/claude/permissions/permission-options\": {\n \"types\": \"./dist/adapters/claude/permissions/permission-options.d.ts\",\n \"import\": \"./dist/adapters/claude/permissions/permission-options.js\"\n },\n \"./adapters/claude/tools\": {\n \"types\": \"./dist/adapters/claude/tools.d.ts\",\n \"import\": \"./dist/adapters/claude/tools.js\"\n },\n \"./adapters/claude/conversion/tool-use-to-acp\": {\n \"types\": \"./dist/adapters/claude/conversion/tool-use-to-acp.d.ts\",\n \"import\": \"./dist/adapters/claude/conversion/tool-use-to-acp.js\"\n },\n \"./adapters/claude/session/jsonl-hydration\": {\n \"types\": \"./dist/adapters/claude/session/jsonl-hydration.d.ts\",\n \"import\": \"./dist/adapters/claude/session/jsonl-hydration.js\"\n },\n \"./adapters/claude/session/models\": {\n \"types\": \"./dist/adapters/claude/session/models.d.ts\",\n \"import\": \"./dist/adapters/claude/session/models.js\"\n },\n \"./adapters/reasoning-effort\": {\n \"types\": \"./dist/adapters/reasoning-effort.d.ts\",\n \"import\": \"./dist/adapters/reasoning-effort.js\"\n },\n \"./adapters/claude/mcp/tool-metadata\": {\n \"types\": \"./dist/adapters/claude/mcp/tool-metadata.d.ts\",\n \"import\": \"./dist/adapters/claude/mcp/tool-metadata.js\"\n },\n \"./execution-mode\": {\n \"types\": \"./dist/execution-mode.d.ts\",\n \"import\": \"./dist/execution-mode.js\"\n },\n \"./resume\": {\n \"types\": \"./dist/resume.d.ts\",\n \"import\": \"./dist/resume.js\"\n },\n \"./handoff-checkpoint\": {\n \"types\": \"./dist/handoff-checkpoint.d.ts\",\n \"import\": \"./dist/handoff-checkpoint.js\"\n },\n \"./tree-tracker\": {\n \"types\": \"./dist/tree-tracker.d.ts\",\n \"import\": \"./dist/tree-tracker.js\"\n },\n \"./server\": {\n \"types\": \"./dist/server/agent-server.d.ts\",\n \"import\": \"./dist/server/agent-server.js\"\n },\n \"./server/schemas\": {\n \"types\": \"./dist/server/schemas.d.ts\",\n \"import\": \"./dist/server/schemas.js\"\n }\n },\n \"bin\": {\n \"agent-server\": \"./dist/server/bin.cjs\"\n },\n \"type\": \"module\",\n \"keywords\": [\n \"posthog\",\n \"claude\",\n \"agent\",\n \"ai\",\n \"git\",\n \"typescript\"\n ],\n \"author\": \"PostHog\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"scripts\": {\n \"build\": \"node ../../scripts/rimraf.mjs dist && tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"pnpm exec tsc --noEmit\",\n \"prepublishOnly\": \"pnpm run build\",\n \"clean\": \"node ../../scripts/rimraf.mjs dist .turbo\"\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"devDependencies\": {\n \"@posthog/shared\": \"workspace:*\",\n \"@posthog/git\": \"workspace:*\",\n \"@posthog/enricher\": \"workspace:*\",\n \"@types/bun\": \"latest\",\n \"@types/tar\": \"^6.1.13\",\n \"msw\": \"^2.12.7\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.20.6\",\n \"typescript\": \"^5.5.0\",\n \"vitest\": \"^2.1.8\"\n },\n \"dependencies\": {\n \"@agentclientprotocol/sdk\": \"0.19.0\",\n \"ajv\": \"^8.17.1\",\n \"@anthropic-ai/claude-agent-sdk\": \"0.2.112\",\n \"@anthropic-ai/sdk\": \"0.89.0\",\n \"@hono/node-server\": \"^1.19.9\",\n \"@opentelemetry/api-logs\": \"^0.208.0\",\n \"@opentelemetry/exporter-logs-otlp-http\": \"^0.208.0\",\n \"@opentelemetry/resources\": \"^2.0.0\",\n \"@opentelemetry/sdk-logs\": \"^0.208.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.0\",\n \"@types/jsonwebtoken\": \"^9.0.10\",\n \"commander\": \"^14.0.2\",\n \"hono\": \"^4.11.7\",\n \"jsonwebtoken\": \"^9.0.2\",\n \"minimatch\": \"^10.0.3\",\n \"tar\": \"^7.5.0\",\n \"uuid\": \"13.0.0\",\n \"yoga-wasm-web\": \"^0.3.3\",\n \"zod\": \"^4.2.0\"\n },\n \"files\": [\n \"dist/**/*\",\n \"src/**/*\",\n \"README.md\",\n \"CLAUDE.md\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export type GatewayProduct = \"posthog_code\" | \"background_agents\";\n\nfunction getGatewayBaseUrl(posthogHost: string): string {\n const url = new URL(posthogHost);\n const hostname = url.hostname;\n\n if (hostname === \"localhost\" || hostname === \"127.0.0.1\") {\n return `${url.protocol}//localhost:3308`;\n }\n\n if (hostname === \"host.docker.internal\") {\n return `${url.protocol}//host.docker.internal:3308`;\n }\n\n const region = hostname.match(/^(us|eu)\\.posthog\\.com$/)?.[1] ?? \"us\";\n return `https://gateway.${region}.posthog.com`;\n}\n\nexport function getLlmGatewayUrl(\n posthogHost: string,\n product: GatewayProduct = \"posthog_code\",\n): string {\n return `${getGatewayBaseUrl(posthogHost)}/${product}`;\n}\n\nexport function getGatewayUsageUrl(\n posthogHost: string,\n product: GatewayProduct = \"posthog_code\",\n): string {\n return `${getGatewayBaseUrl(posthogHost)}/v1/usage/${product}`;\n}\n\nexport function getGatewayInvalidatePlanCacheUrl(\n posthogHost: string,\n product: GatewayProduct = \"posthog_code\",\n): string {\n return `${getGatewayBaseUrl(posthogHost)}/v1/usage/${product}/invalidate-plan-cache`;\n}\n","import packageJson from \"../package.json\" with { type: \"json\" };\nimport type {\n ArtifactType,\n PostHogAPIConfig,\n StoredEntry,\n Task,\n TaskRun,\n TaskRunArtifact,\n} from \"./types\";\nimport {\n getGatewayInvalidatePlanCacheUrl,\n getGatewayUsageUrl,\n getLlmGatewayUrl,\n} from \"./utils/gateway\";\n\nexport {\n getGatewayInvalidatePlanCacheUrl,\n getGatewayUsageUrl,\n getLlmGatewayUrl,\n};\n\nconst DEFAULT_USER_AGENT = `posthog/agent.hog.dev; version: ${packageJson.version}`;\n\nexport interface TaskArtifactUploadPayload {\n name: string;\n type: ArtifactType;\n content: string;\n content_type?: string;\n}\n\nexport type TaskRunUpdate = Partial<\n Pick<\n TaskRun,\n | \"status\"\n | \"branch\"\n | \"stage\"\n | \"error_message\"\n | \"output\"\n | \"state\"\n | \"environment\"\n >\n> & {\n state_remove_keys?: string[];\n};\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\")\n ? this.config.apiUrl.slice(0, -1)\n : this.config.apiUrl;\n return host;\n }\n\n private isAuthFailure(status: number): boolean {\n return status === 401 || status === 403;\n }\n\n private async resolveApiKey(forceRefresh = false): Promise<string> {\n if (forceRefresh && this.config.refreshApiKey) {\n return this.config.refreshApiKey();\n }\n\n return this.config.getApiKey();\n }\n\n private async buildHeaders(\n options: RequestInit,\n forceRefresh = false,\n ): Promise<Headers> {\n const headers = new Headers(options.headers);\n headers.set(\n \"Authorization\",\n `Bearer ${await this.resolveApiKey(forceRefresh)}`,\n );\n headers.set(\"Content-Type\", \"application/json\");\n headers.set(\"User-Agent\", this.config.userAgent ?? DEFAULT_USER_AGENT);\n return headers;\n }\n\n private async performRequest(\n endpoint: string,\n options: RequestInit,\n forceRefresh = false,\n ): Promise<Response> {\n const url = `${this.baseUrl}${endpoint}`;\n\n return fetch(url, {\n ...options,\n headers: await this.buildHeaders(options, forceRefresh),\n });\n }\n\n private async performRequestWithRetry(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<Response> {\n let response = await this.performRequest(endpoint, options);\n\n if (!response.ok && this.isAuthFailure(response.status)) {\n response = await this.performRequest(endpoint, options, true);\n }\n\n return response;\n }\n\n private async apiRequest<T>(\n endpoint: string,\n options: RequestInit = {},\n ): Promise<T> {\n const response = await this.performRequestWithRetry(endpoint, options);\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n private getTeamId(): number {\n return this.config.projectId;\n }\n\n async getApiKey(forceRefresh = false): Promise<string> {\n return this.resolveApiKey(forceRefresh);\n }\n\n getLlmGatewayUrl(): string {\n return getLlmGatewayUrl(this.baseUrl);\n }\n\n async getTask(taskId: string): Promise<Task> {\n const teamId = this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\n }\n\n async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`,\n );\n }\n\n async resumeRunInCloud(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/resume_in_cloud/`,\n { method: \"POST\" },\n );\n }\n\n async updateTaskRun(\n taskId: string,\n runId: string,\n payload: TaskRunUpdate,\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`,\n {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n },\n );\n }\n\n async setTaskRunOutput(\n taskId: string,\n runId: string,\n output: Record<string, unknown>,\n ): Promise<TaskRun> {\n return this.apiRequest(\n `/api/projects/${this.getTeamId()}/tasks/${taskId}/runs/${runId}/set_output/`,\n {\n method: \"PATCH\",\n body: JSON.stringify(output),\n },\n );\n }\n\n async appendTaskRunLog(\n taskId: string,\n runId: string,\n entries: StoredEntry[],\n ): Promise<TaskRun> {\n const teamId = this.getTeamId();\n return this.apiRequest<TaskRun>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`,\n {\n method: \"POST\",\n body: JSON.stringify({ entries }),\n },\n );\n }\n\n async relayMessage(\n taskId: string,\n runId: string,\n text: string,\n ): Promise<void> {\n const teamId = this.getTeamId();\n await this.apiRequest<{ status: string }>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/relay_message/`,\n {\n method: \"POST\",\n body: JSON.stringify({ text }),\n },\n );\n }\n\n async uploadTaskArtifacts(\n taskId: string,\n runId: string,\n artifacts: TaskArtifactUploadPayload[],\n ): Promise<TaskRunArtifact[]> {\n if (!artifacts.length) {\n return [];\n }\n\n const teamId = this.getTeamId();\n const response = await this.apiRequest<{ artifacts: TaskRunArtifact[] }>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/`,\n {\n method: \"POST\",\n body: JSON.stringify({ artifacts }),\n },\n );\n\n const manifest = response.artifacts ?? [];\n\n // The backend returns the full run artifact manifest after each upload.\n // Callers want the artifacts corresponding to this upload request only.\n return manifest.slice(-artifacts.length);\n }\n\n /**\n * Download artifact content by storage path\n * Streams the file through the PostHog backend so the sandbox does not need\n * direct access to object storage.\n */\n async downloadArtifact(\n taskId: string,\n runId: string,\n storagePath: string,\n ): Promise<ArrayBuffer | null> {\n const teamId = this.getTeamId();\n\n try {\n const response = await this.performRequestWithRetry(\n `/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/download/`,\n {\n method: \"POST\",\n body: JSON.stringify({ storage_path: storagePath }),\n },\n );\n if (!response.ok) {\n throw new Error(`Failed to download artifact: ${response.status}`);\n }\n return response.arrayBuffer();\n } catch {\n return null;\n }\n }\n\n /**\n * Fetch logs for a task run via the logs API endpoint\n * @param taskRun - The task run to fetch logs for\n * @returns Array of stored entries, or empty array if no logs available\n */\n async fetchTaskRunLogs(taskRun: TaskRun): Promise<StoredEntry[]> {\n const teamId = this.getTeamId();\n const endpoint = `/api/projects/${teamId}/tasks/${taskRun.task}/runs/${taskRun.id}/logs`;\n\n try {\n const response = await this.performRequestWithRetry(endpoint);\n\n if (!response.ok) {\n if (response.status === 404) {\n return [];\n }\n throw new Error(\n `Failed to fetch logs: ${response.status} ${response.statusText}`,\n );\n }\n\n const content = await response.text();\n\n if (!content.trim()) {\n return [];\n }\n\n // Parse newline-delimited JSON\n return content\n .trim()\n .split(\"\\n\")\n .map((line) => JSON.parse(line) as StoredEntry);\n } catch (error) {\n throw new Error(\n `Failed to fetch task run logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n}\n"],"mappings":";AAAA;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,YAAc;AAAA,EACd,aAAe;AAAA,EACf,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,oBAAoB;AAAA,MAClB,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACf,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,qCAAqC;AAAA,MACnC,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,IACA,oDAAoD;AAAA,MAClD,OAAS;AAAA,MACT,QAAU;AAAA,IACZ;AAAA,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CAAkC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAC1F;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -8605,7 +8605,7 @@ import { z as z4 } from "zod";
|
|
|
8605
8605
|
// package.json
|
|
8606
8606
|
var package_default = {
|
|
8607
8607
|
name: "@posthog/agent",
|
|
8608
|
-
version: "2.3.
|
|
8608
|
+
version: "2.3.398",
|
|
8609
8609
|
repository: "https://github.com/PostHog/code",
|
|
8610
8610
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
8611
8611
|
exports: {
|
|
@@ -8657,6 +8657,10 @@ var package_default = {
|
|
|
8657
8657
|
types: "./dist/adapters/reasoning-effort.d.ts",
|
|
8658
8658
|
import: "./dist/adapters/reasoning-effort.js"
|
|
8659
8659
|
},
|
|
8660
|
+
"./adapters/claude/mcp/tool-metadata": {
|
|
8661
|
+
types: "./dist/adapters/claude/mcp/tool-metadata.d.ts",
|
|
8662
|
+
import: "./dist/adapters/claude/mcp/tool-metadata.js"
|
|
8663
|
+
},
|
|
8660
8664
|
"./execution-mode": {
|
|
8661
8665
|
types: "./dist/execution-mode.d.ts",
|
|
8662
8666
|
import: "./dist/execution-mode.js"
|
|
@@ -13657,10 +13661,12 @@ async function fetchMcpToolMetadata(q, logger = new Logger({ debug: false, prefi
|
|
|
13657
13661
|
for (const tool of server.tools) {
|
|
13658
13662
|
const toolKey = buildToolKey(server.name, tool.name);
|
|
13659
13663
|
const readOnly = tool.annotations?.readOnly === true;
|
|
13664
|
+
const existing = mcpToolMetadataCache.get(toolKey);
|
|
13660
13665
|
mcpToolMetadataCache.set(toolKey, {
|
|
13661
13666
|
readOnly,
|
|
13662
13667
|
name: tool.name,
|
|
13663
|
-
description: tool.description
|
|
13668
|
+
description: tool.description,
|
|
13669
|
+
approvalState: existing?.approvalState
|
|
13664
13670
|
});
|
|
13665
13671
|
if (readOnly) readOnlyCount++;
|
|
13666
13672
|
}
|
|
@@ -13702,6 +13708,23 @@ function getConnectedMcpServerNames() {
|
|
|
13702
13708
|
}
|
|
13703
13709
|
return [...names];
|
|
13704
13710
|
}
|
|
13711
|
+
function getMcpToolApprovalState(toolName) {
|
|
13712
|
+
return mcpToolMetadataCache.get(toolName)?.approvalState;
|
|
13713
|
+
}
|
|
13714
|
+
function setMcpToolApprovalStates(approvals) {
|
|
13715
|
+
for (const [toolKey, approvalState] of Object.entries(approvals)) {
|
|
13716
|
+
const existing = mcpToolMetadataCache.get(toolKey);
|
|
13717
|
+
if (existing) {
|
|
13718
|
+
existing.approvalState = approvalState;
|
|
13719
|
+
} else {
|
|
13720
|
+
mcpToolMetadataCache.set(toolKey, {
|
|
13721
|
+
readOnly: false,
|
|
13722
|
+
name: toolKey,
|
|
13723
|
+
approvalState
|
|
13724
|
+
});
|
|
13725
|
+
}
|
|
13726
|
+
}
|
|
13727
|
+
}
|
|
13705
13728
|
|
|
13706
13729
|
// src/adapters/claude/conversion/tool-use-to-acp.ts
|
|
13707
13730
|
var SYSTEM_REMINDER_REGEX = /\s*<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
@@ -15397,6 +15420,72 @@ async function handleDefaultPermissionFlow(context) {
|
|
|
15397
15420
|
return { behavior: "deny", message, interrupt: !feedback };
|
|
15398
15421
|
}
|
|
15399
15422
|
}
|
|
15423
|
+
function parseMcpToolName(toolName) {
|
|
15424
|
+
const parts2 = toolName.split("__");
|
|
15425
|
+
return {
|
|
15426
|
+
serverName: parts2[1] ?? toolName,
|
|
15427
|
+
tool: parts2.slice(2).join("__") || toolName
|
|
15428
|
+
};
|
|
15429
|
+
}
|
|
15430
|
+
async function handleMcpApprovalFlow(context) {
|
|
15431
|
+
const { toolName, toolInput, toolUseID, client, sessionId } = context;
|
|
15432
|
+
const { serverName, tool: displayTool } = parseMcpToolName(toolName);
|
|
15433
|
+
const metadata2 = getMcpToolMetadata(toolName);
|
|
15434
|
+
const description = metadata2?.description ? `
|
|
15435
|
+
|
|
15436
|
+
${metadata2.description}` : "";
|
|
15437
|
+
const response = await client.requestPermission({
|
|
15438
|
+
options: [
|
|
15439
|
+
{ kind: "allow_once", name: "Yes", optionId: "allow" },
|
|
15440
|
+
{
|
|
15441
|
+
kind: "allow_always",
|
|
15442
|
+
name: "Yes, always allow",
|
|
15443
|
+
optionId: "allow_always"
|
|
15444
|
+
},
|
|
15445
|
+
{
|
|
15446
|
+
kind: "reject_once",
|
|
15447
|
+
name: "Type here to tell the agent what to do differently",
|
|
15448
|
+
optionId: "reject",
|
|
15449
|
+
_meta: { customInput: true }
|
|
15450
|
+
}
|
|
15451
|
+
],
|
|
15452
|
+
sessionId,
|
|
15453
|
+
toolCall: {
|
|
15454
|
+
toolCallId: toolUseID,
|
|
15455
|
+
title: `The agent wants to call ${displayTool} (${serverName})`,
|
|
15456
|
+
kind: "other",
|
|
15457
|
+
content: description ? [{ type: "content", content: text(description) }] : [],
|
|
15458
|
+
rawInput: { ...toolInput, toolName }
|
|
15459
|
+
}
|
|
15460
|
+
});
|
|
15461
|
+
if (context.signal?.aborted || response.outcome?.outcome === "cancelled") {
|
|
15462
|
+
throw new Error("Tool use aborted");
|
|
15463
|
+
}
|
|
15464
|
+
if (response.outcome?.outcome === "selected" && (response.outcome.optionId === "allow" || response.outcome.optionId === "allow_always")) {
|
|
15465
|
+
if (response.outcome.optionId === "allow_always") {
|
|
15466
|
+
return {
|
|
15467
|
+
behavior: "allow",
|
|
15468
|
+
updatedInput: toolInput,
|
|
15469
|
+
updatedPermissions: [
|
|
15470
|
+
{
|
|
15471
|
+
type: "addRules",
|
|
15472
|
+
rules: [{ toolName }],
|
|
15473
|
+
behavior: "allow",
|
|
15474
|
+
destination: "localSettings"
|
|
15475
|
+
}
|
|
15476
|
+
]
|
|
15477
|
+
};
|
|
15478
|
+
}
|
|
15479
|
+
return {
|
|
15480
|
+
behavior: "allow",
|
|
15481
|
+
updatedInput: toolInput
|
|
15482
|
+
};
|
|
15483
|
+
}
|
|
15484
|
+
const feedback = response._meta?.customInput?.trim();
|
|
15485
|
+
const message = feedback ? `User refused permission to run tool with feedback: ${feedback}` : "User refused permission to run tool";
|
|
15486
|
+
await emitToolDenial(context, message);
|
|
15487
|
+
return { behavior: "deny", message, interrupt: !feedback };
|
|
15488
|
+
}
|
|
15400
15489
|
function handlePlanFileException(context) {
|
|
15401
15490
|
const { session, toolName, toolInput } = context;
|
|
15402
15491
|
if (session.permissionMode !== "plan" || !WRITE_TOOLS.has(toolName)) {
|
|
@@ -15467,6 +15556,17 @@ async function canUseTool(context) {
|
|
|
15467
15556
|
}
|
|
15468
15557
|
}
|
|
15469
15558
|
}
|
|
15559
|
+
if (toolName.startsWith("mcp__")) {
|
|
15560
|
+
const approvalState = getMcpToolApprovalState(toolName);
|
|
15561
|
+
if (approvalState === "do_not_use") {
|
|
15562
|
+
const message = "This tool has been blocked. To re-enable it, go to Settings > MCP Servers in PostHog Code.";
|
|
15563
|
+
await emitToolDenial(context, message);
|
|
15564
|
+
return { behavior: "deny", message, interrupt: false };
|
|
15565
|
+
}
|
|
15566
|
+
if (approvalState === "needs_approval") {
|
|
15567
|
+
return handleMcpApprovalFlow(context);
|
|
15568
|
+
}
|
|
15569
|
+
}
|
|
15470
15570
|
if (isToolAllowedForMode(toolName, session.permissionMode)) {
|
|
15471
15571
|
return {
|
|
15472
15572
|
behavior: "allow",
|
|
@@ -15679,7 +15779,14 @@ Only enter plan mode (EnterPlanMode) when the user is requesting a significant c
|
|
|
15679
15779
|
|
|
15680
15780
|
When in doubt, continue executing and incorporate the feedback inline.
|
|
15681
15781
|
`;
|
|
15682
|
-
var
|
|
15782
|
+
var MCP_TOOLS = `
|
|
15783
|
+
# MCP Tool Access
|
|
15784
|
+
|
|
15785
|
+
If an MCP tool call is explicitly denied with a message, relay that denial message to the user exactly as given. Do NOT suggest checking "Claude Code settings."
|
|
15786
|
+
|
|
15787
|
+
If an MCP tool call returns an error, treat it as a normal tool error \u2014 troubleshoot, retry, or inform the user about the specific error. Do NOT assume it is a permissions issue and do NOT direct the user to any settings page.
|
|
15788
|
+
`;
|
|
15789
|
+
var APPENDED_INSTRUCTIONS = BRANCH_NAMING + PLAN_MODE + MCP_TOOLS;
|
|
15683
15790
|
|
|
15684
15791
|
// src/adapters/claude/session/options.ts
|
|
15685
15792
|
function buildSystemPrompt(customPrompt) {
|
|
@@ -17008,6 +17115,9 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
17008
17115
|
const earlyModelId = settingsManager.getSettings().model || meta?.model || "";
|
|
17009
17116
|
const mcpServers = supportsMcpInjection(earlyModelId) ? parseMcpServers(params) : {};
|
|
17010
17117
|
const systemPrompt = buildSystemPrompt(meta?.systemPrompt);
|
|
17118
|
+
if (meta?.mcpToolApprovals) {
|
|
17119
|
+
setMcpToolApprovalStates(meta.mcpToolApprovals);
|
|
17120
|
+
}
|
|
17011
17121
|
const outputFormat = meta?.jsonSchema && this.options?.onStructuredOutput ? { type: "json_schema", schema: meta.jsonSchema } : void 0;
|
|
17012
17122
|
this.logger.debug(isResume ? "Resuming session" : "Creating new session", {
|
|
17013
17123
|
sessionId,
|