Files
UHD_Media_Tool/apps/server/src/modules/search/actions.ts
T
rootandClaude Opus 5.5 1c1a954703 feat(整理): 问题在整理记录就地处理,识别失败自动叫智能体识别
- 整理记录「需要处理」:列表 attention 筛选与统计同口径(没被后来的整理取代,且有未关闭事项或失败 / 部分完成未忽略),
  记录带 attention(原因类别、精简事项、能否让智能体识别);忽略端点记 attention_cleared_at(迁移 0078)并关闭关联事项
- 识别失败(organize_identity)按 agent.autoIdentifyOrganize 自动派一次识别会话;新能力 organize.assign_identity
  指定作品后复用人工指定的钩子路径自动重新整理,只放行本事项的识别会话与用户对话;整理记录里可手动「让智能体识别」
- GET /attention:整理需要处理条数、等你批准的智能体操作、系统健康问题(铃铛 / 首页 / 运行状态共用)
- 原因码文案不再指向待处理;命令面板「待处理」换成「需要处理的整理记录」

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
2026-10-06 16:47:18 +08:00

72 lines
3.7 KiB
TypeScript

import type { SearchAction } from "@umt/contracts";
// 页面与操作跳转(命令面板静态清单),按 IA-2 导航:概览 / 获取 / 整理 / 系统(任务归系统;RSS 在站点详情里)。
// href 是控制台内路径;action 类带查询参数,由前端页面识别后打开对应表单。
const page = (id: string, group: string, title: string, href: string, keywords: string[] = []): SearchAction => ({
id: `page.${id}`,
kind: "page",
group,
title,
href,
keywords,
});
const action = (id: string, group: string, title: string, href: string, keywords: string[] = []): SearchAction => ({
id: `action.${id}`,
kind: "action",
group,
title,
href,
keywords,
});
export const SEARCH_ACTIONS: readonly SearchAction[] = [
page("home", "概览", "首页", "/console", ["home", "dashboard", "概览"]),
page("agent", "概览", "智能体会话", "/console/agent", ["agent", "会话"]),
page("schedules", "概览", "计划", "/console/schedules", ["schedule", "cron", "巡检", "计划", "定时任务"]),
page("sites", "获取", "站点", "/console/sites", ["site", "pt", "站点账号", "rss", "feed", "bt"]),
page("subscriptions", "获取", "订阅", "/console/subscriptions", ["subscription", "追剧"]),
page("rules", "获取", "规则", "/console/rules", ["rules", "收录策略", "policy"]),
page("downloads", "整理", "下载面板", "/console/downloads", ["download", "qb", "下载任务"]),
page("organize", "整理", "整理记录", "/console/organize", ["organize", "入库", "历史"]),
page("organize-attention", "整理", "需要处理的整理记录", "/console/organize?tab=records&attention=1", [
"inbox",
"待处理",
"识别不到",
"decision",
]),
page("files", "整理", "文件管理", "/console/files", ["files", "文件"]),
page("trash", "整理", "回收站", "/console/files/trash", ["trash", "删除"]),
page("library", "整理", "媒体库", "/console/library", ["library", "媒体库", "作品"]),
page("tasks", "系统", "任务", "/console/tasks", ["task", "运行", "历史"]),
page("settings", "系统", "设置", "/console/settings", ["settings", "配置", "tmdb", "下载器"]),
page("audit", "系统", "审计", "/console/audit", ["audit", "日志"]),
page("preferences", "系统", "偏好", "/console/preferences", ["preferences", "主题"]),
action("new-subscription", "获取", "新建订阅", "/console/subscriptions?new=1", ["subscribe", "订阅"]),
action("new-agent-run", "概览", "新建智能体会话", "/console/agent?new=1", ["agent", "委托"]),
action("add-site", "获取", "添加站点", "/console/sites?new=1", ["site", "站点", "rss", "feed", "bt"]),
// RSS 属于站点(IA-2):添加 RSS 源 = 添加「自定义 RSS 源」类型的站点
action("add-feed", "获取", "添加自定义 RSS 源", "/console/sites?new=rss_feed", ["rss", "feed"]),
action("new-schedule", "概览", "新建巡检", "/console/schedules?new=1", ["巡检", "agent_check"]),
];
/** 标题 / 关键词 / 路径包含查询词(不区分大小写);标题前缀命中排前 */
export function matchActions(q: string, limit: number): SearchAction[] {
const needle = q.trim().toLowerCase();
if (!needle) return [];
const scored: { a: SearchAction; score: number }[] = [];
for (const a of SEARCH_ACTIONS) {
const title = a.title.toLowerCase();
let score = 0;
if (title.startsWith(needle)) score = 3;
else if (title.includes(needle)) score = 2;
else if (a.keywords.some((k) => k.toLowerCase().includes(needle)) || a.href.toLowerCase().includes(needle))
score = 1;
if (score) scored.push({ a, score });
}
return scored
.sort((x, y) => y.score - x.score)
.slice(0, limit)
.map((x) => x.a);
}