feat: improve tool usage guidance in SOUL.md and add cron.create/cron.delete tools
- SOUL.md: list all available tools (web.search, memory.*, cron.*, etc.)
and add Tool Usage Rules section enforcing 'act, don't narrate'
- cron.ts: add getJob(), addJob(), removeJob() to CronScheduler for
runtime (ephemeral) cron job management
- cron tools: add cron.create and cron.delete tools, enhance cron.list
to show schedule/output/message details
- policy.ts: add cron tools to messaging and coding profiles, add
group:cron to tool groups
Fixes issue where models would narrate tool intent ('let me search...')
then stop without actually calling tools.
This commit is contained in:
@@ -100,4 +100,54 @@ export class CronScheduler implements ChannelAdapter {
|
||||
getJobNames(): string[] {
|
||||
return Array.from(this.jobs.keys());
|
||||
}
|
||||
|
||||
/** Get a job's config by name. */
|
||||
getJob(name: string): CronJobConfig | undefined {
|
||||
return this.jobs.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new cron job at runtime and start it immediately.
|
||||
* The job is ephemeral — it persists only until the daemon restarts.
|
||||
* Returns true if the job was created, false if a job with that name already exists.
|
||||
*/
|
||||
addJob(config: CronJobConfig): boolean {
|
||||
if (this.jobs.has(config.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.jobs.set(config.name, config);
|
||||
|
||||
if (config.enabled && this._status === 'connected') {
|
||||
const cronInstance = new Cron(config.schedule, {
|
||||
timezone: config.timezone,
|
||||
paused: false,
|
||||
}, () => {
|
||||
this.triggerJob(config.name);
|
||||
});
|
||||
|
||||
this.cronInstances.set(config.name, cronInstance);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a cron job by name. Stops the cron instance if running.
|
||||
* Returns true if the job was found and removed, false otherwise.
|
||||
*/
|
||||
removeJob(name: string): boolean {
|
||||
if (!this.jobs.has(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const cronInstance = this.cronInstances.get(name);
|
||||
if (cronInstance) {
|
||||
cronInstance.stop();
|
||||
this.cronInstances.delete(name);
|
||||
}
|
||||
|
||||
this.jobs.delete(name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user