shadok-ai 0.19.7 → 0.19.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -335,6 +335,15 @@ Enter to skip; you can add it later from the web UI).
335
335
  otherwise just print a local path you cannot open. **Artifacts are denied**
336
336
  cockpit-wide for the same reason — a page on claude.ai is not the file you
337
337
  asked for (`SHADOK_ALLOW_ARTIFACTS=1` lifts it).
338
+ - **Agents can ask an admin for help** — an agent stuck on something only a
339
+ human can fix (a Linear token that expired, no access to the Slack token it
340
+ needs, a Claude API key answering 401, a bug) files a report through the
341
+ `shadok-report` skill instead of failing silently. Every admin gets a badge
342
+ and a sound on the **Reports** button (🚩 in the header), and the Telegram
343
+ owner gets a DM. The panel shows each report with what the agent was doing,
344
+ merges a repeated failure into one card (`×3`), opens the vault on the
345
+ credential named (`--secret LINEAR_API_KEY`) and lets you mark it resolved.
346
+ Agents never put a secret's value in a report, only its name.
338
347
  - **Photos and videos, viewable** — an image or a **video** (mp4/webm/mov…) in
339
348
  the chat renders inline (a video gets a real player), and clicking a photo
340
349
  opens it full-size in a lightbox. The 🖼 button in an agent's bar opens a
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: shadok-report
3
+ description: Ask an admin for help when you are STUCK on something only a human can fix — a token that expired or answers 401/403 (Linear, Slack, GitHub, the Claude API…), a credential or access you were never given, a broken tool or a shadok bug. The admins get a notification. Use it instead of failing silently or retrying for ever.
4
+ ---
5
+
6
+ # shadok-report
7
+
8
+ Nobody may be watching your chat — you may be running on a schedule, or the
9
+ person who started you may have left. When you hit a wall only a human can
10
+ remove, **report it**: every admin of this cockpit gets a badge and a sound, and
11
+ the Telegram owner gets a DM.
12
+
13
+ ```bash
14
+ node ~/.claude/skills/shadok-report/scripts/report.mjs --kind access --secret LINEAR_API_KEY \
15
+ "Linear token expired" <<'BODY'
16
+ GET https://api.linear.app/graphql → 401 "Authentication required".
17
+ I was triaging the sprint board; nothing was written.
18
+ BODY
19
+ ```
20
+
21
+ - **title** (the argument): one line, what is wrong. Same title again = the
22
+ same report (the admins see `×2`, not a second card), so keep it stable while
23
+ the problem is the same.
24
+ - **`--kind`**: `access` (a credential missing, expired or refused), `bug`
25
+ (something is broken — the default), `blocked` (anything else stopping you).
26
+ - **`--secret NAME`**: with `access`, the environment variable concerned
27
+ (`LINEAR_API_KEY`, `SLACK_BOT_TOKEN`, `ANTHROPIC_API_KEY`…). The admin gets a
28
+ button that opens the vault on that name. The **name only — never the value.**
29
+ - **body** (stdin as above, or `--body "…"`, optional): the error you got, what you were doing, what
30
+ you already tried. Short and factual.
31
+
32
+ ## Rules
33
+
34
+ - **Never put a secret value in a report** — no token, no key, no password,
35
+ not even partially. Name the variable; that is enough.
36
+ - **Report once, then move on.** Don't loop on the same failure: report, tell
37
+ the person in your chat (if any) that you asked an admin, and do whatever
38
+ else you can without that access. A reload may be needed once the admin
39
+ fixes the secret — they will tell you, or reload you.
40
+ - **Not for questions the person in front of you can answer.** If someone is
41
+ talking to you, ask them first. This is for what nobody in the conversation
42
+ can fix.
43
+
44
+ ## If it fails
45
+
46
+ `403` means your session key is missing or you predate this feature: say so in
47
+ your chat and ask for *Reload agent*. `429` means you already filed many reports
48
+ this hour: stop filing, wait.
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ // Ask an admin for help: POST /reports with this agent's session key.
3
+ // A script rather than a raw curl so the body can come from stdin without any
4
+ // quoting trap, and so a refusal is said plainly.
5
+ const args = process.argv.slice(2);
6
+ const die = (m) => { console.error(m); process.exit(1); };
7
+ const USAGE = 'usage: report.mjs [--kind access|bug|blocked] [--secret ENV_NAME] [--body "…"] "title" [<<< body]';
8
+
9
+ let kind, secret, bodyArg;
10
+ const rest = [];
11
+ for (let i = 0; i < args.length; i++) {
12
+ if (args[i] === "--kind" || args[i] === "-k") kind = args[++i];
13
+ else if (args[i] === "--secret" || args[i] === "-s") secret = args[++i];
14
+ else if (args[i] === "--body" || args[i] === "-b") bodyArg = args[++i];
15
+ else if (args[i] === "--help" || args[i] === "-h") die(USAGE);
16
+ else rest.push(args[i]);
17
+ }
18
+ const title = rest.join(" ").trim();
19
+ if (!title) die(USAGE);
20
+
21
+ // The body comes from `--body` or from stdin. stdin is read only when it is not
22
+ // a TTY AND something actually arrives quickly: an agent's Bash tool hands the
23
+ // script a pipe that is never written nor closed, and a plain `for await` over
24
+ // it hung for ever (measured). Once data starts, it is read to the end.
25
+ async function readStdin() {
26
+ if (process.stdin.isTTY) return "";
27
+ return new Promise((resolve) => {
28
+ let buf = "";
29
+ let started = false;
30
+ const done = () => { clearTimeout(idle); process.stdin.pause(); process.stdin.removeAllListeners(); resolve(buf); };
31
+ const idle = setTimeout(() => { if (!started) done(); }, 400);
32
+ process.stdin.setEncoding("utf8");
33
+ process.stdin.on("data", (c) => { started = true; buf += c; });
34
+ process.stdin.on("end", done);
35
+ process.stdin.on("error", done);
36
+ });
37
+ }
38
+ const body = bodyArg ?? (await readStdin());
39
+
40
+ const port = process.env.SHADOK_PORT;
41
+ const key = process.env.SHADOK_SESSION_KEY;
42
+ if (!port) die("Not inside a shadok-ai agent (SHADOK_PORT unset).");
43
+ if (!key) die("SHADOK_SESSION_KEY is unset — say so in your chat and ask the human to reload this agent.");
44
+
45
+ let res;
46
+ try {
47
+ res = await fetch(`http://127.0.0.1:${port}/reports`, {
48
+ method: "POST",
49
+ headers: { "content-type": "application/json", "x-shadok-session-key": key },
50
+ body: JSON.stringify({ title, ...(kind ? { kind } : {}), ...(secret ? { secret } : {}), ...(body.trim() ? { body } : {}) }),
51
+ signal: AbortSignal.timeout(30_000),
52
+ });
53
+ } catch (e) {
54
+ die(`The cockpit did not answer (${e?.message ?? e}). Say so in your chat instead.`);
55
+ }
56
+ const out = await res.json().catch(() => ({}));
57
+ if (!res.ok) die(`Refused (${res.status}): ${out.error ?? "no reason given"}`);
58
+ const how = ["the cockpit's Reports panel", out.notified?.telegram ? "a Telegram DM to the owner" : null].filter(Boolean).join(" and ");
59
+ process.stdin.destroy();
60
+ console.log(`reported${out.merged ? ` again (×${out.count})` : ""} — the admins were told through ${how}.`);
@@ -0,0 +1,102 @@
1
+ /** What kind of help is asked. `access` is the common one: a credential that is
2
+ * missing, expired or refused — which an admin fixes in the vault. */
3
+ export declare const REPORT_KINDS: readonly ["access", "bug", "blocked"];
4
+ export type ReportKind = (typeof REPORT_KINDS)[number];
5
+ export interface AgentReport {
6
+ id: string;
7
+ /** First filed. */
8
+ at: number;
9
+ /** Last filed again (a duplicate bumps it and `count`). */
10
+ lastAt: number;
11
+ sessionId: string;
12
+ /** The agent's display name and group at filing time — the agent may be gone
13
+ * by the time someone reads it. */
14
+ agent: string;
15
+ group?: string | null;
16
+ profile?: string | null;
17
+ kind: ReportKind;
18
+ title: string;
19
+ body?: string;
20
+ /** For `access`: the environment variable / vault name concerned, so the panel
21
+ * can open the vault on it. */
22
+ secret?: string;
23
+ count: number;
24
+ status: "open" | "resolved";
25
+ resolvedBy?: string;
26
+ resolvedAt?: number;
27
+ /** When the owner was last DMed about it (a duplicate re-notifies at most hourly). */
28
+ notifiedAt?: number;
29
+ /** Admins who have opened the panel since it was (re)filed. */
30
+ seenBy?: string[];
31
+ }
32
+ export declare const TITLE_MAX = 200;
33
+ export declare const BODY_MAX = 8000;
34
+ /** A runaway agent must not flood the admins: new reports per agent per hour. */
35
+ export declare const MAX_NEW_PER_HOUR = 10;
36
+ /** A duplicate re-notifies at most this often. */
37
+ export declare const RENOTIFY_MS = 3600000;
38
+ export declare const MAX_REPORTS = 500;
39
+ /** Resolved reports are kept this long, open ones until resolved. */
40
+ export declare const RESOLVED_TTL_MS: number;
41
+ export type ReportInput = {
42
+ kind: ReportKind;
43
+ title: string;
44
+ body?: string;
45
+ secret?: string;
46
+ };
47
+ /** Validate what an agent posted. Never echoes the body back. */
48
+ export declare function reportInput(raw: unknown): {
49
+ ok: true;
50
+ input: ReportInput;
51
+ } | {
52
+ ok: false;
53
+ error: string;
54
+ };
55
+ /**
56
+ * Refuse a NEW report from an agent that already filed `MAX_NEW_PER_HOUR` in the
57
+ * last hour. Duplicates are not counted (they merge), so an agent retrying the
58
+ * same failure in a loop is never refused — it just bumps the count.
59
+ */
60
+ export declare function rateRefusal(list: AgentReport[], sessionId: string, now: number): string | null;
61
+ /**
62
+ * File a report. An OPEN report from the same agent with the same title is the
63
+ * same problem seen again: it is bumped (count, lastAt, latest body, unread
64
+ * again), never duplicated.
65
+ */
66
+ export declare function fileReport(list: AgentReport[], input: ReportInput, who: {
67
+ sessionId: string;
68
+ agent: string;
69
+ group?: string | null;
70
+ profile?: string | null;
71
+ }, now: number, id?: string): {
72
+ list: AgentReport[];
73
+ report: AgentReport;
74
+ merged: boolean;
75
+ };
76
+ /** DM the owner for a new report; for a duplicate, only if the last DM is an hour old. */
77
+ export declare function shouldNotify(r: AgentReport, merged: boolean, now: number): boolean;
78
+ export interface ReportsInbox {
79
+ /** Open first (newest activity first), then resolved. */
80
+ reports: (AgentReport & {
81
+ unread: boolean;
82
+ })[];
83
+ /** Open reports this admin has not seen since they were (re)filed. */
84
+ badge: number;
85
+ }
86
+ export declare function reportsInbox(list: AgentReport[], viewer: string): ReportsInbox;
87
+ export declare function markReportsSeen(list: AgentReport[], viewer: string): AgentReport[];
88
+ /** Resolve (or reopen) one report. */
89
+ export declare function resolveReport(list: AgentReport[], id: string, by: string, now: number, reopen?: boolean): {
90
+ ok: true;
91
+ list: AgentReport[];
92
+ report: AgentReport;
93
+ } | {
94
+ ok: false;
95
+ error: string;
96
+ };
97
+ export declare const kindLabel: (k: ReportKind) => string;
98
+ /** The Telegram DM. Short: the panel holds the detail. */
99
+ export declare function notificationText(r: AgentReport, cockpitTitle?: string | null): string;
100
+ export declare function reportsFile(cwd?: string): string;
101
+ export declare function loadReports(file?: string): AgentReport[];
102
+ export declare function saveReports(list: AgentReport[], file?: string): void;
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Agent reports — the place an agent that is STUCK goes to ask an admin for
3
+ * help: an expired Linear token, no access to the Slack token it was told to
4
+ * use, a Claude API key answering 401, a bug in shadok itself.
5
+ *
6
+ * Before this, the only way out was to say it in its own chat, which nobody
7
+ * reads if nobody is watching that agent — so a cron agent blocked on a dead
8
+ * token failed every hour, silently, for days. A report lands in ONE place every
9
+ * admin sees (the Reports panel, with a badge), and the Telegram owner gets a DM.
10
+ *
11
+ * Spec: docs/superpowers/specs/2026-11-10-agent-reports.md. Pure cores
12
+ * (`reportInput`, `fileReport`, `rateRefusal`, `shouldNotify`, `reportsInbox`,
13
+ * `markReportsSeen`, `resolveReport`, `notificationText`) are tested; the file
14
+ * I/O is the thin part.
15
+ */
16
+ import { randomBytes } from "node:crypto";
17
+ import fs from "node:fs";
18
+ import os from "node:os";
19
+ import path from "node:path";
20
+ import { instanceKey } from "./paths.js";
21
+ /** What kind of help is asked. `access` is the common one: a credential that is
22
+ * missing, expired or refused — which an admin fixes in the vault. */
23
+ export const REPORT_KINDS = ["access", "bug", "blocked"];
24
+ export const TITLE_MAX = 200;
25
+ export const BODY_MAX = 8000;
26
+ /** A runaway agent must not flood the admins: new reports per agent per hour. */
27
+ export const MAX_NEW_PER_HOUR = 10;
28
+ /** A duplicate re-notifies at most this often. */
29
+ export const RENOTIFY_MS = 3600_000;
30
+ export const MAX_REPORTS = 500;
31
+ /** Resolved reports are kept this long, open ones until resolved. */
32
+ export const RESOLVED_TTL_MS = 30 * 24 * 3600_000;
33
+ /** Same shape as the vault's names (src/secrets.ts): what an env var can be. */
34
+ const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
35
+ /** Validate what an agent posted. Never echoes the body back. */
36
+ export function reportInput(raw) {
37
+ const b = (raw ?? {});
38
+ const title = typeof b.title === "string" ? b.title.trim().replace(/\s+/g, " ") : "";
39
+ if (!title)
40
+ return { ok: false, error: "a report needs a title: one line saying what is wrong" };
41
+ if (title.length > TITLE_MAX)
42
+ return { ok: false, error: `title too long (max ${TITLE_MAX} characters) — put the detail in the body` };
43
+ const kind = b.kind === undefined || b.kind === "" ? "bug" : b.kind;
44
+ if (!REPORT_KINDS.includes(kind))
45
+ return { ok: false, error: `kind must be one of ${REPORT_KINDS.join(", ")}` };
46
+ const body = typeof b.body === "string" ? b.body.trim() : "";
47
+ if (body.length > BODY_MAX)
48
+ return { ok: false, error: `body too long (max ${BODY_MAX} characters)` };
49
+ const secret = typeof b.secret === "string" ? b.secret.trim() : "";
50
+ if (secret && !ENV_NAME.test(secret))
51
+ return { ok: false, error: "secret must be an environment variable NAME (e.g. LINEAR_API_KEY), never its value" };
52
+ return { ok: true, input: { kind: kind, title, ...(body ? { body } : {}), ...(secret ? { secret } : {}) } };
53
+ }
54
+ const norm = (s) => s.toLowerCase().replace(/\s+/g, " ").trim();
55
+ /** Drop what has aged out: resolved reports past their TTL, then the oldest beyond the cap. */
56
+ function prune(list, now) {
57
+ const kept = list.filter((r) => r.status === "open" || now - (r.resolvedAt ?? r.lastAt) <= RESOLVED_TTL_MS);
58
+ return kept.length > MAX_REPORTS ? [...kept].sort((a, b) => a.lastAt - b.lastAt).slice(-MAX_REPORTS) : kept;
59
+ }
60
+ /**
61
+ * Refuse a NEW report from an agent that already filed `MAX_NEW_PER_HOUR` in the
62
+ * last hour. Duplicates are not counted (they merge), so an agent retrying the
63
+ * same failure in a loop is never refused — it just bumps the count.
64
+ */
65
+ export function rateRefusal(list, sessionId, now) {
66
+ const recent = list.filter((r) => r.sessionId === sessionId && now - r.at < 3600_000).length;
67
+ return recent >= MAX_NEW_PER_HOUR ? `too many reports from this agent in the last hour (max ${MAX_NEW_PER_HOUR}) — wait for an admin` : null;
68
+ }
69
+ /**
70
+ * File a report. An OPEN report from the same agent with the same title is the
71
+ * same problem seen again: it is bumped (count, lastAt, latest body, unread
72
+ * again), never duplicated.
73
+ */
74
+ export function fileReport(list, input, who, now, id) {
75
+ const same = list.find((r) => r.status === "open" && r.sessionId === who.sessionId && norm(r.title) === norm(input.title));
76
+ if (same) {
77
+ const report = {
78
+ ...same,
79
+ lastAt: now,
80
+ count: same.count + 1,
81
+ kind: input.kind,
82
+ ...(input.body ? { body: input.body } : {}),
83
+ ...(input.secret ? { secret: input.secret } : {}),
84
+ seenBy: [],
85
+ };
86
+ return { list: prune(list.map((r) => (r.id === same.id ? report : r)), now), report, merged: true };
87
+ }
88
+ const report = {
89
+ id: id ?? randomBytes(9).toString("base64url"),
90
+ at: now,
91
+ lastAt: now,
92
+ sessionId: who.sessionId,
93
+ agent: who.agent,
94
+ ...(who.group !== undefined ? { group: who.group } : {}),
95
+ ...(who.profile ? { profile: who.profile } : {}),
96
+ ...input,
97
+ count: 1,
98
+ status: "open",
99
+ seenBy: [],
100
+ };
101
+ return { list: prune([...list, report], now), report, merged: false };
102
+ }
103
+ /** DM the owner for a new report; for a duplicate, only if the last DM is an hour old. */
104
+ export function shouldNotify(r, merged, now) {
105
+ if (!merged)
106
+ return true;
107
+ return now - (r.notifiedAt ?? 0) >= RENOTIFY_MS;
108
+ }
109
+ export function reportsInbox(list, viewer) {
110
+ const rows = [...list]
111
+ .sort((a, b) => (a.status === b.status ? b.lastAt - a.lastAt : a.status === "open" ? -1 : 1))
112
+ .map((r) => ({ ...r, unread: r.status === "open" && !(r.seenBy ?? []).includes(viewer) }));
113
+ return { reports: rows, badge: rows.filter((r) => r.unread).length };
114
+ }
115
+ export function markReportsSeen(list, viewer) {
116
+ return list.map((r) => ((r.seenBy ?? []).includes(viewer) ? r : { ...r, seenBy: [...(r.seenBy ?? []), viewer] }));
117
+ }
118
+ /** Resolve (or reopen) one report. */
119
+ export function resolveReport(list, id, by, now, reopen = false) {
120
+ const r = list.find((x) => x.id === id);
121
+ if (!r)
122
+ return { ok: false, error: "no such report" };
123
+ const next = reopen
124
+ ? (({ resolvedBy: _b, resolvedAt: _a, ...rest }) => ({ ...rest, status: "open" }))(r)
125
+ : { ...r, status: "resolved", resolvedBy: by, resolvedAt: now };
126
+ return { ok: true, list: list.map((x) => (x.id === id ? next : x)), report: next };
127
+ }
128
+ const KIND_LABEL = { access: "🔑 access", bug: "🐞 bug", blocked: "⛔ blocked" };
129
+ export const kindLabel = (k) => KIND_LABEL[k];
130
+ /** The Telegram DM. Short: the panel holds the detail. */
131
+ export function notificationText(r, cockpitTitle) {
132
+ const where = cockpitTitle ? ` · ${cockpitTitle}` : "";
133
+ const again = r.count > 1 ? ` (×${r.count})` : "";
134
+ const lines = [`🆘 ${r.agent} needs an admin${where}`, `${KIND_LABEL[r.kind]}: ${r.title}${again}`];
135
+ if (r.secret)
136
+ lines.push(`secret: ${r.secret}`);
137
+ if (r.body)
138
+ lines.push("", r.body.length > 600 ? r.body.slice(0, 600) + "…" : r.body);
139
+ lines.push("", "Open the cockpit → Reports to resolve it.");
140
+ return lines.join("\n");
141
+ }
142
+ // ── Storage ──────────────────────────────────────────────────────────────────
143
+ export function reportsFile(cwd = process.cwd()) {
144
+ return path.join(os.homedir(), ".shadok-ai", "reports", instanceKey(cwd) + ".json");
145
+ }
146
+ export function loadReports(file = reportsFile()) {
147
+ try {
148
+ const v = JSON.parse(fs.readFileSync(file, "utf8"));
149
+ return Array.isArray(v) ? v.filter((r) => r && typeof r.id === "string" && typeof r.title === "string") : [];
150
+ }
151
+ catch {
152
+ return [];
153
+ }
154
+ }
155
+ export function saveReports(list, file = reportsFile()) {
156
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
157
+ const tmp = `${file}.${process.pid}.tmp`;
158
+ fs.writeFileSync(tmp, JSON.stringify(list, null, 2), { mode: 0o600 });
159
+ fs.renameSync(tmp, file);
160
+ }
161
+ //# sourceMappingURL=agent-reports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-reports.js","sourceRoot":"","sources":["../src/agent-reports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAA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AK,EAAE,CAAC,CAAC;IACtE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC"}
package/dist/server.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { randomUUID, randomBytes, timingSafeEqual } from "node:crypto";
2
2
  import { newRequest, askVerdict, approveVerdict, cancelVerdict, dueRequests, expire, upsertRequest, requestsFor, describeRequest, loadRequests, saveRequests, isOpen, REQUEST_TTL_MS } from "./admin-requests.js";
