@openacp/cli 0.2.26 → 0.2.28

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.
@@ -53,9 +53,19 @@ import path from "path";
53
53
  import { randomUUID } from "crypto";
54
54
  import { ClientSideConnection, ndJsonStream } from "@agentclientprotocol/sdk";
55
55
  var log = createChildLogger({ module: "agent-instance" });
56
+ function findPackageRoot(startDir) {
57
+ let dir = startDir;
58
+ while (dir !== path.dirname(dir)) {
59
+ if (fs.existsSync(path.join(dir, "package.json"))) {
60
+ return dir;
61
+ }
62
+ dir = path.dirname(dir);
63
+ }
64
+ return startDir;
65
+ }
56
66
  function resolveAgentCommand(cmd) {
57
67
  const searchRoots = [process.cwd()];
58
- const ownDir = path.resolve(import.meta.dirname, "..", "..");
68
+ const ownDir = findPackageRoot(import.meta.dirname);
59
69
  if (ownDir !== process.cwd()) {
60
70
  searchRoots.push(ownDir);
61
71
  }
@@ -285,7 +295,9 @@ ${stderr}`
285
295
  name: update.title,
286
296
  kind: update.kind ?? void 0,
287
297
  status: update.status ?? "pending",
288
- content: update.content ?? void 0
298
+ content: update.content ?? void 0,
299
+ rawInput: update.rawInput ?? void 0,
300
+ meta: update._meta ?? void 0
289
301
  };
290
302
  break;
291
303
  case "tool_call_update":
@@ -293,7 +305,9 @@ ${stderr}`
293
305
  type: "tool_update",
294
306
  id: update.toolCallId,
295
307
  status: update.status ?? "pending",
296
- content: update.content ?? void 0
308
+ content: update.content ?? void 0,
309
+ rawInput: update.rawInput ?? void 0,
310
+ meta: update._meta ?? void 0
297
311
  };
298
312
  break;
299
313
  case "plan":
@@ -852,10 +866,27 @@ var JsonFileSessionStore = class {
852
866
  };
853
867
 
854
868
  // src/tunnel/extract-file-info.ts
