mirror of
https://github.com/microcron/pink.git
synced 2026-04-27 18:22: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) {
|
async function sendNtfy(msg, priority) {
|
||||||
const url = process.env.NTFY_URL
|
const url = process.env.NTFY_URL
|
||||||
if (!url) return console.warn("!! NTFY_URL not set")
|
if (!url) return console.warn("!! NTFY_URL not set")
|
||||||
await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Priority": String(priority) },
|
headers: { "Priority": String(priority) },
|
||||||
body: msg
|
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) {
|
for (const file of files) {
|
||||||
@@ -80,6 +81,7 @@ for (const file of files) {
|
|||||||
// --- Parse ntfy block ---
|
// --- Parse ntfy block ---
|
||||||
const ntfyMatch = reasonAnswer.match(/```ntfy([1-5])\n([\s\S]*?)```/)
|
const ntfyMatch = reasonAnswer.match(/```ntfy([1-5])\n([\s\S]*?)```/)
|
||||||
if (ntfyMatch) await sendNtfy(ntfyMatch[2].trim(), parseInt(ntfyMatch[1]))
|
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) ---
|
// --- Trim to rolling window (each window = 4 messages) ---
|
||||||
const windowSize = 4
|
const windowSize = 4
|
||||||
|
|||||||
Reference in New Issue
Block a user