@posthog/agent 2.3.53 → 2.3.62

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.3.53",
907
+ version: "2.3.62",
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: {
@@ -1729,6 +1729,14 @@ function isMcpToolReadOnly(toolName) {
1729
1729
  const metadata = mcpToolMetadataCache.get(toolName);
1730
1730
  return metadata?.readOnly === true;
1731
1731
  }
1732
+ function getConnectedMcpServerNames() {
1733
+ const names = /* @__PURE__ */ new Set();
1734
+ for (const key of mcpToolMetadataCache.keys()) {
1735
+ const parts = key.split("__");
1736
+ if (parts.length >= 3) names.add(parts[1]);
1737
+ }
1738
+ return [...names];
1739
+ }
1732
1740
 
1733
1741
  // src/adapters/claude/conversion/tool-use-to-acp.ts
1734
1742
  var SYSTEM_REMINDER_REGEX = /\s*<system-reminder>[\s\S]*?<\/system-reminder>/g;
@@ -2485,7 +2493,10 @@ function handleToolResultChunk(chunk, ctx) {
2485
2493
  toolCallId: chunk.tool_use_id,
2486
2494
  sessionUpdate: "tool_call_update",
2487
2495
  status: chunk.is_error ? "failed" : "completed",
2488
- rawOutput: chunk.content,
2496
+ rawOutput: ctx.mcpToolUseResult ? { ...ctx.mcpToolUseResult, isError: chunk.is_error ?? false } : {
2497
+ content: Array.isArray(chunk.content) ? chunk.content : typeof chunk.content === "string" ? [{ type: "text", text: chunk.content }] : [],
2498
+ isError: chunk.is_error ?? false
2499
+ },
2489
2500
  ...toolUpdate
2490
2501
  });
2491
2502
  return updates;
@@ -2539,7 +2550,7 @@ function processContentChunk(chunk, role, ctx) {
2539
2550
  return [];
2540
2551
  }
2541
2552
  }
2542
- function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentCache, client, logger, parentToolCallId, registerHooks, supportsTerminalOutput, cwd) {
2553
+ function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentCache, client, logger, parentToolCallId, registerHooks, supportsTerminalOutput, cwd, mcpToolUseResult) {
2543
2554
  if (typeof content === "string") {
2544
2555
  const update = {
2545
2556
  sessionUpdate: messageUpdateType(role),
@@ -2563,7 +2574,8 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentC
2563
2574
  parentToolCallId,
2564
2575
  registerHooks,
2565
2576
  supportsTerminalOutput,
2566
- cwd
2577
+ cwd,
2578
+ mcpToolUseResult
2567
2579
  };
2568
2580
  const output = [];
2569
2581
  for (const chunk of content) {
@@ -2822,6 +2834,7 @@ async function handleUserAssistantMessage(message, context) {
2822
2834
  const content = message.message.content;
2823
2835
  const contentToProcess = message.type === "assistant" ? filterMessageContent(content) : content;
2824
2836
  const parentToolCallId = "parent_tool_use_id" in message ? message.parent_tool_use_id ?? void 0 : void 0;
2837
+ const mcpToolUseResult = message.type === "user" && message.tool_use_result != null ? message.tool_use_result : void 0;
2825
2838
  for (const notification of toAcpNotifications(
2826
2839
  contentToProcess,
2827
2840
  message.message.role,
@@ -2833,7 +2846,8 @@ async function handleUserAssistantMessage(message, context) {
2833
2846
  parentToolCallId,
2834
2847
  context.registerHooks,
2835
2848
  context.supportsTerminalOutput,
2836
- session.cwd
2849
+ session.cwd,
2850
+ mcpToolUseResult
2837
2851
  )) {
2838
2852
  await client.sessionUpdate(notification);
2839
2853
  session.notificationHistory.push(notification);
@@ -4673,11 +4687,17 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
4673
4687
  * Both populate caches used later — neither is needed to return configOptions.
4674
4688
  */
4675
4689
  deferBackgroundFetches(q) {
4690
+ this.logger.info("Starting background fetches (commands + MCP metadata)");
4676
4691
  Promise.all([
4677
4692
  new Promise((resolve4) => setTimeout(resolve4, 10)).then(
4678
4693
  () => this.sendAvailableCommandsUpdate()
4679
4694
  ),
4680
- fetchMcpToolMetadata(q, this.logger)
4695
+ fetchMcpToolMetadata(q, this.logger).then(() => {
4696
+ const serverNames = getConnectedMcpServerNames();
4697
+ if (serverNames.length > 0) {
4698
+ this.options?.onMcpServersReady?.(serverNames);
4699
+ }
4700
+ })
4681
4701
  ]).catch(
4682
4702
  (err) => this.logger.error("Background fetch failed", { error: err })
4683
4703
  );