From 399406a23e5a17316d150ac596d69abed6fe70a9 Mon Sep 17 00:00:00 2001 From: "planetrenox@protonmail.com" Date: Mon, 12 Oct 2026 18:45:17 +0000 Subject: [PATCH] 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 --- run.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/run.js b/run.js index 0b54b39..47206ce 100644 --- a/run.js +++ b/run.js @@ -71,6 +71,19 @@ function tag(r) { 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) { try { ws.send(JSON.stringify(obj)) } catch {} } @@ -128,7 +141,7 @@ function stop(r) { try { r.controller?.abort() } catch {} saveSnapshot(r) 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) { @@ -143,7 +156,7 @@ function fail(r, message) { try { r.controller?.abort() } catch {} saveSnapshot(r) 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) { @@ -253,6 +266,7 @@ export function handleMessage(rid, ws, msg) { r.startedAt = Date.now() r.provider = resolvedProvider r.model = body.model || null + r.settings = settingsOf(body).join(' ยท ') // Hard timeout safety net r.timeoutTimer = setTimeout(() => {