@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 CHANGED
@@ -4030,7 +4030,7 @@ import { v7 as uuidv7 } from "uuid";
4030
4030
  // package.json
4031
4031
  var package_default = {
4032
4032
  name: "@posthog/agent",
4033
- version: "2.3.619",
4033
+ version: "2.3.643",
4034
4034
  repository: "https://github.com/PostHog/code",
4035
4035
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
4036
4036
  exports: {
@@ -8577,6 +8577,28 @@ var BaseAcpAgent = class {
8577
8577
  // src/adapters/claude/conversion/acp-to-sdk.ts
8578
8578
  import * as path5 from "path";
8579
8579
  import { fileURLToPath as fileURLToPath2 } from "url";
8580
+ var PDF_EXTENSIONS = /* @__PURE__ */ new Set(["pdf"]);
8581
+ var COMMON_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
8582
+ "png",
8583
+ "jpg",
8584
+ "jpeg",
8585
+ "gif",
8586
+ "webp",
8587
+ "bmp",
8588
+ "svg",
8589
+ "heic",
8590
+ "tif",
8591
+ "tiff"
8592
+ ]);
8593
+ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([
8594
+ "mp4",
8595
+ "mov",
8596
+ "webm",
8597
+ "mkv",
8598
+ "avi",
8599
+ "mpeg",
8600
+ "mpg"
8601
+ ]);
8580
8602
  function sdkText(value) {
8581
8603
  return { type: "text", text: value };
8582
8604
  }
@@ -8591,20 +8613,37 @@ function formatUriAsLink(uri) {
8591
8613
  return uri;
8592
8614
  }
8593
8615
  }
8594
- function formatFileAttachment(uri) {
8616
+ function readToolGuidanceForPath(filePath) {
8617
+ const ext = path5.extname(filePath).slice(1).toLowerCase();
8618
+ if (PDF_EXTENSIONS.has(ext)) {
8619
+ return 'Optional `pages` string (e.g. "1-5") per Read call instead of loading the entire PDF.';
8620
+ }
8621
+ if (COMMON_IMAGE_EXTENSIONS.has(ext) || VIDEO_EXTENSIONS.has(ext)) {
8622
+ return "Binary file \u2014 use Read with `file_path`; prefer bounded reads where supported.";
8623
+ }
8624
+ return "Large text \u2014 use multiple Read calls with optional `offset` and `limit`.";
8625
+ }
8626
+ function workspacePromptFromFileUri(uri) {
8595
8627
  try {
8596
8628
  const filePath = fileURLToPath2(uri);
8597
8629
  const name2 = path5.basename(filePath) || filePath;
8598
8630
  return [
8599
- "Attached file available in the workspace:",
8600
- `- name: ${name2}`,
8601
- `- path: ${filePath}`,
8602
- "Use the available tools to inspect this file if needed."
8631
+ "Attached workspace file \u2014 use Read with required `file_path`:",
8632
+ `- file_path: ${filePath}`,
8633
+ `- name (context): ${name2}`,
8634
+ readToolGuidanceForPath(filePath)
8603
8635
  ].join("\n");
8604
8636
  } catch {
8605
- return `Attached file available at ${uri}`;
8637
+ return [
8638
+ "Attached file \u2014 decode path from URI, call Read with that path as `file_path`:",
8639
+ uri,
8640
+ 'Chunk PDFs with `pages` (e.g. "1-5"); long text with `offset`/`limit`.'
8641
+ ].join("\n");
8606
8642
  }
8607
8643
  }
8644
+ function isFileSchemeUri(uri) {
8645
+ return Boolean(uri?.startsWith("file://"));
8646
+ }
8608
8647
  function transformMcpCommand(text2) {
8609
8648
  const mcpMatch = text2.match(/^\/mcp:([^:\s]+):(\S+)(\s+.*)?$/);
8610
8649
  if (mcpMatch) {
@@ -8621,17 +8660,22 @@ function processPromptChunk(chunk, content, context) {
8621
8660
  case "resource_link":
8622
8661
  content.push(
8623
8662
  sdkText(
8624
- chunk.uri.startsWith("file://") ? formatFileAttachment(chunk.uri) : formatUriAsLink(chunk.uri)
8663
+ chunk.uri.startsWith("file://") ? workspacePromptFromFileUri(chunk.uri) : formatUriAsLink(chunk.uri)
8625
8664
  )
8626
8665
  );
8627
8666
  break;
8628
8667
  case "resource":
8629
8668
  if ("text" in chunk.resource) {
8630
- content.push(sdkText(formatUriAsLink(chunk.resource.uri)));
8669
+ const uri = chunk.resource.uri;
8670
+ if (uri != null && isFileSchemeUri(uri)) {
8671
+ content.push(sdkText(workspacePromptFromFileUri(uri)));
8672
+ break;
8673
+ }
8674
+ content.push(sdkText(formatUriAsLink(uri ?? "")));
8631
8675
  context.push(
8632
8676
  sdkText(
8633
8677
  `
8634
- <context ref="${chunk.resource.uri}">
8678
+ <context ref="${uri ?? ""}">
8635
8679
  ${chunk.resource.text}
8636
8680
  </context>`
8637
8681
  )
@@ -8653,6 +8697,8 @@ ${chunk.resource.text}
8653
8697
  type: "image",
8654
8698
  source: { type: "url", url: chunk.uri }
8655
8699
  });
8700
+ } else if (chunk.uri != null && isFileSchemeUri(chunk.uri)) {
8701
+ content.push(sdkText(workspacePromptFromFileUri(chunk.uri)));
8656
8702
  }
8657
8703
  break;
8658
8704
  default: