Add one-shot run diagnosis and agent-feedback hardening

This commit is contained in:
gitea committed 2026-09-30 11:49:50 +08:00
1 parent 951c8fc372
commit f2738ee4a3
15 files changed
+583 -49

No files matched your search

+20
View File
@@ -211,6 +211,26 @@ export async function handleApprovalRunsCommand(
return;
}
if (action === "diagnose") {
const recordId = args.command[2];
const sn = stringOption(args.options.sn) ?? stringOption(args.options["document-sn"]);
if (!recordId && !sn) {
throw new Error("Usage: seal-use approval-runs diagnose <recordId>|--sn <documentSN> [--full] [--corp <corpId>]");
}
await runTool(
"seal_approval_run_diagnose",
client,
corp,
{
recordId,
sn,
full: booleanOption(args.options.full) === true
},
outputOptions(args.options)
);
return;
}
if (action === "attachments") {
const subAction = args.command[2];
if (subAction === "download") {
+6 -3
View File
@@ -39,11 +39,14 @@ export async function handleCorpSync(
}
if (!confirmed) {
const preview = await syncTestEnterprise(prodCorp, testCorp, { versionName, execute: false }) as {
rulesPlan: { sourceDraftRuleCount: number };
documentsPlan: { sourceDocumentCount: number };
rulesPlan: { sourceDraftRuleCount: number; targetExistingDraftRuleCount: number };
documentsPlan: { sourceDocumentCount: number; toDeleteCount: number };
};
throw confirmationRequired(
`Refusing to overwrite test enterprise '${testCorp.name}' (${testCorp.id}) with preferences, ${preview.rulesPlan.sourceDraftRuleCount} draft rules, and ${preview.documentsPlan.sourceDocumentCount} knowledge documents from production enterprise '${prodCorp.name}' (${prodCorp.id}) without --yes. This will replace test draft rules, synchronize knowledge documents, and publish a new version on the test enterprise.`,
`Refusing to sync into test enterprise '${testCorp.name}' (${testCorp.id}) without --yes. ` +
`This is DESTRUCTIVE for the test tenant: it will DELETE its ${preview.rulesPlan.targetExistingDraftRuleCount} existing draft rules and rebuild them from ${preview.rulesPlan.sourceDraftRuleCount} production draft rules, ` +
`DELETE ${preview.documentsPlan.toDeleteCount} existing knowledge documents and re-import ${preview.documentsPlan.sourceDocumentCount} documents from production, overwrite test preferences, and publish a new rules version. ` +
`Run with --dry-run first to review the exact documents that will be deleted.`,
`seal-use corps sync-test ${prodCorp.id} --yes`
);
}
+9
View File
@@ -521,6 +521,15 @@ export const HELP_REGISTRY: AreaHelp[] = [
summary: "Inspect rules cited by AI in an approval decision",
usage: ["seal-use approval-runs cited-rules <recordId> [--corp <corpId>]"]
},
{
name: "diagnose",
summary: "One-shot complaint/document diagnosis: document summary, AI decision, cited rules, rule version snapshot, and Langfuse trace pointer in a single call",
usage: ["seal-use approval-runs diagnose <recordId>|--sn <documentSN> [--full] [--corp <corpId>]"],
options: [
{ flag: "--sn <documentSN>", description: "Target the run by Hose document SN instead of record ID" },
{ flag: "--full", description: "Include the full raw AI result payload instead of the summary" }
]
},
{
name: "document-summary",
summary: "Inspect parsed source document summary",
+1
View File
@@ -44,6 +44,7 @@ const READ_ONLY_COMMANDS: Record<string, string[]> = {
"bridge",
"get",
"cited-rules",
"diagnose",
"document-summary",
"attachments",
"result",