MCPcopy Create free account
hub / github.com/apache/maka / shapeTerminalResult

Function shapeTerminalResult

packages/runtime/src/shell-tools.ts:543–582  ·  view source on GitHub ↗
(input: {
  cwd: string;
  command: string;
  result: ForegroundBashResult | BoundedShellResult;
})

Source from the content-addressed store, hash-verified

541}
542
543export function shapeTerminalResult(input: {
544 cwd: string;
545 command: string;
546 result: ForegroundBashResult | BoundedShellResult;
547}): TerminalToolResult {
548 const stdout = redactSecrets(input.result.stdout);
549 const stderr = redactSecrets(input.result.stderr);
550 const stdoutView = truncateToolOutput(stdout, { direction: 'tail' });
551 const stderrView = truncateToolOutput(stderr, { direction: 'tail' });
552 return {
553 kind: 'terminal',
554 cwd: input.cwd,
555 cmd: redactSecrets(input.command),
556 status: terminalStatus(input.result),
557 exitCode: input.result.exitCode,
558 output: {
559 mode: 'pipes',
560 stdout: stdoutView.content,
561 stderr: stderrView.content,
562 stdoutTruncated: Boolean(input.result.stdoutTruncated) || stdoutView.truncated,
563 stderrTruncated: Boolean(input.result.stderrTruncated) || stderrView.truncated,
564 redacted: stdout !== input.result.stdout || stderr !== input.result.stderr,
565 },
566 ...(isLikelySandboxDenial({
567 stdout: input.result.stdout,
568 stderr: input.result.stderr,
569 sandboxed: 'sandboxed' in input.result && input.result.sandboxed === true,
570 })
571 ? {
572 sandboxDenial: {
573 likely: true,
574 ...('sandboxType' in input.result &&
575 (input.result.sandboxType === 'macos-seatbelt' || input.result.sandboxType === 'linux')
576 ? { backend: input.result.sandboxType }
577 : {}),
578 },
579 }
580 : {}),
581 };
582}
583
584function terminalStatus(
585 result: ForegroundBashResult | BoundedShellResult,

Callers 3

buildExecutorBashToolFunction · 0.85
buildForegroundBashToolFunction · 0.85

Calls 4

redactSecretsFunction · 0.90
truncateToolOutputFunction · 0.85
isLikelySandboxDenialFunction · 0.85
terminalStatusFunction · 0.70

Tested by

no test coverage detected