feat: wire 10 new tools — file_read, file_write, glob, grep, web_fetch, task CRUD, send_message, schedule_cron
- 10 new JS tool classes in src/tools/ (clean, no framework deps) - tools/index.js: registry-based init with env toggles - bot/index.js: 16 tool definitions + 16 handlers (was 4) - Added glob npm dependency - Tools: bash, file_edit, file_read, file_write, glob, grep, web_search, web_fetch, git, task_create/update/list, send_message, schedule_cron, delegate_agent, run_skill
This commit is contained in:
36
src/tools/TaskCreateTool.js
Normal file
36
src/tools/TaskCreateTool.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { logger } from '../utils/logger.js';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
const TASKS_FILE = 'data/tasks.json';
|
||||
|
||||
export class TaskCreateTool {
|
||||
constructor() {
|
||||
this.name = 'task_create';
|
||||
this.description = 'Create a new task with description';
|
||||
}
|
||||
|
||||
async execute(args) {
|
||||
const { description } = args;
|
||||
try {
|
||||
const tasks = await this._loadTasks();
|
||||
const id = String(Date.now()).slice(-8);
|
||||
tasks.push({ id, description, status: 'pending', created: new Date().toISOString() });
|
||||
await this._saveTasks(tasks);
|
||||
return `✅ Task created: #${id} — ${description}`;
|
||||
} catch (e) {
|
||||
return `❌ ${e.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
async _loadTasks() {
|
||||
try {
|
||||
return await fs.readJson(TASKS_FILE);
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
async _saveTasks(tasks) {
|
||||
await fs.ensureDir(path.dirname(TASKS_FILE));
|
||||
await fs.writeJson(TASKS_FILE, tasks, { spaces: 2 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user