feat: 支持同 run runner 多轮 command
This commit is contained in:
@@ -33,21 +33,24 @@ export function normalizeRunEventPayload(type: EventType, payload: JsonRecord):
|
||||
export function eventContractSummary(events: RunEvent[]): JsonRecord {
|
||||
const issues: JsonRecord[] = [];
|
||||
let terminalStatusCount = 0;
|
||||
let runTerminalStatusCount = 0;
|
||||
for (let index = 0; index < events.length; index += 1) {
|
||||
const event = events[index];
|
||||
if (!eventTypeSet.has(event.type)) issues.push({ code: "event-type-invalid", seq: event.seq, type: event.type });
|
||||
if (event.seq !== index + 1) issues.push({ code: "seq-not-contiguous", expectedSeq: index + 1, actualSeq: event.seq });
|
||||
if (event.type === "terminal_status") {
|
||||
terminalStatusCount += 1;
|
||||
if (typeof event.payload.commandId !== "string") runTerminalStatusCount += 1;
|
||||
if (!isTerminalStatus(event.payload.terminalStatus)) issues.push({ code: "terminal-status-invalid", seq: event.seq, terminalStatus: String(event.payload.terminalStatus ?? "") });
|
||||
}
|
||||
}
|
||||
if (terminalStatusCount > 1) issues.push({ code: "terminal-status-duplicated", terminalStatusCount });
|
||||
if (runTerminalStatusCount > 1) issues.push({ code: "run-terminal-status-duplicated", runTerminalStatusCount });
|
||||
return {
|
||||
ok: issues.length === 0,
|
||||
eventCount: events.length,
|
||||
lastSeq: events.at(-1)?.seq ?? 0,
|
||||
terminalStatusCount,
|
||||
runTerminalStatusCount,
|
||||
issues,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user