mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 21:48:57 +01:00
* fix(openclaw): every scheduled job sends only what has one tap, else NO_REPLY
On 2026-11-02 the chat still carried OpenClaw's own messages that fail the
owner's test: "Invoice / Payment Alert … if credit card is on file, no
action needed", "Gateway was not running. Restarted automatically. All good
now." The scheduled jobs' prompts live only on the box, so:
- contract.md: one short block appended (between markers, replaced on each
install) to every enabled job except the day plan: send only what needs
him, each item with the ONE link that does it, never status or counts, and
reply exactly NO_REPLY when nothing passes — OpenClaw's documented silent
token, which suppresses delivery.
- The installer lists, by path only, every file on the box that calls the
Telegram API or says "restarted automatically", so the remaining sender is
found from the public log without printing anything private.
- Notices carry no machine name ("orangecat-cat · …"); the source stays on
the list row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
* docs(telegram): register the day-plan installer (it only searches for senders)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
* fix(notify): close the review's critical and high findings
An independent review of the messaging system found real defects; these
are the ones that lose an urgent message, send a wrong one, or wake him:
- Intrusions could be dropped: the caps held urgent notices, every SSH
password login shared one dedupe key, and /api/notify/box answered 200
when nothing was recorded, so the box never used its direct fallback.
Urgent notices skip the caps, intrusion lines are keyed on the whole line,
and the route answers 503 when an urgent line was not delivered.
- A link chosen by an email could become a trusted one-tap button. Buttons
now open only own domains, Gmail, Google Calendar, GitHub or Hetzner.
- Long titles/labels or a fourth button dropped real notices into the list;
they are clipped instead. Only a missing or unsafe action refuses.
- SSH login from a new address and edits to authorized_keys/sudoers/shadow/
PAM/ld.so.preload are intrusion signs (both lists, kept equal by test);
the button opens /today, where the notice is listed; the title names the box.
- Customers' escalations and capped goals reached the owner's chat
(selfTelegramTarget); they now use telegramTargetFor. The gateway-down
message went once per fleet account; it is sent once.
- The notify routes accept bearer tokens only (no browser session/CSRF).
- countDeliveries ignored rows older than a week; it no longer does.
- Night silence (22:00–07:00 Zurich) for the direct senders too: lib-alert's
fallback, ivy-health, fleet-uptime, deploy-hetzner. ivy-health names what
broke and offers Redeploy only when Loki's app is the failure, Box doctor
otherwise, and reads the chat id from the box's telegram.env.
- Prompts: the day plan no longer asks for approve links it cannot get or a
page it cannot open, never uses links found inside emails, and says when a
source failed. The summaries he asked for (reflection, digests, scorecard,
evening wrap) get a digest contract instead of being silenced; jobs with no
text prompt are left untouched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
* feat(day-plan): one morning message; the email scanner twice a day
Approved by the owner 2026-11-02. The day plan now carries a half-line on
each person he meets today, and the separate 07:30 "Meeting People Brief"
is switched off. The email deadline scanner runs at 08:00 and 17:00 instead
of four times a day.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtzUbLhg3oqt4X1NaN
---------
Co-authored-by: Claude <noreply@anthropic.com>
103 lines
3.7 KiB
TypeScript
103 lines
3.7 KiB
TypeScript
/**
|
|
* Box lines → notices (src/lib/notify/box.ts). Every line below reached the
|
|
* owner's phone on the night of 2026-11-01; only an intrusion may now.
|
|
*
|
|
* Run: npx tsx scripts/test/notify-box.ts
|
|
*/
|
|
import { readFileSync } from "node:fs";
|
|
import { boxKey, boxNotice, isIntrusion } from "@/lib/notify/box";
|
|
import { validateNotice } from "@/lib/notify/policy";
|
|
|
|
let failures = 0;
|
|
function check(name: string, cond: boolean) {
|
|
if (cond) console.log(` ✓ ${name}`);
|
|
else {
|
|
failures += 1;
|
|
console.log(` ✗ ${name}`);
|
|
}
|
|
}
|
|
const APP = "https://loki.orangecat.ch";
|
|
console.log("notify-box:");
|
|
|
|
const noise = [
|
|
"⚙️ STILL FAILING: run-p1977852-i194871759; run-p1977874-i194871764",
|
|
"⚙️ STILL FAILING: appcron-substrata-sweep",
|
|
"✅ RECOVERED: appcron-substrata-auto-updates",
|
|
"📝 2 SENSITIVE FILE(S) CHANGED: edited /etc/caddy/apps.d/petvity.caddy, edited /etc/systemd/system/petvity-app.service. If this was you or a deploy, ignore.",
|
|
"🧩 reparaturbonus-zh: unit is enabled but inactive",
|
|
"✅ RECOVERED: keller",
|
|
"🔴 DOWN: orangecat-app.service — fetch failed → 🤖 fix agent dispatched (orangecat)",
|
|
];
|
|
for (const line of noise) {
|
|
const n = boxNotice(line, APP);
|
|
check(
|
|
`list only, never the phone: ${line.slice(0, 48)}`,
|
|
!validateNotice(n).ok && n.urgency === "today",
|
|
);
|
|
}
|
|
|
|
const intrusion = boxNotice("🚨 SSH PASSWORD LOGIN ACCEPTED for root from 1.2.3.4", APP);
|
|
check(
|
|
"an accepted SSH password login is actionable and urgent",
|
|
validateNotice(intrusion).ok && intrusion.urgency === "now",
|
|
);
|
|
check("its button opens the list it is on (/today)", intrusion.actions[0]?.url === `${APP}/today`);
|
|
check("it names the machine", intrusion.title.startsWith("bitbaum: "));
|
|
check(
|
|
"two different intrusion lines are two notices, not a held reminder",
|
|
boxNotice("🚨 SSH PASSWORD LOGIN ACCEPTED for root from 1.2.3.4", APP).key !==
|
|
boxNotice("🚨 SSH PASSWORD LOGIN ACCEPTED for root from 5.6.7.8", APP).key,
|
|
);
|
|
check(
|
|
"an SSH login from a new address is an intrusion sign",
|
|
isIntrusion("🔑 SSH LOGIN as root from 9.9.9.9"),
|
|
);
|
|
check(
|
|
"an edited authorized_keys is an intrusion sign; a deploy's unit file is not",
|
|
isIntrusion("📝 1 SENSITIVE FILE(S) CHANGED: edited /root/.ssh/authorized_keys") &&
|
|
!isIntrusion("📝 1 SENSITIVE FILE(S) CHANGED: edited /etc/systemd/system/x.service"),
|
|
);
|
|
|
|
// The box's own copy (used when Loki is unreachable) must say the same.
|
|
{
|
|
const lib = readFileSync("scripts/hetzner/install-host-alerts.sh", "utf8");
|
|
const fn = lib.slice(lib.indexOf("_alert_intrusion() {"), lib.indexOf("_alert_loki_token() {"));
|
|
for (const probe of [
|
|
"SSH PASSWORD LOGIN",
|
|
"🔑 SSH LOGIN",
|
|
"☠️",
|
|
"🔓 SSHD",
|
|
"🧱 FIREWALL",
|
|
"👤 NEW PRIVILEGED",
|
|
"authorized_keys",
|
|
]) {
|
|
check(`lib-alert's fallback list names ${probe}`, fn.includes(probe));
|
|
}
|
|
}
|
|
check("a suspicious process is an intrusion", isIntrusion("☠️ SUSPICIOUS PROCESS: /tmp/x (pid 1)"));
|
|
check("a disk warning is not", !isIntrusion("💾 DISK 87% on / (>85%)"));
|
|
|
|
const rescale = boxNotice(
|
|
"🟢 Hetzner: cx43 (16GB) is AVAILABLE to rescale bitbaum in fsn1 NOW.",
|
|
APP,
|
|
);
|
|
check(
|
|
"a rescale window is actionable: one button to the Hetzner Console",
|
|
validateNotice(rescale).ok && rescale.actions.length === 1,
|
|
);
|
|
|
|
check(
|
|
"the same kind of line folds into one row",
|
|
boxKey("⚙️ STILL FAILING: run-p1-i2") === boxKey("⚙️ STILL FAILING: run-p3-i4"),
|
|
);
|
|
check(
|
|
"different apps' findings stay separate rows",
|
|
boxKey("🧩 keller: unit is enabled but inactive") !==
|
|
boxKey("🧩 sbb-fundbuero: unit is enabled but inactive"),
|
|
);
|
|
|
|
if (failures) {
|
|
console.log(`\n ${failures} failure(s)`);
|
|
process.exit(1);
|
|
}
|