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:
42
src/tools/TaskUpdateTool.js
Normal file
42
src/tools/TaskUpdateTool.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { logger } from '../utils/logger.js';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
const TASKS_FILE = 'data/tasks.json';
|
||||
|
||||
export class TaskUpdateTool {
|
||||
constructor() {
|
||||
this.name = 'task_update';
|
||||
this.description = 'Update task status (pending/in_progress/completed/cancelled)';
|
||||
}
|
||||
|
||||
async execute(args) {
|
||||
const { task_id, status } = args;
|
||||
const validStatuses = ['pending', 'in_progress', 'completed', 'cancelled'];
|
||||
if (!validStatuses.includes(status)) {
|
||||
return `❌ Invalid status. Use: ${validStatuses.join(', ')}`;
|
||||
}
|
||||
|
||||
try {
|
||||
const tasks = await this._loadTasks();
|
||||
const task = tasks.find(t => t.id === task_id);
|
||||
if (!task) return `❌ Task not found: #${task_id}`;
|
||||
|
||||
task.status = status;
|
||||
task.updated = new Date().toISOString();
|
||||
await this._saveTasks(tasks);
|
||||
return `✅ Task #${task_id} → ${status}`;
|
||||
} 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