132 lines
4.7 KiB
TypeScript
132 lines
4.7 KiB
TypeScript
import { z } from "zod";
|
||
import type { KyInstance } from "ky";
|
||
import { buildMonthlyReport, getMonthlyReportData } from "../reports/index.js";
|
||
import type { CapabilityContext } from "./helpers.js";
|
||
|
||
export const reportCapabilities = [
|
||
{
|
||
name: "sealReportMonthlyGet",
|
||
description:
|
||
"生成 AI 审核准确率报告(Markdown)。按模板结构从效能/风险/审批运行接口取数填充,返回填充后的内容与各章节数据完备度;无法从上游取得的口径(人工准确率、失准原因分类)如实标注而非编造",
|
||
parameters: z.object({
|
||
startDate: z
|
||
.string()
|
||
.optional()
|
||
.describe("统计起始日期 (YYYY-MM-DD)"),
|
||
endDate: z
|
||
.string()
|
||
.optional()
|
||
.describe("统计截止日期 (YYYY-MM-DD)"),
|
||
month: z
|
||
.string()
|
||
.regex(/^\d{4}-\d{2}$/)
|
||
.optional()
|
||
.describe("统计月份 (YYYY-MM,可选快捷方式)"),
|
||
templates: z
|
||
.array(z.string())
|
||
.optional()
|
||
.describe("单据模板白名单列表(可选,未指定则统计全量单据模板)"),
|
||
templatePath: z
|
||
.string()
|
||
.optional()
|
||
.describe("自定义模板 Markdown 路径;缺省用随 CLI 内嵌的仓内 monthly.md,不依赖当前目录"),
|
||
reportId: z.string().optional().describe("自定义报告编号(RPT-YYYYMM-XXXXXX)"),
|
||
ledgerPath: z.string().optional().describe("本地已编辑/已裁决的台账文件路径 (.xlsx 或 .csv),传入时直接以该台账为唯一事实源"),
|
||
maxRuns: z
|
||
.number()
|
||
.int()
|
||
.positive()
|
||
.max(100000)
|
||
.optional()
|
||
.describe("拉取审批运行明细分块的上限(可选,未指定时默认拉取指定时间区间内的全量单据,最大安全上限 100000)"),
|
||
allowUnreviewed: z
|
||
.boolean()
|
||
.optional()
|
||
.describe("是否跳过前置裁决门禁(当存在未裁决的分歧单时强行出具草稿,默认 false)")
|
||
}),
|
||
handler: async (
|
||
client: KyInstance,
|
||
params: {
|
||
startDate?: string;
|
||
endDate?: string;
|
||
month?: string;
|
||
templates?: string[];
|
||
ledgerPath?: string;
|
||
templatePath?: string;
|
||
reportId?: string;
|
||
maxRuns?: number;
|
||
allowUnreviewed?: boolean;
|
||
},
|
||
context: CapabilityContext
|
||
) =>
|
||
buildMonthlyReport(client, {
|
||
startDate: params.startDate,
|
||
endDate: params.endDate,
|
||
month: params.month,
|
||
templates: params.templates,
|
||
ledgerPath: params.ledgerPath,
|
||
corp: { id: context.corp.id, name: context.corp.name },
|
||
templatePath: params.templatePath,
|
||
reportId: params.reportId,
|
||
maxRuns: params.maxRuns,
|
||
allowUnreviewed: params.allowUnreviewed
|
||
})
|
||
},
|
||
{
|
||
name: "sealReportDataGet",
|
||
description:
|
||
"获取 AI 审核报告的轻量纯结构化数据包(效能指标、分模板统计、风险标签、人机分歧单据列表与单个触发条件)。不依赖 Markdown 模板,供 Agent 交互复核或填充文档",
|
||
parameters: z.object({
|
||
startDate: z
|
||
.string()
|
||
.optional()
|
||
.describe("统计起始日期 (YYYY-MM-DD)"),
|
||
endDate: z
|
||
.string()
|
||
.optional()
|
||
.describe("统计截止日期 (YYYY-MM-DD)"),
|
||
month: z
|
||
.string()
|
||
.regex(/^\d{4}-\d{2}$/)
|
||
.optional()
|
||
.describe("统计月份 (YYYY-MM,可选快捷方式)"),
|
||
templates: z
|
||
.array(z.string())
|
||
.optional()
|
||
.describe("单据模板白名单列表(可选,未指定则统计全量单据模板)"),
|
||
ledgerPath: z
|
||
.string()
|
||
.optional()
|
||
.describe("本地已编辑/已裁决的台账文件路径 (.xlsx 或 .csv),传入时直接以该台账为唯一事实源"),
|
||
maxRuns: z
|
||
.number()
|
||
.int()
|
||
.positive()
|
||
.max(100000)
|
||
.optional()
|
||
.describe("拉取审批运行明细分块的上限(可选,未指定时默认拉取指定时间区间内的全量单据,最大安全上限 100000)")
|
||
}),
|
||
handler: async (
|
||
client: KyInstance,
|
||
params: {
|
||
startDate?: string;
|
||
endDate?: string;
|
||
month?: string;
|
||
templates?: string[];
|
||
ledgerPath?: string;
|
||
maxRuns?: number;
|
||
},
|
||
context: CapabilityContext
|
||
) =>
|
||
getMonthlyReportData(client, {
|
||
startDate: params.startDate,
|
||
endDate: params.endDate,
|
||
month: params.month,
|
||
templates: params.templates,
|
||
ledgerPath: params.ledgerPath,
|
||
corp: { id: context.corp.id, name: context.corp.name },
|
||
maxRuns: params.maxRuns
|
||
})
|
||
}
|
||
];
|