MCPcopy Create free account
hub / github.com/coder/mux / extractText

Function extractText

src/node/services/devToolsService.ts:31–60  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

29}
30
31function extractText(value: unknown): string {
32 if (typeof value === "string") {
33 return value;
34 }
35
36 if (Array.isArray(value)) {
37 return value
38 .map((item) => extractText(item))
39 .filter((item) => item.length > 0)
40 .join(" ");
41 }
42
43 if (!isRecord(value)) {
44 return "";
45 }
46
47 if (typeof value.text === "string") {
48 return value.text;
49 }
50
51 if ("content" in value) {
52 return extractText(value.content);
53 }
54
55 if ("parts" in value) {
56 return extractText(value.parts);
57 }
58
59 return "";
60}
61
62function truncateMessage(message: string, maxLength = 80): string {
63 if (message.length <= maxLength) {

Callers 1

buildRunSummaryMethod · 0.70

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected