(input: {
cwd: string;
command: string;
result: ForegroundBashResult | BoundedShellResult;
})
| 541 | } |
| 542 | |
| 543 | export 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 | |
| 584 | function terminalStatus( |
| 585 | result: ForegroundBashResult | BoundedShellResult, |
no test coverage detected