feat: add unified OA event flow
This commit is contained in:
+12
-10
@@ -307,18 +307,16 @@ function compactAttemptCycle(value: unknown, full: boolean): Record<string, unkn
|
||||
};
|
||||
}
|
||||
|
||||
function traceStepCounts(steps: Record<string, unknown>[]): Record<string, number> {
|
||||
return steps.reduce<Record<string, number>>((counts, step) => {
|
||||
const kind = String(step.kind || "message");
|
||||
counts[kind] = (counts[kind] ?? 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function renderTraceConsoleRows(summary: Record<string, unknown>, steps: Record<string, unknown>[]): string[] {
|
||||
const rows: string[] = [];
|
||||
const execution = asRecord(summary.execution) ?? {};
|
||||
const counts = traceStepCounts(steps);
|
||||
const stats = asRecord(execution.traceStats) ?? asRecord(summary.traceStats);
|
||||
const statsSource = String(execution.statsSource || summary.statsSource || "");
|
||||
const stat = (key: string): string | number => {
|
||||
if (!stats || statsSource !== "oa-event-flow") return "--";
|
||||
const value = Number(stats[key]);
|
||||
return Number.isFinite(value) && value >= 0 ? Math.floor(value) : "--";
|
||||
};
|
||||
rows.push([
|
||||
`task=${summary.id ?? ""}`,
|
||||
`status=${summary.status ?? ""}`,
|
||||
@@ -326,7 +324,11 @@ function renderTraceConsoleRows(summary: Record<string, unknown>, steps: Record<
|
||||
`model=${summary.model ?? ""}`,
|
||||
`updated=${summary.updatedAt ?? ""}`,
|
||||
].filter((item) => !item.endsWith("=")).join(" "));
|
||||
rows.push(`progressive steps=${steps.length} tools=${execution.toolCallCount ?? 0} read=${execution.readCount ?? counts.explored ?? 0} edit=${execution.editCount ?? counts.edited ?? 0} run=${execution.runCount ?? counts.ran ?? 0} errors=${counts.error ?? 0}`);
|
||||
const read = stat("readCount");
|
||||
const edit = stat("editCount");
|
||||
const run = stat("runCount");
|
||||
const toolCount = typeof read === "number" || typeof edit === "number" || typeof run === "number" ? Number(read === "--" ? 0 : read) + Number(edit === "--" ? 0 : edit) + Number(run === "--" ? 0 : run) : "--";
|
||||
rows.push(`progressive steps=${steps.length} tools=${toolCount} read=${read} edit=${edit} run=${run} errors=${stat("errorCount")}`);
|
||||
for (const step of steps) {
|
||||
const head = [`#${step.seq ?? "?"}`, `[${step.label ?? traceKindLabel(step.kind)}]`, step.title ?? ""]
|
||||
.filter((item) => String(item).length > 0)
|
||||
|
||||
Reference in New Issue
Block a user