705
}
706
707
>
function createSandboxLines(networkDomains?: ITerminalSandboxResolvedNetworkDomains): string[] {
copilotShellTools.ts
708
>
const lines = [
709
>
'',
710
>
'Sandboxing:',
711
>
'- ATTENTION: Terminal sandboxing is enabled, commands run in a sandbox by default',
712
>
'- When executing commands within the sandboxed environment, all operations requiring a temporary directory must utilize the $TMPDIR environment variable. The /tmp directory is not guaranteed to be accessible or writable and must be avoided',
713
>
'- Tools and scripts should respect the TMPDIR environment variable, which is automatically set to an appropriate path within the sandbox',
714
>
'- When a command fails due to sandbox restrictions, immediately re-run it with requestUnsandboxedExecution=true. Do NOT ask the user for permission — setting this flag automatically shows a confirmation prompt to the user',
715
>
'- Only set requestUnsandboxedExecution=true when there is evidence of failures caused by the sandbox, e.g. \'Operation not permitted\' errors, network failures, or file access errors, etc',
716
>
'- Do NOT set requestUnsandboxedExecution=true without first executing the command in sandbox mode. Always try the command in the sandbox first, and only set requestUnsandboxedExecution=true when retrying after that sandboxed execution failed due to sandbox restrictions.',
717
>
'- When setting requestUnsandboxedExecution=true, also provide requestUnsandboxedExecutionReason explaining why the command needs unsandboxed access',
718
>
];
719
>
if (networkDomains) {
720
>
const deniedSet = new Set(networkDomains.deniedDomains);
721
>
const effectiveAllowed = networkDomains.allowedDomains.filter(d => !deniedSet.has(d));
722
>
if (effectiveAllowed.length === 0) {
723
>
lines.push('- All network access is blocked in the sandbox');
724
>
} else {
725
lines.push(`- Only the following domains are accessible in the sandbox (all other network access is blocked): ${effectiveAllowed.join(', ')}`);
726
}
728
lines.push(`- The following domains are explicitly blocked in the sandbox: ${networkDomains.deniedDomains.join(', ')}`);
729
}
731
>
return lines;
732
>
}
733
734
function createGenericDescription(shellType: string, isSandboxEnabled: boolean, networkDomains?: ITerminalSandboxResolvedNetworkDomains): string {