855
- function extractFileInfo(name, kind, content) {
856
- if (!content) return null;
869
+ function extractFileInfo(name, kind, content, rawInput, meta) {
857
870
  if (kind && !["read", "edit", "write"].includes(kind)) return null;
858
- const info = parseContent(content);
871
+ let info = null;
872
+ if (meta) {
873
+ const m = meta;
874
+ const file = m?.claudeCode?.toolResponse?.file;
875
+ if (file?.filePath && file?.content) {
876
+ info = { filePath: file.filePath, content: file.content };
877
+ }
878
+ }
879
+ if (!info && rawInput) {
880
+ const ri = rawInput;
881
+ const filePath = ri?.file_path || ri?.filePath || ri?.path;
882
+ if (typeof filePath === "string") {
883
+ const parsed = content ? parseContent(content) : null;
884
+ info = { filePath, content: parsed?.content || ri?.content };
885
+ }
886
+ }
887
+ if (!info && content) {
888
+ info = parseContent(content);
889
+ }
859
890
  if (!info) return null;
860
891
  if (!info.filePath) {
861
892
  const pathMatch = name.match(/(?:Read|Edit|Write|View)\s+(.+)/i);
@@ -1154,7 +1185,7 @@ var OpenACPCore = class {
1154
1185
  { name, kind, status: event.status, hasContent: !!event.content },
1155
1186
  "enrichWithViewerLinks: inspecting event"
1156
1187
  );
1157
- const fileInfo = extractFileInfo(name, kind, event.content);
1188
+ const fileInfo = extractFileInfo(name, kind, event.content, event.rawInput, event.meta);
1158
1189
  if (!fileInfo) return;
1159
1190
  log3.info(
1160
1191
  {
@@ -1186,6 +1217,7 @@ var OpenACPCore = class {
1186
1217
  if (id) viewerLinks.file = this.tunnelService.fileUrl(id);
1187
1218
  if (Object.keys(viewerLinks).length > 0) {
1188
1219
  metadata.viewerLinks = viewerLinks;
1220
+ metadata.viewerFilePath = fileInfo.filePath;
1189
1221
  }
1190
1222
  }
1191
1223
  // Public — adapters call this for assistant session wiring
@@ -1527,7 +1559,7 @@ function formatToolCall(tool) {
1527
1559
  text += `
1528
1560
  <pre>${escapeHtml(truncateContent(details))}</pre>`;
1529
1561
  }
1530
- text += formatViewerLinks(tool.viewerLinks);
1562
+ text += formatViewerLinks(tool.viewerLinks, tool.viewerFilePath);
1531
1563
  return text;
1532
1564
  }
1533
1565
  function formatToolUpdate(update) {
@@ -1540,16 +1572,17 @@ function formatToolUpdate(update) {
1540
1572
  text += `
1541
1573
  <pre>${escapeHtml(truncateContent(details))}</pre>`;
1542
1574
  }
1543
- text += formatViewerLinks(update.viewerLinks);
1575
+ text += formatViewerLinks(update.viewerLinks, update.viewerFilePath);
1544
1576
  return text;
1545
1577
  }
1546
- function formatViewerLinks(links) {
1578
+ function formatViewerLinks(links, filePath) {
1547
1579
  if (!links) return "";
1548
- let text = "";
1580
+ const fileName = filePath ? filePath.split("/").pop() || filePath : "";
1581
+ let text = "\n";
1549
1582
  if (links.file) text += `
1550
- \u{1F4C4} <a href="${escapeHtml(links.file)}">View file</a>`;
1583
+ \u{1F4C4} <a href="${escapeHtml(links.file)}">View ${escapeHtml(fileName || "file")}</a>`;
1551
1584
  if (links.diff) text += `
1552
- \u{1F4DD} <a href="${escapeHtml(links.diff)}">View diff</a>`;
1585
+ \u{1F4DD} <a href="${escapeHtml(links.diff)}">View diff${fileName ? ` \u2014 ${escapeHtml(fileName)}` : ""}</a>`;
1553
1586
  return text;
1554
1587
  }
1555
1588
  function formatPlan(plan) {
@@ -2631,7 +2664,8 @@ Workspace: <code>${workspace}</code>
2631
2664
  msgId: msg.message_id,
2632
2665
  name: meta.name,
2633
2666
  kind: meta.kind,
2634
- viewerLinks: meta.viewerLinks
2667
+ viewerLinks: meta.viewerLinks,
2668
+ viewerFilePath: content.metadata?.viewerFilePath
2635
2669
  });
2636
2670
  break;
2637
2671
  }
@@ -2640,12 +2674,15 @@ Workspace: <code>${workspace}</code>
2640
2674
  const toolState = this.toolCallMessages.get(sessionId)?.get(meta.id);
2641
2675
  if (toolState) {
2642
2676
  const viewerLinks = meta.viewerLinks || toolState.viewerLinks;
2677
+ const viewerFilePath = content.metadata?.viewerFilePath || toolState.viewerFilePath;
2643
2678
  if (meta.viewerLinks) toolState.viewerLinks = meta.viewerLinks;
2679
+ if (viewerFilePath) toolState.viewerFilePath = viewerFilePath;
2644
2680
  const merged = {
2645
2681
  ...meta,
2646
2682
  name: meta.name || toolState.name,
2647
2683
  kind: meta.kind || toolState.kind,
2648
- viewerLinks
2684
+ viewerLinks,
2685
+ viewerFilePath
2649
2686
  };
2650
2687
  try {
2651
2688
  await this.sendQueue.enqueue(
@@ -2920,4 +2957,4 @@ export {
2920
2957
  ApiServer,
2921
2958
  TelegramAdapter
2922
2959
  };
2923
- //# sourceMappingURL=chunk-HHQW27DT.js.map
2960
+ //# sourceMappingURL=chunk-6HORD4FS.js.map