3
3
  import { recordEvent, loadEvents, saveEvents, inboxFor, markSeen, notMeEffect, describeEvent } from "./security-events.js";
4
+ import { reportInput, fileReport, rateRefusal, shouldNotify, reportsInbox, markReportsSeen, resolveReport, notificationText as reportNotificationText, loadReports, saveReports } from "./agent-reports.js";
4
5
  import { execFile, execFileSync, spawnSync, spawn as spawnChild } from "node:child_process";
5
6
  import fs from "node:fs";
6
7
  import os from "node:os";
@@ -3438,6 +3439,8 @@ const SKILL_SOURCES = [
3438
3439
  // Seeded to the server HOME by seedFactorySkill; a Skillsmith running as a
3439
3440
  // group's own OS user reads only this tier.
3440
3441
  ["factory-skill", "shadok-factory"],
3442
+ // Asking an admin for help when stuck (src/agent-reports.ts).
3443
+ ["report-skill", "shadok-report"],
3441
3444
  ];
3442
3445
  /** Claude Code's machine-wide ("Enterprise"/managed) skills directory — read by
3443
3446
  * EVERY OS user regardless of HOME, with precedence over a personal
@@ -6235,6 +6238,15 @@ function broadcastAll(msg) {
6235
6238
  if (c.readyState === c.OPEN)
6236
6239
  c.send(data);
6237
6240
  }
6241
+ /** Send a message to every socket an ADMIN person opened (stamped at connect,
6242
+ * never from a frame). Agents and members never get it: a report may name a
6243
+ * credential problem the rest of the instance has no business reading. */
6244
+ function broadcastAdmins(msg) {
6245
+ const data = JSON.stringify(msg);
6246
+ for (const c of wss.clients)
6247
+ if (c.readyState === c.OPEN && c.__admin)
6248
+ c.send(data);
6249
+ }
6238
6250
  /** The version + settings snapshot every client needs: running/latest version,
6239
6251
  * whether auto-update is armed, and the spawn permission mode. */
