export async function run(args){ const { url } = params; if (!url) throw new Error('missing url'); const res = await fetch(url); const buffer = await res.buffer(); const filename = new Date().getTime() + '.' + url.split('.').pop(); const content = buffer.slice(0, 500).toString('utf8'); // save the file to the chroot const filePath = `/workspaces/aiTools/root/${filename}`; fs.writeFileSync(filePath, content); return { 'Downloaded to:': filename }; }; // metadata for the tool runner export default { type: 'function', name: 'wget', description: 'Download URL to filesystem', strict: true, parameters: { type: 'object', required: ['url'], additionalProperties: false, properties: { url: { type: 'string', description: 'The url to get.' } } } };