style(copy): fix remaining punctuation violations and make check:copy strict
Auto-fix of 602 string literals across 74 files (half-width punctuation next to Chinese, parenthesised Chinese, quotes); biome reflow; e2/e6 assertions follow the new full-width summaries. check:copy now runs with --strict in ci. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
0fccfe257d
commit
fb84a71f80
76 files changed
+582
-570
No files matched your search
@@ -33,7 +33,7 @@ export function registerBrowserCapabilities(registry: CapabilityRegistry, svc: (
|
||||
const resolveSession = async (input: { sessionId?: string | undefined; siteId?: string | undefined }) => {
|
||||
if (input.sessionId) return input.sessionId;
|
||||
const row = input.siteId ? await svc().liveSessionFor(input.siteId) : undefined;
|
||||
if (!row) throw new BrowserServiceError("not_found", "该站点没有浏览器会话,先用 browser.navigate 打开页面");
|
||||
if (!row) throw new BrowserServiceError("not_found", "该站点没有浏览器会话,先用 browser.navigate 打开页面");
|
||||
return row.id;
|
||||
};
|
||||
|
||||
@@ -176,12 +176,12 @@ export function registerBrowserCapabilities(registry: CapabilityRegistry, svc: (
|
||||
sourceReleaseId: v.sourceReleaseId,
|
||||
duplicate: !!v.duplicate,
|
||||
note: v.duplicate
|
||||
? "同一会话已捕获过这个文件;先查已有下载计划,不要重复提交"
|
||||
? "同一会话已捕获过这个文件;先查已有下载计划,不要重复提交"
|
||||
: !v.verification.valid
|
||||
? "不是有效的种子文件"
|
||||
: v.sourceReleaseId
|
||||
? "已暂存核验;用 download.plan 提交这个 sourceReleaseId"
|
||||
: "资源不在本地索引;先 release.search 该站点后再提交",
|
||||
? "已暂存核验;用 download.plan 提交这个 sourceReleaseId"
|
||||
: "资源不在本地索引;先 release.search 该站点后再提交",
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -244,20 +244,20 @@ export function registerBrowserRoutes(app: ModuleApp, svc: () => BrowserService)
|
||||
const v = await svc().verifyDownload(params.id, artifact);
|
||||
let submission: ManualAcquisitionResult | null = null;
|
||||
let note: string | null = null;
|
||||
if (v.duplicate) note = "同一会话已捕获过这个文件,未重复提交";
|
||||
else if (!v.verification.valid) note = "不是有效的种子文件,未提交";
|
||||
else if (!v.sourceReleaseId) note = "资源不在本地索引(先快照或搜索该站点),未提交";
|
||||
if (v.duplicate) note = "同一会话已捕获过这个文件,未重复提交";
|
||||
else if (!v.verification.valid) note = "不是有效的种子文件,未提交";
|
||||
else if (!v.sourceReleaseId) note = "资源不在本地索引(先快照或搜索该站点),未提交";
|
||||
else if (body.submit) {
|
||||
try {
|
||||
submission = await dispatch.call<ManualAcquisitionResult>(c, "POST", "/acquisition-plans", {
|
||||
...body.submit,
|
||||
sourceReleaseId: v.sourceReleaseId,
|
||||
});
|
||||
if (!submission.submitted) note = "提交未生成下载计划,见 rejected";
|
||||
if (!submission.submitted) note = "提交未生成下载计划,见 rejected";
|
||||
} catch (e) {
|
||||
// 与 POST /acquisition-plans 相同的拒绝(未识别、无授权等):产物已暂存,结果照常返回
|
||||
if (!(e instanceof ApiException) || e.code === "internal") throw e;
|
||||
note = `提交未通过:${e.message}`;
|
||||
note = `提交未通过:${e.message}`;
|
||||
}
|
||||
}
|
||||
await svc().recordDownload(params.id, {
|
||||
|
||||
@@ -86,7 +86,7 @@ export function fromBrowserError(e: unknown): unknown {
|
||||
case "rate_limited":
|
||||
return new BrowserServiceError("rate_limited", e.message);
|
||||
default:
|
||||
return new BrowserServiceError("upstream", `浏览器服务不可用:${e.message}`);
|
||||
return new BrowserServiceError("upstream", `浏览器服务不可用:${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,8 @@ export class BrowserService {
|
||||
.where("kind", "<>", "none");
|
||||
if (id) q = q.where("id", "=", id);
|
||||
const row = await q.orderBy("created_at").executeTakeFirst();
|
||||
if (!row) throw new BrowserServiceError("precondition", "没有启用的浏览器服务(camofox),见 docs/runbook/browser.md");
|
||||
if (!row)
|
||||
throw new BrowserServiceError("precondition", "没有启用的浏览器服务(camofox),见 docs/runbook/browser.md");
|
||||
return row;
|
||||
}
|
||||
|
||||
@@ -329,13 +330,13 @@ export class BrowserService {
|
||||
.executeTakeFirst();
|
||||
if (!prow?.enabled) {
|
||||
await this.closeRow(row, "provider_disabled");
|
||||
throw new BrowserServiceError("precondition", "浏览器服务已停用,会话已关闭");
|
||||
throw new BrowserServiceError("precondition", "浏览器服务已停用,会话已关闭");
|
||||
}
|
||||
const site = await this.liveSite(row.site_id).catch(() => null);
|
||||
if (!site?.enabled) {
|
||||
// 站点关闭即停止其网络访问(REQ §4.6、§4.7.3)
|
||||
await this.closeRow(row, "site_disabled", prow);
|
||||
throw new BrowserServiceError("precondition", "站点已停用,浏览器会话已关闭");
|
||||
throw new BrowserServiceError("precondition", "站点已停用,浏览器会话已关闭");
|
||||
}
|
||||
const provider = this.providerFor(prow);
|
||||
if (!provider.sessionInfo(row.id)) {
|
||||
@@ -611,8 +612,8 @@ export class BrowserService {
|
||||
kind: "other",
|
||||
status: "awaiting_user",
|
||||
severity: "warning",
|
||||
title: `${site?.name ?? "站点"}:原站需要人工处理`,
|
||||
summary: `${REASON_TEXT[reason] ?? reason}。在站点详情的原站视图接管会话,完成后交还。`,
|
||||
title: `${site?.name ?? "站点"}:原站需要人工处理`,
|
||||
summary: `${REASON_TEXT[reason] ?? reason}。在站点详情的原站视图接管会话,完成后交还。`,
|
||||
subject_type: "browser_session",
|
||||
subject_id: row.id,
|
||||
dedupe_key: `browser.waiting:${row.id}`,
|
||||
@@ -783,8 +784,8 @@ export class BrowserService {
|
||||
throw new BrowserServiceError(
|
||||
"conflict",
|
||||
row.controller === "human"
|
||||
? "会话正由人工接管,自动化动作已停止"
|
||||
: `会话在等待人工处理(${REASON_TEXT[rs.waitingReason ?? ""] ?? rs.waitingReason ?? "未知原因"}),自动化动作已停止`,
|
||||
? "会话正由人工接管,自动化动作已停止"
|
||||
: `会话在等待人工处理(${REASON_TEXT[rs.waitingReason ?? ""] ?? rs.waitingReason ?? "未知原因"}),自动化动作已停止`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -803,7 +804,7 @@ export class BrowserService {
|
||||
if (e instanceof BrowserError && e.kind === "not_found" && e.httpStatus === 404) {
|
||||
const r = await loaded.provider.reconcileTabs(id).catch(() => null);
|
||||
await this.persist(id, loaded.provider, { needsSnapshot: true });
|
||||
if (r?.lost.length) throw new BrowserServiceError("conflict", "标签页已被浏览器服务回收,重新打开页面");
|
||||
if (r?.lost.length) throw new BrowserServiceError("conflict", "标签页已被浏览器服务回收,重新打开页面");
|
||||
}
|
||||
await this.persist(id, loaded.provider).catch(() => {});
|
||||
throw fromBrowserError(e);
|
||||
|
||||
Reference in new issue
Block a user