From fd38bf5bd743929f9eedf3970943a6414771da4d Mon Sep 17 00:00:00 2001 From: tsingliu <410869548@qq.com> Date: Sat, 7 Feb 2026 19:21:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- src/tools/core.ts | 24 ++++++++++++++++++++++++ src/tools/index.ts | 3 ++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eea2873..33096b7 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ You can run one instance to fix a local script, or orchestrate **10,000+ instanc - 📜 **Headless Execution**: No browsers, no GUIs. Pure terminal efficiency. - 🤖 **Non-Interactive Mode**: Intelligent flag handling (`-y`, `--no-interactive`) for zero-touch automation. - 📂 **Universal Control**: From simple file I/O to complex system administration. -- 🧠 **Context Aware**: Detects container environments to optimize command strategies. +- 🧠 **Context Aware**: Detects container environments and provides accurate system time for relative date queries. - 🌐 **Web Search**: Integrated with Tavily for real-time information retrieval. +- 🕒 **Time Accuracy**: Built-in tool to get precise system date and time for correct temporal context. - 📧 **Communication**: Send emails and push notifications to chat groups automatically. ## Tech Stack @@ -141,6 +142,10 @@ Configure SMTP settings to let the agent send emails. Configure webhooks to receive alerts or reports in your team chat apps. - **Usage**: "Notify the team on Feishu that the build has finished." +### Date & Time +Built-in utility to provide the agent with the current system time, ensuring accurate handling of relative time requests. +- **Usage**: "What's the date today?" or "Remind me to check the logs next Monday." + ## License MIT diff --git a/src/tools/core.ts b/src/tools/core.ts index 2ece8dd..c0453d7 100644 --- a/src/tools/core.ts +++ b/src/tools/core.ts @@ -107,3 +107,27 @@ export const WriteFileTool: ToolModule = { } } }; + +export const DateTimeTool: ToolModule = { + name: "Date & Time", + definition: { + type: "function", + function: { + name: "get_current_datetime", + description: "Get the current system date and time. Use this when the user refers to relative dates (like 'today', 'next week', 'this March') to ensure accuracy.", + parameters: { + type: "object", + properties: {} + } + } + }, + handler: async () => { + const now = new Date(); + return JSON.stringify({ + iso: now.toISOString(), + local: now.toLocaleString(), + timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, + weekday: now.toLocaleDateString('en-US', { weekday: 'long' }) + }, null, 2); + } +}; diff --git a/src/tools/index.ts b/src/tools/index.ts index 19e1427..1d09cb7 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,5 +1,5 @@ import { ToolModule } from './interface.js'; -import { ShellTool, ReadFileTool, WriteFileTool } from './core.js'; +import { ShellTool, ReadFileTool, WriteFileTool, DateTimeTool } from './core.js'; import { EmailTool } from './email.js'; import { SearchTool } from './search.js'; import { NotifyTool } from './notify.js'; @@ -10,6 +10,7 @@ export const toolRegistry: ToolModule[] = [ ShellTool, ReadFileTool, WriteFileTool, + DateTimeTool, EmailTool, SearchTool, NotifyTool,