feat: 增强 Sub2API 运维最短路径
This commit is contained in:
@@ -527,12 +527,16 @@ function renderRuntimeAccountList(lines: string[], runtime: Record<string, unkno
|
||||
const group = runtimeRecord(runtime.group) ?? {};
|
||||
const accounts = runtimeRecords(runtime.accounts);
|
||||
lines.push(`SUB2API RUNTIME ACCOUNTS ok=${runtime.ok === true ? "true" : "false"} group=${runtimeText(group.name)} count=${accounts.length}`);
|
||||
const recent = runtimeRecord(runtime.recentFilter);
|
||||
if (recent !== null) {
|
||||
lines.push(`RECENT window=${runtimeText(recent.window)} cutoff=${runtimeText(recent.cutoff)} matched=${runtimeText(recent.matchedCount)} total=${runtimeText(runtime.totalAccountCount)} unknownCreatedAt=${runtimeText(recent.unknownCreatedAtCount)}`);
|
||||
}
|
||||
lines.push(renderTable([
|
||||
["NAME", "ID", "MANAGEMENT", "STATUS", "SCHED", "CONCURRENCY", "LOAD", "PRIORITY", "TEMP_RULES", "TEMPLATE"],
|
||||
["NAME", "ID", "CREATED", "MANAGEMENT", "STATUS", "SCHED", "CONCURRENCY", "LOAD", "PRIORITY", "TEMP_RULES", "TEMPLATE"],
|
||||
...accounts.map((account) => {
|
||||
const temp = runtimeRecord(account.tempUnschedulable) ?? {};
|
||||
return [
|
||||
runtimeShort(account.accountName, 36), runtimeText(account.accountId), runtimeText(account.management), runtimeText(account.status),
|
||||
runtimeShort(account.accountName, 36), runtimeText(account.accountId), runtimeTimestamp(account.createdAt), runtimeText(account.management), runtimeText(account.status),
|
||||
runtimeText(account.schedulable), `${runtimeText(account.currentConcurrency)}/${runtimeText(account.concurrencyLimit)}`,
|
||||
runtimeText(account.loadFactor), runtimeText(account.priority), runtimeText(temp.ruleCount), runtimeText(account.matchingTemplate),
|
||||
];
|
||||
@@ -541,6 +545,13 @@ function renderRuntimeAccountList(lines: string[], runtime: Record<string, unkno
|
||||
lines.push("", "Detail: bun scripts/cli.ts platform-infra sub2api codex-pool runtime get --account <name-or-id>");
|
||||
}
|
||||
|
||||
function runtimeTimestamp(value: unknown): string {
|
||||
if (typeof value !== "string" || value.trim().length === 0) return "unknown";
|
||||
const parsed = Date.parse(value);
|
||||
if (!Number.isFinite(parsed)) return value;
|
||||
return new Date(parsed).toISOString().replace("T", " ").replace(/\.\d{3}Z$/u, "Z");
|
||||
}
|
||||
|
||||
function renderRuntimeAccountDetail(lines: string[], runtime: Record<string, unknown>): void {
|
||||
const account = runtimeRecord(runtime.account) ?? {};
|
||||
const temp = runtimeRecord(account.tempUnschedulable) ?? {};
|
||||
|
||||
Reference in New Issue
Block a user