MCPcopy Create free account
hub / github.com/Waishnav/devspace / truncateOutput

Function truncateOutput

src/process-sessions.ts:194–206  ·  view source on GitHub ↗
(output: string, maxCharacters: number)

Source from the content-addressed store, hash-verified

192}
193
194function truncateOutput(output: string, maxCharacters: number): { output: string; truncated: boolean } {
195 const outputCharacters = codePointLength(output);
196 if (outputCharacters <= maxCharacters) return { output, truncated: false };
197
198 const marker = "\n... output truncated ...\n";
199 const markerCharacters = codePointLength(marker);
200 const available = Math.max(0, maxCharacters - markerCharacters);
201 const budget = splitBudget(available);
202 return {
203 output: takeHead(output, budget.head) + marker + takeTail(output, budget.tail),
204 truncated: true,
205 };
206}
207
208export class ProcessSessionManager {
209 private readonly sessions = new Map<number, ProcessSession>();

Callers 1

drainMethod · 0.85

Calls 4

codePointLengthFunction · 0.85
splitBudgetFunction · 0.85
takeHeadFunction · 0.85
takeTailFunction · 0.85

Tested by

no test coverage detected