( executor: CommandExecutor, sessionId?: string )
| 676 | /** |
| 677 | * Check available disk space and total disk space for the container. |
| 678 | * Uses `df` command on the root filesystem which is available in the sandbox environment. |
| 679 | * Always checks `/` since all paths in the container share the same filesystem. |
| 680 | * |
| 681 | * @param session - Execution session to run the check |
| 682 | * @returns Structured disk space result |
| 683 | * @throws Error if disk check fails (command error, parse error, or exception) |
| 684 | */ |
| 685 | export async function checkDiskSpace(executor: CommandExecutor): Promise<DiskSpaceResult> { |
| 686 | // df -B1 gives output in bytes for clean numeric parsing (no M/G/K suffixes) |
| 687 | // --output=avail,size gives available and total space |
| 688 | // Always use "/" since all container paths share the same root filesystem |
| 689 | let result: ExecResult; |
| 690 | try { |
| 691 | result = await timedExec( |
| 692 | executor, |
| 693 | 'df -B1 --output=avail,size / | tail -1', |
| 694 | 'workspace.checkDiskSpace', |
| 695 | { timeoutMs: DISK_CHECK_TIMEOUT_MS } |
no test coverage detected