fluxy-bot 0.5.16 → 0.5.19
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
package/supervisor/index.ts
CHANGED
|
@@ -46,6 +46,43 @@ const MIME_TYPES: Record<string, string> = {
|
|
|
46
46
|
'.json': 'application/json',
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
// Service worker content — embedded here so it ships with supervisor/ (always updated)
|
|
50
|
+
const SW_JS = `// Service worker — PWA installability + push notifications
|
|
51
|
+
self.addEventListener('install', () => self.skipWaiting());
|
|
52
|
+
self.addEventListener('activate', (e) => e.waitUntil(self.clients.claim()));
|
|
53
|
+
self.addEventListener('fetch', () => {});
|
|
54
|
+
|
|
55
|
+
// Push notification
|
|
56
|
+
self.addEventListener('push', (event) => {
|
|
57
|
+
let data = { title: 'Fluxy', body: 'New message' };
|
|
58
|
+
try { data = event.data.json(); } catch {}
|
|
59
|
+
event.waitUntil(
|
|
60
|
+
self.registration.showNotification(data.title || 'Fluxy', {
|
|
61
|
+
body: data.body || '',
|
|
62
|
+
icon: '/fluxy-icon-192.png',
|
|
63
|
+
badge: '/fluxy.png',
|
|
64
|
+
vibrate: [100, 50, 100],
|
|
65
|
+
tag: data.tag || 'fluxy-default',
|
|
66
|
+
data: { url: data.url || '/' },
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Notification click — focus or open app
|
|
72
|
+
self.addEventListener('notificationclick', (event) => {
|
|
73
|
+
event.notification.close();
|
|
74
|
+
const url = event.notification.data?.url || '/';
|
|
75
|
+
event.waitUntil(
|
|
76
|
+
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => {
|
|
77
|
+
for (const client of clients) {
|
|
78
|
+
if (client.url.includes('/fluxy') && 'focus' in client) return client.focus();
|
|
79
|
+
}
|
|
80
|
+
return self.clients.openWindow(url);
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
`;
|
|
85
|
+
|
|
49
86
|
const RECOVERING_HTML = `<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Recovering</title>
|
|
50
87
|
<style>body{background:#0a0a0f;color:#94a3b8;font-family:system-ui;display:flex;align-items:center;justify-content:center;height:100vh;margin:0}
|
|
51
88
|
div{text-align:center}h1{font-size:18px;margin-bottom:8px;color:#e2e8f0}p{font-size:14px}a{color:#60a5fa}</style></head>
|
|
@@ -170,11 +207,10 @@ export async function startSupervisor() {
|
|
|
170
207
|
return;
|
|
171
208
|
}
|
|
172
209
|
|
|
173
|
-
// Service worker — served
|
|
210
|
+
// Service worker — served from embedded constant (supervisor/ is always updated)
|
|
174
211
|
if (req.url === '/sw.js' || req.url === '/fluxy/sw.js') {
|
|
175
|
-
const swPath = path.join(PKG_DIR, 'workspace', 'client', 'public', 'sw.js');
|
|
176
212
|
res.writeHead(200, { 'Content-Type': 'application/javascript', 'Cache-Control': 'no-cache' });
|
|
177
|
-
res.end(
|
|
213
|
+
res.end(SW_JS);
|
|
178
214
|
return;
|
|
179
215
|
}
|
|
180
216
|
|
package/supervisor/scheduler.ts
CHANGED
|
@@ -145,6 +145,13 @@ function triggerAgent(prompt: string, label: string, onComplete?: () => void) {
|
|
|
145
145
|
log.warn(`[scheduler] Failed to get/create conversation for ${label}: ${err.message}`);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
// Fetch bot name for push notification title
|
|
149
|
+
let botName = 'Fluxy';
|
|
150
|
+
try {
|
|
151
|
+
const status = await workerApi('/api/onboard/status');
|
|
152
|
+
if (status.agentName) botName = status.agentName;
|
|
153
|
+
} catch {}
|
|
154
|
+
|
|
148
155
|
let fullResponse = '';
|
|
149
156
|
|
|
150
157
|
startFluxyAgentQuery(convId, prompt, model, (type, eventData) => {
|
|
@@ -185,7 +192,7 @@ function triggerAgent(prompt: string, label: string, onComplete?: () => void) {
|
|
|
185
192
|
|
|
186
193
|
// Send push notification for closed tabs / locked devices
|
|
187
194
|
workerApi('/api/push/send', 'POST', {
|
|
188
|
-
title: titleMatch?.[1] ||
|
|
195
|
+
title: titleMatch?.[1] || botName,
|
|
189
196
|
body: messageContent.slice(0, 200),
|
|
190
197
|
tag: `fluxy-${label}`,
|
|
191
198
|
url: '/',
|
|
@@ -14,7 +14,7 @@ self.addEventListener('push', (event) => {
|
|
|
14
14
|
self.registration.showNotification(data.title || 'Fluxy', {
|
|
15
15
|
body: data.body || '',
|
|
16
16
|
icon: '/fluxy-icon-192.png',
|
|
17
|
-
badge: '/fluxy
|
|
17
|
+
badge: '/fluxy.png',
|
|
18
18
|
vibrate: [100, 50, 100],
|
|
19
19
|
tag: data.tag || 'fluxy-default',
|
|
20
20
|
data: { url: data.url || '/' },
|