- 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
37 lines
944 B
JavaScript
37 lines
944 B
JavaScript
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 });
|
|
}
|
|
}
|