6240
6252
  /** What both /version and the WS `version` message report. */
@@ -6419,6 +6431,70 @@ app.post("/files", (req, res) => {
6419
6431
  return res.status(400).json({ error: refused.join("; ") });
6420
6432
  res.json({ ok: true, sent: accepted.map((f) => ({ path: f.path, name: f.name, size: f.size })), refused });
6421
6433
  });
6434
+ // ── Agent reports (src/agent-reports.ts): an agent that is stuck asks an
6435
+ // admin for help — an expired token, an access it does not have, a bug.
6436
+ //
6437
+ // Filed by the AGENT only, authenticated by its session key (invariant 33): a
6438
+ // person has the chat and the admins themselves. Read and resolved by an ADMIN
6439
+ // person only. Notified twice, because a report nobody sees is the very failure
6440
+ // this exists to end: a DM to the Telegram owner, and a live `agent-report`
6441
+ // frame to every admin socket (badge + sound), backed by the panel's poll.
6442
+ app.post("/reports", (req, res) => {
6443
+ const agent = agentPrincipal(req);
6444
+ if (!agent)
6445
+ return res.status(403).json({ error: "agents only — authenticate with x-shadok-session-key" });
6446
+ const v = reportInput(req.body);
6447
+ if (!v.ok)
6448
+ return res.status(400).json({ error: v.error });
6449
+ const now = Date.now();
6450
+ let list = loadReports();
6451
+ const ch = loadChannels().find((c) => c.sessionId === agent.sessionId);
6452
+ const who = { sessionId: agent.sessionId, agent: ch?.name || agent.sessionId.slice(0, 8), group: agent.group, profile: agent.profile };
6453
+ const filed = fileReport(list, v.input, who, now);
6454
+ if (!filed.merged) {
6455
+ const refused = rateRefusal(list, agent.sessionId, now);
6456
+ if (refused)
6457
+ return res.status(429).json({ error: refused });
6458
+ }
6459
+ list = filed.list;
6460
+ const r = filed.report;
6461
+ const notify = shouldNotify(r, filed.merged, now);
6462
+ if (notify)
6463
+ list = list.map((x) => (x.id === r.id ? { ...x, notifiedAt: now } : x));
6464
+ saveReports(list);
6465
+ console.log(`reports: ${who.agent} (${agent.sessionId.slice(0, 8)}) filed ${r.kind} "${r.title}"${filed.merged ? ` ×${r.count}` : ""}`);
6466
+ broadcastAdmins({ type: "agent-report", id: r.id, agent: r.agent, kind: r.kind, title: r.title, count: r.count });
6467
+ let telegram = Promise.resolve(false);
6468
+ if (notify)
6469
+ telegram = tgBridge.notifyOwner(reportNotificationText(r, titleForCwd(loadConfig(), process.cwd()))).catch(() => false);
6470
+ void telegram.then((sent) => {
6471
+ res.json({ ok: true, id: r.id, merged: filed.merged, count: r.count, notified: { cockpit: true, telegram: sent } });
6472
+ });
6473
+ });
6474
+ app.get("/reports", (req, res) => {
6475
+ const me = accountAdmin(req, res, false, "read agent reports");
6476
+ if (!me)
6477
+ return;
6478
+ res.json(reportsInbox(loadReports(), me.name));
6479
+ });
6480
+ app.post("/reports/seen", (req, res) => {
6481
+ const me = accountAdmin(req, res, true, "read agent reports");
6482
+ if (!me)
6483
+ return;
6484
+ saveReports(markReportsSeen(loadReports(), me.name));
6485
+ res.json({ ok: true });
6486
+ });
6487
+ app.post("/reports/resolve", (req, res) => {
6488
+ const me = accountAdmin(req, res, true, "resolve agent reports");
6489
+ if (!me)
6490
+ return;
6491
+ const out = resolveReport(loadReports(), String(req.body?.id ?? ""), me.name, Date.now(), req.body?.reopen === true);
6492
+ if (!out.ok)
6493
+ return res.status(404).json({ error: out.error });
6494
+ saveReports(out.list);
6495
+ console.log(`reports: ${me.name} ${req.body?.reopen === true ? "reopened" : "resolved"} "${out.report.title}"`);
6496
+ res.json({ ok: true, report: out.report });
6497
+ });
6422
6498
  /**
6423
6499
  * The session's history for the web, WITH the files it handed over via POST
6424
6500
  * /files (`ShadokFile`) merged back in as `file` turns.
@@ -9133,6 +9209,8 @@ wss.on("connection", (ws, req) => {
9133
9209
  // so the cockpit always shows which peer created what.
9134
9210
  const callerPeerRestricted = restrictedBoxOf(req) !== null;
9135
9211
  ws.__peer = callerPeer;
9212
+ // An admin PERSON's socket receives `agent-report` frames (broadcastAdmins).
9213
+ ws.__admin = me?.role === "admin" && !me.agent && !callerPeer;
9136
9214
  // A same-origin browser, decided ONCE at connect from the upgrade's headers —
9137
9215
  // not from anything a frame says. `run` is gated on it: shell mode bypasses a
9138
9216
  // profile's `deny` (measured), so pilotctl and the agents, which connect with
@@ -10540,6 +10618,26 @@ function seedFilesSkill() {
10540
10618
  }
10541
10619
  if (SEED_SKILLS)
10542
10620
  seedFilesSkill();
10621
+ /** The `shadok-report` skill — an agent that is stuck asks an admin for help
10622
+ * (POST /reports). Seeded like shadok-files, for the same reason: every boot
10623
+ * reaches the agents already running. */
10624
+ function seedReportSkill() {
10625
+ try {
10626
+ const src = path.join(__dirname, "..", "context", "report-skill");
10627
+ if (!fs.existsSync(path.join(src, "SKILL.md")))
10628
+ return;
10629
+ const dst = path.join(os.homedir(), ".claude", "skills", "shadok-report");
10630
+ fs.mkdirSync(path.join(dst, "scripts"), { recursive: true });
10631
+ fs.copyFileSync(path.join(src, "SKILL.md"), path.join(dst, "SKILL.md"));
10632
+ fs.copyFileSync(path.join(src, "scripts", "report.mjs"), path.join(dst, "scripts", "report.mjs"));
10633
+ fs.chmodSync(path.join(dst, "scripts", "report.mjs"), 0o755);
10634
+ }
10635
+ catch {
10636
+ /* best effort — without it an agent says it in its own chat, as before */
10637
+ }
10638
+ }
10639
+ if (SEED_SKILLS)
10640
+ seedReportSkill();
10543
10641
  /** The `shadok-social` skill — posting on a connected LinkedIn account. */
10544
10642
  function seedSocialSkill() {
10545
10643
  try {