@posthog/agent 2.3.655 → 2.3.656
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/agent.js +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.d.ts +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +34 -4
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +34 -4
- package/dist/server/bin.cjs.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/server/agent-server.configure-environment.test.ts +64 -1
- package/src/server/agent-server.ts +33 -5
- package/src/types.ts +2 -1
- package/src/utils/gateway.test.ts +70 -0
- package/src/utils/gateway.ts +31 -1
package/dist/server/bin.cjs
CHANGED
|
@@ -9471,7 +9471,7 @@ var import_zod4 = require("zod");
|
|
|
9471
9471
|
// package.json
|
|
9472
9472
|
var package_default = {
|
|
9473
9473
|
name: "@posthog/agent",
|
|
9474
|
-
version: "2.3.
|
|
9474
|
+
version: "2.3.656",
|
|
9475
9475
|
repository: "https://github.com/PostHog/code",
|
|
9476
9476
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
9477
9477
|
exports: {
|
|
@@ -21481,6 +21481,18 @@ var HandoffCheckpointTracker = class {
|
|
|
21481
21481
|
};
|
|
21482
21482
|
|
|
21483
21483
|
// src/utils/gateway.ts
|
|
21484
|
+
function resolveGatewayProduct({
|
|
21485
|
+
isInternal,
|
|
21486
|
+
originProduct
|
|
21487
|
+
} = {}) {
|
|
21488
|
+
if (isInternal) {
|
|
21489
|
+
return originProduct === "signal_report" ? "signals" : "background_agents";
|
|
21490
|
+
}
|
|
21491
|
+
return "posthog_code";
|
|
21492
|
+
}
|
|
21493
|
+
function buildGatewayPropertyHeaders(properties) {
|
|
21494
|
+
return Object.entries(properties).filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => `x-posthog-property-${key}: ${value}`).join("\n");
|
|
21495
|
+
}
|
|
21484
21496
|
function getGatewayBaseUrl(posthogHost) {
|
|
21485
21497
|
const url = new URL(posthogHost);
|
|
21486
21498
|
const hostname = url.hostname;
|
|
@@ -23183,7 +23195,13 @@ var AgentServer = class {
|
|
|
23183
23195
|
return null;
|
|
23184
23196
|
})
|
|
23185
23197
|
]);
|
|
23186
|
-
this.configureEnvironment({
|
|
23198
|
+
this.configureEnvironment({
|
|
23199
|
+
isInternal: preTask?.internal === true,
|
|
23200
|
+
originProduct: preTask?.origin_product,
|
|
23201
|
+
taskId: payload.task_id,
|
|
23202
|
+
taskRunId: payload.run_id,
|
|
23203
|
+
taskUserId: payload.user_id
|
|
23204
|
+
});
|
|
23187
23205
|
const prUrl = getTaskRunStateString(preTaskRun, "slack_notified_pr_url");
|
|
23188
23206
|
if (prUrl) {
|
|
23189
23207
|
this.detectedPrUrl = prUrl;
|
|
@@ -23921,12 +23939,23 @@ ${signedCommitInstructions}
|
|
|
23921
23939
|
}
|
|
23922
23940
|
}
|
|
23923
23941
|
configureEnvironment({
|
|
23924
|
-
isInternal = false
|
|
23942
|
+
isInternal = false,
|
|
23943
|
+
originProduct,
|
|
23944
|
+
taskId,
|
|
23945
|
+
taskRunId,
|
|
23946
|
+
taskUserId
|
|
23925
23947
|
} = {}) {
|
|
23926
23948
|
const { apiKey, apiUrl, projectId } = this.config;
|
|
23927
|
-
const product = isInternal
|
|
23949
|
+
const product = resolveGatewayProduct({ isInternal, originProduct });
|
|
23928
23950
|
const gatewayUrl = process.env.LLM_GATEWAY_URL || getLlmGatewayUrl(apiUrl, product);
|
|
23929
23951
|
const openaiBaseUrl = gatewayUrl.endsWith("/v1") ? gatewayUrl : `${gatewayUrl}/v1`;
|
|
23952
|
+
const customHeaders = buildGatewayPropertyHeaders({
|
|
23953
|
+
task_origin_product: originProduct,
|
|
23954
|
+
task_internal: isInternal,
|
|
23955
|
+
task_id: taskId,
|
|
23956
|
+
task_run_id: taskRunId,
|
|
23957
|
+
task_user_id: taskUserId
|
|
23958
|
+
});
|
|
23930
23959
|
Object.assign(process.env, {
|
|
23931
23960
|
// PostHog
|
|
23932
23961
|
POSTHOG_API_KEY: apiKey,
|
|
@@ -23938,6 +23967,7 @@ ${signedCommitInstructions}
|
|
|
23938
23967
|
ANTHROPIC_API_KEY: apiKey,
|
|
23939
23968
|
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
23940
23969
|
ANTHROPIC_BASE_URL: gatewayUrl,
|
|
23970
|
+
ANTHROPIC_CUSTOM_HEADERS: customHeaders,
|
|
23941
23971
|
// OpenAI (for models like GPT-4, o1, etc.)
|
|
23942
23972
|
OPENAI_API_KEY: apiKey,
|
|
23943
23973
|
OPENAI_BASE_URL: openaiBaseUrl,
|