@posthog/agent 2.1.113 → 2.1.114

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.113",
907
+ version: "2.1.114",
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: {
@@ -2112,31 +2112,49 @@ function toolUpdateFromToolResult(toolResult, toolUse) {
2112
2112
  }
2113
2113
  }
2114
2114
  }
2115
+ function itemToText(item) {
2116
+ if (!item || typeof item !== "object") return null;
2117
+ const obj = item;
2118
+ if (obj.type === "text" && typeof obj.text === "string") {
2119
+ return obj.text;
2120
+ }
2121
+ try {
2122
+ return JSON.stringify(obj, null, 2);
2123
+ } catch {
2124
+ return null;
2125
+ }
2126
+ }
2115
2127
  function toAcpContentUpdate(content, isError = false) {
2116
2128
  if (Array.isArray(content) && content.length > 0) {
2117
- return {
2118
- content: content.map((item) => {
2119
- const itemObj = item;
2120
- if (isError && itemObj.type === "text") {
2121
- return {
2122
- type: "content",
2123
- content: text(`\`\`\`
2124
- ${itemObj.text ?? ""}
2125
- \`\`\``)
2126
- };
2127
- }
2128
- return {
2129
- type: "content",
2130
- content: item
2131
- };
2132
- })
2133
- };
2129
+ const texts = [];
2130
+ for (const item of content) {
2131
+ const t = itemToText(item);
2132
+ if (t) texts.push(t);
2133
+ }
2134
+ if (texts.length > 0) {
2135
+ const combined = texts.join("\n");
2136
+ return {
2137
+ content: toolContent().text(isError ? `\`\`\`
2138
+ ${combined}
2139
+ \`\`\`` : combined).build()
2140
+ };
2141
+ }
2134
2142
  } else if (typeof content === "string" && content.length > 0) {
2135
2143
  return {
2136
2144
  content: toolContent().text(isError ? `\`\`\`
2137
2145
  ${content}
2138
2146
  \`\`\`` : content).build()
2139
2147
  };
2148
+ } else if (content && typeof content === "object") {
2149
+ try {
2150
+ const json = JSON.stringify(content, null, 2);
2151
+ if (json && json !== "{}") {
2152
+ return {
2153
+ content: toolContent().text(json).build()
2154
+ };
2155
+ }
2156
+ } catch {
2157
+ }
2140
2158
  }
2141
2159
  return {};
2142
2160
  }