MCPcopy Create free account
hub / github.com/OperationT00/T-Code / webFetchSummary

Method webFetchSummary

src/main/java/com/tcode/agent/Agent.java:642–665  ·  view source on GitHub ↗
(ToolExecutionResult result)

Source from the content-addressed store, hash-verified

640 }
641
642 private String webFetchSummary(ToolExecutionResult result) {
643 String text = result.result() == null ? "" : result.result();
644 String url = extractJsonArg(result.argumentsJson(), "url");
645 String target = url.isBlank() ? "页面" : compactOneLine(url.replaceFirst("^https?://", ""), 80);
646 if (text.startsWith("抓取失败") || text.startsWith("❌")) {
647 return "抓取 " + target + " 失败: " + compactOneLine(text, 100);
648 }
649 String title = text.lines()
650 .filter(line -> line.startsWith("📄 标题:"))
651 .map(line -> line.substring("📄 标题:".length()).trim())
652 .findFirst()
653 .orElse("");
654 String length = text.lines()
655 .filter(line -> line.startsWith("📏 正文"))
656 .findFirst()
657 .orElse("");
658 if (!title.isBlank() && !length.isBlank()) {
659 return "抓取 " + target + " 完成: " + title + " · " + length.replace("📏 ", "");
660 }
661 if (!title.isBlank()) {
662 return "抓取 " + target + " 完成: " + title;
663 }
664 return "抓取 " + target + " 完成";
665 }
666
667 private String extractJsonArg(String json, String key) {
668 if (json == null || json.isBlank() || key == null || key.isBlank()) {

Callers 1

emitToolResultSummaryMethod · 0.95

Calls 3

extractJsonArgMethod · 0.95
compactOneLineMethod · 0.95
resultMethod · 0.80

Tested by

no test coverage detected