feat: summarize codex stream progress events

This commit is contained in:
AI Bot
2026-06-03 12:53:43 +08:00
parent bc9a586e81
commit 142fb2a4b3
11 changed files with 419 additions and 3 deletions

View File

@@ -258,6 +258,17 @@ export interface ExecutionProgressReasoningSummary {
summary: string;
}
export interface ExecutionProgressStreamEvents {
status: string;
agentDeltaCount?: number;
planDeltaCount?: number;
reasoningDeltaCount?: number;
toolProgressCount?: number;
commandOutputChunkCount?: number;
terminalInteractionCount?: number;
fileOutputChunkCount?: number;
}
export interface ExecutionProgressSnapshot {
taskId: string;
projectId: string;
@@ -291,6 +302,7 @@ export interface ExecutionProgressSnapshot {
threadCollaboration?: ExecutionProgressThreadCollaboration;
toolActivities?: ExecutionProgressToolActivity[];
reasoningSummary?: ExecutionProgressReasoningSummary;
streamEvents?: ExecutionProgressStreamEvents;
updatedAt: string;
}
@@ -335,6 +347,15 @@ export interface ExecutionProgressInput {
content?: unknown;
itemId?: unknown;
};
streamEvents?: Partial<ExecutionProgressStreamEvents> & {
delta?: unknown;
text?: unknown;
content?: unknown;
output?: unknown;
command?: unknown;
itemId?: unknown;
turnId?: unknown;
};
}
export interface ForwardSource {
@@ -4027,6 +4048,7 @@ function normalizeExecutionProgressSnapshot(raw: Partial<ExecutionProgressSnapsh
reasoningSummary: nativeRemoteControl
? undefined
: normalizeExecutionProgressReasoningSummary(raw.reasoningSummary),
streamEvents: nativeRemoteControl ? undefined : normalizeExecutionProgressStreamEvents(raw.streamEvents),
updatedAt: raw.updatedAt ?? nowIso(),
};
}
@@ -5871,6 +5893,39 @@ function normalizeExecutionProgressReasoningSummary(
};
}
function normalizeStreamEventCount(value: unknown) {
const count = normalizeOptionalNumber(value);
return count === undefined ? undefined : Math.max(0, Math.min(9999, count));
}
function normalizeExecutionProgressStreamEvents(
input?: ExecutionProgressInput["streamEvents"],
): ExecutionProgressStreamEvents | undefined {
if (!input) {
return undefined;
}
const streamEvents: ExecutionProgressStreamEvents = {
status: safeExecutionProgressText(input.status) || "streaming",
agentDeltaCount: normalizeStreamEventCount(input.agentDeltaCount),
planDeltaCount: normalizeStreamEventCount(input.planDeltaCount),
reasoningDeltaCount: normalizeStreamEventCount(input.reasoningDeltaCount),
toolProgressCount: normalizeStreamEventCount(input.toolProgressCount),
commandOutputChunkCount: normalizeStreamEventCount(input.commandOutputChunkCount),
terminalInteractionCount: normalizeStreamEventCount(input.terminalInteractionCount),
fileOutputChunkCount: normalizeStreamEventCount(input.fileOutputChunkCount),
};
const hasCount = [
streamEvents.agentDeltaCount,
streamEvents.planDeltaCount,
streamEvents.reasoningDeltaCount,
streamEvents.toolProgressCount,
streamEvents.commandOutputChunkCount,
streamEvents.terminalInteractionCount,
streamEvents.fileOutputChunkCount,
].some((count) => typeof count === "number" && count > 0);
return hasCount ? streamEvents : undefined;
}
function defaultExecutionProgressStepTexts(task: Pick<MasterAgentTask, "taskType" | "relayViaMasterAgent">) {
if (task.taskType === "browser_control") {
return [
@@ -6029,6 +6084,7 @@ function buildExecutionProgressSnapshot(
reasoningSummary: nativeRemoteControl
? undefined
: normalizeExecutionProgressReasoningSummary(input?.reasoningSummary),
streamEvents: nativeRemoteControl ? undefined : normalizeExecutionProgressStreamEvents(input?.streamEvents),
updatedAt: nowIso(),
};
}