fluxy-bot 0.5.6 → 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.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-content" />
6
6
  <title>Fluxy Chat</title>
7
- <script type="module" crossorigin src="/fluxy/assets/fluxy-A_p_vv4X.js"></script>
7
+ <script type="module" crossorigin src="/fluxy/assets/fluxy-C55TbNi6.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/fluxy/assets/globals-BeMw745s.js">
9
9
  <link rel="stylesheet" crossorigin href="/fluxy/assets/globals-GP9z02As.css">
10
10
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.5.6",
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",
@@ -79,34 +79,6 @@ function FluxyApp() {
79
79
  }
80
80
  }
81
81
 
82
- // Check push state on mount
83
- useEffect(() => {
84
- if (!authenticated) return;
85
- (async () => {
86
- if (!('PushManager' in window) || !('serviceWorker' in navigator)) {
87
- setPushState('unsupported');
88
- return;
89
- }
90
- if (Notification.permission === 'denied') {
91
- setPushState('denied');
92
- return;
93
- }
94
- try {
95
- const reg = await navigator.serviceWorker.ready;
96
- const subscription = await reg.pushManager.getSubscription();
97
- if (subscription) {
98
- const res = await fetch(`/api/push/status?endpoint=${encodeURIComponent(subscription.endpoint)}`);
99
- const data = await res.json();
100
- setPushState(data.subscribed ? 'subscribed' : 'unsubscribed');
101
- } else {
102
- setPushState('unsubscribed');
103
- }
104
- } catch {
105
- setPushState('unsupported');
106
- }
107
- })();
108
- }, [authenticated]);
109
-
110
82
  // Install App (PWA)
111
83
  const [showIosModal, setShowIosModal] = useState(false);
112
84
  const isIos = /iPad|iPhone|iPod/.test(navigator.userAgent);
@@ -182,6 +154,34 @@ function FluxyApp() {
182
154
  });
183
155
  }, []);
184
156
 
157
+ // Check push state on mount
158
+ useEffect(() => {
159
+ if (!authenticated) return;
160
+ (async () => {
161
+ if (!('PushManager' in window) || !('serviceWorker' in navigator)) {
162
+ setPushState('unsupported');
163
+ return;
164
+ }
165
+ if (Notification.permission === 'denied') {
166
+ setPushState('denied');
167
+ return;
168
+ }
169
+ try {
170
+ const reg = await navigator.serviceWorker.ready;
171
+ const subscription = await reg.pushManager.getSubscription();
172
+ if (subscription) {
173
+ const res = await fetch(`/api/push/status?endpoint=${encodeURIComponent(subscription.endpoint)}`);
174
+ const data = await res.json();
175
+ setPushState(data.subscribed ? 'subscribed' : 'unsubscribed');
176
+ } else {
177
+ setPushState('unsubscribed');
178
+ }
179
+ } catch {
180
+ setPushState('unsupported');
181
+ }
182
+ })();
183
+ }, [authenticated]);
184
+
185
185
  // Connect WebSocket only when authenticated
186
186
  useEffect(() => {
187
187
  if (!authenticated) return;
@@ -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;