@posthog/agent 2.3.619 → 2.3.643
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 +56 -10
- 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 +56 -10
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +56 -10
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/conversion/acp-to-sdk.test.ts +109 -13
- package/src/adapters/claude/conversion/acp-to-sdk.ts +63 -9
package/dist/server/bin.cjs
CHANGED
|
@@ -8809,7 +8809,7 @@ var import_zod3 = require("zod");
|
|
|
8809
8809
|
// package.json
|
|
8810
8810
|
var package_default = {
|
|
8811
8811
|
name: "@posthog/agent",
|
|
8812
|
-
version: "2.3.
|
|
8812
|
+
version: "2.3.643",
|
|
8813
8813
|
repository: "https://github.com/PostHog/code",
|
|
8814
8814
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
8815
8815
|
exports: {
|
|
@@ -13562,6 +13562,28 @@ var BaseAcpAgent = class {
|
|
|
13562
13562
|
// src/adapters/claude/conversion/acp-to-sdk.ts
|
|
13563
13563
|
var path5 = __toESM(require("path"), 1);
|
|
13564
13564
|
var import_node_url = require("url");
|
|
13565
|
+
var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
|
|
13566
|
+
var COMMON_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
13567
|
+
"png",
|
|
13568
|
+
"jpg",
|
|
13569
|
+
"jpeg",
|
|
13570
|
+
"gif",
|
|
13571
|
+
"webp",
|
|
13572
|
+
"bmp",
|
|
13573
|
+
"svg",
|
|
13574
|
+
"heic",
|
|
13575
|
+
"tif",
|
|
13576
|
+
"tiff"
|
|
13577
|
+
]);
|
|
13578
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
13579
|
+
"mp4",
|
|
13580
|
+
"mov",
|
|
13581
|
+
"webm",
|
|
13582
|
+
"mkv",
|
|
13583
|
+
"avi",
|
|
13584
|
+
"mpeg",
|
|
13585
|
+
"mpg"
|
|
13586
|
+
]);
|
|
13565
13587
|
function sdkText(value) {
|
|
13566
13588
|
return { type: "text", text: value };
|
|
13567
13589
|
}
|
|
@@ -13576,20 +13598,37 @@ function formatUriAsLink(uri) {
|
|
|
13576
13598
|
return uri;
|
|
13577
13599
|
}
|
|
13578
13600
|
}
|
|
13579
|
-
function
|
|
13601
|
+
function readToolGuidanceForPath(filePath) {
|
|
13602
|
+
const ext = path5.extname(filePath).slice(1).toLowerCase();
|
|
13603
|
+
if (PDF_EXTENSIONS.has(ext)) {
|
|
13604
|
+
return 'Optional `pages` string (e.g. "1-5") per Read call instead of loading the entire PDF.';
|
|
13605
|
+
}
|
|
13606
|
+
if (COMMON_IMAGE_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext)) {
|
|
13607
|
+
return "Binary file \u2014 use Read with `file_path`; prefer bounded reads where supported.";
|
|
13608
|
+
}
|
|
13609
|
+
return "Large text \u2014 use multiple Read calls with optional `offset` and `limit`.";
|
|
13610
|
+
}
|
|
13611
|
+
function workspacePromptFromFileUri(uri) {
|
|
13580
13612
|
try {
|
|
13581
13613
|
const filePath = (0, import_node_url.fileURLToPath)(uri);
|
|
13582
13614
|
const name2 = path5.basename(filePath) || filePath;
|
|
13583
13615
|
return [
|
|
13584
|
-
"Attached file
|
|
13585
|
-
`-
|
|
13586
|
-
`-
|
|
13587
|
-
|
|
13616
|
+
"Attached workspace file \u2014 use Read with required `file_path`:",
|
|
13617
|
+
`- file_path: ${filePath}`,
|
|
13618
|
+
`- name (context): ${name2}`,
|
|
13619
|
+
readToolGuidanceForPath(filePath)
|
|
13588
13620
|
].join("\n");
|
|
13589
13621
|
} catch {
|
|
13590
|
-
return
|
|
13622
|
+
return [
|
|
13623
|
+
"Attached file \u2014 decode path from URI, call Read with that path as `file_path`:",
|
|
13624
|
+
uri,
|
|
13625
|
+
'Chunk PDFs with `pages` (e.g. "1-5"); long text with `offset`/`limit`.'
|
|
13626
|
+
].join("\n");
|
|
13591
13627
|
}
|
|
13592
13628
|
}
|
|
13629
|
+
function isFileSchemeUri(uri) {
|
|
13630
|
+
return Boolean(uri?.startsWith("file://"));
|
|
13631
|
+
}
|
|
13593
13632
|
function transformMcpCommand(text2) {
|
|
13594
13633
|
const mcpMatch = text2.match(/^\/mcp:([^:\s]+):(\S+)(\s+.*)?$/);
|
|
13595
13634
|
if (mcpMatch) {
|
|
@@ -13606,17 +13645,22 @@ function processPromptChunk(chunk, content, context) {
|
|
|
13606
13645
|
case "resource_link":
|
|
13607
13646
|
content.push(
|
|
13608
13647
|
sdkText(
|
|
13609
|
-
chunk.uri.startsWith("file://") ?
|
|
13648
|
+
chunk.uri.startsWith("file://") ? workspacePromptFromFileUri(chunk.uri) : formatUriAsLink(chunk.uri)
|
|
13610
13649
|
)
|
|
13611
13650
|
);
|
|
13612
13651
|
break;
|
|
13613
13652
|
case "resource":
|
|
13614
13653
|
if ("text" in chunk.resource) {
|
|
13615
|
-
|
|
13654
|
+
const uri = chunk.resource.uri;
|
|
13655
|
+
if (uri != null && isFileSchemeUri(uri)) {
|
|
13656
|
+
content.push(sdkText(workspacePromptFromFileUri(uri)));
|
|
13657
|
+
break;
|
|
13658
|
+
}
|
|
13659
|
+
content.push(sdkText(formatUriAsLink(uri ?? "")));
|
|
13616
13660
|
context.push(
|
|
13617
13661
|
sdkText(
|
|
13618
13662
|
`
|
|
13619
|
-
<context ref="${
|
|
13663
|
+
<context ref="${uri ?? ""}">
|
|
13620
13664
|
${chunk.resource.text}
|
|
13621
13665
|
</context>`
|
|
13622
13666
|
)
|
|
@@ -13638,6 +13682,8 @@ ${chunk.resource.text}
|
|
|
13638
13682
|
type: "image",
|
|
13639
13683
|
source: { type: "url", url: chunk.uri }
|
|
13640
13684
|
});
|
|
13685
|
+
} else if (chunk.uri != null && isFileSchemeUri(chunk.uri)) {
|
|
13686
|
+
content.push(sdkText(workspacePromptFromFileUri(chunk.uri)));
|
|
13641
13687
|
}
|
|
13642
13688
|
break;
|
|
13643
13689
|
default:
|