Include non-empty sune settings in ntfy run notifications

System prompts, model and request plumbing (incl. apiKey) are skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 18:45:17 +00:00
co-authored by Claude Opus 5.5
parent 73b09b3f22
commit 399406a23e
+16 -2
View File
@@ -71,6 +71,19 @@ function tag(r) {
return `[${r.provider || '?'}/${r.model || '?'}]` return `[${r.provider || '?'}/${r.model || '?'}]`
} }
// Non-empty generation settings for ntfy; prompts, model and request plumbing (incl. apiKey) are skipped
const NOT_SETTINGS = new Set(['messages', 'system', 'model', 'stream', 'apiKey', 'rid', 'type', 'after', 'provider', 'or_body'])
function settingsOf(o, pre = '') {
return Object.entries(o || {}).flatMap(([k, v]) => {
if ((!pre && NOT_SETTINGS.has(k)) || v == null || v === '' || (typeof v === 'object' && !Object.keys(v).length)) return []
if (typeof v === 'object' && !Array.isArray(v)) return settingsOf(v, `${pre}${k}.`)
return [`${pre}${k}=${String(v).slice(0, 80)}`]
})
}
const withSettings = (r, s) => r.settings ? `${s}\n${r.settings}` : s
function send(ws, obj) { function send(ws, obj) {
try { ws.send(JSON.stringify(obj)) } catch {} try { ws.send(JSON.stringify(obj)) } catch {}
} }
@@ -128,7 +141,7 @@ function stop(r) {
try { r.controller?.abort() } catch {} try { r.controller?.abort() } catch {}
saveSnapshot(r) saveSnapshot(r)
bcast(r, { type: 'done' }) bcast(r, { type: 'done' })
notify(`Run ${r.rid} ${tag(r)} ended. Duration: ${duration}s`, 2, ['stop_sign']) notify(withSettings(r, `Run ${r.rid} ${tag(r)} ended. Duration: ${duration}s`), 2, ['stop_sign'])
} }
function fail(r, message) { function fail(r, message) {
@@ -143,7 +156,7 @@ function fail(r, message) {
try { r.controller?.abort() } catch {} try { r.controller?.abort() } catch {}
saveSnapshot(r) saveSnapshot(r)
bcast(r, { type: 'err', message: r.error }) bcast(r, { type: 'err', message: r.error })
notify(`Run ${r.rid} ${tag(r)} failed after ${duration}s: ${r.error}`, 2, ['rotating_light']) notify(withSettings(r, `Run ${r.rid} ${tag(r)} failed after ${duration}s: ${r.error}`), 2, ['rotating_light'])
} }
function sanitizeMessages(messages) { function sanitizeMessages(messages) {
@@ -253,6 +266,7 @@ export function handleMessage(rid, ws, msg) {
r.startedAt = Date.now() r.startedAt = Date.now()
r.provider = resolvedProvider r.provider = resolvedProvider
r.model = body.model || null r.model = body.model || null
r.settings = settingsOf(body).join(' · ')
// Hard timeout safety net // Hard timeout safety net
r.timeoutTimer = setTimeout(() => { r.timeoutTimer = setTimeout(() => {