fluxy-bot 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Self-hosted, self-evolving AI agent with its own dashboard.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -117,7 +117,7 @@ function cronMatchesNow(schedule: string): boolean {
117
117
  }
118
118
  }
119
119
 
120
- function triggerAgent(prompt: string, label: string) {
120
+ function triggerAgent(prompt: string, label: string, onComplete?: () => void) {
121
121
  if (!schedulerOpts) return;
122
122
  const { broadcastFluxy, workerApi, restartBackend, getModel } = schedulerOpts;
123
123
  const timestamp = Date.now();
@@ -193,6 +193,7 @@ function triggerAgent(prompt: string, label: string) {
193
193
  log.info(`[scheduler] File tools used — restarting backend`);
194
194
  restartBackend();
195
195
  }
196
+ onComplete?.();
196
197
  }
197
198
 
198
199
  if (type === 'bot:error') {
@@ -228,21 +229,20 @@ function tick() {
228
229
  const oneMinuteAgo = now - 60_000;
229
230
  if (lastRun < oneMinuteAgo) {
230
231
  lastCronRuns.set(cron.id, now);
231
- triggerAgent(`<CRON>${cron.id}</CRON>`, cron.id);
232
- if (cron.oneShot) firedOneShots.push(cron.id);
232
+ // One-shots: defer removal until agent completes (so agent can still read CRONS.json)
233
+ const onComplete = cron.oneShot ? () => {
234
+ log.info(`[scheduler] Removing fired one-shot cron: ${cron.id}`);
235
+ const fresh = readCronsConfig().filter((c) => c.id !== cron.id);
236
+ writeCronsConfig(fresh);
237
+ } : undefined;
238
+ triggerAgent(`<CRON>${cron.id}</CRON>`, cron.id, onComplete);
233
239
  }
234
240
  }
235
241
  }
236
242
 
237
- // ── Cleanup: remove fired one-shots + expired one-shots ──
243
+ // ── Cleanup: remove expired one-shots (schedule in the past, never gonna fire) ──
238
244
  if (crons.length > 0) {
239
245
  const cleaned = crons.filter((c) => {
240
- // Remove one-shots that just fired
241
- if (c.oneShot && firedOneShots.includes(c.id)) {
242
- log.info(`[scheduler] Removing fired one-shot cron: ${c.id}`);
243
- return false;
244
- }
245
- // Remove one-shots whose schedule is in the past (never gonna fire)
246
246
  if (c.oneShot && cronIsExpired(c.schedule)) {
247
247
  log.info(`[scheduler] Removing expired one-shot cron: ${c.id}`);
248
248
  return false;