docs: 更新 AGENTS/README 平台架构说明与月度总结,运行日志视图支持已取消状态

This commit is contained in:
2026-10-31 17:55:25 +08:00
parent 62de24eb4d
commit 85051f979b
201 changed files with 11049 additions and 7398 deletions
+13 -7
View File
@@ -113,7 +113,8 @@ function terminateRun(runId) {
};
finishRun(runId, info, "cancelled", "用户取消了排队任务", "");
try {
licensing.report(dropped.account || rec.account || "", "", info.id, info.version, "error", "用户取消了排队任务", 0);
// 用户取消不是失败:上报 cancelled(中心统计只把 error/failed 计入失败,cancelled 不进成功率分母)
licensing.report(dropped.account || rec.account || "", "", info.id, info.version, "cancelled", "用户取消了排队任务", 0);
} catch (e) {
logger.warning(`取消排队任务上报失败:${e.message}`);
}
@@ -410,9 +411,11 @@ async function executeQueued(item) {
};
const r = await scheduler.requestStart(account, plugin.id, plugin.version || "0", startFn);
if (!r.ok) {
const err = isUserStopped(runId) ? "用户手动强制停止" : r.error;
if (isUserStopped(runId)) _USER_STOPPED.delete(runId);
finishRun(runId, plugin, "error", err, "");
// 用户点了强制停止(子进程还没真正拉起):按「已取消」收尾,不记失败
const stopped = isUserStopped(runId);
if (stopped) _USER_STOPPED.delete(runId);
finishRun(runId, plugin, stopped ? "cancelled" : "error",
stopped ? "用户手动强制停止" : r.error, "");
return;
}
// 真正开始执行:此刻才写 started(排队时长不计入运行耗时)并广播 run_start
@@ -568,7 +571,8 @@ function startChild(plugin, fields, runId, account) {
status = "error";
error = spawnErr;
} else if (isUserStopped(runId)) {
status = "error";
// 用户主动强制停止:不是失败,落「已取消」(error 保留原因,历史仍可回看这次运行)
status = "cancelled";
error = "用户手动强制停止";
} else if (timedOut) {
status = "error";
@@ -623,7 +627,8 @@ function reportRun(plugin, runId) {
try {
const run = state.RUNS.get(runId) || {};
const account = run.account || "";
const status = run.status === "done" ? "done" : run.status === "running" ? "running" : "error";
// 状态原样上报:done / cancelled / error(中心只把 error/failed 计入失败,取消不进成功率分母)
const status = ["done", "cancelled", "running"].includes(run.status) ? run.status : "error";
const msg = run.error || "";
const duration = run.started ? Math.floor(Date.now() / 1000 - run.started) : 0;
licensing.report(account, "", plugin.id, run.version || "", status, msg, duration);
@@ -641,7 +646,8 @@ function onQueueExpire(item) {
const info = { id: item.plugin_id, name: item.name || item.plugin_id, version: item.version || "0" };
finishRun(item.run_id, info, "cancelled", reason, "");
try {
licensing.report(item.account || "", "", item.plugin_id || "", item.version || "", "error", reason, 0);
// 排队超时是系统自动取消,同样不算失败
licensing.report(item.account || "", "", item.plugin_id || "", item.version || "", "cancelled", reason, 0);
} catch (e) {
logger.warning(`排队超时上报失败:${e.message}`);
}
+2 -1
View File
@@ -431,7 +431,8 @@ function watchRun(scheduleId, runId) {
if (timer) clearTimeout(timer);
const target = _schedules.find((x) => x.id === scheduleId);
if (!target) return; // 任务已被删除
target.last_status = ev.ok ? "ok" : "error";
// 用户强制停止 / 排队取消记为 cancelled:计划视图显示「已取消」,不混进失败
target.last_status = ev.ok ? "ok" : (ev.status === "cancelled" ? "cancelled" : "error");
target.last_duration = parseInt(ev.duration_sec, 10) || 0;
target.last_error = ev.ok ? "" : ev.error || "";
persist();