Fix scheduled tasks and improve task scheduling UX
- Fix Apple Container mount issue: move groups/CLAUDE.md to groups/global/ directory (Apple Container only supports directory mounts, not file mounts) - Fix scheduled tasks for main group: properly detect isMain based on group_folder instead of always setting false - Add isScheduledTask flag so agent knows when running as scheduled task - Improve schedule_task tool description with clear format examples for cron, interval, and once schedule types - Update global CLAUDE.md with instructions for scheduled tasks to use mcp__nanoclaw__send_message when needed Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ interface ContainerInput {
|
||||
groupFolder: string;
|
||||
chatJid: string;
|
||||
isMain: boolean;
|
||||
isScheduledTask?: boolean;
|
||||
}
|
||||
|
||||
interface ContainerOutput {
|
||||
@@ -219,11 +220,17 @@ async function main(): Promise<void> {
|
||||
let result: string | null = null;
|
||||
let newSessionId: string | undefined;
|
||||
|
||||
// Add context for scheduled tasks
|
||||
let prompt = input.prompt;
|
||||
if (input.isScheduledTask) {
|
||||
prompt = `[SCHEDULED TASK - You are running automatically, not in response to a user message. Use mcp__nanoclaw__send_message if needed to communicate with the user.]\n\n${input.prompt}`;
|
||||
}
|
||||
|
||||
try {
|
||||
log('Starting agent...');
|
||||
|
||||
for await (const message of query({
|
||||
prompt: input.prompt,
|
||||
prompt,
|
||||
options: {
|
||||
cwd: '/workspace/group',
|
||||
resume: input.sessionId,
|
||||
|
||||
@@ -67,11 +67,16 @@ export function createIpcMcp(ctx: IpcMcpContext) {
|
||||
|
||||
tool(
|
||||
'schedule_task',
|
||||
'Schedule a recurring or one-time task. The task will run as a full agent with access to all tools.',
|
||||
`Schedule a recurring or one-time task. The task will run as a full agent with access to all tools.
|
||||
|
||||
IMPORTANT - schedule_value format depends on schedule_type:
|
||||
• cron: Standard cron expression (e.g., "*/5 * * * *" for every 5 minutes, "0 9 * * *" for daily at 9am)
|
||||
• interval: Milliseconds between runs (e.g., "300000" for 5 minutes, "3600000" for 1 hour)
|
||||
• once: ISO 8601 timestamp (e.g., "2026-02-01T15:30:00.000Z"). Calculate this from current time.`,
|
||||
{
|
||||
prompt: z.string().describe('What the agent should do when the task runs'),
|
||||
schedule_type: z.enum(['cron', 'interval', 'once']).describe('Type of schedule'),
|
||||
schedule_value: z.string().describe('Cron expression, interval in ms, or ISO timestamp'),
|
||||
schedule_type: z.enum(['cron', 'interval', 'once']).describe('cron=recurring at specific times, interval=recurring every N ms, once=run once at specific time'),
|
||||
schedule_value: z.string().describe('cron: "*/5 * * * *" | interval: milliseconds like "300000" | once: ISO timestamp like "2026-02-01T15:30:00.000Z"'),
|
||||
target_group: z.string().optional().describe('Target group folder (main only, defaults to current group)')
|
||||
},
|
||||
async (args) => {
|
||||
|
||||
Reference in New Issue
Block a user