MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / shortText

Function shortText

layers/decision-alignment.ts:16–28  ·  view source on GitHub ↗
(value: unknown, maxLen = MAX_TEXT_LEN)

Source from the content-addressed store, hash-verified

14const MAX_CONTEXT_MESSAGES = 4;
15
16function shortText(value: unknown, maxLen = MAX_TEXT_LEN): string {
17 let text = "";
18 if (typeof value === "string") text = value;
19 else {
20 try {
21 text = JSON.stringify(value);
22 } catch {
23 text = String(value);
24 }
25 }
26 text = text.replace(/\s+/g, " ").trim();
27 return text.length > maxLen ? `${text.slice(0, maxLen - 3)}...` : text;
28}
29
30function asMessage(value: unknown): Record<string, unknown> | null {
31 if (!value || typeof value !== "object") return null;

Callers 3

summarizeMessageFunction · 0.85
buildJudgeInputFunction · 0.85
normalizeJudgeResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected