@posthog/agent 2.1.113 → 2.1.115
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 +40 -22
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.d.ts +2 -1
- package/dist/posthog-api.js +5 -5
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +42 -23
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +42 -23
- 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/src/server/agent-server.ts +4 -1
- package/src/utils/gateway.ts +9 -4
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.1.
|
|
907
|
+
version: "2.1.115",
|
|
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
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
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
|
}
|
|
@@ -4203,17 +4221,17 @@ function createCodexConnection(config) {
|
|
|
4203
4221
|
}
|
|
4204
4222
|
|
|
4205
4223
|
// src/utils/gateway.ts
|
|
4206
|
-
function getLlmGatewayUrl(posthogHost) {
|
|
4224
|
+
function getLlmGatewayUrl(posthogHost, product = "twig") {
|
|
4207
4225
|
const url = new URL(posthogHost);
|
|
4208
4226
|
const hostname = url.hostname;
|
|
4209
4227
|
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
4210
|
-
return `${url.protocol}//localhost:3308
|
|
4228
|
+
return `${url.protocol}//localhost:3308/${product}`;
|
|
4211
4229
|
}
|
|
4212
4230
|
if (hostname === "host.docker.internal") {
|
|
4213
|
-
return `${url.protocol}//host.docker.internal:3308
|
|
4231
|
+
return `${url.protocol}//host.docker.internal:3308/${product}`;
|
|
4214
4232
|
}
|
|
4215
4233
|
const region = hostname.match(/^(us|eu)\.posthog\.com$/)?.[1] ?? "us";
|
|
4216
|
-
return `https://gateway.${region}.posthog.com
|
|
4234
|
+
return `https://gateway.${region}.posthog.com/${product}`;
|
|
4217
4235
|
}
|
|
4218
4236
|
|
|
4219
4237
|
// src/posthog-api.ts
|
|
@@ -10660,7 +10678,8 @@ Important:
|
|
|
10660
10678
|
}
|
|
10661
10679
|
configureEnvironment() {
|
|
10662
10680
|
const { apiKey, apiUrl, projectId } = this.config;
|
|
10663
|
-
const
|
|
10681
|
+
const product = this.config.mode === "background" ? "background_agents" : "twig";
|
|
10682
|
+
const gatewayUrl = process.env.LLM_GATEWAY_URL || getLlmGatewayUrl(apiUrl, product);
|
|
10664
10683
|
const openaiBaseUrl = gatewayUrl.endsWith("/v1") ? gatewayUrl : `${gatewayUrl}/v1`;
|
|
10665
10684
|
Object.assign(process.env, {
|
|
10666
10685
|
// PostHog
|