feat(app): background collection frame for sites, search words and RSS feeds

Targets (none by default), interval and keep days on a new 백그라운드 수집 screen with the
results; the worker collects on its own thread through the web search's address check and
writes only to the data folder's collect/ (logs carry target names and counts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 21:29:49 +09:00
parent d531eb0ffc
commit b94e9dc112
15 changed files with 861 additions and 14 deletions

View File

@@ -123,6 +123,8 @@ function editor(f, value) {
return chatChannelsEditor(f, value);
case "mcpServers":
return mcpServersEditor(f, value);
case "collectTargets":
return collectTargetsEditor(f, value);
default:
el = h("span", { class: "muted" }, JSON.stringify(value));
read = () => value;
@@ -243,6 +245,67 @@ function mcpServersEditor(f, value) {
list, h("button", { class: "btn", onclick: () => addServer() }, "서버 추가")), read, wide: true };
}
// The background collection targets: one row each (admin.spec.md, "Background collection").
const KIND = { site: "사이트", search: "검색어", rss: "RSS" };
function collectTargetsEditor(f, value) {
const body = h("tbody");
const addRow = (t = {}) => {
const kind = h("select", { "data-k": "kind" },
Object.entries(KIND).map(([k, label]) => h("option", { value: k, selected: (t.kind ?? "site") === k }, label)));
const val = h("input", { type: "text", value: t.value ?? "", "data-k": "value" });
const hint = () => (val.placeholder = kind.value === "search" ? "검색어" : "https:// 주소");
kind.addEventListener("change", hint);
hint();
const on = h("input", { type: "checkbox", "data-k": "enabled" });
on.checked = t.enabled ?? true;
const tr = h("tr", {},
h("td", {}, h("input", { type: "text", value: t.name ?? "", placeholder: "이름 (글자, 숫자, - _)", "data-k": "name" })),
h("td", {}, kind), h("td", {}, val),
h("td", {}, h("input", { type: "number", min: 15, max: 10080, value: t.everyMinutes ?? 60, "data-k": "everyMinutes" })),
h("td", {}, on),
h("td", {}, h("button", { class: "btn", onclick: () => tr.remove() }, "삭제")));
body.append(tr);
};
(value || []).forEach(addRow);
const read = () => [...body.rows].map((tr) => {
const k = (key) => tr.querySelector(`[data-k="${key}"]`);
const every = Number(k("everyMinutes").value);
if (!Number.isInteger(every)) throw new Error(`${f.label}: 주기는 분 단위 정수`);
return { name: k("name").value.trim(), kind: k("kind").value, value: k("value").value.trim(),
everyMinutes: every, enabled: k("enabled").checked };
});
const table = h("table", {}, h("thead", {}, h("tr", {}, ["이름", "종류", "주소 또는 검색어", "주기(분)", "켜기", ""]
.map((x) => h("th", {}, x)))), body);
return { el: h("div", {}, h("div", { class: "hint" }, "기본 수집 대상은 없습니다. 모은 내용은 데이터 폴더의 collect 폴더에만 저장됩니다."),
table, h("button", { class: "btn", onclick: () => addRow() }, "대상 추가")), read, wide: true };
}
/** The newest collected items, filtered by target; web content, so shown only as plain text. */
async function collectResults() {
const pick = h("select", {}, h("option", { value: "" }, "모든 대상"));
const list = h("div");
const load = async () => {
try {
const items = await api("collect_results", { target: pick.value || null, limit: 100 });
if (!pick.value) {
for (const name of new Set(items.map((i) => i.target)))
if (![...pick.options].some((o) => o.value === name)) pick.append(h("option", { value: name }, name));
}
list.replaceChildren(items.length ? h("table", {}, h("tbody", {}, items.map((i) => h("tr", {},
h("td", { class: "small muted" }, (i.at || "").replace("T", " ").slice(0, 16)),
h("td", { class: "small" }, i.target),
h("td", {}, h("div", {}, i.title || i.url || ""),
i.url ? h("div", { class: "small muted" }, i.url) : null,
i.text ? h("div", { class: "small" }, i.text.length > 200 ? i.text.slice(0, 200) + "…" : i.text) : null)))))
: h("div", { class: "muted" }, "아직 모은 내용이 없습니다."));
} catch (e) { fail(e); }
};
pick.addEventListener("change", load);
load();
return h("div", { class: "card" }, h("h2", {}, "수집 결과"),
h("div", { class: "field" }, h("label", {}, "대상"), pick, h("button", { class: "btn", onclick: load }, "새로 고침")), list);
}
async function settingsScreen(screen, title, extra) {
const [all, view] = await Promise.all([fields(), api("settings_view")]);
const list = all.filter((f) => f.screen === screen);
@@ -476,9 +539,11 @@ async function show(name) {
try {
if (name === "dashboard") { screen.replaceChildren(); await refresh(); ticker = setInterval(refresh, 1000); return; }
if (name === "logs") { const l = logsScreen(); screen.replaceChildren(l.view); ticker = setInterval(l.tick, 1000); return; }
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능" };
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능",
collect: "백그라운드 수집" };
const extra = name === "bot" ? await tokenCard() : null;
const view = await settingsScreen(name, titles[name], extra);
if (name === "collect") view.append(await collectResults());
if (my === gen) screen.replaceChildren(view);
} catch (e) { fail(e); }
}

View File

@@ -18,6 +18,7 @@
<button data-screen="memory" class="nav">대화 기억</button>
<button data-screen="model" class="nav">모델</button>
<button data-screen="features" class="nav">기능</button>
<button data-screen="collect" class="nav">백그라운드 수집</button>
<button data-screen="logs" class="nav">로그</button>
<div class="side-foot" id="version"></div>
</nav>