notify 0.1.2: a Gotify channel (#593, UnspokenSpell)
notify 0.1.2 adds a Gotify channel (UnspokenSpell): POST <server>/message with X-Gotify-Key, title and message; priority only when the channel sets it (an explicit 0 stays 0), so the application's own default applies otherwise; extras when set. Needs server and token. post() also reads Gotify's errorDescription on failure. Gotify is listed in the package README (with priority's fallback and extras), the root README and the registry summary.
Answers the 11-01 review at f2f5806: priority no longer defaults to 5, the sibling channel lists name Gotify, extras is documented and tested, errorDescription is read.
Run at the reviewed head f84a6a7 on mote:
- bun test packages/notify: 58 pass, 0 fail
- full bun test with HOME=$(mktemp -d): 4551 pass, 9 skip, 0 fail
- Broken by hand, each red then restored: priority back to `?? 5` (1 fail), errorDescription dropped (1 fail)
- A real Gotify server (3.1.1, 127.0.0.1, app with defaultPriority 2) through channels.mjs send(): no priority -> stored with priority 2; priority 0 -> stored 0; wrong token -> {ok:false,status:401,error:"you need to provide a valid access token or user credentials to access this api"}
Not tried: Gotify behind a reverse proxy at this head (tried at f2f5806, unchanged path code).
This commit is contained in:
@@ -145,7 +145,7 @@ Like middleware, these run on the requests agents send, but in magpie's Bun host
|
||||
| [nowledge-mem](packages/nowledge-mem) | [Nowledge Mem](https://mem.nowledge.co) recall, Context Bundle or Working Memory, per-harness provenance and opt-in conversation import as Mem Threads, automatic for every harness behind Magpie |
|
||||
| [aelios](packages/aelios) | [Aelios](https://github.com/wusaki0723/Aelios) recall before each turn from your own Aelios on Cloudflare, and opt-in recording of each turn so Aelios can remember it |
|
||||
| [respire-memory](packages/respire-memory) | [Respire](https://github.com/risense-ai/respire-magpie): per-turn recall and complete policy reads, automatic process diaries, and grounded experience archival with readback; storage runs after reply completion |
|
||||
| [notify](packages/notify) | A push to ntfy, Bark, Server酱, Feishu, DingTalk, WeCom, Telegram or a webhook when an agent's turn is done or fails, after it ran `minMinutes` or longer |
|
||||
| [notify](packages/notify) | A push to ntfy, Bark, Gotify, Server酱, Feishu, DingTalk, WeCom, Telegram or a webhook when an agent's turn is done or fails, after it ran `minMinutes` or longer |
|
||||
|
||||
Use the same plugin management commands as middleware:
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ The hook changes nothing in a request, and sending never holds one up: it return
|
||||
"channels": [ // one or more; each sends the same push
|
||||
{ "type": "ntfy", "topic": "…", "server": "https://ntfy.sh", "token": "…", "priority": 3 },
|
||||
{ "type": "bark", "key": "…", "server": "https://api.day.app", "group": "magpie", "sound": "…" },
|
||||
{ "type": "gotify", "server": "https://push.example.com", "token": "…", "extras": { "client::display": { "contentType": "text/markdown" } } },
|
||||
{ "type": "serverchan", "key": "SCT… or sctp…" },
|
||||
{ "type": "feishu", "webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/…", "secret": "…" },
|
||||
{ "type": "dingtalk", "webhook": "https://oapi.dingtalk.com/robot/send?access_token=…", "secret": "SEC…" },
|
||||
@@ -61,7 +62,7 @@ The hook changes nothing in a request, and sending never holds one up: it return
|
||||
}
|
||||
```
|
||||
|
||||
Optional fields are shown with their defaults. A channel missing what it needs (a topic, a key, a webhook) is skipped; `"off": true` turns one off without deleting it. Feishu's and DingTalk's `secret` is the robot's signing secret (签名校验 / 加签), used when the robot asks for it. `webhook` posts `{title, body, event}` where `event` is `{kind, agent, model, project, seconds}`.
|
||||
Optional fields are shown with their defaults where they have one. A channel missing what it needs (a topic, a key, a webhook) is skipped; `"off": true` turns one off without deleting it. Feishu's and DingTalk's `secret` is the robot's signing secret (签名校验 / 加签), used when the robot asks for it. Gotify's `priority` falls back to the application's default when omitted; its `extras` accepts an object of `namespace::action` keys (e.g. `{"client::display": {"contentType": "text/markdown"}}`). `webhook` posts `{title, body, event}` where `event` is `{kind, agent, model, project, seconds}`.
|
||||
|
||||
## Privacy
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ async function post(url, body, headers = {}, form = false) {
|
||||
try { data = await res.json() } catch {}
|
||||
const code = data?.code ?? data?.errcode ?? data?.StatusCode
|
||||
const okBody = data?.ok !== false && (code == null || code === 0 || code === 200)
|
||||
return res.ok && okBody ? { ok: true, status: res.status } : { ok: false, status: res.status, error: String(data?.msg ?? data?.errmsg ?? data?.description ?? data?.message ?? res.statusText ?? "").slice(0, 200) }
|
||||
return res.ok && okBody ? { ok: true, status: res.status } : { ok: false, status: res.status, error: String(data?.msg ?? data?.errmsg ?? data?.description ?? data?.errorDescription ?? data?.message ?? res.statusText ?? "").slice(0, 200) }
|
||||
}
|
||||
|
||||
const trimSlash = (s) => String(s).replace(/\/+$/, "")
|
||||
@@ -33,6 +33,11 @@ export const kinds = {
|
||||
device_key: c.key, title: m.title, body: m.body, group: c.group ?? "magpie", ...(c.sound ? { sound: c.sound } : {}),
|
||||
}),
|
||||
|
||||
// Gotify: self-hosted push notifications
|
||||
gotify: (c, m) => post(`${trimSlash(c.server)}/message`, {
|
||||
title: m.title, message: m.body, ...(c.priority != null ? { priority: c.priority } : {}), ...(c.extras ? { extras: c.extras } : {}),
|
||||
}, { "X-Gotify-Key": c.token }),
|
||||
|
||||
// Server酱 Turbo (SCT…) and Server酱³ (sctp<uid>t…)
|
||||
serverchan: (c, m) => {
|
||||
const key = String(c.key ?? "")
|
||||
@@ -77,7 +82,7 @@ export const kinds = {
|
||||
|
||||
// what each kind needs before it can send
|
||||
const needs = {
|
||||
ntfy: ["topic"], bark: ["key"], serverchan: ["key"], feishu: ["webhook"], dingtalk: ["webhook"],
|
||||
ntfy: ["topic"], bark: ["key"], gotify: ["server", "token"], serverchan: ["key"], feishu: ["webhook"], dingtalk: ["webhook"],
|
||||
wecom: ["webhook"], telegram: ["token", "chatId"], webhook: ["url"],
|
||||
}
|
||||
|
||||
|
||||
@@ -747,6 +747,23 @@ test("each channel posts where and what its service documents", async () => {
|
||||
expect(calls.at(-1).url).toBe("https://api.day.app/push")
|
||||
expect(JSON.parse(calls.at(-1).body)).toMatchObject({ device_key: "K", title: "T", body: "B", group: "magpie" })
|
||||
|
||||
await send({ type: "gotify", server: "https://gotify.example.com/", token: "tk123" }, m)
|
||||
expect(calls.at(-1).url).toBe("https://gotify.example.com/message")
|
||||
expect(calls.at(-1).init.headers["X-Gotify-Key"]).toBe("tk123")
|
||||
expect(JSON.parse(calls.at(-1).body)).toEqual({ title: "T", message: "B" })
|
||||
|
||||
await send({
|
||||
type: "gotify", server: "https://gotify.example.com/", token: "tk123",
|
||||
priority: 8, extras: { "client::display": { contentType: "text/markdown" } },
|
||||
}, m)
|
||||
expect(JSON.parse(calls.at(-1).body)).toEqual({
|
||||
title: "T", message: "B", priority: 8, extras: { "client::display": { contentType: "text/markdown" } },
|
||||
})
|
||||
|
||||
// 0 is a real priority (an application made quiet), not "unset"
|
||||
await send({ type: "gotify", server: "https://gotify.example.com/", token: "tk123", priority: 0 }, m)
|
||||
expect(JSON.parse(calls.at(-1).body)).toEqual({ title: "T", message: "B", priority: 0 })
|
||||
|
||||
await send({ type: "serverchan", key: "SCT123abc" }, m)
|
||||
expect(calls.at(-1).url).toBe("https://sctapi.ftqq.com/SCT123abc.send")
|
||||
expect(calls.at(-1).body).toBe("title=T&desp=B")
|
||||
@@ -780,6 +797,9 @@ test("Feishu and DingTalk sign with the robot's secret", async () => {
|
||||
test("a channel missing what it needs is dropped from the options", () => {
|
||||
expect(usable({ type: "ntfy" })).toBe(false)
|
||||
expect(usable({ type: "telegram", token: "x" })).toBe(false)
|
||||
expect(usable({ type: "gotify", server: "https://example.com" })).toBe(false)
|
||||
expect(usable({ type: "gotify", token: "x" })).toBe(false)
|
||||
expect(usable({ type: "gotify", server: "https://example.com", token: "x" })).toBe(true)
|
||||
expect(usable({ type: "nope", url: "x" })).toBe(false)
|
||||
expect(usable({ type: "bark", key: "k", off: true })).toBe(false)
|
||||
expect(options({ channels: [{ type: "ntfy" }, ntfy] }).channels).toEqual([ntfy])
|
||||
@@ -790,3 +810,10 @@ test("Bark's success answer (code 200) is a success", async () => {
|
||||
answer = () => Response.json({ code: 200, message: "success" })
|
||||
expect((await send({ type: "bark", key: "K" }, m)).ok).toBe(true)
|
||||
})
|
||||
|
||||
test("Gotify's errorDescription is read on failure", async () => {
|
||||
answer = () => Response.json({ error: "Unauthorized", errorCode: 401, errorDescription: "bad token" }, { status: 401 })
|
||||
const r = await send({ type: "gotify", server: "https://gotify.example.com", token: "bad" }, m)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toBe("bad token")
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@magpie-community/gateway-notify",
|
||||
"version": "0.1.1",
|
||||
"description": "A push to your phone or team chat when an agent's turn is done: ntfy, Bark, Server酱, Feishu, DingTalk, WeCom, Telegram or a webhook",
|
||||
"version": "0.1.2",
|
||||
"description": "A push to your phone or team chat when an agent's turn is done: ntfy, Bark, Gotify, Server酱, Feishu, DingTalk, WeCom, Telegram or a webhook",
|
||||
"type": "module",
|
||||
"files": ["notify.hooks.mjs", "turn.mjs", "channels.mjs", "README.md"],
|
||||
"keywords": ["magpie", "magpie-gateway", "magpie-hooks", "notification", "ntfy", "bark", "feishu", "dingtalk", "telegram"],
|
||||
"keywords": ["magpie", "magpie-gateway", "magpie-hooks", "notification", "ntfy", "bark", "gotify", "feishu", "dingtalk", "telegram"],
|
||||
"license": "MIT",
|
||||
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/notify" },
|
||||
"magpie": {
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@
|
||||
"summary": { "en": "Reads the session files of Claude Code, Codex, Copilot CLI, Kimi Code, DeepSeek Harness, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build on this computer (prompts, replies and tool commands; text can be turned off). Shows them in a real WebGL 3D office with six scenes, an isometric/2D office, or a grouped workbench with Today usage, recent conversations and approvals.", "zh": "读取本机 Claude Code、Codex、Copilot CLI、Kimi Code、DeepSeek Harness、Gemini CLI、Qwen Code、Pi、omp、Qoder、WorkBuddy、CodeBuddy、Grok Build 的会话文件(含提问、回复与工具命令,可关闭文本),用真 3D 办公室(六种场景)、等距/2D 办公室或分组工作台展示,带今日用量、最近对话与批准状态。" } },
|
||||
{"package": "@magpie-community/agent-kimi-desktop", "name": "Kimi", "kind": "agent", "community": true, "summary": {"en": "Kimi desktop Work on Magpie's Agents page: select a model from Magpie, then disconnect to restore the original service. Not Kimi Code CLI.", "zh": "把普通 Kimi 桌面版 Work 接入 Magpie Agent 页,使用已配置的模型;断开恢复原连接。不是 Kimi Code CLI。"}},
|
||||
{ "package": "@magpie-community/gateway-notify", "name": "Notify", "kind": "middleware", "community": true,
|
||||
"summary": { "en": "A push when an agent's turn is done or fails, after it ran long enough to be worth one: ntfy, Bark, Server酱, Feishu, DingTalk, WeCom, Telegram or your own webhook. Agent, project, model and time only by default; the reply's text is opt-in.", "zh": "agent 一轮任务跑完或失败时推送提醒(只提醒跑够设定时长的任务):支持 ntfy、Bark、Server酱、飞书、钉钉、企业微信、Telegram 和自定义 webhook。默认只发 agent、项目、模型和用时,回复正文需手动开启。" } },
|
||||
"summary": { "en": "A push when an agent's turn is done or fails, after it ran long enough to be worth one: ntfy, Bark, Gotify, Server酱, Feishu, DingTalk, WeCom, Telegram or your own webhook. Agent, project, model and time only by default; the reply's text is opt-in.", "zh": "agent 一轮任务跑完或失败时推送提醒(只提醒跑够设定时长的任务):支持 ntfy、Bark、Gotify、Server酱、飞书、钉钉、企业微信、Telegram 和自定义 webhook。默认只发 agent、项目、模型和用时,回复正文需手动开启。" } },
|
||||
{ "package": "@magpie-community/hooks-mail-watch", "name": "Mail Watch", "kind": "middleware", "community": true,
|
||||
"summary": { "en": "Email alerts when a provider call fails or a quota window runs out: your own SMTP account, your own words in the mail, and your own list of what to watch, with cooldowns and an hourly cap so a bad hour stays bounded — plus an optional periodic usage digest.", "zh": "供应商调用失败或额度窗口用尽时发邮件提醒:用你自己的 SMTP 账号、自己的邮件文案、自己勾选的监控事项;同类事件冷却合并,另有每小时上限,糟糕的一小时不会失控;另可开启定期用量摘要。" } },
|
||||
{ "package": "@magpie-community/opencode-cloudflare-workers-ai-auth", "name": "Cloudflare Workers AI", "providers": ["cloudflare-workers-ai"], "community": true,
|
||||
|
||||
Reference in New Issue
Block a user