(args: {
client: OpencodeClient;
config: RunnerConfig;
questionState: QuestionRunState;
state: RunnerStateFile;
questionId: string;
})
| 737 | } |
| 738 | |
| 739 | async function cleanupSessions(args: { |
| 740 | client: OpencodeClient; |
| 741 | config: RunnerConfig; |
| 742 | questionState: QuestionRunState; |
| 743 | state: RunnerStateFile; |
| 744 | questionId: string; |
| 745 | }): Promise<void> { |
| 746 | const { client, config, questionState, state, questionId } = args; |
| 747 | if (!config.cleanupSessions || questionState.cleanupCompleted) { |
| 748 | return; |
| 749 | } |
| 750 | |
| 751 | for (const sessionId of questionState.createdSessionIds) { |
| 752 | try { |
| 753 | await deleteSession(client, config, sessionId); |
| 754 | } catch (error) { |
| 755 | await appendLog(config.paths.logFile, `Cleanup failed for ${questionId}/${sessionId}: ${asError(error).message}`); |
| 756 | } |
| 757 | } |
| 758 | questionState.cleanupCompleted = true; |
| 759 | questionState.updatedAt = nowIso(); |
| 760 | state.inProgress[questionId] = questionState; |
| 761 | await persistState(config, state); |
| 762 | } |
| 763 | |
| 764 | async function markQuestionCompleted(args: { |
| 765 | config: RunnerConfig; |
no test coverage detected