MCPcopy
hub / github.com/RedPlanetHQ/core / buildTruncationNote

Function buildTruncationNote

packages/cli/src/server/tools/exec-tools.ts:525–551  ·  view source on GitHub ↗
(
	r: ExecuteResult,
	stdoutCap: number,
	stderrCap: number,
)

Source from the content-addressed store, hash-verified

523}
524
525function buildTruncationNote(
526 r: ExecuteResult,
527 stdoutCap: number,
528 stderrCap: number,
529): string | undefined {
530 if (!r.stdoutTruncated && !r.stderrTruncated && !r.killedForOversize) {
531 return undefined;
532 }
533 const parts: string[] = [];
534 if (r.stdoutTruncated) {
535 parts.push(
536 `stdout exceeded ${formatBytes(stdoutCap)} cap (${formatBytes(r.stdoutTotalBytes)} total)`,
537 );
538 }
539 if (r.stderrTruncated) {
540 parts.push(
541 `stderr exceeded ${formatBytes(stderrCap)} cap (${formatBytes(r.stderrTotalBytes)} total)`,
542 );
543 }
544 if (r.killedForOversize) {
545 parts.push('command was killed for runaway output');
546 }
547 return (
548 parts.join('; ') +
549 '. Use head/tail/grep/sed -n to narrow the next call, or redirect to a file and read a slice.'
550 );
551}
552
553// ============ Tool Execution ============
554

Callers 1

handleExecCommandFunction · 0.85

Calls 2

pushMethod · 0.80
formatBytesFunction · 0.70

Tested by

no test coverage detected