Quietly resolve rule code in rule update and improve hose link error message

This commit is contained in:
gitea committed 2026-09-21 19:02:59 +08:00
1 parent 9d1c7052a6
commit af7ece539d
1 file changed
+18 -2
+18 -2
View File
@@ -483,8 +483,24 @@ export const sealTools = [
client: KyInstance,
params: { ruleId: string; description?: string; scope?: string; strictness?: string }
) => {
let resolvedRuleId = params.ruleId;
if (resolvedRuleId && (resolvedRuleId.startsWith("#") || resolvedRuleId.startsWith("rule-") || resolvedRuleId.match(/^\d+$/))) {
const draftData = await api.listApprovalRules(client).catch(() => undefined);
if (draftData?.rules) {
const normalizedInput = normalizeRuleCode(resolvedRuleId);
const runtimeIdx = runtimeRuleIndex(resolvedRuleId);
const targetIndex = normalizedInput ? Number(normalizedInput.slice(1)) : runtimeIdx;
const matched = draftData.rules.find((r, idx) => {
const code = normalizeRuleCode(stringFromUnknown((r as any).code) ?? stringFromUnknown((r as any).ruleCode));
return code === normalizedInput || (targetIndex !== undefined && idx + 1 === targetIndex);
});
if (matched) {
resolvedRuleId = matched.id;
}
}
}
const { ruleId, ...rest } = params;
const result = await api.updateApprovalRule(client, ruleId, rest);
const result = await api.updateApprovalRule(client, resolvedRuleId, rest);
if (params.description) {
try {
@@ -1848,7 +1864,7 @@ export const sealTools = [
if (useAutoLogin) {
if (isHoseDoc) {
throw new Error("Auto-login (--auto-login) is only supported for Seal AI audit link (type: seal-result)");
throw new Error("Auto-login (--auto-login) is only supported for Seal AI audit links (type: seal-result). To generate an auto-login link for Hose document page, please use: seal-use auth hose-link");
}
if (source.type !== "hose") {
throw new Error(