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
@@ -75,7 +75,7 @@ const safe = (s: string | null | undefined, n = 1500) => clip(redactString(s ??
|
||||
*/
|
||||
export class AwaitSuspendedError extends CapabilityError {
|
||||
constructor() {
|
||||
super("precondition", "会话已挂起等待子会话结束,恢复后重放本调用");
|
||||
super("precondition", "会话已挂起等待子会话结束,恢复后重放本调用");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ export async function cascadeCancel(ctx: ServerContext, runId: string, reason: s
|
||||
.updateTable("agent_run")
|
||||
.set({
|
||||
cancel_requested_at: now,
|
||||
error: JSON.stringify({ abortReason: `父会话已取消:${reason}`, by: `agent:${runId}` }),
|
||||
error: JSON.stringify({ abortReason: `父会话已取消:${reason}`, by: `agent:${runId}` }),
|
||||
})
|
||||
.where("id", "in", ids)
|
||||
.where("cancel_requested_at", "is", null)
|
||||
@@ -330,7 +330,7 @@ export async function cascadeCancel(ctx: ServerContext, runId: string, reason: s
|
||||
if (taskIds.length)
|
||||
await ctx.db
|
||||
.updateTable("task")
|
||||
.set({ cancel_requested_at: now, cancel_reason: `父会话已取消:${reason}` })
|
||||
.set({ cancel_requested_at: now, cancel_reason: `父会话已取消:${reason}` })
|
||||
.where("id", "in", taskIds)
|
||||
.where("cancel_requested_at", "is", null)
|
||||
.execute();
|
||||
@@ -489,7 +489,7 @@ export async function allocateBudget(
|
||||
if (want !== undefined) out[k] = want;
|
||||
return;
|
||||
}
|
||||
if (left < min) throw new CapabilityError("budget", `本会话剩余${label}不足,不能再派生子会话(剩余 ${left})`);
|
||||
if (left < min) throw new CapabilityError("budget", `本会话剩余${label}不足,不能再派生子会话(剩余 ${left})`);
|
||||
if (want !== undefined && want > left)
|
||||
throw new CapabilityError("budget", `子会话${label} ${want} 超过本会话剩余预算 ${left}`);
|
||||
const v = want ?? (k === "maxCostUsd" ? left / 2 : Math.max(min, Math.floor(left / 2)));
|
||||
@@ -498,7 +498,7 @@ export async function allocateBudget(
|
||||
pick("maxToolCalls", remain.maxToolCalls, "工具调用次数", 1);
|
||||
pick("maxTokens", remain.maxTokens, " token", 1);
|
||||
pick("maxCostUsd", remain.maxCostUsd, "费用", 0.0001);
|
||||
pick("maxDurationSec", remain.maxDurationSec, "时长(秒)", 5);
|
||||
pick("maxDurationSec", remain.maxDurationSec, "时长(秒)", 5);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -528,10 +528,10 @@ export function spawnScope(
|
||||
const kindOf = (id: string) => CAPABILITY_CATALOG[id as KnownCapabilityId]?.kind;
|
||||
if (requested?.length) {
|
||||
const outside = requested.filter((id) => !parentCaps.includes(id));
|
||||
if (outside.length) throw new CapabilityError("unauthorized", `子会话能力超出本会话白名单:${outside.join(", ")}`);
|
||||
if (outside.length) throw new CapabilityError("unauthorized", `子会话能力超出本会话白名单:${outside.join(", ")}`);
|
||||
const tooStrong = requested.filter((id) => !kinds.includes(kindOf(id) as CapabilityKind));
|
||||
if (tooStrong.length)
|
||||
throw new CapabilityError("unauthorized", `子会话模式/授权上限不允许这些能力:${tooStrong.join(", ")}`);
|
||||
throw new CapabilityError("unauthorized", `子会话模式/授权上限不允许这些能力:${tooStrong.join(", ")}`);
|
||||
}
|
||||
const caps = (requested?.length ? [...new Set(requested)] : parentCaps).filter((id) =>
|
||||
kinds.includes(kindOf(id) as CapabilityKind),
|
||||
@@ -587,7 +587,7 @@ export async function awaitChildren(
|
||||
const rows = await q.orderBy("created_at").execute();
|
||||
if (ids?.length && rows.length !== new Set(ids).size) {
|
||||
const missing = ids.filter((id) => !rows.some((r) => r.id === id));
|
||||
throw new CapabilityError("not_found", `不是本会话派生的子会话:${missing.join(", ")}`);
|
||||
throw new CapabilityError("not_found", `不是本会话派生的子会话:${missing.join(", ")}`);
|
||||
}
|
||||
await liveRun(parentId)?.pump();
|
||||
const allDone = rows.every((r) => SETTLED.includes(r.status));
|
||||
@@ -644,7 +644,7 @@ export async function wakeParent(ctx: ServerContext, childRunId: string): Promis
|
||||
await ctx.engine.signal(w.engineRunId, w.fact, { childRunId });
|
||||
return true;
|
||||
} catch (err) {
|
||||
ctx.logger.warn({ childRunId, err: { message: (err as Error).message } }, "唤醒父会话失败(父会话会兜底轮询)");
|
||||
ctx.logger.warn({ childRunId, err: { message: (err as Error).message } }, "唤醒父会话失败(父会话会兜底轮询)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -662,7 +662,7 @@ export async function wakeRun(
|
||||
await ctx.engine.signal(w.engineRunId, w.fact, payload);
|
||||
return true;
|
||||
} catch (err) {
|
||||
ctx.logger.warn({ runId, err: { message: (err as Error).message } }, "唤醒会话失败(会话会兜底轮询)");
|
||||
ctx.logger.warn({ runId, err: { message: (err as Error).message } }, "唤醒会话失败(会话会兜底轮询)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -719,9 +719,9 @@ export function registerSubagentCapabilities(registry: CapabilityRegistry, ctx:
|
||||
const parent = await parentOf(ctx, c);
|
||||
const s = await ctx.settings.all();
|
||||
const cfg = subagentSettings(s);
|
||||
if (!cfg.enabled) throw new CapabilityError("precondition", "子会话未开启(设置 → Agent → 允许子会话)");
|
||||
if (!cfg.enabled) throw new CapabilityError("precondition", "子会话未开启(设置 → Agent → 允许子会话)");
|
||||
if (parent.cancel_requested_at || TERMINAL.includes(parent.status))
|
||||
throw new CapabilityError("precondition", "本会话已取消或已结束,不能派生子会话");
|
||||
throw new CapabilityError("precondition", "本会话已取消或已结束,不能派生子会话");
|
||||
const dedupeKey = `subagent:${c.idempotencyKey ?? `${parent.id}:${Date.now()}`}`;
|
||||
const existing = await ctx.db
|
||||
.selectFrom("agent_run")
|
||||
@@ -731,7 +731,7 @@ export function registerSubagentCapabilities(registry: CapabilityRegistry, ctx:
|
||||
let child = existing;
|
||||
if (!child) {
|
||||
if (parent.depth + 1 > cfg.maxDepth)
|
||||
throw new CapabilityError("precondition", `派生层数已达上限 ${cfg.maxDepth},子会话不能再派生`);
|
||||
throw new CapabilityError("precondition", `派生层数已达上限 ${cfg.maxDepth},子会话不能再派生`);
|
||||
const mode: AgentRunMode = input.mode ?? parent.mode;
|
||||
if (parent.mode === "plan_only" && mode === "execute")
|
||||
throw new CapabilityError("unauthorized", "只给方案的会话只能派生只给方案的子会话");
|
||||
@@ -812,7 +812,7 @@ export async function exceedsAncestors(
|
||||
for (const a of chain) {
|
||||
const sc = (a.scope ?? {}) as Partial<RunScope>;
|
||||
if (sc.capabilities?.length && !sc.capabilities.includes(capabilityId))
|
||||
return `超出父会话 ${a.id} 的能力白名单:${capabilityId}`;
|
||||
return `超出父会话 ${a.id} 的能力白名单:${capabilityId}`;
|
||||
if (sc.allowedKinds && !sc.allowedKinds.includes(kind)) return `父会话 ${a.id} 不允许 ${kind} 类能力`;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user