feat(agent): downloader.list 能力与汇报计数规则(FIX-7)

智能体原先只能从 site.list 推断下载器,会把没看到汇报成下载器不在系统内。
新增只读能力 downloader.list(下载器与媒体服务器、连通状态、管理的任务数);
原因码表补能力错误、下载盘判定、站点登录与待处理类型,带分类前缀的码按后半段查;
汇报格式加「数量以工具返回为准」。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 23:59:51 +08:00
1 parent 68f53390f6
commit 1b22bb5131
12 files changed
+163 -9

No files matched your search

+34
View File
@@ -320,6 +320,37 @@ export const DownloadInspectOutput = z.object({
otherMatches: z.array(Id),
});
/** downloader.list(FIX-7):已配置的下载器与媒体服务器(只读本地记录,不含地址和凭证) */
export const DownloaderListInput = z.object({
includeDisabled: z.boolean().default(true),
});
const InstanceHealth = z.enum(["unknown", "healthy", "degraded", "offline"]);
export const DownloaderListOutput = z.object({
downloaders: z.array(
z.object({
id: Id,
name: z.string(),
kind: z.string(),
enabled: z.boolean(),
healthStatus: InstanceHealth,
lastSeenAt: z.string().nullable(),
version: z.string().nullable(),
/** 本工具管理、未移除的下载任务 */
tasks: z.object({ total: NonNegInt, active: NonNegInt, failed: NonNegInt }),
}),
),
mediaServers: z.array(
z.object({
id: Id,
name: z.string(),
kind: z.string(),
enabled: z.boolean(),
healthStatus: InstanceHealth,
lastSeenAt: z.string().nullable(),
}),
),
});
// ── 子代理(W7-B) ──
/** 子会话预算:缺省按父会话剩余预算的一半划拨;超过剩余预算直接拒绝 */
@@ -842,6 +873,7 @@ export const CAPABILITY_IO = {
"subscription.list": { input: SubscriptionListInput, output: SubscriptionListOutput },
"decision.list": { input: DecisionListInput, output: DecisionListOutput },
"download.inspect": { input: DownloadInspectInput, output: DownloadInspectOutput },
"downloader.list": { input: DownloaderListInput, output: DownloaderListOutput },
"agent.spawn": { input: AgentSpawnInput, output: AgentSpawnOutput },
"agent.await": { input: AgentAwaitInput, output: AgentAwaitOutput },
"site.list": { input: SiteListInput, output: SiteListOutput },
@@ -918,6 +950,8 @@ export type DecisionListInput = z.infer<typeof DecisionListInput>;
export type DecisionListOutput = z.infer<typeof DecisionListOutput>;
export type DownloadInspectInput = z.infer<typeof DownloadInspectInput>;
export type DownloadInspectOutput = z.infer<typeof DownloadInspectOutput>;
export type DownloaderListInput = z.infer<typeof DownloaderListInput>;
export type DownloaderListOutput = z.infer<typeof DownloaderListOutput>;
export type AgentSpawnInput = z.infer<typeof AgentSpawnInput>;
export type AgentSpawnOutput = z.infer<typeof AgentSpawnOutput>;
export type AgentAwaitInput = z.infer<typeof AgentAwaitInput>;
+14
View File
@@ -69,6 +69,7 @@ export const CAPABILITY_IDS = [
"subscription.list",
"decision.list",
"download.inspect",
"downloader.list",
"agent.spawn",
"agent.await",
"site.list",
@@ -329,6 +330,18 @@ export const CAPABILITY_CATALOG: Record<KnownCapabilityId, CapabilityDescriptor>
true,
false,
),
// FIX-7:智能体原先只能从站点列表推断下载器是否接入(site.list 不含下载器),汇报成"下载器不在系统内"
"downloader.list": d(
"downloader.list",
"查看下载器",
"列出已配置的下载器和媒体服务器:名称、类型、是否启用、最近一次连通状态与时间、本工具管理的下载任务数(按进行中 / 失败计)。只读本地记录,不连下载器;问下载器或媒体服务器是否接入、是否正常时先用它,某个下载任务用 download.inspect",
"read",
"DownloaderList",
"read",
"low",
true,
false,
),
// 子代理(设置 pi.subagents 开启后才提供给模型):类别 propose——只建有界子会话,不产生外部副作用,
// "先给方案"的会话也能派生(子会话同样只给方案);授权不高于父会话,由服务端校验
"agent.spawn": d(
@@ -612,6 +625,7 @@ export const CAPABILITY_ACTIVITY: Record<KnownCapabilityId, CapabilityActivity>
"subscription.list": act("查", "订阅"),
"decision.list": act("查", "待处理事项"),
"download.inspect": act("查", "下载任务", "个"),
"downloader.list": act("查", "下载器"),
"agent.spawn": act("派出", "子会话", "个"),
"agent.await": act("等", "子会话"),
"site.list": act("查", "站点"),
+31 -1
View File
@@ -48,6 +48,35 @@ const REASONS: Record<string, ReasonText> = {
not_imported_kind: { text: "这类文件不入库" },
target_root_not_managed: { text: "目标目录不是本工具管理的媒体库目录", action: "在设置 → 媒体库与目录里检查" },
download_removed: { text: "下载任务已从下载器删除" },
// FIX-7:智能体汇报与工具结果里常见的码(能力错误、下载计划的空间判定、站点登录、待处理类型)
invalid_input: { text: "参数不对" },
invalid_output: { text: "返回结果格式不对" },
unauthorized: { text: "需要你批准" },
forbidden: { text: "没有权限" },
not_found: { text: "没找到" },
precondition: { text: "前置条件不满足" },
internal: { text: "内部错误" },
volume_state_unknown: { text: "下载盘用量未知", action: "在下载面板检查下载盘" },
hard_threshold_reached: { text: "下载盘已到暂停线" },
projected_over_threshold: { text: "下完会超过下载盘暂停线" },
awaiting_resume_watermark: { text: "等下载盘降到恢复线" },
request_size_unknown: { text: "资源大小未知" },
inflight_size_unknown: { text: "在下的任务大小未知" },
budget_exceeded: { text: "超出下载额度" },
budget_unknown_size: { text: "资源大小未知,无法核对下载额度" },
no_downloader_instance: { text: "没有可用的下载器", action: "在设置 → 下载器里添加" },
download_save_path_unmapped: { text: "下载目录没有路径映射", action: "在设置 → 下载器里添加路径映射" },
site_out_of_scope: { text: "站点不在这次的范围内" },
slot_changed_or_reserved: { text: "收录版本已变化或被占用" },
auth_missing: { text: "站点没有配置 Cookie", action: "在站点账号里填写" },
auth_expired: { text: "站点登录已过期", action: "刷新站点登录" },
auth_invalid: { text: "站点登录无效", action: "检查站点账号" },
source_unreachable: { text: "站点连不上" },
download_failed: { text: "下载失败" },
download_stalled: { text: "下载无进展" },
space_insufficient: { text: "空间不足" },
unidentifiable: { text: "没识别出作品" },
user_deleted: { text: "已删除" },
};
/**
@@ -69,7 +98,8 @@ export function reasonText(raw: string | null | undefined): ReasonText | null {
...(parts[0]?.action ? { action: parts[0].action } : {}),
};
}
return REASONS[s] ?? REASONS[head] ?? null;
// 带分类前缀的码(`cache:volume_state_unknown`、`deferred:no_downloader_instance`)按冒号后的码查
return REASONS[s] ?? REASONS[head] ?? (rest ? (REASONS[rest.trim()] ?? null) : null);
}
/** 只要一句话:"没识别出作品。指定作品后重新整理";不认识的码返回 fallback */