feat(engine): 实现同步引擎与 engine_status 快照

apps/engine 独立进程(syncRound + 防重叠调度);上游 log/token;QPU 采样;
server 读 engine_status;时刻出参 toUnixSec;中文日志;zod-openapi 扩展顺序修复。
This commit is contained in:
2026-10-07 12:54:13 +08:00
parent 3e12db1706
commit d47cb5543c
28 changed files with 676 additions and 102 deletions
+20
View File
@@ -62,3 +62,23 @@ export function addUsage(a: UsageSum, b: UsageSum): UsageSum {
quota_usd: a.quota_usd,
};
}
/** 解析日志行 other JSON(billing_source / subscription_id) */
export function parseOtherJson(other: string | undefined | null): {
billing_source: string | null;
subscription_id: number | null;
raw: Record<string, unknown> | null;
} {
if (!other) return { billing_source: null, subscription_id: null, raw: null };
try {
const o = JSON.parse(other) as Record<string, unknown>;
return {
billing_source: typeof o.billing_source === "string" ? o.billing_source : null,
subscription_id:
typeof o.subscription_id === "number" ? o.subscription_id : null,
raw: o,
};
} catch {
return { billing_source: null, subscription_id: null, raw: null };
}
}