Update CLI scripts to enhance functionality and error handling. Change shebang in cli-ink.js for improved compatibility with TypeScript. Modify websearch.js to utilize EXA_API_KEY from environment variables, adding error handling for missing keys. Refactor wget.js to use ES module syntax and improve filename generation for downloaded content.

This commit is contained in:
sebseb7
2025-08-12 05:44:17 +00:00
parent 62e9754ab0
commit ac09e4ed08
6 changed files with 66 additions and 7 deletions

View File

@@ -1,17 +1,17 @@
const fetch = require('node-fetch');
module.exports = async function wget(params) {
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 = url.split('/').filter(Boolean).pop() || 'index.html';
const filename = new Date().getTime() + '.' + url.split('.').pop();
const content = buffer.slice(0, 500).toString('utf8');
return { filename, content };
};
// metadata for the tool runner
module.exports.meta = {
export default {
type: 'function',
name: 'wget',
description: 'Download URL to filesystem',