(
parentWorkspaceId: string
)
| 9068 | } |
| 9069 | |
| 9070 | private async resolvePendingBestOfGroupForParent( |
| 9071 | parentWorkspaceId: string |
| 9072 | ): Promise<{ groupId: string; total: number } | null> { |
| 9073 | const partial = await this.historyService.readPartial(parentWorkspaceId); |
| 9074 | if (!partial) { |
| 9075 | return null; |
| 9076 | } |
| 9077 | |
| 9078 | const pendingParts = partial.parts.filter( |
| 9079 | (part): part is DynamicToolPart & { toolName: "task"; state: "input-available" } => |
| 9080 | isDynamicToolPart(part) && part.toolName === "task" && part.state === "input-available" |
| 9081 | ); |
| 9082 | if (pendingParts.length !== 1) { |
| 9083 | return null; |
| 9084 | } |
| 9085 | |
| 9086 | const parsedInput = TaskToolArgsSchema.safeParse(pendingParts[0].input); |
| 9087 | if (!parsedInput.success) { |
| 9088 | return null; |
| 9089 | } |
| 9090 | |
| 9091 | const requestedTotal = getTaskGroupCount(parsedInput.data); |
| 9092 | if (requestedTotal <= 1) { |
| 9093 | return null; |
| 9094 | } |
| 9095 | |
| 9096 | const requestedAgentId = coerceNonEmptyString( |
| 9097 | parsedInput.data.agentId ?? parsedInput.data.subagent_type |
| 9098 | )?.toLowerCase(); |
| 9099 | const requestedTitle = coerceNonEmptyString(parsedInput.data.title); |
| 9100 | const partialStartedAt = |
| 9101 | typeof partial.metadata?.timestamp === "number" ? partial.metadata.timestamp : undefined; |
| 9102 | |
| 9103 | const cfg = this.config.loadConfigOrDefault(); |
| 9104 | const groups = new Map<string, { groupId: string; total: number; createdAtMs: number[] }>(); |
| 9105 | for (const project of cfg.projects.values()) { |
| 9106 | for (const workspace of project.workspaces) { |
| 9107 | if (workspace.parentWorkspaceId !== parentWorkspaceId) { |
| 9108 | continue; |
| 9109 | } |
| 9110 | |
| 9111 | const groupId = coerceNonEmptyString(workspace.bestOf?.groupId); |
| 9112 | const total = workspace.bestOf?.total; |
| 9113 | if (!groupId || total !== requestedTotal) { |
| 9114 | continue; |
| 9115 | } |
| 9116 | |
| 9117 | const workspaceAgentId = resolvePersistedAgentId(workspace, ""); |
| 9118 | if (requestedAgentId && workspaceAgentId && workspaceAgentId !== requestedAgentId) { |
| 9119 | continue; |
| 9120 | } |
| 9121 | |
| 9122 | const workspaceTitle = coerceNonEmptyString(workspace.title); |
| 9123 | if (requestedTitle && workspaceTitle && workspaceTitle !== requestedTitle) { |
| 9124 | continue; |
| 9125 | } |
| 9126 | |
| 9127 | const entry = groups.get(groupId) ?? { groupId, total, createdAtMs: [] }; |
no test coverage detected