mirror of
https://github.com/microcron/pink.git
synced 2026-04-27 10:12:13 +00:00
Fix: Log ntfy HTTP errors instead of silently discarding
Co-authored-by: Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
6
pink.js
6
pink.js
@@ -26,12 +26,13 @@ async function chat(model, messages, system) {
|
||||
async function sendNtfy(msg, priority) {
|
||||
const url = process.env.NTFY_URL
|
||||
if (!url) return console.warn("!! NTFY_URL not set")
|
||||
await fetch(url, {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Priority": String(priority) },
|
||||
body: msg
|
||||
})
|
||||
console.log(`📨 ntfy (p${priority}): ${msg.slice(0, 80)}`)
|
||||
if (!res.ok) console.error(`!! ntfy ${res.status}: ${await res.text()}`)
|
||||
else console.log(`📨 ntfy (p${priority}): ${msg.slice(0, 80)}`)
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
@@ -80,6 +81,7 @@ for (const file of files) {
|
||||
// --- Parse ntfy block ---
|
||||
const ntfyMatch = reasonAnswer.match(/```ntfy([1-5])\n([\s\S]*?)```/)
|
||||
if (ntfyMatch) await sendNtfy(ntfyMatch[2].trim(), parseInt(ntfyMatch[1]))
|
||||
else console.warn(`!! no ntfy block found in reason response for ${file}`)
|
||||
|
||||
// --- Trim to rolling window (each window = 4 messages) ---
|
||||
const windowSize = 4
|
||||
|
||||
Reference in New Issue
Block a user