@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.
- package/dist/adapters/claude/conversion/tool-use-to-acp.js +35 -17
- package/dist/adapters/claude/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/agent.js +36 -18
- 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.js +36 -18
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +36 -18
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/conversion/tool-use-to-acp.ts +39 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/agent",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.114",
|
|
4
4
|
"repository": "https://github.com/PostHog/twig",
|
|
5
5
|
"description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
6
6
|
"exports": {
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"tsx": "^4.20.6",
|
|
72
72
|
"typescript": "^5.5.0",
|
|
73
73
|
"vitest": "^2.1.8",
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
74
|
+
"@twig/git": "1.0.0",
|
|
75
|
+
"@posthog/shared": "1.0.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@agentclientprotocol/sdk": "^0.14.0",
|
|
@@ -609,32 +609,56 @@ export function toolUpdateFromToolResult(
|
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
611
|
|
|
612
|
+
function itemToText(item: unknown): string | null {
|
|
613
|
+
if (!item || typeof item !== "object") return null;
|
|
614
|
+
const obj = item as Record<string, unknown>;
|
|
615
|
+
// Standard text block
|
|
616
|
+
if (obj.type === "text" && typeof obj.text === "string") {
|
|
617
|
+
return obj.text;
|
|
618
|
+
}
|
|
619
|
+
// Any other structured object — serialize it
|
|
620
|
+
try {
|
|
621
|
+
return JSON.stringify(obj, null, 2);
|
|
622
|
+
} catch {
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
612
627
|
function toAcpContentUpdate(
|
|
613
628
|
content: unknown,
|
|
614
629
|
isError: boolean = false,
|
|
615
630
|
): Pick<ToolCallUpdate, "content"> {
|
|
616
631
|
if (Array.isArray(content) && content.length > 0) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}),
|
|
631
|
-
};
|
|
632
|
+
const texts: string[] = [];
|
|
633
|
+
for (const item of content) {
|
|
634
|
+
const t = itemToText(item);
|
|
635
|
+
if (t) texts.push(t);
|
|
636
|
+
}
|
|
637
|
+
if (texts.length > 0) {
|
|
638
|
+
const combined = texts.join("\n");
|
|
639
|
+
return {
|
|
640
|
+
content: toolContent()
|
|
641
|
+
.text(isError ? `\`\`\`\n${combined}\n\`\`\`` : combined)
|
|
642
|
+
.build(),
|
|
643
|
+
};
|
|
644
|
+
}
|
|
632
645
|
} else if (typeof content === "string" && content.length > 0) {
|
|
633
646
|
return {
|
|
634
647
|
content: toolContent()
|
|
635
648
|
.text(isError ? `\`\`\`\n${content}\n\`\`\`` : content)
|
|
636
649
|
.build(),
|
|
637
650
|
};
|
|
651
|
+
} else if (content && typeof content === "object") {
|
|
652
|
+
try {
|
|
653
|
+
const json = JSON.stringify(content, null, 2);
|
|
654
|
+
if (json && json !== "{}") {
|
|
655
|
+
return {
|
|
656
|
+
content: toolContent().text(json).build(),
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
} catch {
|
|
660
|
+
// ignore serialization errors
|
|
661
|
+
}
|
|
638
662
|
}
|
|
639
663
|
return {};
|
|
640
664
|
}
|