* Stream-end settlement for interrupted tasks. Guarantees every pending waiter * is settled exactly once: resolved if an agent_report exists, rejected otherwise. * No waiter should depend on timeout to discover terminal interruption.
(
workspaceId: string,
entry: { projectPath: string; workspace: WorkspaceConfigEntry },
reportArgs: {
reportMarkdown: string;
title?: string;
structuredOutput?: unknown;
planFilePath?: string;
} | null,
options?: { rejectionError?: Error }
)
| 8682 | * No waiter should depend on timeout to discover terminal interruption. |
| 8683 | */ |
| 8684 | private async settleInterruptedTaskAtStreamEnd( |
| 8685 | workspaceId: string, |
| 8686 | entry: { projectPath: string; workspace: WorkspaceConfigEntry }, |
| 8687 | reportArgs: { |
| 8688 | reportMarkdown: string; |
| 8689 | title?: string; |
| 8690 | structuredOutput?: unknown; |
| 8691 | planFilePath?: string; |
| 8692 | } | null, |
| 8693 | options?: { rejectionError?: Error } |
| 8694 | ): Promise<void> { |
| 8695 | if (reportArgs) { |
| 8696 | const finalization = await this.finalizeAgentTaskReport(workspaceId, entry, reportArgs); |
| 8697 | if (!finalization.finalized) { |
| 8698 | this.rejectWaiters(workspaceId, new Error(finalization.message)); |
| 8699 | } |
| 8700 | return; |
| 8701 | } |
| 8702 | |
| 8703 | this.rejectWaiters(workspaceId, options?.rejectionError ?? new Error("Task interrupted")); |
| 8704 | |
| 8705 | const parentWorkspaceId = entry.workspace.parentWorkspaceId; |
| 8706 | const bestOf = entry.workspace.bestOf; |
| 8707 | if ( |
| 8708 | parentWorkspaceId && |
| 8709 | bestOf?.total != null && |
| 8710 | bestOf.total > 1 && |
| 8711 | !this.aiService.isStreaming(parentWorkspaceId) |
| 8712 | ) { |
| 8713 | await this.deliverDeferredBestOfSiblingReports({ |
| 8714 | parentWorkspaceId, |
| 8715 | groupId: bestOf.groupId, |
| 8716 | total: bestOf.total, |
| 8717 | }); |
| 8718 | } |
| 8719 | } |
| 8720 | |
| 8721 | private async handleSuccessfulWorkflowProposePlan(args: { |
| 8722 | workspaceId: string; |
no test coverage detected