@astrofoundry/pi-astro 0.40.2 → 0.40.4
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/agents/media.md +1 -1
- package/extensions/astro-discord/daily-run.test.ts +2 -2
- package/extensions/astro-discord/daily-run.ts +2 -2
- package/extensions/astro-discord/index.ts +44 -3
- package/extensions/astro-discord/media.test.ts +31 -2
- package/extensions/astro-discord/media.ts +49 -3
- package/package.json +1 -1
- package/skills/media/SKILL.md +1 -1
- package/specialists/README.md +1 -1
package/agents/media.md
CHANGED
|
@@ -19,6 +19,6 @@ Rules:
|
|
|
19
19
|
- Movies go to `add-movies`, series to `add-series`; batch independent IDs in one call.
|
|
20
20
|
- Success needs an explicit `added` or `already_exists` in `results`; `already_exists` means it was already there, not newly added. Report every ID of a batch.
|
|
21
21
|
- Pause or resume downloads only when the task asks for it, then report the returned state. Adding never implies a queue change.
|
|
22
|
-
- Keep replies short: canonical title and year,
|
|
22
|
+
- Keep replies short: canonical title and year, and the outcome. When an add returned `sabnzbd_paused: true`, end with "Downloads are paused."; say nothing about the queue otherwise. Outside failures, name no tool or service (SABnzbd, Radarr, Sonarr, trendarr, TMDB, OMDb): say downloads, library, search.
|
|
23
23
|
- Library settings, quality profiles, Radarr and Sonarr configuration, and deletions are operator tasks; say so and stop.
|
|
24
24
|
- Delegate through `subagent` only to another specialist (`astro.arcane` for the media containers on the Arcane VM) and only for that specialist's own area.
|
|
@@ -83,8 +83,8 @@ describe("morning status lines", () => {
|
|
|
83
83
|
expect(dnsStatus({ status: "ok" }, null)).toMatchObject({ problem: "DNS: the secondary resolver does not answer" });
|
|
84
84
|
expect(inferenceStatus("embed \tstate = running \tpid = 80042 health=200\nrerank \tstate = running \tpid = 81670 health=200")).toEqual({ area: "Inference", line: "Nexus embed, rerank running and healthy" });
|
|
85
85
|
expect(inferenceStatus("embed \tstate = running \tpid = 80042 health=503")).toMatchObject({ problem: "Inference: embed not healthy on Nexus" });
|
|
86
|
-
expect(mediaStatus({ sabnzbd_paused: true, warnings: [] })).toEqual({ area: "Media", line: "
|
|
87
|
-
expect(mediaStatus({ sabnzbd_paused: false, warnings: [{ text: "login failed" }] })).toMatchObject({ line: "
|
|
86
|
+
expect(mediaStatus({ sabnzbd_paused: true, warnings: [] })).toEqual({ area: "Media", line: "downloads paused" });
|
|
87
|
+
expect(mediaStatus({ sabnzbd_paused: false, warnings: [{ text: "login failed" }] })).toMatchObject({ line: "downloads running, 1 warning", problem: "Media: the downloader shows 1 warning", route: "media" });
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
it("checks last night's Proxmox archives and the restic check", () => {
|
|
@@ -111,8 +111,8 @@ export function mediaStatus(sab: unknown): AreaStatus {
|
|
|
111
111
|
const r = sab as { sabnzbd_paused?: unknown; warnings?: unknown } | null;
|
|
112
112
|
if (!r || typeof r.sabnzbd_paused !== "boolean") return failed("Media", "media", "sabnzbd status");
|
|
113
113
|
const warnings = Array.isArray(r.warnings) ? r.warnings.length : 0;
|
|
114
|
-
const line = `
|
|
115
|
-
return { area: "Media", line, ...(warnings > 0 ? { problem: `Media:
|
|
114
|
+
const line = `downloads ${r.sabnzbd_paused ? "paused" : "running"}${warnings > 0 ? `, ${warnings} warning${warnings === 1 ? "" : "s"}` : ""}`;
|
|
115
|
+
return { area: "Media", line, ...(warnings > 0 ? { problem: `Media: the downloader shows ${warnings} warning${warnings === 1 ? "" : "s"}`, route: "media" as const } : {}) };
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/** Every guest is backed up nightly at 02:30; an archive older than this means last night's run missed it. */
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
writePostedArcane,
|
|
35
35
|
} from "./daily-report.ts";
|
|
36
36
|
import { GatewayClient } from "./gateway.ts";
|
|
37
|
-
import { type CommandOption, IS_COMPONENTS_V2, KeyedQueue, MEDIA, MEDIA_COMMANDS, type MediaKind, type Outcome, addOutcome, applyOutcome, commandArgs, hasActiveButton, listMessage, mediaAccess, mediaPointer, parseAddButton, parseAddReport, parseMediaList, parseQueueState, queueLine } from "./media.ts";
|
|
37
|
+
import { type CommandOption, IS_COMPONENTS_V2, KeyedQueue, MEDIA, MEDIA_COMMANDS, type MediaKind, type Outcome, PAUSED_TEXT, RESUME_ID, addOutcome, addedWhilePaused, applyOutcome, commandArgs, hasActiveButton, listMessage, mediaAccess, mediaPointer, parseAddButton, parseAddReport, parseMediaList, parseQueueState, queueLine, resumedText, unpauseRow } from "./media.ts";
|
|
38
38
|
import { cancelledApprovalText, interruptedTaskText, readOpenWork, type OpenWork, type StopReason, writeOpenWork } from "./open-work.ts";
|
|
39
39
|
import { DISMISSED, type Picks, parseNoButton, parsePicks, picksArgs, picksFailureText, picksMessage, readPicksState, withDismissed, withSuggested, writePicksState } from "./media-picks.ts";
|
|
40
40
|
import { FRIDAY, isDue, MONDAY, readReportState, writeReportState, zonedWeekday } from "./reports.ts";
|
|
@@ -1379,7 +1379,7 @@ class Bridge {
|
|
|
1379
1379
|
if (command.view === "downloads") {
|
|
1380
1380
|
const paused = parseQueueState(output);
|
|
1381
1381
|
if (paused === null) throw new Error("the media wrapper returned no queue state");
|
|
1382
|
-
await this.rest.editOriginal(app, interaction.token, { content: queueLine(paused) });
|
|
1382
|
+
await this.rest.editOriginal(app, interaction.token, { content: queueLine(paused), ...(paused ? { components: unpauseRow() } : {}) });
|
|
1383
1383
|
return;
|
|
1384
1384
|
}
|
|
1385
1385
|
const list = parseMediaList(output);
|
|
@@ -1440,12 +1440,45 @@ class Bridge {
|
|
|
1440
1440
|
await this.rest.editOriginal(app, interaction.token, { components: next });
|
|
1441
1441
|
this.rememberMediaMessage(message.id, next);
|
|
1442
1442
|
log(`media add ${target.imdbId} for ${userId}: ${outcome.label}`);
|
|
1443
|
-
if (outcome.note) await this.rest.followUp(app, interaction.token, { content: outcome.note, flags: EPHEMERAL });
|
|
1443
|
+
if (outcome.note) await this.rest.followUp(app, interaction.token, { content: outcome.note, flags: EPHEMERAL, ...(outcome.paused ? { components: unpauseRow() } : {}) });
|
|
1444
1444
|
})
|
|
1445
1445
|
.catch((err) => log(`media add ${target.imdbId} failed: ${err instanceof Error ? err.message : String(err)}`))
|
|
1446
1446
|
.finally(() => this.untrackMedia(interaction));
|
|
1447
1447
|
}
|
|
1448
1448
|
|
|
1449
|
+
/** Unpause under a media answer or an Add note: the queue resumes, and the message says who resumed it. */
|
|
1450
|
+
private async onResumeButton(interaction: Interaction): Promise<void> {
|
|
1451
|
+
const message = interaction.message;
|
|
1452
|
+
if (!message) return;
|
|
1453
|
+
const userId = interaction.member?.user?.id ?? interaction.user?.id ?? "";
|
|
1454
|
+
if (this.stopping) {
|
|
1455
|
+
await this.rest.ephemeralReply(interaction.id, interaction.token, "The bridge is restarting; try again in a minute.");
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
if (!(await this.mediaAllowed(interaction, userId))) return;
|
|
1459
|
+
await this.rest.deferUpdate(interaction.id, interaction.token);
|
|
1460
|
+
const app = this.config.applicationId;
|
|
1461
|
+
await this.mediaClicks
|
|
1462
|
+
.run(message.id, async () => {
|
|
1463
|
+
if (!hasActiveButton(message.components ?? [], RESUME_ID)) return;
|
|
1464
|
+
let paused: boolean | null = null;
|
|
1465
|
+
let reason = "";
|
|
1466
|
+
try {
|
|
1467
|
+
paused = parseQueueState(JSON.parse(await this.runEntry(MEDIA, `discord-${userId}`, ["sabnzbd", "resume"], MEDIA_TIMEOUT_MS)));
|
|
1468
|
+
} catch (err) {
|
|
1469
|
+
reason = (err instanceof Error ? err.message : String(err)).split("\n")[0].slice(0, 300);
|
|
1470
|
+
}
|
|
1471
|
+
if (paused === false) {
|
|
1472
|
+
await this.rest.editOriginal(app, interaction.token, { content: resumedText(userId), components: [] });
|
|
1473
|
+
log(`media: downloads resumed by ${userId}`);
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
log(`media: resume for ${userId} failed: ${reason || "the queue still reports paused"}`);
|
|
1477
|
+
await this.rest.followUp(app, interaction.token, { content: `Downloads are still paused: ${reason || "the queue did not resume"}.`, flags: EPHEMERAL });
|
|
1478
|
+
})
|
|
1479
|
+
.catch((err) => log(`media: resume failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1449
1482
|
/** Not interested on a weekly pick: the title never comes back, unlike an ignored one, and only that button changes. */
|
|
1450
1483
|
private async onDismissButton(interaction: Interaction, customId: string): Promise<void> {
|
|
1451
1484
|
const target = parseNoButton(customId);
|
|
@@ -1598,6 +1631,10 @@ class Bridge {
|
|
|
1598
1631
|
this.conversations = recordAnswer(this.conversations, task.conversation.key, answers, Date.now());
|
|
1599
1632
|
saveState(this.conversations);
|
|
1600
1633
|
if (task.specialist === "arcane") await this.carefulOutcome(task.channelId, messages).catch((err) => log(`arcane: careful outcome failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
1634
|
+
if (task.specialist === MEDIA && addedWhilePaused(messages)) {
|
|
1635
|
+
const last = answers[answers.length - 1];
|
|
1636
|
+
await this.rest.createMessage(task.channelId, { content: PAUSED_TEXT, components: unpauseRow(), ...(last ? { replyTo: last } : {}) }).catch((err) => log(`media: paused notice failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
1637
|
+
}
|
|
1601
1638
|
return failed;
|
|
1602
1639
|
}
|
|
1603
1640
|
|
|
@@ -1656,6 +1693,10 @@ class Bridge {
|
|
|
1656
1693
|
}
|
|
1657
1694
|
if (interaction.type !== 3) return;
|
|
1658
1695
|
const customId = interaction.data?.custom_id ?? "";
|
|
1696
|
+
if (customId === RESUME_ID) {
|
|
1697
|
+
await this.onResumeButton(interaction);
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1659
1700
|
if (customId.startsWith("media:no:")) {
|
|
1660
1701
|
await this.onDismissButton(interaction, customId);
|
|
1661
1702
|
return;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Message } from "@earendil-works/pi-ai";
|
|
1
2
|
import { describe, expect, it, vi } from "vitest";
|
|
2
3
|
import { helpText } from "./commands.ts";
|
|
3
4
|
import { validateConfig } from "./config.ts";
|
|
@@ -22,6 +23,11 @@ import {
|
|
|
22
23
|
parseMediaList,
|
|
23
24
|
parseQueueState,
|
|
24
25
|
queueLine,
|
|
26
|
+
PAUSED_TEXT,
|
|
27
|
+
RESUME_ID,
|
|
28
|
+
addedWhilePaused,
|
|
29
|
+
resumedText,
|
|
30
|
+
unpauseRow,
|
|
25
31
|
} from "./media.ts";
|
|
26
32
|
import { DiscordRest, type MessageComponent } from "./rest.ts";
|
|
27
33
|
|
|
@@ -76,7 +82,8 @@ describe("media slash commands", () => {
|
|
|
76
82
|
expect(parseAddReport(null)).toBeNull();
|
|
77
83
|
expect(parseQueueState({ sabnzbd_paused: false })).toBe(false);
|
|
78
84
|
expect(parseQueueState({})).toBeNull();
|
|
79
|
-
expect(queueLine(true)).toBe("
|
|
85
|
+
expect(queueLine(true)).toBe("⏸️ Downloads are paused");
|
|
86
|
+
expect(queueLine(false)).toBe("▶️ Downloads are running");
|
|
80
87
|
});
|
|
81
88
|
});
|
|
82
89
|
|
|
@@ -130,7 +137,8 @@ describe("media add buttons", () => {
|
|
|
130
137
|
it("turns each add result into a button state and a private note", () => {
|
|
131
138
|
const report = (status: string, paused: boolean | null = false, detail: string | null = null) => ({ results: [{ imdb_id: "tt1", title: "Hope", status, detail }], sabnzbd_paused: paused });
|
|
132
139
|
expect(addOutcome(report("added"), "movie", "tt1")).toEqual({ label: "Added", style: 3, disabled: true });
|
|
133
|
-
expect(addOutcome(report("added", true), "movie", "tt1")
|
|
140
|
+
expect(addOutcome(report("added", true), "movie", "tt1")).toMatchObject({ note: "Added **Hope**; the search started. ⏸️ Downloads are paused.", paused: true });
|
|
141
|
+
expect(addOutcome(report("added", false), "movie", "tt1").paused).toBeUndefined();
|
|
134
142
|
expect(addOutcome(report("already_exists"), "movie", "tt1")).toEqual({ label: "In library", style: 2, disabled: true });
|
|
135
143
|
expect(addOutcome(report("not_found"), "series", "tt1")).toMatchObject({ label: "Not found", disabled: true, note: expect.stringMatching(/Sonarr/) });
|
|
136
144
|
expect(addOutcome(report("error", false, "quality profile missing"), "movie", "tt1")).toMatchObject({ label: "Retry", disabled: false, note: "Not added: quality profile missing." });
|
|
@@ -242,3 +250,24 @@ describe("media rest calls", () => {
|
|
|
242
250
|
expect((JSON.parse(calls[4].init.body as string) as { name: string }[]).map((c) => c.name)).toEqual(["trending", "search", "downloads"]);
|
|
243
251
|
});
|
|
244
252
|
});
|
|
253
|
+
|
|
254
|
+
describe("paused downloads", () => {
|
|
255
|
+
const call = (id: string, args: string[], name = "media") => ({ role: "assistant", content: [{ type: "toolCall", id, name, arguments: { args } }] });
|
|
256
|
+
const result = (id: string, value: unknown, isError = false) => ({ role: "toolResult", toolCallId: id, toolName: "media", content: [{ type: "text", text: JSON.stringify(value) }], isError, timestamp: 1 });
|
|
257
|
+
const added = (paused: boolean | null) => ({ results: [{ imdb_id: "tt1", title: "X", status: "added", detail: null }], sabnzbd_paused: paused, warnings: [] });
|
|
258
|
+
|
|
259
|
+
it("asks to unpause only when an add left the queue paused", () => {
|
|
260
|
+
expect(addedWhilePaused([call("a", ["search", "x"]), result("a", { movies: [], series: [] }), call("b", ["add-movies", "tt1"]), result("b", added(true))] as unknown as Message[])).toBe(true);
|
|
261
|
+
expect(addedWhilePaused([call("b", ["add-movies", "tt1"]), result("b", added(true)), call("c", ["sabnzbd", "resume"]), result("c", { sabnzbd_paused: false })] as unknown as Message[])).toBe(false);
|
|
262
|
+
expect(addedWhilePaused([call("b", ["add-series", "tt1"]), result("b", added(false))] as unknown as Message[])).toBe(false);
|
|
263
|
+
expect(addedWhilePaused([call("c", ["sabnzbd", "status"]), result("c", { sabnzbd_paused: true })] as unknown as Message[])).toBe(false);
|
|
264
|
+
expect(addedWhilePaused([call("b", ["add-movies", "tt1"]), result("b", "failed", true)] as unknown as Message[])).toBe(false);
|
|
265
|
+
expect(addedWhilePaused([call("b", ["add-movies", "tt1"], "arcane"), result("b", added(true))] as unknown as Message[])).toBe(false);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("offers one Unpause button and names who resumed", () => {
|
|
269
|
+
expect(unpauseRow()).toEqual([{ type: 1, components: [{ type: 2, style: 1, label: "Unpause", custom_id: RESUME_ID }] }]);
|
|
270
|
+
expect(PAUSED_TEXT).toBe("⏸️ Downloads are paused");
|
|
271
|
+
expect(resumedText("178096425509453824")).toBe("▶️ Downloads resumed by <@178096425509453824>");
|
|
272
|
+
});
|
|
273
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Message } from "@earendil-works/pi-ai";
|
|
1
2
|
import { type ChannelSettings, type DiscordConfig, canUse, channelSpecialists } from "./config.ts";
|
|
2
3
|
import type { MessageComponent } from "./rest.ts";
|
|
3
4
|
|
|
@@ -73,7 +74,7 @@ export const MEDIA_COMMANDS = [
|
|
|
73
74
|
{
|
|
74
75
|
name: "downloads",
|
|
75
76
|
type: 1,
|
|
76
|
-
description: "
|
|
77
|
+
description: "Downloads: status, pause, or resume (unpause)",
|
|
77
78
|
contexts: [GUILD_CONTEXT],
|
|
78
79
|
options: [
|
|
79
80
|
{
|
|
@@ -228,6 +229,8 @@ export interface Outcome {
|
|
|
228
229
|
disabled: boolean;
|
|
229
230
|
/** Shown only to the user who clicked. */
|
|
230
231
|
note?: string;
|
|
232
|
+
/** The add left downloads paused; the note carries an Unpause button. */
|
|
233
|
+
paused?: boolean;
|
|
231
234
|
}
|
|
232
235
|
|
|
233
236
|
/** What the clicked button turns into after the add, from the wrapper's answer or its failure text. */
|
|
@@ -236,7 +239,7 @@ export function addOutcome(report: AddReport | null, kind: MediaKind, imdbId: st
|
|
|
236
239
|
const result = report.results.find((r) => r.imdb_id === imdbId);
|
|
237
240
|
const name = result?.title ? `**${escapeDiscord(result.title)}**` : imdbId;
|
|
238
241
|
if (result?.status === "added") {
|
|
239
|
-
return { label: "Added", style: SUCCESS, disabled: true, ...(report.sabnzbd_paused === true ? { note: `Added ${name}; the search started
|
|
242
|
+
return { label: "Added", style: SUCCESS, disabled: true, ...(report.sabnzbd_paused === true ? { note: `Added ${name}; the search started. ${PAUSED_TEXT}.`, paused: true } : {}) };
|
|
240
243
|
}
|
|
241
244
|
if (result?.status === "already_exists") return { label: "In library", style: SECONDARY, disabled: true };
|
|
242
245
|
if (result?.status === "not_found") return { label: "Not found", style: DANGER, disabled: true, note: `${name} was not found ${kind === "movie" ? "in Radarr" : "on TMDB or in Sonarr"}; nothing was added.` };
|
|
@@ -269,6 +272,49 @@ export function applyOutcome(components: readonly MessageComponent[], customId:
|
|
|
269
272
|
}));
|
|
270
273
|
}
|
|
271
274
|
|
|
275
|
+
export const PAUSED_TEXT = "⏸️ Downloads are paused";
|
|
276
|
+
export const RESUME_ID = "media:resume";
|
|
277
|
+
|
|
278
|
+
export function unpauseRow(): MessageComponent[] {
|
|
279
|
+
return [{ type: 1, components: [{ type: 2, style: PRIMARY, label: "Unpause", custom_id: RESUME_ID }] }];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function resumedText(userId: string): string {
|
|
283
|
+
return `▶️ Downloads resumed by <@${userId}>`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function mediaArgs(args: unknown): string[] {
|
|
287
|
+
const list = (args as { args?: unknown } | null)?.args;
|
|
288
|
+
return Array.isArray(list) ? list.filter((a): a is string => typeof a === "string") : [];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Whether a media task added something and the queue was still paused at its
|
|
293
|
+
* end: the pause state each add or queue call reported, the last one winning.
|
|
294
|
+
*/
|
|
295
|
+
export function addedWhilePaused(messages: readonly Message[]): boolean {
|
|
296
|
+
const calls = new Map<string, string>();
|
|
297
|
+
for (const m of messages) {
|
|
298
|
+
if (m.role !== "assistant") continue;
|
|
299
|
+
for (const part of m.content) if (part.type === "toolCall" && part.name === MEDIA) calls.set(part.id, mediaArgs(part.arguments)[0] ?? "");
|
|
300
|
+
}
|
|
301
|
+
let added = false;
|
|
302
|
+
let paused: boolean | null = null;
|
|
303
|
+
for (const m of messages) {
|
|
304
|
+
if (m.role !== "toolResult" || m.isError) continue;
|
|
305
|
+
const command = calls.get(m.toolCallId);
|
|
306
|
+
if (command !== "add-movies" && command !== "add-series" && command !== "sabnzbd") continue;
|
|
307
|
+
try {
|
|
308
|
+
const state = parseQueueState(JSON.parse(m.content.map((c) => (c.type === "text" ? c.text : "")).join("")));
|
|
309
|
+
if (command !== "sabnzbd") added = true;
|
|
310
|
+
if (state !== null) paused = state;
|
|
311
|
+
} catch {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return added && paused === true;
|
|
316
|
+
}
|
|
317
|
+
|
|
272
318
|
export type MediaAccess = "ok" | "channel" | "user";
|
|
273
319
|
|
|
274
320
|
/** Media commands answer where the media specialist is present and for owners or users listed under `access.media`. */
|
|
@@ -285,7 +331,7 @@ export function mediaPointer(config: DiscordConfig, configured: readonly string[
|
|
|
285
331
|
}
|
|
286
332
|
|
|
287
333
|
export function queueLine(paused: boolean): string {
|
|
288
|
-
return
|
|
334
|
+
return paused ? PAUSED_TEXT : "▶️ Downloads are running";
|
|
289
335
|
}
|
|
290
336
|
|
|
291
337
|
/**
|
package/package.json
CHANGED
package/skills/media/SKILL.md
CHANGED
|
@@ -54,7 +54,7 @@ Leave out the rating part when it is null. Add nothing else. When the user then
|
|
|
54
54
|
|
|
55
55
|
## Replies
|
|
56
56
|
|
|
57
|
-
Short and factual. Example: `Added **Dune: Part Three (2026)**. Search started
|
|
57
|
+
Short and factual. Example: `Added **Dune: Part Three (2026)**. Search started.` For a batch, one line per title. When the add returned `sabnzbd_paused: true`, end with `Downloads are paused.` and nothing on how to resume: in Discord the bridge posts an Unpause button under the answer. Say nothing about the queue when it is not paused. Outside failures, name no tool or service (SABnzbd, Radarr, Sonarr, trendarr, TMDB, OMDb): say downloads, library, search. For an existing title: `**Title (Year)** is already in the library.` For failures, what was not added and why.
|
|
58
58
|
|
|
59
59
|
## When to stop and report
|
|
60
60
|
|
package/specialists/README.md
CHANGED
|
@@ -141,7 +141,7 @@ Check: `sudo -n -u specialist -H /usr/local/bin/specialist-cli arcane --caller t
|
|
|
141
141
|
The `astro-discord` extension gives Discord users access to the specialists from a channel. It runs in a headless Pi host on Cortex (LaunchAgent `com.astrofoundry.astro-discord`, user `cortex`), never in interactive sessions.
|
|
142
142
|
|
|
143
143
|
- Channels are configured one by one (`channels.<id>`): `trigger` is `always` (every message that names a specialist counts) or `mention` (only messages that start with `@Cortex` or reply to the bot); `specialists` is `*` or a list. A channel with one specialist needs no prefix: every message there is a task for it. In a channel with several, `dns list the zones` names the specialist; an addressed message without a name gets a reply asking for one. Threads inherit their parent channel's entry; unlisted channels are ignored. The bot replies at once with "<specialist> is working on your task" and shows the typing indicator until the answer replaces that reply. Reactions on your message: ⏳ running, 🔒 waiting for an owner's approval, ✅ done, ❌ failed. `help` shows the specialists you may use in that channel and the commands (`status` lists running tasks; owners in the admin channel also see the `config` commands). Each channel and specialist has one conversation: a reply to the bot's answer, or another task for that specialist within 30 minutes, continues it with everything the specialist saw before; otherwise a new one starts, and a task beginning with `new` forces that. Replied-to and forwarded messages (text, embeds, attachment names) travel with the task, so "check this" on a forwarded alert works. Image attachments on the message or on what it quotes (up to 4, 8 MiB each) are downloaded and passed to the specialist, which sees them; other file types are named only. Sessions live under `~/.config/astro-discord/sessions/<specialist>/` and are deleted after 7 days. Long answers arrive as a `.md` attachment. When the bridge restarts, open approval requests are marked cancelled and running tasks interrupted in Discord; ask again. Scheduled reports are a list in the config, one entry per report: `"reports": [{ "report": "arcane", "channelId": "<id>", "time": "06:00", "timeZone": "Europe/Madrid" }, { "report": "tools", "channelId": "<admin channel id>", "time": "06:00", "timeZone": "Europe/Madrid" }]` (the earlier single `dailyReport` key is refused; move it into the list). The Arcane report posts an "Arcane Daily Report:" message every morning from a fresh `update-report`: one section per stack with updates, each service as current to target version with the kind of change, a release-notes verdict on every major version, and an Update button per stack that only owners can press (it runs `arcane stack-update <stack>`; the button turns into the outcome and the reason arrives as a note only the clicker sees). Stacks held in `update-holds.json` at the root of the arcane GitOps repository (`{ "supabase": "coordinated release: review first" }`) show the reason and get no button. Replying to the report asks the arcane specialist with the report as context. The tools report posts "Cortex Tools Report:": every tool on Cortex with a newer version (Homebrew packages installed on request and casks, Pi, pi-astro, and through `specialist-install` the wrappers, arcane-cli at the Arcane server's version, trendarr, and the specialist Node at the latest LTS), a release-notes verdict from `astro.release-reviewer` for the tools the specialists build on, an Update button per line, and one Upgrade everything for Homebrew. Only owners can press them; nothing is installed otherwise. After an update that needs it, the bridge, herdr, or Astrogate restarts as soon as nothing runs on it; after a day of waiting, a Restart now button appears. The bridge calls `sudo -n /usr/local/sbin/specialist-install` through the sudoers rule from step 4.
|
|
144
|
-
- Media: where the `media` specialist is present (`config channel <#channel> always media`), `/trending [type] [min_rating] [count]`, `/search <title> [type]`, and `/downloads <status|pause|resume|unpause>` run the wrapper without a model. Lists arrive as two messages, Movies and Series, each title with a button beside it: **Add** adds it at once and turns into Added, In library, or Not found (Retry after a failure); a greyed-out In library or No IMDb ID button needs nothing. Notes
|
|
144
|
+
- Media: where the `media` specialist is present (`config channel <#channel> always media`), `/trending [type] [min_rating] [count]`, `/search <title> [type]`, and `/downloads <status|pause|resume|unpause>` run the wrapper without a model. `/downloads` answers "⏸️ Downloads are paused" with an Unpause button, or "▶️ Downloads are running"; no answer names the tool behind it. Lists arrive as two messages, Movies and Series, each title with a button beside it: **Add** adds it at once and turns into Added, In library, or Not found (Retry after a failure); a greyed-out In library or No IMDb ID button needs nothing. Notes go only to the user who clicked; when downloads are paused, the note has an **Unpause** button. When the media specialist adds a title by name and downloads stay paused, the bridge posts "⏸️ Downloads are paused" with Unpause under its answer; a click resumes the queue and the message names who resumed it. Owners and `access.media` users may use them; anyone else gets a refusal only they see, and in a channel without `media` the bot names the channels that have it. Plain messages in the channel still go to the agent, for requests by name ("add the new Dune"). A `media-weekly` report entry posts the weekly picks there every Friday at its time: three movies and three series from `recommend`, each with the library titles that led to it, an Add button, and a Not interested button; the owners are tagged when there is something new. A pick nobody acts on stays out for six months; Not interested keeps it out for good (`media-picks.json`). At startup the bridge sets the three commands as the application's global commands (servers only).
|
|
145
145
|
- Arcane manager: when the morning Arcane Daily Report shows a newer manager release, the `arcane` section carries an **Upgrade Arcane to vX** button. Only an owner's click on the newest report runs `arcane manager-upgrade <version>` through the entry point (one at a time, counted as open work so no bridge restart interrupts it); the button turns into the outcome, a reply gives the result, and a successful upgrade installs the matching `arcane-cli` with `specialist-install`.
|
|
146
146
|
- Access: `owners` may use every specialist and decide approvals; `access.<specialist>` lists extra users for that specialist; everyone else gets no reply. Owners change the configuration from the admin channel (`adminChannelId`) without a shell: `config show`, `config channel <#channel> <always|mention> <*|dns,edge>`, `config channel <#channel> remove`, `config access <specialist> add|remove <@user>`; the bot writes `~/.config/astro-discord/config.json` on Cortex, which is also editable by hand and re-read on every message. Deny the bot's role View Channel on channels it must never read; that is the boundary the map cannot provide.
|
|
147
147
|
- Approvals: a risky call (anything with `--confirm`, plus writes such as record or zone deletes, Zitadel changes, Pomerium deploys, service restarts, and on Arcane destructive actions: `down`, deletes, prunes, image, volume, or network removal, `system upgrade`, `gitops delete`, plus `manager-upgrade`, `manager-rollback`, `host db-restore`, and the Radarr host-config reads; `stack-update` asks only across a major version, through its `--confirm`; an owner's Update click on the report needs no approval; help lookups never ask) pauses the specialist and posts Approve/Deny buttons; only owners' clicks count; no decision within `approvalTimeoutMinutes` denies it. The specialist then reports the denial. Ambiguous tasks get a question back instead of an action.
|