@posthog/agent 2.3.341 → 2.3.346
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 +29 -26
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.d.ts +5 -3
- package/dist/posthog-api.js +9 -20
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.d.ts +7 -0
- package/dist/server/agent-server.js +185 -38
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +185 -38
- package/dist/server/bin.cjs.map +1 -1
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
- package/src/adapters/claude/conversion/acp-to-sdk.test.ts +49 -0
- package/src/adapters/claude/conversion/acp-to-sdk.ts +23 -6
- package/src/posthog-api.test.ts +32 -0
- package/src/posthog-api.ts +13 -30
- package/src/server/agent-server.test.ts +96 -0
- package/src/server/agent-server.ts +207 -11
- package/src/server/schemas.test.ts +10 -0
- package/src/server/schemas.ts +25 -6
- package/src/test/mocks/msw-handlers.ts +4 -1
- package/src/types.ts +4 -1
package/dist/agent.js
CHANGED
|
@@ -3164,7 +3164,7 @@ import { v7 as uuidv7 } from "uuid";
|
|
|
3164
3164
|
// package.json
|
|
3165
3165
|
var package_default = {
|
|
3166
3166
|
name: "@posthog/agent",
|
|
3167
|
-
version: "2.3.
|
|
3167
|
+
version: "2.3.346",
|
|
3168
3168
|
repository: "https://github.com/PostHog/code",
|
|
3169
3169
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
3170
3170
|
exports: {
|
|
@@ -6760,16 +6760,12 @@ var BaseAcpAgent = class {
|
|
|
6760
6760
|
|
|
6761
6761
|
// src/adapters/claude/conversion/acp-to-sdk.ts
|
|
6762
6762
|
import * as path4 from "path";
|
|
6763
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6763
6764
|
function sdkText(value) {
|
|
6764
6765
|
return { type: "text", text: value };
|
|
6765
6766
|
}
|
|
6766
6767
|
function formatUriAsLink(uri) {
|
|
6767
6768
|
try {
|
|
6768
|
-
if (uri.startsWith("file://")) {
|
|
6769
|
-
const filePath = uri.slice(7);
|
|
6770
|
-
const name2 = path4.basename(filePath) || filePath;
|
|
6771
|
-
return `[@${name2}](${uri})`;
|
|
6772
|
-
}
|
|
6773
6769
|
if (uri.startsWith("zed://")) {
|
|
6774
6770
|
const name2 = path4.basename(uri) || uri;
|
|
6775
6771
|
return `[@${name2}](${uri})`;
|
|
@@ -6779,6 +6775,20 @@ function formatUriAsLink(uri) {
|
|
|
6779
6775
|
return uri;
|
|
6780
6776
|
}
|
|
6781
6777
|
}
|
|
6778
|
+
function formatFileAttachment(uri) {
|
|
6779
|
+
try {
|
|
6780
|
+
const filePath = fileURLToPath2(uri);
|
|
6781
|
+
const name2 = path4.basename(filePath) || filePath;
|
|
6782
|
+
return [
|
|
6783
|
+
"Attached file available in the workspace:",
|
|
6784
|
+
`- name: ${name2}`,
|
|
6785
|
+
`- path: ${filePath}`,
|
|
6786
|
+
"Use the available tools to inspect this file if needed."
|
|
6787
|
+
].join("\n");
|
|
6788
|
+
} catch {
|
|
6789
|
+
return `Attached file available at ${uri}`;
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6782
6792
|
function transformMcpCommand(text2) {
|
|
6783
6793
|
const mcpMatch = text2.match(/^\/mcp:([^:\s]+):(\S+)(\s+.*)?$/);
|
|
6784
6794
|
if (mcpMatch) {
|
|
@@ -6793,7 +6803,11 @@ function processPromptChunk(chunk, content, context) {
|
|
|
6793
6803
|
content.push(sdkText(transformMcpCommand(chunk.text)));
|
|
6794
6804
|
break;
|
|
6795
6805
|
case "resource_link":
|
|
6796
|
-
content.push(
|
|
6806
|
+
content.push(
|
|
6807
|
+
sdkText(
|
|
6808
|
+
chunk.uri.startsWith("file://") ? formatFileAttachment(chunk.uri) : formatUriAsLink(chunk.uri)
|
|
6809
|
+
)
|
|
6810
|
+
);
|
|
6797
6811
|
break;
|
|
6798
6812
|
case "resource":
|
|
6799
6813
|
if ("text" in chunk.resource) {
|
|
@@ -11716,32 +11730,21 @@ var PostHogAPIClient = class {
|
|
|
11716
11730
|
);
|
|
11717
11731
|
return response.artifacts ?? [];
|
|
11718
11732
|
}
|
|
11719
|
-
|
|
11733
|
+
/**
|
|
11734
|
+
* Download artifact content by storage path
|
|
11735
|
+
* Streams the file through the PostHog backend so the sandbox does not need
|
|
11736
|
+
* direct access to object storage.
|
|
11737
|
+
*/
|
|
11738
|
+
async downloadArtifact(taskId, runId, storagePath) {
|
|
11720
11739
|
const teamId = this.getTeamId();
|
|
11721
11740
|
try {
|
|
11722
|
-
const response = await this.
|
|
11723
|
-
`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/
|
|
11741
|
+
const response = await this.performRequestWithRetry(
|
|
11742
|
+
`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/artifacts/download/`,
|
|
11724
11743
|
{
|
|
11725
11744
|
method: "POST",
|
|
11726
11745
|
body: JSON.stringify({ storage_path: storagePath })
|
|
11727
11746
|
}
|
|
11728
11747
|
);
|
|
11729
|
-
return response.url;
|
|
11730
|
-
} catch {
|
|
11731
|
-
return null;
|
|
11732
|
-
}
|
|
11733
|
-
}
|
|
11734
|
-
/**
|
|
11735
|
-
* Download artifact content by storage path
|
|
11736
|
-
* Gets a presigned URL and fetches the content
|
|
11737
|
-
*/
|
|
11738
|
-
async downloadArtifact(taskId, runId, storagePath) {
|
|
11739
|
-
const url = await this.getArtifactPresignedUrl(taskId, runId, storagePath);
|
|
11740
|
-
if (!url) {
|
|
11741
|
-
return null;
|
|
11742
|
-
}
|
|
11743
|
-
try {
|
|
11744
|
-
const response = await fetch(url);
|
|
11745
11748
|
if (!response.ok) {
|
|
11746
11749
|
throw new Error(`Failed to download artifact: ${response.status}`);
|
|
11747
11750
|
}
|